KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
assign_scalar_variable_to_entities_process.h
Go to the documentation of this file.
1 //
2 // | / |
3 // ' / __| _` | __| _ \ __|
4 // . \ | ( | | ( |\__ `
5 // _|\_\_| \__,_|\__|\___/ ____/
6 // Multi-Physics
7 //
8 // License: BSD License
9 // Kratos default license: kratos/license.txt
10 //
11 // Main authors: Josep Maria Carbonell
12 // Vicente Mataix Ferrandiz
13 //
14 
15 #if !defined(KRATOS_ASSIGN_SCALAR_VARIABLE_TO_ENTITIES_PROCESS_H_INCLUDED )
16 #define KRATOS_ASSIGN_SCALAR_VARIABLE_TO_ENTITIES_PROCESS_H_INCLUDED
17 
18 // System includes
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/model_part.h"
25 #include "processes/process.h"
27 
28 namespace Kratos
29 {
30 
33 
43 template<class TEntity>
44 class KRATOS_API(KRATOS_CORE) AssignScalarVariableToEntitiesProcess
45  : public Process
46 {
47 public:
50 
52  typedef Node NodeType;
53 
56 
59 
63 
70  ModelPart& rModelPart,
71  Parameters rParameters
72  );
73 
76 
80 
82  void operator()()
83  {
84  Execute();
85  }
86 
90 
94  void Execute() override;
95 
100  {
101  Execute();
102  }
103 
107  const Parameters GetDefaultParameters() const override;
108 
112 
113 
117 
118 
122 
124  std::string Info() const override
125  {
126  return "AssignScalarVariableToEntitiesProcess";
127  }
128 
130  void PrintInfo(std::ostream& rOStream) const override
131  {
132  rOStream << "AssignScalarVariableToEntitiesProcess";
133  }
134 
136  void PrintData(std::ostream& rOStream) const override
137  {
138  }
139 
144 
145 protected:
146 
155 
170 
171 private:
172 
178 
179  ModelPart& mrModelPart;
180  std::string mVariableName;
181  double mDoubleValue;
182  int mIntValue;
183  bool mBoolValue;
184  std::size_t mMeshId;
185 
189 
195  template< class TVarType, class TDataType >
196  void InternalAssignValue(TVarType& rVar, const TDataType Value)
197  {
198  VariableUtils().SetNonHistoricalVariable(rVar, Value, GetEntitiesContainer());
199  }
200 
206  template< class TVarType, class TDataType >
207  void InternalAssignValueSerial(TVarType& rVar, const TDataType Value)
208  {
209  auto& r_entities_array = GetEntitiesContainer();
210  const int number_of_entities = static_cast<int>(r_entities_array.size());
211 
212  if(number_of_entities != 0) {
213  const auto it_begin = r_entities_array.begin();
214 
215  for(int i = 0; i<number_of_entities; i++) {
216  auto it_entity = it_begin + i;
217 
218  it_entity->SetValue(rVar, Value);
219  }
220  }
221  }
222 
227  EntityContainerType& GetEntitiesContainer();
228 
235 
246 
247 }; // Class AssignScalarVariableToEntitiesProcess
248 
249 
251 
254 
255 
259 
260 
262 template<class TEntity>
263 inline std::istream& operator >> (std::istream& rIStream,
265 
267 template<class TEntity>
268 inline std::ostream& operator << (std::ostream& rOStream,
270 {
271  rThis.PrintInfo(rOStream);
272  rOStream << std::endl;
273  rThis.PrintData(rOStream);
274 
275  return rOStream;
276 }
278 
279 
280 } // namespace Kratos.
281 
282 #endif // KRATOS_ASSIGN_SCALAR_VARIABLE_TO_ENTITIES_PROCESS_H_INCLUDED defined
The base class for assigning a value to scalar variables or array_1d components processes in Kratos.
Definition: assign_scalar_variable_to_entities_process.h:46
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: assign_scalar_variable_to_entities_process.h:82
~AssignScalarVariableToEntitiesProcess() override
Destructor.
Definition: assign_scalar_variable_to_entities_process.h:75
std::string Info() const override
Turn back information as a string.
Definition: assign_scalar_variable_to_entities_process.h:124
PointerVectorSet< TEntity, IndexedObject > EntityContainerType
The container of the entities.
Definition: assign_scalar_variable_to_entities_process.h:55
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: assign_scalar_variable_to_entities_process.h:130
Node NodeType
Node type definition.
Definition: assign_scalar_variable_to_entities_process.h:52
KRATOS_CLASS_POINTER_DEFINITION(AssignScalarVariableToEntitiesProcess)
Pointer definition of AssignScalarVariableToEntitiesProcess.
void ExecuteInitializeSolutionStep() override
This function will be executed at every time step BEFORE performing the solve phase.
Definition: assign_scalar_variable_to_entities_process.h:99
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: assign_scalar_variable_to_entities_process.h:136
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
The base class for all processes in Kratos.
Definition: process.h:49
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetNonHistoricalVariable(const TVarType &rVariable, const TType &Value, TContainerType &rContainer)
Sets the container value of any type of non historical variable.
Definition: variable_utils.h:790
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
integer i
Definition: TensorModule.f:17