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.
shock_capturing_entropy_viscosity_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 author: Eduard Gómez
11 //
12 
13 #if !defined(KRATOS_SHOCK_CAPTURING_ENTROPY_VISCOSITY_H_INCLUDED)
14 #define KRATOS_SHOCK_CAPTURING_ENTROPY_VISCOSITY_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "containers/model.h"
22 #include "processes/process.h"
23 
24 // Application includes
25 
26 
27 namespace Kratos
28 {
31 
34 
38 
42 
46 
50 
58 class KRATOS_API(FLUID_DYNAMICS_APPLICATION) ShockCapturingEntropyViscosityProcess : public Process
59 {
60 public:
61 
64 
66 
67  struct InfNormData
68  {
70  double Density;
71  double TotalVelocity;
72  };
73 
74 
83  {
87 
89  : TotalDerivativeUtil(0, 0)
90  {}
91 
93  const std::size_t NumberOfDimensions,
94  const std::size_t NumberOfNodes)
95  : Value {NumberOfNodes, 0.0},
96  TimeDerivative {NumberOfNodes, 0.0},
97  Flux {NumberOfNodes, NumberOfDimensions, 0.0}
98  {
99  }
100 
102  const Variable<double>& rVariable,
103  const NodeType& rNode,
104  const std::size_t NodeIndex,
105  const array_1d<double, 3>& Velocity,
106  const double DeltaTime)
107  {
108  KRATOS_TRY
109 
110  const auto old_value = rNode.FastGetSolutionStepValue(rVariable, 1);
111  Value[NodeIndex] = rNode.FastGetSolutionStepValue(rVariable);
112  TimeDerivative[NodeIndex] = (Value[NodeIndex] - old_value) / DeltaTime;
113 
114  Flux(NodeIndex, 0) = Value[NodeIndex] * Velocity[0];
115  Flux(NodeIndex, 1) = Value[NodeIndex] * Velocity[1];
116  if(Flux.size2()==3){ // (if 3D)
117  Flux(NodeIndex, 2) = Value[NodeIndex] * Velocity[2];
118  }
119 
120  KRATOS_CATCH("")
121  }
122 
124  const MatrixRow<const Matrix>& rShapeFunctions,
125  const Matrix& rShapeFunctionsGradents) const
126  {
127  KRATOS_TRY
128 
129  const double divergence = Divergence(rShapeFunctionsGradents, Flux);
130  const double time_derivative = inner_prod(TimeDerivative, rShapeFunctions);
131  return time_derivative + divergence;
132 
133  KRATOS_CATCH("") // Catching possible error in divergence computation
134  }
135 
136  private:
144  static double Divergence(const Matrix& rShapeFunGradients, const Matrix& rNodalValues);
145  };
146 
147 
150 
154 
157  Model& rModel,
158  Parameters rParameters)
159  : ShockCapturingEntropyViscosityProcess(rModel.GetModelPart(rParameters["model_part_name"].GetString()), rParameters) {};
160 
163  ModelPart& rModelPart,
164  Parameters rParameters);
165 
169 
170 
174 
175  void ExecuteInitializeSolutionStep() override;
176 
177  int Check() override;
178 
179  const Parameters GetDefaultParameters() const override;
180 
184 
185 
189 
190 
194 
196  std::string Info() const override
197  {
198  std::stringstream buffer;
199  buffer << "ShockCapturingEntropyViscosityProcess";
200  return buffer.str();
201  }
202 
204  void PrintInfo(std::ostream& rOStream) const override { rOStream << "ShockCapturingEntropyViscosityProcess"; }
205 
207  void PrintData(std::ostream&) const override {}
208 
212 
213 
215 private:
218 
219 
223 
224  ModelPart& mrModelPart;
225  bool mIsInitialized = false;
226  bool mComputeAreasEveryStep = false;
227  double mEntropyConstant = 0.0;
228  double mEnergyConstant = 0.0;
229  double mArtificialMassDiffusivityPrandtl = 0.0;
230  double mArtificialConductivityPrandtl = 0.0;
231 
235 
236 
240 
241  void ValidateAndAssignParameters(Parameters &rParameters);
242 
243  void UpdateNodalAreaProcess();
244 
251  void ComputeNodalEntropies(const unsigned int WriteBufferIndex = 0);
252 
253  void ComputeArtificialMagnitudes();
254 
255  void DistributeVariablesToNodes(
256  Element& rElement,
257  const double ArtificialDynamicViscosity,
258  const double ArtificialMassDiffusivity,
259  const double ArtificialConductivity,
260  const std::function<double(Geometry<Node>*)>& rGeometrySize) const;
261 
262  static double ComputeEntropy(
263  const double Density,
264  const double Pressure,
265  const double Gamma)
266  {
267  return Density / (Gamma - 1.0) * std::log(Pressure / std::pow(Density, Gamma));
268  }
269 
276  template <unsigned int TDim>
277  static double MinimumEdgeLengthSquared(const Element &rElement);
278 
279 
287  static InfNormData ComputeElementalInfNormData(
288  const Element& rElement,
289  const double DeltaTime,
290  const double HeatCapacityRatio,
291  const double SpecificHeatCV);
292 
299  static std::tuple<TotalDerivativeUtil, TotalDerivativeUtil, Vector> BuildTotalDerivativeUtils(
300  const Element& rElement,
301  const double DeltaTime,
302  const double HeatCapacityRatio,
303  const double SpecificHeatCV);
304 
309  static InfNormData ComputeInfNorms(
310  const Geometry<NodeType>& rGeometry,
311  const TotalDerivativeUtil& rEntropyTotalDerivative,
312  const TotalDerivativeUtil& rDensityTotalDerivative,
313  const Vector& rTotalVelocities);
314 
315 
316 
320 
321 
325 
326 
330 
332  ShockCapturingEntropyViscosityProcess& operator=(ShockCapturingEntropyViscosityProcess const& rOther);
333 
335  ShockCapturingEntropyViscosityProcess(ShockCapturingEntropyViscosityProcess const& rOther);
336 
338 
339 }; // Class ShockCapturingEntropyViscosityProcess
340 
344 
345 
349 
351 inline std::ostream& operator << (
352  std::ostream& rOStream,
354 {
355  rThis.PrintInfo(rOStream);
356  return rOStream;
357 }
358 
360 
362 
363 } // namespace Kratos.
364 
365 #endif // KRATOS_SHOCK_CAPTURING_ENTROPY_VISCOSITY_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Base class for all Elements.
Definition: element.h:60
Geometry base class.
Definition: geometry.h:71
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
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
Definition: shock_capturing_entropy_viscosity_process.h:59
KRATOS_CLASS_POINTER_DEFINITION(ShockCapturingEntropyViscosityProcess)
Pointer definition of ShockCapturingEntropyViscosityProcess.
void PrintData(std::ostream &) const override
Print object's data.
Definition: shock_capturing_entropy_viscosity_process.h:207
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: shock_capturing_entropy_viscosity_process.h:204
std::string Info() const override
Turn back information as a string.
Definition: shock_capturing_entropy_viscosity_process.h:196
ShockCapturingEntropyViscosityProcess(Model &rModel, Parameters rParameters)
Constructor with model.
Definition: shock_capturing_entropy_viscosity_process.h:156
ModelPart::NodeType NodeType
Definition: shock_capturing_entropy_viscosity_process.h:65
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
AMatrix::MatrixRow< TExpressionType > MatrixRow
Definition: amatrix_interface.h:492
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def Gamma(n, j)
Definition: quadrature.py:146
Definition: shock_capturing_entropy_viscosity_process.h:68
double EntropyResidual
Definition: shock_capturing_entropy_viscosity_process.h:69
double Density
Definition: shock_capturing_entropy_viscosity_process.h:70
double TotalVelocity
Definition: shock_capturing_entropy_viscosity_process.h:71
Small utility to compute the total derivative of a magnitude.
Definition: shock_capturing_entropy_viscosity_process.h:83
Matrix Flux
Definition: shock_capturing_entropy_viscosity_process.h:86
double ComputeAtGaussPoint(const MatrixRow< const Matrix > &rShapeFunctions, const Matrix &rShapeFunctionsGradents) const
Definition: shock_capturing_entropy_viscosity_process.h:123
TotalDerivativeUtil(const std::size_t NumberOfDimensions, const std::size_t NumberOfNodes)
Definition: shock_capturing_entropy_viscosity_process.h:92
TotalDerivativeUtil()
Definition: shock_capturing_entropy_viscosity_process.h:88
void LoadNodalValues(const Variable< double > &rVariable, const NodeType &rNode, const std::size_t NodeIndex, const array_1d< double, 3 > &Velocity, const double DeltaTime)
Definition: shock_capturing_entropy_viscosity_process.h:101
Vector Value
Definition: shock_capturing_entropy_viscosity_process.h:84
Vector TimeDerivative
Definition: shock_capturing_entropy_viscosity_process.h:85