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_input_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: Vicente Mataix Ferrandiz
12 //
13 
14 #if !defined(KRATOS_ASSIGN_SCALAR_INPUT_TO_ENTITIES_PROCESS_H_INCLUDED )
15 #define KRATOS_ASSIGN_SCALAR_INPUT_TO_ENTITIES_PROCESS_H_INCLUDED
16 
17 // System includes
18 
19 // External includes
20 
21 // Project includes
22 #include "includes/model_part.h"
24 #include "processes/process.h"
26 
27 namespace Kratos
28 {
29 
32 
37 {
38  // Defining clearer options
39  constexpr static bool SaveAsHistoricalVariable = true;
40  constexpr static bool SaveAsNonHistoricalVariable = false;
41 };
42 
51 template<class TEntity, bool THistorical = false>
52 class KRATOS_API(KRATOS_CORE) AssignScalarInputToEntitiesProcess
53  : public Process
54 {
55 public:
58 
60  typedef Node NodeType;
61 
63  typedef std::size_t IndexType;
64 
66  typedef std::size_t SizeType;
67 
70 
73 
75  KRATOS_DEFINE_LOCAL_FLAG( GEOMETRIC_DEFINITION );
76 
80 
84  enum class Algorithm {
85  NEAREST_NEIGHBOUR = 0
86  };
87 
91 
98  ModelPart& rModelPart,
99  Parameters rParameters
100  );
101 
104 
108 
112 
116  void ExecuteInitializeSolutionStep() override;
117 
121  const Parameters GetDefaultParameters() const override;
122 
126 
127 
131 
132 
136 
138  std::string Info() const override
139  {
140  return "AssignScalarInputToEntitiesProcess";
141  }
142 
144  void PrintInfo(std::ostream& rOStream) const override
145  {
146  rOStream << "AssignScalarInputToEntitiesProcess";
147  }
148 
150  void PrintData(std::ostream& rOStream) const override
151  {
152  }
153 
158 
159 protected:
160 
182 
183 private:
184 
190 
191  ModelPart& mrModelPart;
192 
193  const Variable<double>* mpVariable = nullptr;
194 
195  ResultDatabase mDatabase;
196 
197  std::vector<std::unordered_map<IndexType, double>> mWeightExtrapolation;
198 
199  std::vector<array_1d<double, 3>> mCoordinates;
200 
201  Algorithm mAlgorithm = Algorithm::NEAREST_NEIGHBOUR;
202 
206 
211  void IdentifyDataTXT(const std::string& rFileName);
212 
217  void IdentifyDataJSON(const std::string& rFileName);
218 
223  void ReadDataTXT(const std::string& rFileName);
224 
229  void ReadDataJSON(const std::string& rFileName);
230 
234  void ComputeExtrapolationWeight();
235 
241  void InternalAssignValue(
242  const Variable<double>& rVariable,
243  const double Value
244  );
245 
251  Algorithm ConvertAlgorithmString(const std::string& Str)
252  {
253  if(Str == "NEAREST_NEIGHBOUR" || Str == "nearest_neighbour")
254  return Algorithm::NEAREST_NEIGHBOUR;
255  else
256  return Algorithm::NEAREST_NEIGHBOUR;
257  }
258 
264  array_1d<double, 3> GetCoordinatesEntity(const IndexType Id);
265 
270  EntityContainerType& GetEntitiesContainer();
271 
275  void ResetValues();
276 
283  void SetValue(
284  TEntity& rEntity,
285  const Variable<double>& rVariable,
286  const double Value
287  );
288 
295  double& GetValue(
296  TEntity& rEntity,
297  const Variable<double>& rVariable
298  );
299 
316 
317 }; // Class AssignScalarInputToEntitiesProcess
318 
319 
321 
324 
325 
329 
330 
332 template<class TEntity>
333 inline std::istream& operator >> (std::istream& rIStream,
335 
337 template<class TEntity>
338 inline std::ostream& operator << (std::ostream& rOStream,
340 {
341  rThis.PrintInfo(rOStream);
342  rOStream << std::endl;
343  rThis.PrintData(rOStream);
344 
345  return rOStream;
346 }
348 
349 
350 } // namespace Kratos.
351 
352 #endif // KRATOS_ASSIGN_SCALAR_INPUT_TO_ENTITIES_PROCESS_H_INCLUDED defined
This function assigns a value from an input to a variable belonging to all of the entities in a given...
Definition: assign_scalar_input_to_entities_process.h:54
std::string Info() const override
Turn back information as a string.
Definition: assign_scalar_input_to_entities_process.h:138
KRATOS_CLASS_POINTER_DEFINITION(AssignScalarInputToEntitiesProcess)
Pointer definition of AssignScalarInputToEntitiesProcess.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: assign_scalar_input_to_entities_process.h:144
PointerVectorSet< TEntity, IndexedObject > EntityContainerType
The container of the entities.
Definition: assign_scalar_input_to_entities_process.h:69
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: assign_scalar_input_to_entities_process.h:150
std::size_t IndexType
The definition of the index type.
Definition: assign_scalar_input_to_entities_process.h:63
Node NodeType
Node type definition.
Definition: assign_scalar_input_to_entities_process.h:60
~AssignScalarInputToEntitiesProcess() override
Destructor.
Definition: assign_scalar_input_to_entities_process.h:103
KRATOS_DEFINE_LOCAL_FLAG(GEOMETRIC_DEFINITION)
Local Flags.
std::size_t SizeType
The definition of the sizetype.
Definition: assign_scalar_input_to_entities_process.h:66
Algorithm
This enum helps us to identify the algorithm considered.
Definition: assign_scalar_input_to_entities_process.h:84
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 stores the results of a simulation for a later comparison.
Definition: result_dabatase.h:403
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
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
def SetValue(entity, variable, value)
Definition: coupling_interface_data.py:256
This struct is used in order to identify when using the hitorical and non historical variables.
Definition: assign_scalar_input_to_entities_process.h:37
constexpr static bool SaveAsNonHistoricalVariable
Definition: assign_scalar_input_to_entities_process.h:40
constexpr static bool SaveAsHistoricalVariable
Definition: assign_scalar_input_to_entities_process.h:39