13 #if !defined(KRATOS_TEMPORAL_MEAN_METHOD_H_INCLUDED)
14 #define KRATOS_TEMPORAL_MEAN_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 double total_time = old_total_time +
delta_time;
70 const int number_of_items = r_container.size();
71 #pragma omp parallel for
72 for (
int i = 0;
i < number_of_items; ++
i)
74 TContainerItemType& r_item = *(r_container.begin() +
i);
75 const TDataType& r_input_value =
76 TDataRetrievalFunctor<TContainerItemType>()(r_item, mrInputVariable);
77 TDataType& r_output_value =
78 TDataStorageFunctor<TContainerItemType>()(r_item, mrOutputVariable);
81 TemporalMeanMethod::CalculateMean<TDataType>(
82 r_output_value, r_input_value,
delta_time, old_total_time, total_time);
86 <<
"Calculated temporal value mean for " << mrInputVariable.Name()
87 <<
" input variable with " << mrOutputVariable.Name()
93 TContainerType& r_container =
94 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
96 auto& initializer_method =
97 TemporalMethodUtilities::InitializeVariables<TContainerType, TContainerItemType, TDataRetrievalFunctor, TDataStorageFunctor, TDataType>;
98 initializer_method(r_container, mrOutputVariable, mrInputVariable);
101 <<
"Initialized temporal value mean method for "
102 << mrInputVariable.Name() <<
" input variable with "
103 << mrOutputVariable.Name() <<
" mean variable for "
112 template <
class TDataType>
120 const std::string& rNormType,
125 mNormType(rNormType),
126 mrInputVariable(rInputVariable),
127 mrOutputVariable(rOutputVariable)
133 TContainerType& r_container =
134 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
136 const auto& norm_method =
141 const double total_time = old_total_time +
delta_time;
143 const int number_of_items = r_container.size();
144 #pragma omp parallel for
145 for (
int i = 0;
i < number_of_items; ++
i)
147 TContainerItemType& r_item = *(r_container.begin() +
i);
148 const TDataType& r_input_value =
149 TDataRetrievalFunctor<TContainerItemType>()(r_item, mrInputVariable);
150 const double input_norm_value = norm_method(r_input_value);
151 double& r_output_value =
152 TDataStorageFunctor<TContainerItemType>()(r_item, mrOutputVariable);
154 TemporalMeanMethod::CalculateMean<double>(
155 r_output_value, input_norm_value,
delta_time, old_total_time, total_time);
159 <<
"Calculated temporal norm mean for " << mrInputVariable.Name()
160 <<
" input variable with " << mrOutputVariable.
Name()
166 TContainerType& r_container =
167 MethodUtilities::GetDataContainer<TContainerType>(this->
GetModelPart());
169 auto& initializer_method =
170 TemporalMethodUtilities::InitializeVariables<TContainerType, TContainerItemType, TDataStorageFunctor>;
171 initializer_method(r_container, mrOutputVariable, 0.0);
174 <<
"Initialized temporal norm mean method for "
175 << mrInputVariable.Name() <<
" input variable with "
176 << mrOutputVariable.
Name() <<
" mean variable for "
181 const std::string mNormType;
193 "input_variables" : [],
194 "output_variables" : []
198 const std::vector<std::string>& input_variable_names_list =
200 const std::vector<std::string>& output_variable_names_list =
203 std::vector<TemporalMethod::Pointer> method_list;
204 if (rNormType ==
"none")
207 input_variable_names_list, output_variable_names_list);
208 const int number_of_variables = input_variable_names_list.size();
209 for (
int i = 0;
i < number_of_variables; ++
i)
211 const std::string& r_variable_input_name = input_variable_names_list[
i];
212 const std::string& r_variable_output_name =
213 output_variable_names_list[
i];
215 rModelPart, rNormType, r_variable_input_name,
EchoLevel,
223 const int number_of_variables = input_variable_names_list.size();
224 for (
int i = 0;
i < number_of_variables; ++
i)
226 const std::string& r_variable_input_name = input_variable_names_list[
i];
227 const std::string& r_variable_output_name =
228 output_variable_names_list[
i];
230 rModelPart, rNormType, r_variable_input_name,
EchoLevel,
231 r_variable_output_name, method_list,
NormMethod)
241 template <
class TDataType>
242 void static CalculateMean(
244 const TDataType& rNewDataPoint,
245 const double DeltaTime,
246 const double OldTotalTime,
247 const double CurrentTotalTime)
249 rMean = (rMean * OldTotalTime + rNewDataPoint * DeltaTime) * (1.0 / CurrentTotalTime);
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_mean_method.h:114
Definition: temporal_mean_method.h:45
Definition: temporal_mean_method.h:41
Definition: temporal_method.h:40
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
double GetTotalTime() const
Definition: temporal_method.h:87
ValueMethod(ModelPart &rModelPart, const std::string &rNormType, const Variable< TDataType > &rInputVariable, const int EchoLevel, const Variable< TDataType > &rOutputVariable)
Definition: temporal_mean_method.h:49
void InitializeStatisticsVariables() override
Definition: temporal_mean_method.h:164
KRATOS_CLASS_POINTER_DEFINITION(ValueMethod)
NormMethod(ModelPart &rModelPart, const std::string &rNormType, const Variable< TDataType > &rInputVariable, const int EchoLevel, const Variable< double > &rOutputVariable)
Definition: temporal_mean_method.h:118
void InitializeStatisticsVariables() override
Definition: temporal_mean_method.h:91
static std::vector< TemporalMethod::Pointer > CreateTemporalMethodObject(ModelPart &rModelPart, const std::string &rNormType, const int EchoLevel, Parameters Params)
Definition: temporal_mean_method.h:186
KRATOS_CLASS_POINTER_DEFINITION(NormMethod)
void CalculateStatistics() override
Definition: temporal_mean_method.h:61
void CalculateStatistics() override
Definition: temporal_mean_method.h:131
#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