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.
spalart_allmaras.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: Jordi Cotela, Riccardo Rossi
11 //
12 
13 #if !defined(KRATOS_SPALART_ALLMARAS_H_INCLUDED )
14 #define KRATOS_SPALART_ALLMARAS_H_INCLUDED
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 
20 
21 // External includes
22 
23 
24 // Project includes
25 #include "includes/define.h"
26 #include "includes/serializer.h"
27 #include "includes/element.h"
29 
30 
31 namespace Kratos
32 {
35 
38 
42 
46 
50 
54 
56 
58 class SpalartAllmaras : public Element
59 {
60 public:
63 
66 
69 
72 
76 
79  Element(NewId),
80  mIntegrationMethod(GeometryData::IntegrationMethod::GI_GAUSS_1)
81  {}
82 
84  SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry) :
85  Element(NewId, pGeometry),
86  mIntegrationMethod(pGeometry->GetDefaultIntegrationMethod())
87  {}
88 
90  SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) :
91  Element(NewId, pGeometry, pProperties),
92  mIntegrationMethod(pGeometry->GetDefaultIntegrationMethod())
93  {}
94 
96  SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, const Element::IntegrationMethod& ThisIntegrationMethod) :
97  Element(NewId, pGeometry),
98  mIntegrationMethod(ThisIntegrationMethod)
99  {}
100 
102  SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties, const Element::IntegrationMethod& ThisIntegrationMethod) :
103  Element(NewId,pGeometry,pProperties),
104  mIntegrationMethod(ThisIntegrationMethod)
105  {}
106 
108  ~SpalartAllmaras() override
109  {}
110 
114 
115 
119 
121  Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override;
122 
124  Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override;
125 
127 
129  int Check(const ProcessInfo &rCurrentProcessInfo) const override;
130 
132  void Initialize(const ProcessInfo &rCurrentProcessInfo) override;
133 
135  void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
136 
137 // /// Compute projection of convective term for stabilization
138 // virtual void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo);
139 
141 
146  void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override;
147 
148  void CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override;
149 // {
150 // KRATOS_THROW_ERROR(std::logic_error, "SplartAllmaras::CalculateRightHandSide method not implemented", "");
151 // }
152 
154  void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& rCurrentProcessInfo) const override;
155 
157  void EquationIdVector(Element::EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override;
158 
160  void GetValuesVector(Vector& rValues, int Step = 0) const override;
161 
165 
166 
170 
171 
175 
177  std::string Info() const override
178  {
179  std::stringstream buffer;
180  buffer << "SpalartAllmaras" << this->GetGeometry().WorkingSpaceDimension() << "D #" << Id();
181  return buffer.str();
182  }
183 
185  void PrintInfo(std::ostream& rOStream) const override
186  {
187  rOStream << "SpalartAllmaras" << this->GetGeometry().WorkingSpaceDimension() << "D #" << Id() << std::endl;
188  rOStream << "Number of Nodes: " << this->GetGeometry().PointsNumber() << std::endl;
189  rOStream << "Integration method: " << static_cast<int>(this->mIntegrationMethod);
190  }
191 
193  void PrintData(std::ostream& rOStream) const override
194  {
195  this->PrintInfo(rOStream);
196  rOStream << "Geometry Data: " << std::endl;
197  this->GetGeometry().PrintData(rOStream);
198  }
199 
200 
204 
205 
207 
208 protected:
211 
212 
216 
217 
221 
222 
226 
227  void InitializeElementData();
228 
229  void AddMassTerm(MatrixType &rMassMatrix,
230  const ShapeFunctionsType& N,
231  const double Weight);
232 
233  void AddConvection(MatrixType& rLHS,
234  const ShapeFunctionsType& N,
235  const Vector& UGradN,
236  const double Weight);
237 
238  void AddModelTerms(MatrixType& rLHS,
239  const double MolecularViscosity,
240  const double LastEddyViscosity,
241  const array_1d<double,3>& rLastEddyViscosityGradient,
242  const double Distance,
243  const array_1d<double,3>& rVelocity,
244  const ShapeFunctionsType& N,
245  const ShapeDerivativesType& DN_DX,
246  const double Weight);
247 
248  void AddStabilization(MatrixType& rLHS,
249  VectorType& rRHS,
250  const double Tau,
251  const ShapeFunctionsType& N,
252  const ShapeDerivativesType& DN_DX,
253  const Vector& UGradN,
254  const double Weight);
255 
256  void EvaluateConvection(Vector& rResult,
257  const array_1d<double,3>& rConvVel,
258  const ShapeDerivativesType& DN_DX);
259 
260  template< class TVariableType >
261  void EvaluateInPoint(TVariableType& rResult,
263  const ShapeFunctionsType& rShapeFunc)
264  {
265  rResult = rShapeFunc[0] * this->GetGeometry()[0].FastGetSolutionStepValue(Var);
266 
267  for(SizeType i = 1; i < rShapeFunc.size(); i++)
268  {
269  rResult += rShapeFunc[i] * this->GetGeometry()[i].FastGetSolutionStepValue(Var);
270  }
271  }
272 
273  double MeasureOfVorticity(const ShapeDerivativesType& DN_DX);
274 
275  void VelocityGradientNorms(double& rNormS,
276  double& rNormOmega,
277  const ShapeDerivativesType& DN_DX);
278 
279  double CalculateTau(double ElementSize, const ProcessInfo& rCurrentProcessInfo);
280 
281  double ElementSize();
282 
283 
287 
288 
292 
293 
297 
298 
300 
301 private:
304 
305 
309 
311  Element::IntegrationMethod mIntegrationMethod;
312 
314  std::vector< ShapeDerivativesType > mDN_DX;
315 
317 
321  double mDetJ;
322 
326 
327  friend class Serializer;
328 
329  void save(Serializer& rSerializer) const override
330  {
331  KRATOS_TRY;
333  //enum IntegrationMethod {GI_GAUSS_1, GI_GAUSS_2, GI_GAUSS_3, GI_GAUSS_4, GI_GAUSS_5,NumberOfIntegrationMethods};
334  unsigned int IntMethod = 0;
335  switch(mIntegrationMethod)
336  {
338  IntMethod = 1;
339  break;
341  IntMethod = 2;
342  break;
344  IntMethod = 3;
345  break;
347  IntMethod = 4;
348  break;
350  IntMethod = 5;
351  break;
352  default:
353  KRATOS_ERROR << "Unknown integration method encountered on serializer save for SpalartAllmaras element: " << static_cast<int>(mIntegrationMethod) << std::endl;
354  break;
355  }
356  rSerializer.save("IntMethod",IntMethod);
357  rSerializer.save("mDN_DX",mDN_DX);
358  rSerializer.save("mDetJ",mDetJ);
359  KRATOS_CATCH("");
360  }
361 
362  void load(Serializer& rSerializer) override
363  {
364  KRATOS_TRY;
366  unsigned int IntMethod = 0;
367  rSerializer.load("IntMethod",IntMethod);
368  switch(mIntegrationMethod)
369  {
371  mIntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_1;
372  break;
374  mIntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_2;
375  break;
377  mIntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_3;
378  break;
380  mIntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_4;
381  break;
383  mIntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_5;
384  break;
385  default:
386  KRATOS_ERROR << "Unknown integration method encountered on serializer load for SpalartAllmaras element: " << static_cast<int>(IntMethod) << std::endl;
387  break;
388  }
389  rSerializer.load("mDN_DX",mDN_DX);
390  rSerializer.load("mDetJ",mDetJ);
391  KRATOS_CATCH("");
392  }
393 
397 
398 
402 
403 
407 
408 
412 
413 
417 
419  SpalartAllmaras& operator=(SpalartAllmaras const& rOther);
420 
422  SpalartAllmaras(SpalartAllmaras const& rOther);
423 
424 
426 
427 }; // Class SpalartAllmaras
428 
430 
433 
434 
438 
439 
441 inline std::istream& operator >> (std::istream& rIStream,
442  SpalartAllmaras& rThis)
443 {
444  return rIStream;
445 }
446 
448 inline std::ostream& operator << (std::ostream& rOStream,
449  const SpalartAllmaras& rThis)
450 {
451  rThis.PrintInfo(rOStream);
452  rOStream << std::endl;
453  rThis.PrintData(rOStream);
454 
455  return rOStream;
456 }
458 
460 
461 } // namespace Kratos.
462 
463 #endif // KRATOS_SPALART_ALLMARAS_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Base class for all Elements.
Definition: element.h:60
std::size_t SizeType
Definition: element.h:94
Element(IndexType NewId=0)
Definition: element.h:121
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
Matrix MatrixType
Definition: element.h:90
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
std::size_t IndexType
Definition: flags.h:74
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Definition: geometry_data.h:60
IntegrationMethod
Definition: geometry_data.h:76
SizeType PointsNumber() const
Definition: geometry.h:528
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: geometry.h:3834
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
IndexType Id() const
Definition: indexed_object.h:107
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
Short class definition.
Definition: spalart_allmaras.h:59
void GetValuesVector(Vector &rValues, int Step=0) const override
Fill given vector with nodal values of the problem variable (TURBULENT_VISCOSITY)
Definition: spalart_allmaras.cpp:284
SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using geometry and properties.
Definition: spalart_allmaras.h:90
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Evaluate the elemental contribution to the problem for turbulent viscosity.
Definition: spalart_allmaras.cpp:137
SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, const Element::IntegrationMethod &ThisIntegrationMethod)
Additional constructor using a specific quadrature.
Definition: spalart_allmaras.h:96
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(SpalartAllmaras)
Pointer definition of SpalartAllmaras.
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new SpalartAllmaras element and return a pointer to it.
Definition: spalart_allmaras.cpp:10
void VelocityGradientNorms(double &rNormS, double &rNormOmega, const ShapeDerivativesType &DN_DX)
Definition: spalart_allmaras.cpp:511
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Calculate Shape function derivatives for the element.
Definition: spalart_allmaras.cpp:65
SpalartAllmaras(IndexType NewId=0)
Default constructor.
Definition: spalart_allmaras.h:78
Kratos::Matrix ShapeDerivativesType
Type for shape function derivatives container.
Definition: spalart_allmaras.h:71
double MeasureOfVorticity(const ShapeDerivativesType &DN_DX)
Definition: spalart_allmaras.cpp:488
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Fill given array with containing the element's degrees of freedom.
Definition: spalart_allmaras.cpp:261
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create a new SpalartAllmaras element and return a pointer to it.
SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties, const Element::IntegrationMethod &ThisIntegrationMethod)
Additional constructor using a specific quadrature.
Definition: spalart_allmaras.h:102
void AddModelTerms(MatrixType &rLHS, const double MolecularViscosity, const double LastEddyViscosity, const array_1d< double, 3 > &rLastEddyViscosityGradient, const double Distance, const array_1d< double, 3 > &rVelocity, const ShapeFunctionsType &N, const ShapeDerivativesType &DN_DX, const double Weight)
Definition: spalart_allmaras.cpp:367
void InitializeElementData()
Definition: spalart_allmaras.cpp:299
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: spalart_allmaras.h:185
void AddStabilization(MatrixType &rLHS, VectorType &rRHS, const double Tau, const ShapeFunctionsType &N, const ShapeDerivativesType &DN_DX, const Vector &UGradN, const double Weight)
Definition: spalart_allmaras.cpp:450
double CalculateTau(double ElementSize, const ProcessInfo &rCurrentProcessInfo)
Definition: spalart_allmaras.cpp:546
void AddConvection(MatrixType &rLHS, const ShapeFunctionsType &N, const Vector &UGradN, const double Weight)
Definition: spalart_allmaras.cpp:351
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: spalart_allmaras.h:193
void InitializeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Calculates the projection term for stabilization.
Definition: spalart_allmaras.cpp:74
SpalartAllmaras(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using a Geometry instance.
Definition: spalart_allmaras.h:84
double ElementSize()
Definition: spalart_allmaras.cpp:582
void EvaluateConvection(Vector &rResult, const array_1d< double, 3 > &rConvVel, const ShapeDerivativesType &DN_DX)
Definition: spalart_allmaras.cpp:471
~SpalartAllmaras() override
Destructor.
Definition: spalart_allmaras.h:108
std::string Info() const override
Turn back information as a string.
Definition: spalart_allmaras.h:177
void EvaluateInPoint(TVariableType &rResult, const Kratos::Variable< TVariableType > &Var, const ShapeFunctionsType &rShapeFunc)
Definition: spalart_allmaras.h:261
friend class Serializer
Definition: spalart_allmaras.h:327
void AddMassTerm(MatrixType &rMassMatrix, const ShapeFunctionsType &N, const double Weight)
Definition: spalart_allmaras.cpp:331
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: spalart_allmaras.cpp:255
void EquationIdVector(Element::EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Fill given vector with the linear system row index for the element's degrees of freedom.
Definition: spalart_allmaras.cpp:273
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Check that all required data containers are properly initialized and registered in Kratos.
Definition: spalart_allmaras.cpp:20
Kratos::Vector ShapeFunctionsType
Type for shape function values container.
Definition: spalart_allmaras.h:68
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesArrayType
Definition: gid_gauss_point_container.h:42
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 load(f)
Definition: ode_solve.py:307
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17