13 #if !defined(KRATOS_TEMPORAL_SUM_METHOD_H_INCLUDED)
14 #define KRATOS_TEMPORAL_SUM_METHOD_H_INCLUDED
37 namespace TemporalMethods
39 template <
class TContainerType,
class TContainerItemType,
template <
class T>
class TDataRetrievalFunctor,
template <
class T>
class TDataStorageFunctor>
43 template <
class TDataType>
51 const std::string& rNormType,
56 mrInputVariable(rInputVariable),
57 mrOutputVariable(rOutputVariable)
63 TContainerType& r_container =
64 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
68 const int number_of_items = r_container.size();
69 #pragma omp parallel for
70 for (
int i = 0;
i < number_of_items; ++
i)
72 TContainerItemType& r_item = *(r_container.begin() +
i);
73 const TDataType& r_input_value =
74 TDataRetrievalFunctor<TContainerItemType>()(r_item, mrInputVariable);
75 TDataType& r_output_value =
76 TDataStorageFunctor<TContainerItemType>()(r_item, mrOutputVariable);
79 TemporalSumMethod::CalculateSum<TDataType>(
84 <<
"Calculated temporal value sum for " << mrInputVariable.Name()
85 <<
" input variable with " << mrOutputVariable.Name()
91 TContainerType& r_container =
92 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
94 auto& initializer_method =
95 TemporalMethodUtilities::InitializeVariables<TContainerType, TContainerItemType, TDataRetrievalFunctor, TDataStorageFunctor, TDataType>;
96 initializer_method(r_container, mrOutputVariable, mrInputVariable);
99 <<
"Initialized temporal value sum method for "
100 << mrInputVariable.Name() <<
" input variable with "
101 << mrOutputVariable.Name() <<
" output variable for "
110 template <
class TDataType>
118 const std::string& rNormType,
123 mNormType(rNormType),
124 mrInputVariable(rInputVariable),
125 mrOutputVariable(rOutputVariable)
131 TContainerType& r_container =
132 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
134 const auto& norm_method =
139 const int number_of_items = r_container.size();
140 #pragma omp parallel for
141 for (
int i = 0;
i < number_of_items; ++
i)
143 TContainerItemType& r_item = *(r_container.begin() +
i);
144 const TDataType& r_input_value =
145 TDataRetrievalFunctor<TContainerItemType>()(r_item, mrInputVariable);
146 const double input_norm_value = norm_method(r_input_value);
147 double& r_output_value =
148 TDataStorageFunctor<TContainerItemType>()(r_item, mrOutputVariable);
150 TemporalSumMethod::CalculateSum<double>(
151 r_output_value, input_norm_value,
delta_time);
155 <<
"Calculated temporal norm sum for " << mrInputVariable.Name()
156 <<
" input variable with " << mrOutputVariable.
Name()
162 TContainerType& r_container =
163 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
165 auto& initializer_method =
166 TemporalMethodUtilities::InitializeVariables<TContainerType, TContainerItemType, TDataStorageFunctor>;
167 initializer_method(r_container, mrOutputVariable, 0.0);
170 <<
"Initialized temporal norm sum method for "
171 << mrInputVariable.Name() <<
" input variable with "
172 << mrOutputVariable.
Name() <<
" output variable for "
177 const std::string mNormType;
189 "input_variables" : [],
190 "output_variables" : []
194 const std::vector<std::string>& input_variable_names_list =
196 const std::vector<std::string>& output_variable_names_list =
199 std::vector<TemporalMethod::Pointer> method_list;
200 if (rNormType ==
"none")
203 input_variable_names_list, output_variable_names_list);
204 const int number_of_variables = input_variable_names_list.size();
205 for (
int i = 0;
i < number_of_variables; ++
i)
207 const std::string& r_variable_input_name = input_variable_names_list[
i];
208 const std::string& r_variable_output_name =
209 output_variable_names_list[
i];
211 rModelPart, rNormType, r_variable_input_name,
EchoLevel,
219 const int number_of_variables = input_variable_names_list.size();
220 for (
int i = 0;
i < number_of_variables; ++
i)
222 const std::string& r_variable_input_name = input_variable_names_list[
i];
223 const std::string& r_variable_output_name =
224 output_variable_names_list[
i];
226 rModelPart, rNormType, r_variable_input_name,
EchoLevel,
227 r_variable_output_name, method_list,
NormMethod)
237 template <
class TDataType>
238 void static CalculateSum(TDataType& rSum,
const TDataType& rNewDataPoint,
const double DeltaTime)
240 rSum = (rSum + rNewDataPoint * DeltaTime);
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
std::string & Name()
Definition: model_part.h:1811
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
std::vector< std::string > GetStringArray() const
This method returns the array of strings in the current Parameter.
Definition: kratos_parameters.cpp:693
void RecursivelyValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1389
Definition: temporal_method.h:40
Definition: temporal_sum_method.h:112
Definition: temporal_sum_method.h:45
Definition: temporal_sum_method.h:41
const std::string & Name() const
Definition: variable_data.h:201
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
double GetDeltaTime() const
Definition: temporal_method.h:106
int GetEchoLevel() const
Definition: temporal_method.h:112
ModelPart & GetModelPart() const
Definition: temporal_method.h:82
static std::vector< TemporalMethod::Pointer > CreateTemporalMethodObject(ModelPart &rModelPart, const std::string &rNormType, const int EchoLevel, Parameters Params)
Definition: temporal_sum_method.h:182
void CalculateStatistics() override
Definition: temporal_sum_method.h:61
void InitializeStatisticsVariables() override
Definition: temporal_sum_method.h:160
KRATOS_CLASS_POINTER_DEFINITION(NormMethod)
void CalculateStatistics() override
Definition: temporal_sum_method.h:129
void InitializeStatisticsVariables() override
Definition: temporal_sum_method.h:89
ValueMethod(ModelPart &rModelPart, const std::string &rNormType, const Variable< TDataType > &rInputVariable, const int EchoLevel, const Variable< TDataType > &rOutputVariable)
Definition: temporal_sum_method.h:49
NormMethod(ModelPart &rModelPart, const std::string &rNormType, const Variable< TDataType > &rInputVariable, const int EchoLevel, const Variable< double > &rOutputVariable)
Definition: temporal_sum_method.h:116
KRATOS_CLASS_POINTER_DEFINITION(ValueMethod)
#define ADD_TEMPORAL_NORM_METHOD_ONE_OUTPUT_VARIABLE_OBJECT( model_part, norm_type, input_variable, echo_level, output_variable, object_list, method)
Definition: method_utilities.h:77
#define ADD_TEMPORAL_VALUE_METHOD_ONE_OUTPUT_VARIABLE_OBJECT( model_part, norm_type, input_variable, echo_level, output_variable, object_list, method)
Definition: method_utilities.h:27
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
const std::function< double(const TDataType &)> GetNormMethod(const Variable< TDataType > &rVariable, const std::string &rNormType)
Definition: method_utilities.cpp:313
void DataTypeSizeChecker(const TDataType &rData, const TDataType &rReferenceData)
Definition: method_utilities.cpp:131
void CheckInputOutputVariables(const std::vector< std::string > &rInputVariableNamesList, const std::vector< std::string > &rOutputVariableNamesList)
Definition: method_utilities.cpp:678
template void CheckVariableType< double >(const std::vector< std::string > &rVariableNamesList)
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
delta_time
Definition: generate_frictional_mortar_condition.py:130
integer i
Definition: TensorModule.f:17