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.
mesh_controller_utilities.h
Go to the documentation of this file.
1 // ==============================================================================
2 // KratosShapeOptimizationApplication
3 //
4 // License: BSD License
5 // license: ShapeOptimizationApplication/license.txt
6 //
7 // Main authors: Baumgaertner Daniel, https://github.com/dbaumgaertner
8 //
9 // ==============================================================================
10 
11 #ifndef MESH_CONTROLLER_UTILITIES_H
12 #define MESH_CONTROLLER_UTILITIES_H
13 
14 // ------------------------------------------------------------------------------
15 // System includes
16 // ------------------------------------------------------------------------------
17 #include <iostream>
18 #include <string>
19 #include <algorithm>
20 
21 // ------------------------------------------------------------------------------
22 // External includes
23 // ------------------------------------------------------------------------------
24 
25 // ------------------------------------------------------------------------------
26 // Project includes
27 // ------------------------------------------------------------------------------
28 #include "includes/define.h"
29 #include "processes/process.h"
30 #include "includes/node.h"
31 #include "includes/element.h"
32 #include "includes/model_part.h"
33 #include "includes/kratos_flags.h"
36 
37 // ==============================================================================
38 
39 namespace Kratos
40 {
41 
44 
48 
49 
53 
57 
61 
63 
68 {
69 public:
72 
75 
79 
82  : mrModelPart( modelPart )
83  {
84  }
85 
88  {
89  }
90 
91 
95 
96 
100 
101  // --------------------------------------------------------------------------
103  {
104  for(auto & node_i: mrModelPart.Nodes())
105  noalias(node_i.Coordinates()) += node_i.FastGetSolutionStepValue(rInputVariable);
106  }
107 
108  // --------------------------------------------------------------------------
110  {
111  for(auto & node_i: mrModelPart.Nodes())
112  noalias(node_i.Coordinates()) -= node_i.FastGetSolutionStepValue(rInputVariable);
113  }
114 
115  // --------------------------------------------------------------------------
117  {
118  for(auto & node_i: mrModelPart.Nodes())
119  noalias(node_i.FastGetSolutionStepValue(MESH_CHANGE)) += node_i.FastGetSolutionStepValue(rInputVariable);
120  }
121 
122  // --------------------------------------------------------------------------
124  {
125  for(auto & node_i: mrModelPart.Nodes())
126  noalias(node_i.Coordinates()) = node_i.GetInitialPosition();
127  }
128 
129  // --------------------------------------------------------------------------
131  {
132  for(auto & node_i: mrModelPart.Nodes())
133  noalias(node_i.GetInitialPosition()) = node_i.Coordinates();
134  }
135 
136  // --------------------------------------------------------------------------
138  {
139  if(mrModelPart.GetNodalSolutionStepVariablesList().Has(DISPLACEMENT))
140  VariableUtils().SetHistoricalVariableToZero(DISPLACEMENT,mrModelPart.Nodes());
141  if(mrModelPart.GetNodalSolutionStepVariablesList().Has(ROTATION))
142  VariableUtils().SetHistoricalVariableToZero(ROTATION,mrModelPart.Nodes());
143  }
144 
145  // --------------------------------------------------------------------------
147  {
148  for(auto & node_i: mrModelPart.Nodes())
149  noalias(node_i.FastGetSolutionStepValue(rVariable)) = node_i.Coordinates();
150  }
151 
152  // --------------------------------------------------------------------------
154  const Variable<array_1d<double,3>> &rDistanceVariable )
155  {
156  for(auto & node_i: mrModelPart.Nodes()){
157  noalias(node_i.FastGetSolutionStepValue(rDistanceVariable)) =
158  node_i.FastGetSolutionStepValue(rInputVariable) - node_i.Coordinates();
159  }
160  }
161 
162  // --------------------------------------------------------------------------
163  void AddFirstVariableToSecondVariable( const Variable<array_1d<double,3>> &rFirstVariable, const Variable<array_1d<double,3>> &rSecondVariable )
164  {
165  // TODO this is a copy from optimization_utilities
166  for (auto & node_i : mrModelPart.Nodes())
167  noalias(node_i.FastGetSolutionStepValue(rSecondVariable)) += node_i.FastGetSolutionStepValue(rFirstVariable);
168  }
169 
170  // --------------------------------------------------------------------------
171 
175 
176 
180 
181 
185 
187  virtual std::string Info() const
188  {
189  return "MeshControllerUtilities";
190  }
191 
193  virtual void PrintInfo(std::ostream& rOStream) const
194  {
195  rOStream << "MeshControllerUtilities";
196  }
197 
199  virtual void PrintData(std::ostream& rOStream) const
200  {
201  }
202 
203 
207 
208 
210 
211 protected:
214 
215 
219 
220 
224 
225 
229 
230 
234 
235 
239 
240 
244 
245 
247 
248 private:
251 
252 
256 
257  // Initialized by class constructor
258  ModelPart& mrModelPart;
259 
263 
264 
268 
269 
273 
274 
278 
279 
283 
285 // MeshControllerUtilities& operator=(MeshControllerUtilities const& rOther);
286 
288 // MeshControllerUtilities(MeshControllerUtilities const& rOther);
289 
290 
292 
293 }; // Class MeshControllerUtilities
294 
296 
299 
300 
304 
306 
307 
308 } // namespace Kratos.
309 
310 #endif // MESH_CONTROLLER_UTILITIES_H
Short class definition.
Definition: mesh_controller_utilities.h:68
void RevertMeshUpdateAccordingInputVariable(const Variable< array_1d< double, 3 >> &rInputVariable)
Definition: mesh_controller_utilities.h:109
void SetMeshToReferenceMesh()
Definition: mesh_controller_utilities.h:123
KRATOS_CLASS_POINTER_DEFINITION(MeshControllerUtilities)
Pointer definition of MeshControllerUtilities.
void AddFirstVariableToSecondVariable(const Variable< array_1d< double, 3 >> &rFirstVariable, const Variable< array_1d< double, 3 >> &rSecondVariable)
Definition: mesh_controller_utilities.h:163
void UpdateMeshAccordingInputVariable(const Variable< array_1d< double, 3 >> &rInputVariable)
Definition: mesh_controller_utilities.h:102
void SetDeformationVariablesToZero()
Definition: mesh_controller_utilities.h:137
virtual ~MeshControllerUtilities()
Destructor.
Definition: mesh_controller_utilities.h:87
void WriteCoordinatesToVariable(const Variable< array_1d< double, 3 >> &rVariable)
Definition: mesh_controller_utilities.h:146
virtual std::string Info() const
Turn back information as a string.
Definition: mesh_controller_utilities.h:187
MeshControllerUtilities(ModelPart &modelPart)
Default constructor.
Definition: mesh_controller_utilities.h:81
void SubtractCoordinatesFromVariable(const Variable< array_1d< double, 3 >> &rInputVariable, const Variable< array_1d< double, 3 >> &rDistanceVariable)
Definition: mesh_controller_utilities.h:153
void LogMeshChangeAccordingInputVariable(Variable< array_1d< double, 3 >> &rInputVariable)
Definition: mesh_controller_utilities.h:116
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: mesh_controller_utilities.h:193
void SetReferenceMeshToMesh()
Definition: mesh_controller_utilities.h:130
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: mesh_controller_utilities.h:199
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetHistoricalVariableToZero(const Variable< TType > &rVariable, NodesContainerType &rNodes)
Sets the nodal value of any variable to zero.
Definition: variable_utils.h:757
bool Has(const VariableData &rThisVariable) const
Definition: variables_list.h:372
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484