13 #if !defined(KRATOS_METHOD_UTILITIES_H_INCLUDED)
14 #define KRATOS_METHOD_UTILITIES_H_INCLUDED
26 #ifndef ADD_TEMPORAL_VALUE_METHOD_ONE_OUTPUT_VARIABLE_OBJECT
27 #define ADD_TEMPORAL_VALUE_METHOD_ONE_OUTPUT_VARIABLE_OBJECT( \
28 model_part, norm_type, input_variable, echo_level, output_variable, object_list, method) \
30 if (KratosComponents<Variable<double>>::Has(input_variable)) \
32 const Variable<double>& r_variable_input = \
33 KratosComponents<Variable<double>>::Get(input_variable); \
34 const Variable<double>& r_variable_output = \
35 KratosComponents<Variable<double>>::Get(output_variable); \
36 object_list.push_back(std::make_shared<method<double>>( \
37 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
39 else if (KratosComponents<Variable<array_1d<double, 3>>>::Has(input_variable)) \
41 const Variable<array_1d<double, 3>>& r_variable_input = \
42 KratosComponents<Variable<array_1d<double, 3>>>::Get(input_variable); \
43 const Variable<array_1d<double, 3>>& r_variable_output = \
44 KratosComponents<Variable<array_1d<double, 3>>>::Get(output_variable); \
45 object_list.push_back(std::make_shared<method<array_1d<double, 3>>>( \
46 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
48 else if (KratosComponents<Variable<Vector>>::Has(input_variable)) \
50 const Variable<Vector>& r_variable_input = \
51 KratosComponents<Variable<Vector>>::Get(input_variable); \
52 const Variable<Vector>& r_variable_output = \
53 KratosComponents<Variable<Vector>>::Get(output_variable); \
54 object_list.push_back(std::make_shared<method<Vector>>( \
55 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
57 else if (KratosComponents<Variable<Matrix>>::Has(input_variable)) \
59 const Variable<Matrix>& r_variable_input = \
60 KratosComponents<Variable<Matrix>>::Get(input_variable); \
61 const Variable<Matrix>& r_variable_output = \
62 KratosComponents<Variable<Matrix>>::Get(output_variable); \
63 object_list.push_back(std::make_shared<method<Matrix>>( \
64 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
69 << "Input variable not found in Double, Array3D, Vector or " \
70 "Matrix variables list. [ input_variable = " \
71 << input_variable << " ]\n"; \
76 #ifndef ADD_TEMPORAL_NORM_METHOD_ONE_OUTPUT_VARIABLE_OBJECT
77 #define ADD_TEMPORAL_NORM_METHOD_ONE_OUTPUT_VARIABLE_OBJECT( \
78 model_part, norm_type, input_variable, echo_level, output_variable, object_list, method) \
80 if (KratosComponents<Variable<double>>::Has(input_variable)) \
82 const Variable<double>& r_variable_input = \
83 KratosComponents<Variable<double>>::Get(input_variable); \
84 const Variable<double>& r_variable_output = \
85 KratosComponents<Variable<double>>::Get(output_variable); \
86 object_list.push_back(std::make_shared<method<double>>( \
87 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
89 else if (KratosComponents<Variable<array_1d<double, 3>>>::Has(input_variable)) \
91 const Variable<array_1d<double, 3>>& r_variable_input = \
92 KratosComponents<Variable<array_1d<double, 3>>>::Get(input_variable); \
93 const Variable<double>& r_variable_output = \
94 KratosComponents<Variable<double>>::Get(output_variable); \
95 object_list.push_back(std::make_shared<method<array_1d<double, 3>>>( \
96 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
98 else if (KratosComponents<Variable<Vector>>::Has(input_variable)) \
100 const Variable<Vector>& r_variable_input = \
101 KratosComponents<Variable<Vector>>::Get(input_variable); \
102 const Variable<double>& r_variable_output = \
103 KratosComponents<Variable<double>>::Get(output_variable); \
104 object_list.push_back(std::make_shared<method<Vector>>( \
105 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
107 else if (KratosComponents<Variable<Matrix>>::Has(input_variable)) \
109 const Variable<Matrix>& r_variable_input = \
110 KratosComponents<Variable<Matrix>>::Get(input_variable); \
111 const Variable<double>& r_variable_output = \
112 KratosComponents<Variable<double>>::Get(output_variable); \
113 object_list.push_back(std::make_shared<method<Matrix>>( \
114 model_part, norm_type, r_variable_input, echo_level, r_variable_output)); \
119 << "Input variable not found in Double, Array3D, Vector or " \
120 "Matrix variables list. [ input_variable = " \
121 << input_variable << " ]\n"; \
126 #ifndef ADD_TEMPORAL_VALUE_METHOD_TWO_OUTPUT_VARIABLE_OBJECT
127 #define ADD_TEMPORAL_VALUE_METHOD_TWO_OUTPUT_VARIABLE_OBJECT( \
128 model_part, norm_type, input_variable, echo_level, output_variable_1, \
129 output_variable_2, object_list, method) \
131 if (KratosComponents<Variable<double>>::Has(input_variable)) \
133 const Variable<double>& r_variable_input = \
134 KratosComponents<Variable<double>>::Get(input_variable); \
135 const Variable<double>& r_variable_output_1 = \
136 KratosComponents<Variable<double>>::Get(output_variable_1); \
137 const Variable<double>& r_variable_output_2 = \
138 KratosComponents<Variable<double>>::Get(output_variable_2); \
139 object_list.push_back(std::make_shared<method<double>>( \
140 model_part, norm_type, r_variable_input, echo_level, \
141 r_variable_output_1, r_variable_output_2)); \
143 else if (KratosComponents<Variable<array_1d<double, 3>>>::Has(input_variable)) \
145 const Variable<array_1d<double, 3>>& r_variable_input = \
146 KratosComponents<Variable<array_1d<double, 3>>>::Get(input_variable); \
147 const Variable<array_1d<double, 3>>& r_variable_output_1 = \
148 KratosComponents<Variable<array_1d<double, 3>>>::Get(output_variable_1); \
149 const Variable<array_1d<double, 3>>& r_variable_output_2 = \
150 KratosComponents<Variable<array_1d<double, 3>>>::Get(output_variable_2); \
151 object_list.push_back(std::make_shared<method<array_1d<double, 3>>>( \
152 model_part, norm_type, r_variable_input, echo_level, \
153 r_variable_output_1, r_variable_output_2)); \
155 else if (KratosComponents<Variable<Vector>>::Has(input_variable)) \
157 const Variable<Vector>& r_variable_input = \
158 KratosComponents<Variable<Vector>>::Get(input_variable); \
159 const Variable<Vector>& r_variable_output_1 = \
160 KratosComponents<Variable<Vector>>::Get(output_variable_1); \
161 const Variable<Vector>& r_variable_output_2 = \
162 KratosComponents<Variable<Vector>>::Get(output_variable_2); \
163 object_list.push_back(std::make_shared<method<Vector>>( \
164 model_part, norm_type, r_variable_input, echo_level, \
165 r_variable_output_1, r_variable_output_2)); \
167 else if (KratosComponents<Variable<Matrix>>::Has(input_variable)) \
169 const Variable<Matrix>& r_variable_input = \
170 KratosComponents<Variable<Matrix>>::Get(input_variable); \
171 const Variable<Matrix>& r_variable_output_1 = \
172 KratosComponents<Variable<Matrix>>::Get(output_variable_1); \
173 const Variable<Matrix>& r_variable_output_2 = \
174 KratosComponents<Variable<Matrix>>::Get(output_variable_2); \
175 object_list.push_back(std::make_shared<method<Matrix>>( \
176 model_part, norm_type, r_variable_input, echo_level, \
177 r_variable_output_1, r_variable_output_2)); \
182 << "Input variable not found in Double, Array3D, Vector or " \
183 "Matrix variables list. [ input_variable = " \
184 << input_variable << " ]\n"; \
189 #ifndef ADD_TEMPORAL_NORM_METHOD_TWO_OUTPUT_VARIABLE_OBJECT
190 #define ADD_TEMPORAL_NORM_METHOD_TWO_OUTPUT_VARIABLE_OBJECT( \
191 model_part, norm_type, input_variable, echo_level, output_variable_1, \
192 output_variable_2, object_list, method) \
194 if (KratosComponents<Variable<double>>::Has(input_variable)) \
196 const Variable<double>& r_variable_input = \
197 KratosComponents<Variable<double>>::Get(input_variable); \
198 const Variable<double>& r_variable_output_1 = \
199 KratosComponents<Variable<double>>::Get(output_variable_1); \
200 const Variable<double>& r_variable_output_2 = \
201 KratosComponents<Variable<double>>::Get(output_variable_2); \
202 object_list.push_back(std::make_shared<method<double>>( \
203 model_part, norm_type, r_variable_input, echo_level, \
204 r_variable_output_1, r_variable_output_2)); \
206 else if (KratosComponents<Variable<array_1d<double, 3>>>::Has(input_variable)) \
208 const Variable<array_1d<double, 3>>& r_variable_input = \
209 KratosComponents<Variable<array_1d<double, 3>>>::Get(input_variable); \
210 const Variable<double>& r_variable_output_1 = \
211 KratosComponents<Variable<double>>::Get(output_variable_1); \
212 const Variable<double>& r_variable_output_2 = \
213 KratosComponents<Variable<double>>::Get(output_variable_2); \
214 object_list.push_back(std::make_shared<method<array_1d<double, 3>>>( \
215 model_part, norm_type, r_variable_input, echo_level, \
216 r_variable_output_1, r_variable_output_2)); \
218 else if (KratosComponents<Variable<Vector>>::Has(input_variable)) \
220 const Variable<Vector>& r_variable_input = \
221 KratosComponents<Variable<Vector>>::Get(input_variable); \
222 const Variable<double>& r_variable_output_1 = \
223 KratosComponents<Variable<double>>::Get(output_variable_1); \
224 const Variable<double>& r_variable_output_2 = \
225 KratosComponents<Variable<double>>::Get(output_variable_2); \
226 object_list.push_back(std::make_shared<method<Vector>>( \
227 model_part, norm_type, r_variable_input, echo_level, \
228 r_variable_output_1, r_variable_output_2)); \
230 else if (KratosComponents<Variable<Matrix>>::Has(input_variable)) \
232 const Variable<Matrix>& r_variable_input = \
233 KratosComponents<Variable<Matrix>>::Get(input_variable); \
234 const Variable<double>& r_variable_output_1 = \
235 KratosComponents<Variable<double>>::Get(output_variable_1); \
236 const Variable<double>& r_variable_output_2 = \
237 KratosComponents<Variable<double>>::Get(output_variable_2); \
238 object_list.push_back(std::make_shared<method<Matrix>>( \
239 model_part, norm_type, r_variable_input, echo_level, \
240 r_variable_output_1, r_variable_output_2)); \
245 << "Input variable not found in Double, Array3D, Vector or " \
246 "Matrix variables list. [ input_variable = " \
247 << input_variable << " ]\n"; \
260 namespace MethodUtilities
270 template <
class TDataType>
272 TDataType
RaiseToPower(
const TDataType& rData,
const double Power);
274 template <
class TContainerItemType>
278 template <
class TDataType>
281 return rDataItem.GetValue(rVariable);
284 template <
class TDataType>
287 return rDataItem.GetValue(rVariable);
290 template <
class TDataType>
293 rDataItem.SetValue(rVariable, rValue);
297 template <
class TContainerItemType>
301 template <
class TDataType>
306 return rDataItem.FastGetSolutionStepValue(rVariable);
311 template <
class TDataType>
316 return rDataItem.FastGetSolutionStepValue(rVariable);
321 template <
class TDataType>
326 rDataItem.FastGetSolutionStepValue(rVariable) = rValue;
339 void SplitString(std::string& rOutput1, std::string& rOutput2,
const std::string& rInput);
341 template <
class TDataType>
345 template <
class TDataType>
349 template <
class TContainerType>
353 template <
class TContainerType>
357 template <
class TContainerType>
361 template <
class TContainerType>
365 template <
class TDataType>
370 template <
class TDataType>
374 template <class TDataType>
380 const std::vector<
std::
string>& rInputVariableNamesList,
381 const std::vector<
std::
string>& rOutputVariableNamesList);
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
Definition: method_utilities.h:299
TDataType & operator()(TContainerItemType &rDataItem, const Variable< TDataType > &rVariable) const
Definition: method_utilities.h:302
void operator()(TContainerItemType &rDataItem, const Variable< TDataType > &rVariable, const TDataType &rValue) const
Definition: method_utilities.h:322
TDataType operator()(const TContainerItemType &rDataItem, const Variable< TDataType > &rVariable) const
Definition: method_utilities.h:312
Definition: method_utilities.h:276
TDataType operator()(const TContainerItemType &rDataItem, const Variable< TDataType > &rVariable) const
Definition: method_utilities.h:285
void operator()(TContainerItemType &rDataItem, const Variable< TDataType > &rVariable, const TDataType &rValue) const
Definition: method_utilities.h:291
TDataType & operator()(TContainerItemType &rDataItem, const Variable< TDataType > &rVariable) const
Definition: method_utilities.h:279
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Element ElementType
Definition: model_part.h:120
Node NodeType
Definition: model_part.h:117
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
Condition ConditionType
Definition: model_part.h:121
This class defines the node.
Definition: node.h:65
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_API(...)
Definition: kratos_export_api.h:40
NodesContainerType & GetLocalDataContainer(ModelPart &rModelPart)
Definition: method_utilities.cpp:167
ModelPart::NodesContainerType NodesContainerType
Definition: method_utilities.h:266
std::vector< double > SortSortedValuesList(const std::vector< std::vector< double >> &rValues)
Definition: method_utilities.cpp:725
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
int GetIntegerValue(const std::string &rInput)
Definition: method_utilities.cpp:274
TDataType RaiseToPower(const TDataType &rData, const double Power)
Definition: method_utilities.cpp:34
std::string GetVariableTypeName()
ModelPart::ElementsContainerType ElementsContainerType
Definition: method_utilities.h:268
void CheckVariableType(const std::vector< std::string > &rVariableNamesList)
Definition: method_utilities.cpp:664
void CheckInputOutputVariables(const std::vector< std::string > &rInputVariableNamesList, const std::vector< std::string > &rOutputVariableNamesList)
Definition: method_utilities.cpp:678
void SplitString(std::string &rOutput1, std::string &rOutput2, const std::string &rInput)
Definition: method_utilities.cpp:295
double GetDoubleValue(const std::string &rInput)
Definition: method_utilities.cpp:249
void DataTypeSizeInitializer(TDataType &rData, const TDataType &rReferenceData)
Definition: method_utilities.cpp:82
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: method_utilities.h:267
NodesContainerType & GetDataContainer(ModelPart &rModelPart)
Definition: method_utilities.cpp:209
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
tuple const
Definition: ode_solve.py:403
namespace
Definition: array_1d.h:793