diff --git a/python/mesa_pd/kernel/TemperatureIntegration.py b/python/mesa_pd/kernel/TemperatureIntegration.py index 426a9b3874805db5abac7b686baf791d0a46263a..006eb37232df257eb42c5ac2c7d8be1c44ce72ab 100644 --- a/python/mesa_pd/kernel/TemperatureIntegration.py +++ b/python/mesa_pd/kernel/TemperatureIntegration.py @@ -9,11 +9,12 @@ class TemperatureIntegration: self.context = {'interface': []} self.context['interface'].append(create_access("temperature", "walberla::real_t", access="gs")) self.context['interface'].append(create_access("heatFlux", "walberla::real_t", access="gs")) + self.context['interface'].append(create_access("invMass", "walberla::real_t", access="g")) self.context['interface'].append(create_access("type", "uint_t", access="g")) def generate(self, module): ctx = {'module': module, **self.context} - ctx["parameters"] = ["invHeatCapacity"] + ctx["parameters"] = ["invSpecificHeat"] generate_file(module['module_path'], 'kernel/TemperatureIntegration.templ.h', ctx) ctx["InterfaceTestName"] = "TemperatureIntegrationInterfaceCheck" diff --git a/python/mesa_pd/templates/kernel/TemperatureIntegration.templ.h b/python/mesa_pd/templates/kernel/TemperatureIntegration.templ.h index 92aa9f58d9759cf41d4bb708c38b1f4114f025fd..2bdd7f362e6412830c55f78b2f233505ddfc472e 100644 --- a/python/mesa_pd/templates/kernel/TemperatureIntegration.templ.h +++ b/python/mesa_pd/templates/kernel/TemperatureIntegration.templ.h @@ -34,8 +34,8 @@ namespace mesa_pd { namespace kernel { /** - * Kernel which explicitly integrates all particles in time. - * This integrator integrates velocity and position. + * Kernel which explicitly integrates a particle in time. + * The heat flux is converted into a temperature change. * * This kernel requires the following particle accessor interface * \code @@ -53,8 +53,8 @@ namespace kernel { {%- endfor %} * \endcode * - * \pre All forces acting on the particles have to be set. - * \post All forces are reset to 0. + * \pre Heat flux has to be set/reduced. + * \post Heat flux is reset to 0. * \ingroup mesa_pd_kernel */ class TemperatureIntegration @@ -112,14 +112,14 @@ inline real_t TemperatureIntegration::get{{param | capFirst}}(const size_t type) {%- endfor %} template <typename Accessor> -inline void TemperatureIntegration::operator()(const size_t idx, +inline void TemperatureIntegration::operator()(const size_t p_idx, Accessor& ac) const { static_assert(std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor"); //formula for heat capacity - ac.setTemperature(idx, getInvHeatCapacity(ac.getType(idx)) * ac.getHeatFlux(idx) * dt_ + ac.getTemperature(idx)); - ac.setHeatFlux (idx, real_t(0)); + ac.setTemperature(p_idx, getInvSpecificHeat(ac.getType(p_idx)) * ac.getInvMass(p_idx) * ac.getHeatFlux(p_idx) * dt_ + ac.getTemperature(p_idx)); + ac.setHeatFlux (p_idx, real_t(0)); } } //namespace kernel diff --git a/src/mesa_pd/kernel/TemperatureIntegration.h b/src/mesa_pd/kernel/TemperatureIntegration.h index bdfc5732d622164fc05658cb1d30c35285fdd5e8..c90eb3ffcf3b65bb97e77a31d127eb43a02830a9 100644 --- a/src/mesa_pd/kernel/TemperatureIntegration.h +++ b/src/mesa_pd/kernel/TemperatureIntegration.h @@ -34,8 +34,8 @@ namespace mesa_pd { namespace kernel { /** - * Kernel which explicitly integrates all particles in time. - * This integrator integrates velocity and position. + * Kernel which explicitly integrates a particle in time. + * The heat flux is converted into a temperature change. * * This kernel requires the following particle accessor interface * \code @@ -45,12 +45,14 @@ namespace kernel { * const walberla::real_t& getHeatFlux(const size_t p_idx) const; * void setHeatFlux(const size_t p_idx, const walberla::real_t& v); * + * const walberla::real_t& getInvMass(const size_t p_idx) const; + * * const uint_t& getType(const size_t p_idx) const; * * \endcode * - * \pre All forces acting on the particles have to be set. - * \post All forces are reset to 0. + * \pre Heat flux has to be set/reduced. + * \post Heat flux is reset to 0. * \ingroup mesa_pd_kernel */ class TemperatureIntegration @@ -67,16 +69,16 @@ public: /// assumes this parameter is symmetric - void setInvHeatCapacity(const size_t type, const real_t& val); + void setInvSpecificHeat(const size_t type, const real_t& val); - real_t getInvHeatCapacity(const size_t type) const; + real_t getInvSpecificHeat(const size_t type) const; private: real_t dt_ = real_t(0.0); uint_t numParticleTypes_; - std::vector<real_t> invHeatCapacity_ {}; + std::vector<real_t> invSpecificHeat_ {}; }; TemperatureIntegration::TemperatureIntegration(const real_t dt, const uint_t numParticleTypes) @@ -84,32 +86,32 @@ TemperatureIntegration::TemperatureIntegration(const real_t dt, const uint_t num { numParticleTypes_ = numParticleTypes; - invHeatCapacity_.resize(numParticleTypes, real_t(0)); + invSpecificHeat_.resize(numParticleTypes, real_t(0)); } -inline void TemperatureIntegration::setInvHeatCapacity(const size_t type, const real_t& val) +inline void TemperatureIntegration::setInvSpecificHeat(const size_t type, const real_t& val) { WALBERLA_ASSERT_LESS( type, numParticleTypes_ ); - invHeatCapacity_[type] = val; + invSpecificHeat_[type] = val; } -inline real_t TemperatureIntegration::getInvHeatCapacity(const size_t type) const +inline real_t TemperatureIntegration::getInvSpecificHeat(const size_t type) const { WALBERLA_ASSERT_LESS( type, numParticleTypes_ ); - return invHeatCapacity_[type]; + return invSpecificHeat_[type]; } template <typename Accessor> -inline void TemperatureIntegration::operator()(const size_t idx, +inline void TemperatureIntegration::operator()(const size_t p_idx, Accessor& ac) const { static_assert(std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor"); //formula for heat capacity - ac.setTemperature(idx, getInvHeatCapacity(ac.getType(idx)) * ac.getHeatFlux(idx) * dt_ + ac.getTemperature(idx)); - ac.setHeatFlux (idx, real_t(0)); + ac.setTemperature(p_idx, getInvSpecificHeat(ac.getType(p_idx)) * ac.getInvMass(p_idx) * ac.getHeatFlux(p_idx) * dt_ + ac.getTemperature(p_idx)); + ac.setHeatFlux (p_idx, real_t(0)); } } //namespace kernel diff --git a/tests/mesa_pd/kernel/TemperatureIntegration.cpp b/tests/mesa_pd/kernel/TemperatureIntegration.cpp index fefa30cadb52420b7714d39a663213b071e9827c..b84fc9cd285400852b837084603c7185f2fbc9ac 100644 --- a/tests/mesa_pd/kernel/TemperatureIntegration.cpp +++ b/tests/mesa_pd/kernel/TemperatureIntegration.cpp @@ -18,13 +18,11 @@ // //====================================================================================================================== -#include <mesa_pd/data/DataTypes.h> #include <mesa_pd/data/ParticleAccessor.h> #include <mesa_pd/kernel/TemperatureIntegration.h> #include <core/Environment.h> -#include <core/logging/Logging.h> #include <iostream> @@ -45,11 +43,12 @@ int main( int argc, char ** argv ) accessor.setType( 0, 0 ); accessor.setHeatFlux( 0, real_t(8) ); accessor.setTemperature( 0, real_t(5) ); + accessor.setInvMass( 0, real_t(1) ); //init kernels const real_t dt = real_t(1); kernel::TemperatureIntegration integrator( dt, 1 ); - integrator.setInvHeatCapacity( 0, real_t(2) ); + integrator.setInvSpecificHeat( 0, real_t(2) ); integrator(0, accessor); diff --git a/tests/mesa_pd/kernel/interfaces/TemperatureIntegrationInterfaceCheck.cpp b/tests/mesa_pd/kernel/interfaces/TemperatureIntegrationInterfaceCheck.cpp index e764dffa1b0a1a88b597108d2b64fa6adc4060df..dfc209c39f2d3f6890d1017ab687064d1f7d9deb 100644 --- a/tests/mesa_pd/kernel/interfaces/TemperatureIntegrationInterfaceCheck.cpp +++ b/tests/mesa_pd/kernel/interfaces/TemperatureIntegrationInterfaceCheck.cpp @@ -44,6 +44,8 @@ public: const walberla::real_t& getHeatFlux(const size_t /*p_idx*/) const {return heatFlux_;} void setHeatFlux(const size_t /*p_idx*/, const walberla::real_t& v) { heatFlux_ = v;} + const walberla::real_t& getInvMass(const size_t /*p_idx*/) const {return invMass_;} + const uint_t& getType(const size_t /*p_idx*/) const {return type_;} @@ -59,6 +61,7 @@ public: private: walberla::real_t temperature_; walberla::real_t heatFlux_; + walberla::real_t invMass_; uint_t type_; };