13 #if !defined(KRATOS_NAVIER_STOKES)
14 #define KRATOS_NAVIER_STOKES
19 #include "boost/smart_ptr.hpp"
26 #include "utilities/geometry_utilities.h"
61 template<
unsigned int TDim,
unsigned int TNumNodes = TDim + 1 >
106 :
Element(NewId, pGeometry, pProperties)
125 return Kratos::make_intrusive< NavierStokes < TDim, TNumNodes > >(NewId, this->
GetGeometry().
Create(rThisNodes), pProperties);
129 Element::Pointer
Create(
IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties)
const override
132 return Kratos::make_intrusive< NavierStokes < TDim, TNumNodes > >(NewId, pGeom, pProperties);
143 constexpr
unsigned int MatrixSize = TNumNodes*(TDim+1);
145 if (rLeftHandSideMatrix.size1() != MatrixSize)
146 rLeftHandSideMatrix.
resize(MatrixSize, MatrixSize,
false);
148 if (rRightHandSideVector.size() != MatrixSize)
149 rRightHandSideVector.
resize(MatrixSize,
false);
167 for(
unsigned int igauss = 0; igauss<Ncontainer.size2(); igauss++)
177 noalias(rLeftHandSideMatrix) += lhs_local;
178 noalias(rRightHandSideVector) += rhs_local;
181 rLeftHandSideMatrix *=
data.volume/
static_cast<double>(TNumNodes);
182 rRightHandSideVector *=
data.volume/
static_cast<double>(TNumNodes);
193 constexpr
unsigned int MatrixSize = TNumNodes*(TDim+1);
195 if (rRightHandSideVector.size() != MatrixSize)
196 rRightHandSideVector.
resize(MatrixSize,
false);
211 for(
unsigned int igauss = 0; igauss<Ncontainer.size2(); igauss++)
220 noalias(rRightHandSideVector) += rhs_local;
224 rRightHandSideVector *=
data.volume/
static_cast<double>(TNumNodes);
245 if(ErrorCode != 0)
return ErrorCode;
250 if(this->
GetGeometry()[
i].SolutionStepsDataHas(VELOCITY) ==
false)
252 if(this->
GetGeometry()[
i].SolutionStepsDataHas(PRESSURE) ==
false)
255 if(this->
GetGeometry()[
i].HasDofFor(VELOCITY_X) ==
false ||
256 this->
GetGeometry()[
i].HasDofFor(VELOCITY_Y) ==
false ||
265 KRATOS_ERROR <<
"The constitutive law was not set. Cannot proceed. Call the navier_stokes.h Initialize() method needs to be called.";
284 if (rVariable == ERROR_RATIO)
287 this->
SetValue(ERROR_RATIO, rOutput);
308 std::string
Info()
const override
310 return "NavierStokes #";
316 rOStream <<
Info() <<
Id();
384 const Vector& BDFVector = rCurrentProcessInfo[BDF_COEFFICIENTS];
385 rData.
bdf0 = BDFVector[0];
386 rData.
bdf1 = BDFVector[1];
387 rData.
bdf2 = BDFVector[2];
389 rData.
dyn_tau = rCurrentProcessInfo[DYNAMIC_TAU];
390 rData.
dt = rCurrentProcessInfo[DELTA_TIME];
392 rData.
c = rCurrentProcessInfo[SOUND_VELOCITY];
396 rData.
rho = r_prop.GetValue(DENSITY);
397 rData.
mu = r_prop.GetValue(DYNAMIC_VISCOSITY);
399 for (
unsigned int i = 0;
i < TNumNodes;
i++)
408 for(
unsigned int k=0;
k<TDim;
k++)
411 rData.
vn(
i,
k) = vel_n[
k];
412 rData.
vnn(
i,
k) = vel_nn[
k];
417 rData.
p[
i] = this->
GetGeometry()[
i].FastGetSolutionStepValue(PRESSURE);
418 rData.
pn[
i] = this->
GetGeometry()[
i].FastGetSolutionStepValue(PRESSURE,1);
428 for(
unsigned int i=0;
i<TNumNodes;
i++)
431 for(
unsigned int k=0;
k<TDim;
k++)
433 h_inv += DN_DX(
i,
k)*DN_DX(
i,
k);
437 h = sqrt(
h)/
static_cast<double>(TNumNodes);
444 Ncontainer(0,0) = 0.58541020; Ncontainer(0,1) = 0.13819660; Ncontainer(0,2) = 0.13819660; Ncontainer(0,3) = 0.13819660;
445 Ncontainer(1,0) = 0.13819660; Ncontainer(1,1) = 0.58541020; Ncontainer(1,2) = 0.13819660; Ncontainer(1,3) = 0.13819660;
446 Ncontainer(2,0) = 0.13819660; Ncontainer(2,1) = 0.13819660; Ncontainer(2,2) = 0.58541020; Ncontainer(2,3) = 0.13819660;
447 Ncontainer(3,0) = 0.13819660; Ncontainer(3,1) = 0.13819660; Ncontainer(3,2) = 0.13819660; Ncontainer(3,3) = 0.58541020;
453 const double one_sixt = 1.0/6.0;
454 const double two_third = 2.0/3.0;
455 Ncontainer(0,0) = one_sixt; Ncontainer(0,1) = one_sixt; Ncontainer(0,2) = two_third;
456 Ncontainer(1,0) = one_sixt; Ncontainer(1,1) = two_third; Ncontainer(1,2) = one_sixt;
457 Ncontainer(2,0) = two_third; Ncontainer(2,1) = one_sixt; Ncontainer(2,2) = one_sixt;
463 Ncontainer(0,0) = 0.25; Ncontainer(0,1) = 0.25; Ncontainer(0,2) = 0.25; Ncontainer(0,3) = 0.25;
469 Ncontainer(0,0) = 1.0/3.0; Ncontainer(0,1) = 1.0/3.0; Ncontainer(0,2) = 1.0/3.0;
485 rData.
strain[3] =
DN(0,0)*
v(0,1) +
DN(0,1)*
v(0,0) +
DN(1,0)*
v(1,1) +
DN(1,1)*
v(1,0) +
DN(2,0)*
v(2,1) +
DN(2,1)*
v(2,0) +
DN(3,0)*
v(3,1) +
DN(3,1)*
v(3,0);
486 rData.
strain[4] =
DN(0,1)*
v(0,2) +
DN(0,2)*
v(0,1) +
DN(1,1)*
v(1,2) +
DN(1,2)*
v(1,1) +
DN(2,1)*
v(2,2) +
DN(2,2)*
v(2,1) +
DN(3,1)*
v(3,2) +
DN(3,2)*
v(3,1);
487 rData.
strain[5] =
DN(0,0)*
v(0,2) +
DN(0,2)*
v(0,0) +
DN(1,0)*
v(1,2) +
DN(1,2)*
v(1,0) +
DN(2,0)*
v(2,2) +
DN(2,2)*
v(2,0) +
DN(3,0)*
v(3,2) +
DN(3,2)*
v(3,0);
494 rData.
strain[2] =
DN(0,1)*
v(0,0) +
DN(1,1)*
v(1,0) +
DN(2,1)*
v(2,0) +
DN(0,0)*
v(0,1) +
DN(1,0)*
v(1,1) +
DN(2,0)*
v(2,1);
520 ConstitutiveLawOptions.
Set(ConstitutiveLaw::COMPUTE_STRESS);
521 ConstitutiveLawOptions.
Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR);
576 void save(
Serializer& rSerializer)
const override
Base class for all Elements.
Definition: element.h:60
PropertiesType & GetProperties()
Definition: element.h:1024
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
virtual int Check(const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:904
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
std::size_t IndexType
Definition: flags.h:74
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: geometrical_object.h:238
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
virtual Pointer Create(PointsArrayType const &rThisPoints) const
Creates a new geometry pointer.
Definition: geometry.h:813
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 4, 3 > &rDN_DX, array_1d< double, 4 > &rN, double &rVolume)
This function is designed to compute the shape function derivatives, shape functions and volume in 3D...
Definition: geometry_utilities.h:176
IndexType Id() const
Definition: indexed_object.h:107
Definition: amatrix_interface.h:41
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Definition: navier_stokes.h:63
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(NavierStokes)
Counted pointer of.
void GetShapeFunctionsOnGauss(BoundedMatrix< double, 4, 4 > &Ncontainer)
Definition: navier_stokes.h:442
void GetShapeFunctionsOnUniqueGauss(BoundedMatrix< double, 1, 4 > &Ncontainer)
Definition: navier_stokes.h:461
void GetShapeFunctionsOnUniqueGauss(BoundedMatrix< double, 1, 3 > &Ncontainer)
Definition: navier_stokes.h:467
void ComputeGaussPointLHSContribution(BoundedMatrix< double, TNumNodes *(TDim+1), TNumNodes *(TDim+1)> &lhs, const ElementDataStruct &data)
NavierStokes(IndexType NewId, GeometryType::Pointer pGeometry)
Default constructor.
Definition: navier_stokes.h:101
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: navier_stokes.h:314
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Definition: navier_stokes.h:363
void FillElementData(ElementDataStruct &rData, const ProcessInfo &rCurrentProcessInfo)
Definition: navier_stokes.h:374
void ComputeStrain(ElementDataStruct &rData, const unsigned int &strain_size)
Definition: navier_stokes.h:473
ConstitutiveLaw::Pointer mpConstitutiveLaw
Definition: navier_stokes.h:339
double ComputeH(BoundedMatrix< double, TNumNodes, TDim > &DN_DX)
Definition: navier_stokes.h:425
void GetShapeFunctionsOnGauss(BoundedMatrix< double, 3, 3 > &Ncontainer)
Definition: navier_stokes.h:451
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: navier_stokes.h:188
NavierStokes()
Definition: navier_stokes.h:354
void ComputeGaussPointRHSContribution(array_1d< double, TNumNodes *(TDim+1)> &rhs, const ElementDataStruct &data)
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: navier_stokes.h:129
NavierStokes(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Definition: navier_stokes.h:105
void GetDofList(DofsVectorType &ElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
std::string Info() const override
Turn back information as a string.
Definition: navier_stokes.h:308
void Calculate(const Variable< double > &rVariable, double &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: navier_stokes.h:275
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Checks the input and that all required Kratos variables have been registered.
Definition: navier_stokes.h:239
~NavierStokes() override
Destructor.
Definition: navier_stokes.h:110
Element::Pointer Create(IndexType NewId, NodesArrayType const &rThisNodes, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: navier_stokes.h:122
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: navier_stokes.h:137
double SubscaleErrorEstimate(const ElementDataStruct &data)
virtual double ComputeEffectiveViscosity(const ElementDataStruct &rData)
Definition: navier_stokes.h:533
virtual void ComputeConstitutiveResponse(ElementDataStruct &rData, const ProcessInfo &rCurrentProcessInfo)
Definition: navier_stokes.h:499
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
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
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#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
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
v
Definition: generate_convection_diffusion_explicit_element.py:114
DN
Definition: generate_convection_diffusion_explicit_element.py:98
h
Definition: generate_droplet_dynamics.py:91
rhs
Definition: generate_frictional_mortar_condition.py:297
lhs
Definition: generate_frictional_mortar_condition.py:297
int strain_size
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:16
data
Definition: mesh_to_mdpa_converter.py:59
def load(f)
Definition: ode_solve.py:307
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
body_force
Definition: script_ELASTIC.py:102
integer i
Definition: TensorModule.f:17
Definition: constitutive_law.h:189
void SetConstitutiveMatrix(VoigtSizeMatrixType &rConstitutiveMatrix)
Definition: constitutive_law.h:403
void SetStrainVector(StrainVectorType &rStrainVector)
Definition: constitutive_law.h:401
Flags & GetOptions()
Definition: constitutive_law.h:412
void SetStressVector(StressVectorType &rStressVector)
Definition: constitutive_law.h:402
void SetShapeFunctionsValues(const Vector &rShapeFunctionsValues)
Definition: constitutive_law.h:396
Definition: navier_stokes.h:72
double dyn_tau
Definition: navier_stokes.h:90
Vector stress
Definition: navier_stokes.h:80
double c
Definition: navier_stokes.h:86
array_1d< double, TNumNodes > pnn
Definition: navier_stokes.h:74
double rho
Definition: navier_stokes.h:92
BoundedMatrix< double, TNumNodes, TDim > v
Definition: navier_stokes.h:73
double bdf2
Definition: navier_stokes.h:85
BoundedMatrix< double, TNumNodes, TDim > vn
Definition: navier_stokes.h:73
BoundedMatrix< double, TNumNodes, TDim > f
Definition: navier_stokes.h:73
array_1d< double, TNumNodes > N
Definition: navier_stokes.h:77
double dt
Definition: navier_stokes.h:89
BoundedMatrix< double, TNumNodes, TDim > vmesh
Definition: navier_stokes.h:73
double bdf0
Definition: navier_stokes.h:83
Matrix C
Definition: navier_stokes.h:79
double volume
Definition: navier_stokes.h:88
double bdf1
Definition: navier_stokes.h:84
array_1d< double, TNumNodes > p
Definition: navier_stokes.h:74
Vector strain
Definition: navier_stokes.h:81
double mu
Definition: navier_stokes.h:91
double h
Definition: navier_stokes.h:87
array_1d< double, TNumNodes > pn
Definition: navier_stokes.h:74
BoundedMatrix< double, TNumNodes, TDim > vnn
Definition: navier_stokes.h:73
BoundedMatrix< double, TNumNodes, TDim > DN_DX
Definition: navier_stokes.h:76