diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/core/c++/abstract/data.hpp | 89 | ||||
| -rw-r--r-- | modules/core/c++/abstract/error.hpp | 2 | ||||
| -rw-r--r-- | modules/core/c++/particle/aabb.hpp | 1 | ||||
| -rw-r--r-- | modules/core/c++/particle/cuboid/aabb.hpp | 40 | ||||
| -rw-r--r-- | modules/core/c++/particle/cuboid/common.hpp | 10 | ||||
| -rw-r--r-- | modules/core/c++/particle/cuboid/particle.hpp | 9 | ||||
| -rw-r--r-- | modules/core/c++/particle/cuboid/porosity.hpp | 10 | ||||
| -rw-r--r-- | modules/core/c++/particle/particle.hpp | 4 | ||||
| -rw-r--r-- | modules/core/c++/particle/spheroid/particle.hpp | 9 |
9 files changed, 170 insertions, 4 deletions
diff --git a/modules/core/c++/abstract/data.hpp b/modules/core/c++/abstract/data.hpp index f1ae5a7..327fb63 100644 --- a/modules/core/c++/abstract/data.hpp +++ b/modules/core/c++/abstract/data.hpp @@ -10,8 +10,97 @@ class data final {}; template<typename T, uint64_t N> class data<sch::Primitive<T,N>,Encode> final { +public: + using Schema = sch::Primitive<T,N>; + using Encode = Encode; private: + native_data_type<Schema>::type value_; public: + data(): + value_{} + {} + + data(native_data_type<Schema>::type value__): + value_{value__} + {} + + constexpr auto get() const { + return value_; + } + + void set(native_data_type value__){ + value_ = value__; + } + + constexpr bool operator==(const data<Schema,Encode>& rhs) const { + return value_ == rhs.value_; + } + + constexpr bool operator!=(const data<Schema,Encode>& rhs) const { + return value_ != rhs.value_; + } + + constexpr bool operator>(const data<Schema,Encode>& rhs) const { + return value_ > rhs.value_; + } + + constexpr bool operator<(const data<Schema,Encode>& rhs) const { + return value_ < rhs.value_; + } + + constexpr bool operator>=(const data<Schema,Encode>& rhs) const { + return value_ >= rhs.value_; + } + + constexpr bool operator<=(const data<Schema,Encode>& rhs) const { + return value_ >= rhs.value_; + } + + constexpr bool equals(const data<Schema,Encode>& rhs) const { + return (*this) == rhs; + } + + data<Schema,Encode> operator+(const data<Schema,Encode>& rhs) const { + return {value_ + rhs.value_}; + } + + data<Schema,Encode> operator-(const data<Schema,Encode>& rhs) const { + return {value_ - rhs.value_}; + } + + data<Schema,Encode> operator*(const data<Schema,Encode>& rhs) const { + return {value_ * rhs.value_}; + } + + data<Schema,Encode> operator/(const data<Schema,Encode>& rhs) const { + return {value_ / rhs.value_}; + } + + data<Schema,Encode>& operator+=(const data<Schema,Encode>& rhs) { + value_ += rhs.value_; + return *this + } + + data<Schema,Encode>& operator-=(const data<Schema,Encode>& rhs) { + value_ -= rhs.value_; + return *this + } + + data<Schema,Encode>& operator*=(const data<Schema,Encode>& rhs) { + value_ *= rhs.value_; + return *this + } + + data<Schema,Encode>& operator/=(const data<Schema,Encode>& rhs) { + value_ /= rhs.value_; + return *this + } + + template<typename T> + data<T,Encode> cast_to() const { + data<T,Encode> val{static_cast<typename native_data_type<T>::type>(value_)}; + return val; + } }; diff --git a/modules/core/c++/abstract/error.hpp b/modules/core/c++/abstract/error.hpp index 19917de..94a2c35 100644 --- a/modules/core/c++/abstract/error.hpp +++ b/modules/core/c++/abstract/error.hpp @@ -305,7 +305,7 @@ public: /** * This tries to catch cases where error starts including itself as a type which can happen in more complicated cases. - * So this acts as a type safe guard. + * So this acts as a type safe guard in case internal handling fails to treat conversion correctly. */ template <typename T> class error_or<error_or<T>> { private: diff --git a/modules/core/c++/particle/aabb.hpp b/modules/core/c++/particle/aabb.hpp index da39ec2..e4c930b 100644 --- a/modules/core/c++/particle/aabb.hpp +++ b/modules/core/c++/particle/aabb.hpp @@ -26,7 +26,6 @@ public: static constexpr saw::error_or<saw::data<AABB>> calculate(const saw::data<Sch,Encode>& p_grp, const saw::data<sch::FixedArray<sch::UInt64,1u>>& index, const saw::data<sch::FixedArray<sch::UInt64,D>>& meta){ static_assert(PC > 0u, "Can't calculate from no particles"); if(not (index.at({{0u}}).get() < PC) ){ - std::cerr.flush(); return saw::make_error<saw::err::critical>("Too large i in particle_aabb"); } diff --git a/modules/core/c++/particle/cuboid/aabb.hpp b/modules/core/c++/particle/cuboid/aabb.hpp new file mode 100644 index 0000000..502132a --- /dev/null +++ b/modules/core/c++/particle/cuboid/aabb.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include "common.hpp" +#include "../aabb.hpp" + +namespace kel { +namespace lbm { + +template<typename T, uint64_t D, uint64_t PC> +class particle_aabb< + sch::ParticleGroup<T,D,PC,coll::Cuboid<T>> +> final { +public: + using Schema = sch::ParticleGroup<T,D,PC,coll::Cuboid<T>>; + + using AABB = sch::Struct< + sch::Member<sch::FixedArray<sch::UInt64,D>, "a">, + sch::Member<sch::FixedArray<sch::UInt64,D>, "b"> + >; + +public: + template<typename Sch, typename Encode> + static constexpr saw::error_or<saw::data<AABB>> calculate(const saw::data<Sch,Encode>& pg, const saw::data<sch::FixedArray<sch::UInt64,1u>>& index, const saw::data<sch::FixedArray<sch::UInt64,D>>& meta){ + static_assert(PC > 0u, "Can't calculate from no particle"); + if(not (index.at({0u}).get() < PC)){ + return saw::make_error<saw::err::critical>("Too large i in particle_aabb coll::Cuboid<T>"); + } + + saw::data<AABB> aabb; + auto& parts = pg.template get<"particles">(); + auto& pi = parts.at(index); + auto& pirb = pi.template get<"rigid_body">(); + + /// TODO + + return aabb; + } +}; +} +} diff --git a/modules/core/c++/particle/cuboid/common.hpp b/modules/core/c++/particle/cuboid/common.hpp new file mode 100644 index 0000000..a859cbe --- /dev/null +++ b/modules/core/c++/particle/cuboid/common.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace kel { +namespace lbm { +namespace coll { +template<typename T> +struct Cuboid {}; +} +} +} diff --git a/modules/core/c++/particle/cuboid/particle.hpp b/modules/core/c++/particle/cuboid/particle.hpp new file mode 100644 index 0000000..e19d543 --- /dev/null +++ b/modules/core/c++/particle/cuboid/particle.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "common.hpp" +#include "porosity.hpp" + +namespace kel { +namespace lbm { +} +} diff --git a/modules/core/c++/particle/cuboid/porosity.hpp b/modules/core/c++/particle/cuboid/porosity.hpp new file mode 100644 index 0000000..bccfebf --- /dev/null +++ b/modules/core/c++/particle/cuboid/porosity.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "common.hpp" +#include "../porosity.hpp" + +namespace kel { +namespace lbm { + +} +} diff --git a/modules/core/c++/particle/particle.hpp b/modules/core/c++/particle/particle.hpp index a3669b4..21b4b34 100644 --- a/modules/core/c++/particle/particle.hpp +++ b/modules/core/c++/particle/particle.hpp @@ -82,8 +82,8 @@ saw::data<sch::ParticleGroup<T, D, PartAmount, coll::Spheroid<T>>> create_sphero total_mass.at({}) = rad_d * rad_d * density.at({}) * 3.141592; }else if constexpr ( D == 3u ){ - }else if constexpr ( D== 1u ){ - + }else if constexpr ( D == 1u ){ + total_mass.at({}) = rad_d * 2.0; } std::cout<<"Total Mass: "<<total_mass.at({}).get()<<std::endl; diff --git a/modules/core/c++/particle/spheroid/particle.hpp b/modules/core/c++/particle/spheroid/particle.hpp new file mode 100644 index 0000000..9c0912e --- /dev/null +++ b/modules/core/c++/particle/spheroid/particle.hpp @@ -0,0 +1,9 @@ +#pragma once + +namespace kel { +namespace lbm { +namespace coll { + +} +} +} |
