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.
metrics_hessian_process.h
Go to the documentation of this file.
1 // KRATOS __ __ _____ ____ _ _ ___ _ _ ____
2 // | \/ | ____/ ___|| | | |_ _| \ | |/ ___|
3 // | |\/| | _| \___ \| |_| || || \| | | _
4 // | | | | |___ ___) | _ || || |\ | |_| |
5 // |_| |_|_____|____/|_| |_|___|_| \_|\____| APPLICATION
6 //
7 // License: BSD License
8 // license: MeshingApplication/license.txt
9 //
10 // Main authors: Vicente Mataix Ferrandiz
11 //
12 
13 #if !defined(KRATOS_HESSIAN_METRICS_PROCESS)
14 #define KRATOS_HESSIAN_METRICS_PROCESS
15 
16 // Project includes
18 #include "processes/process.h"
20 #include "includes/model_part.h"
21 
22 namespace Kratos
23 {
26 
30 
32  typedef std::size_t SizeType;
33 
37 
41 
45 
53  {
55  const double AnisotropicRatio,
56  const double ElementMinSize,
57  const double ElementMaxSize,
58  const double NodalH,
59  const bool EstimateInterpolationError,
60  const double InterpolationError,
61  const double MeshDependentConstant,
62  const bool AnisotropyRemeshing,
63  const bool EnforceAnisotropyRelativeVariable
64  ) : mAnisotropicRatio(AnisotropicRatio),
65  mElementMinSize(ElementMinSize),
66  mElementMaxSize(ElementMaxSize),
67  mNodalH(NodalH),
68  mEstimateInterpolationError(EstimateInterpolationError),
69  mInterpolationError(InterpolationError),
70  mMeshDependentConstant(MeshDependentConstant),
71  mAnisotropyRemeshing(AnisotropyRemeshing),
72  mEnforceAnisotropyRelativeVariable(EnforceAnisotropyRelativeVariable)
73  {
74 
75  };
76 
78  double mElementMinSize;
79  double mElementMaxSize;
80  double mNodalH;
82  const double mInterpolationError;
83  const double mMeshDependentConstant;
84  const bool mAnisotropyRemeshing;
86  };
87 
96 class KRATOS_API(MESHING_APPLICATION) ComputeHessianSolMetricProcess
97  : public Process
98 {
99 public:
100 
103 
105  typedef Node NodeType;
106 
111 
113  typedef std::size_t IndexType;
114 
117 
121 
125  enum class Interpolation {CONSTANT = 0, LINEAR = 1, EXPONENTIAL = 2};
126 
130  enum class Normalization {CONSTANT = 0, VALUE = 1, NORM_GRADIENT = 2};
131 
135 
136  // Constructor
137 
144  ModelPart& rThisModelPart,
145  Parameters ThisParameters = Parameters(R"({})")
146  );
147 
155  ModelPart& rThisModelPart,
156  Variable<double>& rVariable,
157  Parameters ThisParameters = Parameters(R"({})")
158  );
159 
161  ~ComputeHessianSolMetricProcess() override = default;
162 
166 
167  void operator()()
168  {
169  Execute();
170  }
171 
175 
179  void Execute() override;
180 
184  const Parameters GetDefaultParameters() const override;
185 
189 
190 
194 
195 
199 
201  std::string Info() const override
202  {
203  return "ComputeHessianSolMetricProcess";
204  }
205 
207  void PrintInfo(std::ostream& rOStream) const override
208  {
209  rOStream << "ComputeHessianSolMetricProcess";
210  }
211 
213  void PrintData(std::ostream& rOStream) const override
214  {
215  }
216 
217 protected:
220 
221 
225 
226 
230 
231 
235 
236 
240 
241 
245 
246 
250 
251 
253 
254 private:
257 
261 
262  ModelPart& mrModelPart;
263 
264  bool mNonHistoricalVariable = false;
265  const Variable<double>* mpOriginVariable;
266  const Variable<double>* mpRatioReferenceVariable;
267 
268  Parameters mThisParameters;
269  Interpolation mInterpolation;
270 
274 
278 
285  template<SizeType TDim>
286  static array_1d<double, 3 * (TDim - 1)> ComputeHessianMetricTensor(
287  const Vector& rHessian,
288  const AuxiliarHessianComputationVariables& rAuxiliarHessianComputationVariables
289  );
290 
294  void CalculateAuxiliarHessian();
295 
301  Interpolation ConvertInter(const std::string& Str)
302  {
303  if(Str == "Constant" || Str == "CONSTANT" || Str == "constant")
304  return Interpolation::CONSTANT;
305  else if(Str == "Linear" || Str == "LINEAR" || Str == "linear")
306  return Interpolation::LINEAR;
307  else if(Str == "Exponential" || Str == "EXPONENTIAL" || Str == "exponential")
308  return Interpolation::EXPONENTIAL;
309  else
310  return Interpolation::LINEAR;
311  }
312 
318  Normalization ConvertNormalization(const std::string& Str)
319  {
320  if(Str == "Constant" || Str == "CONSTANT" || Str == "constant")
321  return Normalization::CONSTANT;
322  else if(Str == "Value" || Str == "VALUE" || Str == "value")
323  return Normalization::VALUE;
324  else if(Str == "Norm_Gradient" || Str == "NORM_GRADIENT" || Str == "norm_gradient")
325  return Normalization::NORM_GRADIENT;
326  else
327  return Normalization::CONSTANT;
328  }
329 
337  static double CalculateAnisotropicRatio(
338  const double Distance,
339  const double AnisotropicRatio,
340  const double BoundLayer,
341  const Interpolation rInterpolation
342  );
343 
347  template<SizeType TDim>
348  void CalculateMetric();
349 
353  void InitializeVariables(Parameters ThisParameters);
354 
358 
362 
366 
370 
372  ComputeHessianSolMetricProcess& operator=(ComputeHessianSolMetricProcess const& rOther);
373 
375  //ComputeHessianSolMetricProcess(ComputeHessianSolMetricProcess const& rOther);
376 
378 };// class ComputeHessianSolMetricProcess
380 
381 
384 
385 
389 
391 inline std::istream& operator >> (std::istream& rIStream,
393 
395 inline std::ostream& operator << (std::ostream& rOStream,
396  const ComputeHessianSolMetricProcess& rThis)
397 {
398  rThis.PrintInfo(rOStream);
399  rOStream << std::endl;
400  rThis.PrintData(rOStream);
401 
402  return rOStream;
403 }
404 
405 };// namespace Kratos.
406 #endif /* KRATOS_HESSIAN_METRICS_PROCESS defined */
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
This class is can be used to compute the metrics of the model part with an Hessian approach.
Definition: metrics_hessian_process.h:98
KRATOS_CLASS_POINTER_DEFINITION(ComputeHessianSolMetricProcess)
Pointer definition of ComputeHessianSolMetricProcess.
Node NodeType
Node definition.
Definition: metrics_hessian_process.h:105
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: metrics_hessian_process.h:110
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: metrics_hessian_process.h:207
ModelPart::ElementsContainerType ElementsArrayType
Definition: metrics_hessian_process.h:109
Interpolation
This enums allows to differentiate the interpolation types.
Definition: metrics_hessian_process.h:125
void PrintData(std::ostream &rOStream) const override
Print object"s data.
Definition: metrics_hessian_process.h:213
std::string Info() const override
Turn back information as a string.
Definition: metrics_hessian_process.h:201
void operator()()
Definition: metrics_hessian_process.h:167
ModelPart::NodesContainerType NodesArrayType
Containers definitions.
Definition: metrics_hessian_process.h:108
Normalization
This enums allows to differentiate the normalization types.
Definition: metrics_hessian_process.h:130
~ComputeHessianSolMetricProcess() override=default
Destructor.
std::size_t IndexType
The index type definition.
Definition: metrics_hessian_process.h:113
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
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
Short class definition.
Definition: array_1d.h:61
void InitializeVariables(TContainerType &rContainer, const Variable< TDataType > &rOutputVariable, const Variable< TDataType > &rReferenceVariable)
Definition: temporal_method_utilities.h:36
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
This is an auxiliar struct to store remeshing variables.
Definition: metrics_hessian_process.h:53
double mElementMinSize
The anisotropic ratio.
Definition: metrics_hessian_process.h:78
const double mMeshDependentConstant
The error of interpolation allowed.
Definition: metrics_hessian_process.h:83
const bool mAnisotropyRemeshing
The mesh constant to remesh (depends of the element type)
Definition: metrics_hessian_process.h:84
double mElementMaxSize
The min size of element. This way we can impose as minimum as the previous size if we desire.
Definition: metrics_hessian_process.h:79
AuxiliarHessianComputationVariables(const double AnisotropicRatio, const double ElementMinSize, const double ElementMaxSize, const double NodalH, const bool EstimateInterpolationError, const double InterpolationError, const double MeshDependentConstant, const bool AnisotropyRemeshing, const bool EnforceAnisotropyRelativeVariable)
Definition: metrics_hessian_process.h:54
double mNodalH
The maximal size of the elements. This way we can impose as maximum as the previous size if we desire...
Definition: metrics_hessian_process.h:80
double mAnisotropicRatio
Definition: metrics_hessian_process.h:75
const bool mEnforceAnisotropyRelativeVariable
If we consider anisotropic remeshing.
Definition: metrics_hessian_process.h:85
const bool mEstimateInterpolationError
The size of the local node.
Definition: metrics_hessian_process.h:81
const double mInterpolationError
If the error of interpolation will be estimated.
Definition: metrics_hessian_process.h:82