13 #if !defined(KRATOS_RANS_LINE_OUTPUT_PROCESS_H_INCLUDED)
14 #define KRATOS_RANS_LINE_OUTPUT_PROCESS_H_INCLUDED
30 namespace LineOutputProcessUtilities
50 template <
class TDataType>
62 std::vector<double>& rValuesVector,
63 const TDataType& rValue,
69 <<
"rValuesVector size is not enough to allocate values. "
70 "rValuesVector vector should have atleast "
72 <<
" elements from(including) StartIndex value. [ StartIndex = " << StartIndex
73 <<
", rValuesVector.size() = " << rValuesVector.size() <<
" ].\n";
76 rValuesVector[StartIndex +
i] += rValue[
i];
91 std::vector<std::string>& rNamesVector,
93 const TDataType& rValue,
99 <<
"rNamesVector size is not enough to allocate values. "
100 "rNamesVector vector should have atleast "
102 <<
" elements from(including) StartIndex value. [ StartIndex = " << StartIndex
103 <<
", rNamesVector.size() = " << rNamesVector.size() <<
" ].\n";
106 rNamesVector[StartIndex +
i] =
107 rVariable.
Name() +
"_" + std::to_string(
i + 1);
120 const TDataType& rValue)
122 return rValue.size();
143 template <
class TDataType,
class TValueGetterFunction>
145 std::vector<std::string>& rNamesList,
149 TValueGetterFunction* pValueGetterFunction)
151 for (std::size_t
i = 0;
i < rVariablesList.size(); ++
i) {
152 const auto& r_variable = *(rVariablesList[
i]);
154 rNamesList, r_variable, (*pValueGetterFunction)(rNode, r_variable),
155 rVariableValuesStartIndex[
i]);
169 template <
class TDataType>
187 template <
class TDataType>
206 template <
class TDataType,
class TValueGetterFunction>
210 TValueGetterFunction* pValueGetterFunction,
213 const auto number_of_variables = rVariablesList.size();
216 for (
SizeType i = 0;
i < number_of_variables; ++
i) {
217 start_indices[
i] = Offset;
219 (*pValueGetterFunction)(rNode, *(rVariablesList[
i])));
222 start_indices[number_of_variables] = Offset;
224 return start_indices;
251 template <
class TDataType,
class TValueGetterFunction>
253 std::vector<double>& rValuesList,
255 const double ShapeFunctionValue,
256 TValueGetterFunction* pValueGetterFunction,
261 using variable_data_collector =
264 for (
SizeType i = 0;
i < rVariablesList.size(); ++
i) {
265 variable_data_collector::AddToValuesVector(
266 rValuesList, (*pValueGetterFunction)(rNode, *(rVariablesList[
i])) * ShapeFunctionValue,
267 StartIndexOffset + rVariableValuesStartIndex[
i]);
289 template <
class... TVariableInfoTuplesList>
291 std::vector<double>& rValuesList,
293 const Vector& rSamplingPointShapeFunctions,
294 const SizeType LocalSamplePointValuesOffset,
295 const TVariableInfoTuplesList&... rVariableInfoTuplesList)
302 <<
"number_of_nodes != rSamplingPointShapeFunctions.size().";
304 for (
SizeType i_node = 0; i_node < number_of_nodes; ++i_node) {
305 const auto& r_node = rGeometry[i_node];
306 const double shape_function_value = rSamplingPointShapeFunctions[i_node];
308 int dummy[
sizeof...(rVariableInfoTuplesList)] = {(
310 std::get<2>(rVariableInfoTuplesList),
311 std::get<0>(rVariableInfoTuplesList),
312 std::get<1>(rVariableInfoTuplesList), LocalSamplePointValuesOffset),
376 int Check()
override;
380 void ExecuteInitializeSolutionStep()
override;
384 const Parameters GetDefaultParameters()
const override;
391 std::string
Info()
const override;
394 void PrintInfo(std::ostream& rOStream)
const override;
397 void PrintData(std::ostream& rOStream)
const override;
407 std::string mModelPartName;
408 std::vector<std::string> mVariableNames;
413 double mOutputStepInterval;
414 double mCurrentStepCount = 0.0;
415 double mPreviousStepValue;
416 std::string mOutputFileName;
417 std::string mOutputStepControlVariableName;
419 bool mIsHistoricalValue;
420 bool mUpdatePointsEachStep;
423 std::vector<double> mSamplingPoints;
424 std::vector<int> mSamplingPointElementIds;
425 std::vector<Vector> mSamplingPointElementShapeFunctions;
428 std::vector<IndicesVector> mSamplePointLocalIndexListMaster;
430 template <
class TDataType>
431 using variables_vector_type = std::vector<const Variable<TDataType>*>;
433 variables_vector_type<double> mDoubleVariablesList;
434 variables_vector_type<array_1d<double, 3>> mArray3VariablesList;
435 variables_vector_type<array_1d<double, 4>> mArray4VariablesList;
436 variables_vector_type<array_1d<double, 6>> mArray6VariablesList;
437 variables_vector_type<array_1d<double, 9>> mArray9VariablesList;
438 variables_vector_type<Vector> mVectorVariablesList;
439 variables_vector_type<Matrix> mMatrixVariablesList;
451 void UpdateSamplePoints();
466 template <
class TDataType>
467 bool CheckAndAddVariableToList(
468 variables_vector_type<TDataType>& rVariablesList,
470 const std::string& rVariableName)
475 const auto& r_variable =
478 << rVariableName <<
" is not found in nodal solution step variables list of "
479 << rModelPart.
Name() <<
".";
481 rVariablesList.push_back(&r_variable);
504 template <
class TOutputDataType,
class TDataType>
505 void GetVariableValueFromProcessInfo(
506 bool& rIsValueObtained,
507 TOutputDataType& rOutputValue,
508 const std::string& rVariableName)
const
512 if (KratosComponents<Variable<TDataType>>::
Has(rVariableName)) {
513 const auto& r_process_info =
515 const auto& r_variable =
516 KratosComponents<Variable<TDataType>>::Get(rVariableName);
518 if (r_process_info.Has(r_variable)) {
519 rOutputValue =
static_cast<TOutputDataType
>(r_process_info[r_variable]);
520 rIsValueObtained =
true;
537 template <
class... TDataTypes>
538 double CheckAndGetOutputVariableValue(
539 const std::string& rVariableName)
const
543 bool is_variable_found =
false;
546 int dummy[
sizeof...(TDataTypes)] = {(
547 GetVariableValueFromProcessInfo<double, TDataTypes>(is_variable_found, value, rVariableName),
553 <<
"Output step control variable name not found in variables list. "
555 "output_step_control_variable_name = "
556 << rVariableName <<
" ].\n";
575 void WriteOutputFile()
const;
582 void WriteOutputFileHeader(
583 std::ofstream& rOutputFileStream)
const;
590 std::string GetOutputFileName()
const;
602 std::ostream& rOStream,
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:55
void ExecuteInitialize() override
Definition: periodic_interface_process.hpp:37
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: element.h:83
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
Class to get variable information.
Definition: rans_line_output_process.h:52
static SizeType GetVariableDataLength(const TDataType &rValue)
Get the Variable Data Length.
Definition: rans_line_output_process.h:119
static void AddNamesToVector(std::vector< std::string > &rNamesVector, const Variable< TDataType > &rVariable, const TDataType &rValue, const SizeType StartIndex)
Updates variable names from given variable.
Definition: rans_line_output_process.h:90
static void AddToValuesVector(std::vector< double > &rValuesVector, const TDataType &rValue, const SizeType StartIndex)
Updates TDataType values starting from StartIndex.
Definition: rans_line_output_process.h:61
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
ModelPart & GetModelPart(const std::string &rFullModelPartName)
This method returns a model part given a certain name.
Definition: model.cpp:107
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
std::string & Name()
Definition: model_part.h:1811
bool HasNodalSolutionStepVariable(VariableData const &ThisVariable) const
Definition: model_part.h:544
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
Node NodeType
Definition: model_part.h:117
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
The base class for all processes in Kratos.
Definition: process.h:49
Line output process.
Definition: rans_line_output_process.h:343
std::vector< int > IndicesVector
Definition: rans_line_output_process.h:353
RansLineOutputProcess & operator=(RansLineOutputProcess const &rOther)=delete
Assignment operator.
~RansLineOutputProcess() override=default
Destructor.
RansLineOutputProcess(RansLineOutputProcess const &rOther)=delete
Copy constructor.
KRATOS_CLASS_POINTER_DEFINITION(RansLineOutputProcess)
Pointer definition of RansLineOutputProcess.
std::size_t SizeType
Definition: rans_line_output_process.h:352
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_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
TDataType GetNonHistoricalValue(const NodeType &rNode, const Variable< TDataType > &rVariable)
Get the Historical Value.
Definition: rans_line_output_process.h:188
void InterpolateVariables(std::vector< double > &rValuesList, const GeometryType &rGeometry, const Vector &rSamplingPointShapeFunctions, const SizeType LocalSamplePointValuesOffset, const TVariableInfoTuplesList &... rVariableInfoTuplesList)
Interpolates variables for given variable list tuples.
Definition: rans_line_output_process.h:290
std::size_t SizeType
Definition: rans_line_output_process.h:37
std::vector< int > IndicesVector
Definition: rans_line_output_process.h:38
void AddInterpolationContributions(std::vector< double > &rValuesList, const ModelPart::NodeType &rNode, const double ShapeFunctionValue, TValueGetterFunction *pValueGetterFunction, const IndicesVector &rVariableValuesStartIndex, const std::vector< const Variable< TDataType > * > &rVariablesList, const SizeType StartIndexOffset)
Adds interpolation contributions for given variables list.
Definition: rans_line_output_process.h:252
IndicesVector GetVariableDataStartIndices(const NodeType &rNode, const std::vector< const Variable< TDataType > * > &rVariablesList, TValueGetterFunction *pValueGetterFunction, SizeType &Offset)
Calculates variable start indices.
Definition: rans_line_output_process.h:207
TDataType GetHistoricalValue(const NodeType &rNode, const Variable< TDataType > &rVariable)
Get the Historical Value.
Definition: rans_line_output_process.h:170
void AddVariablesListNamesToVector(std::vector< std::string > &rNamesList, const NodeType &rNode, const std::vector< const Variable< TDataType > * > &rVariablesList, const IndicesVector &rVariableValuesStartIndex, TValueGetterFunction *pValueGetterFunction)
Modifies names from list of variables.
Definition: rans_line_output_process.h:144
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
dummy
Definition: script.py:194
integer i
Definition: TensorModule.f:17