From ae5c44f37053d3df869dd6ac975f74a604c6de9d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 18 Apr 2025 18:23:46 +0200 Subject: wip which doesn't compile yet --- c++/converter.hpp | 28 ++++++++++++++++++++++++++++ c++/lbm_unit.hpp | 44 ++++++++++++++++++++++++++++++++++++-------- tests/converter.cpp | 18 ++++++++++++++++++ 3 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 tests/converter.cpp diff --git a/c++/converter.hpp b/c++/converter.hpp index e07847f..f3c3518 100644 --- a/c++/converter.hpp +++ b/c++/converter.hpp @@ -4,10 +4,38 @@ namespace kel { namespace lbm { + +template class converter { private: + saw::data, SiMeter >> meter_conv_; + saw::data, SiSecond >> second_conv_; public: converter() = delete; + converter( + saw::data, SiMeter >> meter_conv__, + saw::data, SiSecond >> second_conv__ + ): + meter_conv_{meter_conv__}, + second_conv_{second_conv__} + {} + + saw::data> meter_si_to_lbm(const saw::data>& m_si){ + return m_si * meter_conv_; + } + + saw::data> second_si_to_lbm(const saw::data>& s_si){ + return s_si * second_conv_; + } + + saw::data> velocity_si_to_lbm(const saw::data>& vel_si){ + return vel_si * meter_conv_ / second_conv_; + } + + saw::data> acceleration_si_to_lbm(const saw::data>& acc_si){ + return acc_si * meter_conv_ / (second_conv_ * second_conv_); + } + }; } } diff --git a/c++/lbm_unit.hpp b/c++/lbm_unit.hpp index dc1f8e9..4cb9b52 100644 --- a/c++/lbm_unit.hpp +++ b/c++/lbm_unit.hpp @@ -8,26 +8,54 @@ namespace kel { namespace lbm { namespace lbm_type { struct meter { - static constexpr std::string_view name = "meter_l"; - static constexpr std::string_view short_name = "m_l"; + static constexpr std::string_view name = "meter_lbm"; + static constexpr std::string_view short_name = "m_lbm"; }; struct second { - static constexpr std::string_view name = "second_l"; - static constexpr std::string_view short_name = "s_l"; + static constexpr std::string_view name = "second_lbm"; + static constexpr std::string_view short_name = "s_lbm"; }; } +namespace si_type { +struct meter { + static constexpr std::string_view name = "meter_si"; + static constexpr std::string_view short_name = "m_si"; +}; + +struct second { + static constexpr std::string_view name = "second_si"; + static constexpr std::string_view short_name = "s_si"; +}; +} + +namesapce sch { + +template +using SiMeter = schema::Unit>; + +template +using LbmMeter = schema::Unit>; + +template +using SiSecond = schema::Unit>; + template -using lbm_meter = unit>; +using LbmSecond = schema::Unit>; template -using lbm_second = unit>; +using SiVelocity = schema::Unit, schema::UnitElement>; template -using lbm_velocity = unit, unit_component>; +using LbmVelocity = schema::Unit, schema::UnitElement>; template -using lbm_acceleration = unit, unit_component>; +using SiAcceleration = schema::Unit, schema::UnitElement>; + +template +using LbmAcceleration = schema::Unit, schema::UnitElement>; + +} } } diff --git a/tests/converter.cpp b/tests/converter.cpp new file mode 100644 index 0000000..3c66348 --- /dev/null +++ b/tests/converter.cpp @@ -0,0 +1,18 @@ +#include + +#include "../c++/converter.hpp" + + +namespace { +namespace sch { +using namespace kel::lbm::sch; + +using T = Float64; +} + +SAW_TEST("Meter"){ + using namespace kel; + + lbm::converter converter; +} +} -- cgit v1.2.3