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.
compute_nodal_gradient_process.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ \.
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 // Vicente Mataix Ferrandiz
12 //
13 
14 #pragma once
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "includes/define.h"
22 #include "processes/process.h"
23 #include "includes/model_part.h"
25 
26 namespace Kratos
27 {
28 
31 
35 
39 
43 
47 
52 {
53  // Defining clearer options
54  constexpr static bool SaveAsHistoricalVariable = true;
55  constexpr static bool SaveAsNonHistoricalVariable = false;
56  constexpr static bool GetAsHistoricalVariable = true;
57  constexpr static bool GetAsNonHistoricalVariable = false;
58 };
59 
64 {
67  {
68  }
69 
76  virtual void GetVariableVector(
77  const Geometry<Node>& rGeometry,
78  const Variable<double>& rVariable,
79  Vector& rVector
80  )
81  {
82  KRATOS_ERROR << "Calling base class implementation" << std::endl;
83  }
84 };
85 
89 template<bool THistorical>
92 {
95  {
96  }
97 
104  void GetVariableVector(
105  const Geometry<Node>& rGeometry,
106  const Variable<double>& rVariable,
107  Vector& rVector
108  ) override;
109 };
110 
120 template<bool THistorical>
121 class KRATOS_API(KRATOS_CORE) ComputeNodalGradientProcess
122  : public Process
123 {
124 public:
127 
129  typedef Node NodeType;
130 
133 
137 
140  ModelPart& rModelPart,
141  Parameters ThisParameters = Parameters(R"({})")
142  );
143 
146  ModelPart& rModelPart,
147  const Variable<double>& rOriginVariable,
148  const Variable<array_1d<double,3> >& rGradientVariable,
149  const Variable<double>& rAreaVariable = NODAL_AREA,
150  const bool NonHistoricalVariable = false
151  );
152 
155  {
156  }
157 
161 
163  void operator()()
164  {
165  Execute();
166  }
167 
171 
176  void Execute() override;
177 
181  const Parameters GetDefaultParameters() const override;
182 
186 
190 
194 
196  std::string Info() const override
197  {
198  return "ComputeNodalGradientProcess";
199  }
200 
202  void PrintInfo(std::ostream& rOStream) const override
203  {
204  rOStream << "ComputeNodalGradientProcess";
205  }
206 
208  void PrintData(std::ostream& rOStream) const override
209  {
210  }
211 
215 
217 protected:
220 
224 
228 
232 
236 
240 
244 
246 private:
249 
253 
254  ModelPart& mrModelPart;
255  const Variable<double>* mpOriginVariable = nullptr;
256  const Variable<array_1d<double,3>>* mpGradientVariable;
257  const Variable<double>* mpAreaVariable = nullptr;
258  bool mNonHistoricalVariable = false;
259 
263 
267 
268  // TODO: Try to use enable_if!!!
269 
274  void CheckOriginAndAreaVariables();
275 
279  void ClearGradient();
280 
286  array_1d<double, 3>& GetGradient(
287  Element::GeometryType& rThisGeometry,
288  unsigned int i
289  );
290 
296  void ComputeElementalContributionsAndVolume();
297 
301  void PonderateGradient();
302 
306  void SynchronizeGradientAndVolume();
307 
311 
315 
319 
322 
324  //ComputeNodalGradientProcess(ComputeNodalGradientProcess const& rOther);
325 
327 }; // Class ComputeNodalGradientProcess
328 
330 
333 
334 
338 
340 // inline std::istream& operator >> (std::istream& rIStream,
341 // ComputeNodalGradientProcess& rThis);
342 //
343 // /// output stream function
344 // inline std::ostream& operator << (std::ostream& rOStream,
345 // const ComputeNodalGradientProcess& rThis)
346 // {
347 // rThis.PrintInfo(rOStream);
348 // rOStream << std::endl;
349 // rThis.PrintData(rOStream);
350 //
351 // return rOStream;
352 // }
354 
355 } // namespace Kratos.
356 
357 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Compute Nodal Gradient process.
Definition: compute_nodal_gradient_process.h:123
std::string Info() const override
Turn back information as a string.
Definition: compute_nodal_gradient_process.h:196
~ComputeNodalGradientProcess() override
Destructor.
Definition: compute_nodal_gradient_process.h:154
KRATOS_CLASS_POINTER_DEFINITION(ComputeNodalGradientProcess)
Pointer definition of ComputeNodalGradientProcess.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: compute_nodal_gradient_process.h:202
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: compute_nodal_gradient_process.h:208
Node NodeType
The definition of the node.
Definition: compute_nodal_gradient_process.h:129
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: compute_nodal_gradient_process.h:163
Geometry base class.
Definition: geometry.h:71
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
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17
This struct is an auxiliar base class of the VariableVectorRetriever.
Definition: compute_nodal_gradient_process.h:64
virtual ~AuxiliarVariableVectorRetriever()
Destructor.
Definition: compute_nodal_gradient_process.h:66
virtual void GetVariableVector(const Geometry< Node > &rGeometry, const Variable< double > &rVariable, Vector &rVector)
This method fills the vector of values.
Definition: compute_nodal_gradient_process.h:76
This struct is used in order to identify when using the hitorical and non historical variables.
Definition: compute_nodal_gradient_process.h:52
constexpr static bool SaveAsNonHistoricalVariable
Definition: compute_nodal_gradient_process.h:55
constexpr static bool GetAsHistoricalVariable
Definition: compute_nodal_gradient_process.h:56
constexpr static bool GetAsNonHistoricalVariable
Definition: compute_nodal_gradient_process.h:57
constexpr static bool SaveAsHistoricalVariable
Definition: compute_nodal_gradient_process.h:54
This struct is used in order to retrieve values without loosing performance.
Definition: compute_nodal_gradient_process.h:92
~VariableVectorRetriever() override
Destructor.
Definition: compute_nodal_gradient_process.h:94
void GetVariableVector(const Geometry< Node > &rGeometry, const Variable< double > &rVariable, Vector &rVector) override
This method fills the vector of values.
Definition: compute_nodal_gradient_process.cpp:332