From 6e30afcfd8f7dfed450f3060c648660dbaf6071b Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 3 Nov 2019 21:52:40 +0100 Subject: [PATCH] [PL] Replace easyBind with lambdas. --- .../SmallDeformationProcess.cpp | 39 +++++++++---------- ProcessLib/TES/TESProcess.cpp | 22 +++++++---- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp index 7572a404abf..fbcb74cfc3b 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp @@ -13,7 +13,6 @@ #include <cassert> #include <nlohmann/json.hpp> -#include "BaseLib/Functional.h" #include "ProcessLib/Output/IntegrationPointWriter.h" #include "ProcessLib/Process.h" #include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h" @@ -143,38 +142,36 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess( auto const num_components = internal_variable.num_components; DBUG("Registering internal variable %s.", name.c_str()); - auto getIntPtValues = BaseLib::easyBind( + auto getIntPtValues = [fct, num_components]( LocalAssemblerInterface const& loc_asm, const double /*t*/, GlobalVector const& /*current_solution*/, NumLib::LocalToGlobalIndexMap const& /*dof_table*/, std::vector<double>& cache) -> std::vector<double> const& { - const unsigned num_int_pts = - loc_asm.getNumberOfIntegrationPoints(); + const unsigned num_int_pts = loc_asm.getNumberOfIntegrationPoints(); - cache.clear(); - auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix< - double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( - cache, num_components, num_int_pts); + cache.clear(); + auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix< + double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( + cache, num_components, num_int_pts); - // TODO avoid the heap allocation (one per finite element) - std::vector<double> cache_column(num_int_pts); + // TODO avoid the heap allocation (one per finite element) + std::vector<double> cache_column(num_int_pts); - for (unsigned i = 0; i < num_int_pts; ++i) - { - auto const& state = loc_asm.getMaterialStateVariablesAt(i); + for (unsigned i = 0; i < num_int_pts; ++i) + { + auto const& state = loc_asm.getMaterialStateVariablesAt(i); - auto const& int_pt_values = fct(state, cache_column); - assert(int_pt_values.size() == num_components); - auto const int_pt_values_vec = - MathLib::toVector(int_pt_values); + auto const& int_pt_values = fct(state, cache_column); + assert(int_pt_values.size() == num_components); + auto const int_pt_values_vec = MathLib::toVector(int_pt_values); - cache_mat.col(i).noalias() = int_pt_values_vec; - } + cache_mat.col(i).noalias() = int_pt_values_vec; + } - return cache; - }); + return cache; + }; _secondary_variables.addSecondaryVariable( name, diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index 40284d25e8f..eb07ef3edd5 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -9,7 +9,6 @@ */ #include "TESProcess.h" -#include "BaseLib/Functional.h" #include "NumLib/DOF/DOFTableUtil.h" #include "ProcessLib/Utils/CreateLocalAssemblers.h" @@ -189,15 +188,24 @@ void TESProcess::initializeSecondaryVariables() "reaction_damping_factor", makeEx(1, &TESLocalAssemblerInterface::getIntPtReactionDampingFactor)); - add2nd( - "vapour_partial_pressure", - {1, BaseLib::easyBind(&TESProcess::computeVapourPartialPressure, this), - nullptr}); + add2nd("vapour_partial_pressure", + {1, + [&](auto&&... args) -> GlobalVector const& { + return computeVapourPartialPressure(args...); + }, + nullptr}); + namespace PH = std::placeholders; add2nd("relative_humidity", - {1, BaseLib::easyBind(&TESProcess::computeRelativeHumidity, this), + {1, + [&](auto&&... args) -> GlobalVector const& { + return computeRelativeHumidity(args...); + }, nullptr}); add2nd("equilibrium_loading", - {1, BaseLib::easyBind(&TESProcess::computeEquilibriumLoading, this), + {1, + [&](auto&&... args) -> GlobalVector const& { + return computeEquilibriumLoading(args...); + }, nullptr}); } -- GitLab