16 #if !defined(KRATOS_LEVELSET_CONVECTION_ELEMENT_SIMPLEX_INCLUDED )
17 #define KRATOS_LEVELSET_CONVECTION_ELEMENT_SIMPLEX_INCLUDED
31 #include "utilities/geometry_utilities.h"
56 template<
unsigned int TDim,
unsigned int TNumNodes>
80 :
Element(NewId, pGeometry, pProperties)
105 GeometryType::Pointer pGeom,
106 PropertiesType::Pointer pProperties)
const override
116 mElementTauNodal = std::all_of(r_geometry.begin(),
118 [](
const auto& rNode) {
119 return rNode.Has(TAU);
127 if (rLeftHandSideMatrix.size1() != TNumNodes)
128 rLeftHandSideMatrix.
resize(TNumNodes, TNumNodes,
false);
130 if (rRightHandSideVector.size() != TNumNodes)
131 rRightHandSideVector.
resize(TNumNodes,
false);
133 const double delta_t = rCurrentProcessInfo[DELTA_TIME];
134 const double dt_inv = 1.0 /
delta_t;
135 const double theta = rCurrentProcessInfo.
Has(TIME_INTEGRATION_THETA) ? rCurrentProcessInfo[TIME_INTEGRATION_THETA] : 0.5;
137 const ConvectionDiffusionSettings::Pointer& my_settings = rCurrentProcessInfo.
GetValue(CONVECTION_DIFFUSION_SETTINGS);
140 const double dyn_st_beta = rCurrentProcessInfo[DYNAMIC_TAU];
155 for (
unsigned int i = 0;
i < TNumNodes;
i++)
162 vold[
i] =
GetGeometry()[
i].FastGetSolutionStepValue(rConvVar,1);
165 const double norm_grad =
norm_2(grad_phi_halfstep);
172 for (
unsigned int i = 0;
i < TNumNodes;
i++)
173 for(
unsigned int k=0;
k<TDim;
k++)
189 for(
unsigned int igauss=0; igauss<TDim+1; igauss++)
195 for (
unsigned int i = 0;
i < TNumNodes;
i++)
197 for(
unsigned int k=0;
k<TDim;
k++)
198 vel_gauss[
k] += 0.5*
N[
i]*(
v[
i][
k]+vold[
i][
k]);
200 const double norm_vel =
norm_2(vel_gauss);
204 if (mElementTauNodal){
206 for (
unsigned int i = 0;
i < TNumNodes;
i++)
226 if(norm_grad > 1
e-3 && norm_vel > 1
e-9)
228 const double C = rCurrentProcessInfo.
GetValue(CROSS_WIND_STABILIZATION_FACTOR);
230 const double res = -time_derivative -
inner_prod(vel_gauss, grad_phi_halfstep);
232 const double disc_capturing_coeff = 0.5*
C*
h*fabs(
res/norm_grad);
234 const double norm_vel_squared = norm_vel*norm_vel;
235 D += (
std::max( disc_capturing_coeff -
tau*norm_vel_squared , 0.0) - disc_capturing_coeff)/(norm_vel_squared) *
outer_prod(vel_gauss,vel_gauss);
253 rRightHandSideVector *= Volume/
static_cast<double>(TNumNodes);
254 rLeftHandSideMatrix *= Volume/
static_cast<double>(TNumNodes);
276 const ConvectionDiffusionSettings::Pointer& my_settings = rCurrentProcessInfo.
GetValue(CONVECTION_DIFFUSION_SETTINGS);
279 if (rResult.size() != TNumNodes)
280 rResult.resize(TNumNodes,
false);
282 for (
unsigned int i = 0;
i < TNumNodes;
i++)
284 rResult[
i] =
GetGeometry()[
i].GetDof(rUnknownVar).EquationId();
298 const ConvectionDiffusionSettings::Pointer& my_settings = rCurrentProcessInfo.
GetValue(CONVECTION_DIFFUSION_SETTINGS);
301 if (ElementalDofList.size() != TNumNodes)
302 ElementalDofList.resize(TNumNodes);
304 for (
unsigned int i = 0;
i < TNumNodes;
i++)
329 std::string
Info()
const override
331 return "LevelSetConvectionElementSimplex #";
338 rOStream <<
Info() <<
Id();
371 for(
unsigned int i=0;
i<TNumNodes;
i++)
374 for(
unsigned int k=0;
k<TDim;
k++)
376 h_inv += DN_DX(
i,
k)*DN_DX(
i,
k);
387 Ncontainer(0,0) = 0.58541020; Ncontainer(0,1) = 0.13819660; Ncontainer(0,2) = 0.13819660; Ncontainer(0,3) = 0.13819660;
388 Ncontainer(1,0) = 0.13819660; Ncontainer(1,1) = 0.58541020; Ncontainer(1,2) = 0.13819660; Ncontainer(1,3) = 0.13819660;
389 Ncontainer(2,0) = 0.13819660; Ncontainer(2,1) = 0.13819660; Ncontainer(2,2) = 0.58541020; Ncontainer(2,3) = 0.13819660;
390 Ncontainer(3,0) = 0.13819660; Ncontainer(3,1) = 0.13819660; Ncontainer(3,2) = 0.13819660; Ncontainer(3,3) = 0.58541020;
396 const double one_sixt = 1.0/6.0;
397 const double two_third = 2.0/3.0;
398 Ncontainer(0,0) = one_sixt; Ncontainer(0,1) = one_sixt; Ncontainer(0,2) = two_third;
399 Ncontainer(1,0) = one_sixt; Ncontainer(1,1) = two_third; Ncontainer(1,2) = one_sixt;
400 Ncontainer(2,0) = two_third; Ncontainer(2,1) = one_sixt; Ncontainer(2,2) = one_sixt;
433 bool mElementTauNodal;
443 void save(
Serializer& rSerializer)
const override
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
Base class for all Elements.
Definition: element.h:60
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
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
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
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
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
formulation described in https://docs.google.com/document/d/13a_zGLj6xORDuLgoOG5LwHI6BwShvfO166opZ815...
Definition: levelset_convection_element_simplex.h:59
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: levelset_convection_element_simplex.h:336
void GetShapeFunctionsOnGauss(BoundedMatrix< double, 3, 3 > &Ncontainer)
Definition: levelset_convection_element_simplex.h:394
std::string Info() const override
Turn back information as a string.
Definition: levelset_convection_element_simplex.h:329
LevelSetConvectionElementSimplex(IndexType NewId, GeometryType::Pointer pGeometry)
Definition: levelset_convection_element_simplex.h:75
void Initialize(const ProcessInfo &rProcessInfo) override
Definition: levelset_convection_element_simplex.h:113
void GetShapeFunctionsOnGauss(BoundedMatrix< double, 4, 4 > &Ncontainer)
Definition: levelset_convection_element_simplex.h:385
double ComputeH(BoundedMatrix< double, TNumNodes, TDim > &DN_DX, const double Volume)
Definition: levelset_convection_element_simplex.h:368
LevelSetConvectionElementSimplex(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Definition: levelset_convection_element_simplex.h:79
LevelSetConvectionElementSimplex()
Default constructor.
Definition: levelset_convection_element_simplex.h:72
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: levelset_convection_element_simplex.h:123
~LevelSetConvectionElementSimplex() override
Destructor.
Definition: levelset_convection_element_simplex.h:84
void GetDofList(DofsVectorType &ElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Definition: levelset_convection_element_simplex.h:294
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: levelset_convection_element_simplex.h:103
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(LevelSetConvectionElementSimplex)
Counted pointer of.
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Definition: levelset_convection_element_simplex.h:272
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: levelset_convection_element_simplex.h:96
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: levelset_convection_element_simplex.h:263
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
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
AMatrix::IdentityMatrix< double > IdentityMatrix
Definition: amatrix_interface.h:564
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
AMatrix::VectorOuterProductExpression< TExpression1Type, TExpression2Type > outer_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:582
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
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
res
Definition: generate_convection_diffusion_explicit_element.py:211
v
Definition: generate_convection_diffusion_explicit_element.py:114
div_v
Definition: generate_convection_diffusion_explicit_element.py:150
tau
Definition: generate_convection_diffusion_explicit_element.py:115
phi_old
Definition: generate_convection_diffusion_explicit_element.py:103
h
Definition: generate_droplet_dynamics.py:91
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
int tau_denom
Definition: generate_stokes_twofluid_element.py:162
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
float aux2
Definition: isotropic_damage_automatic_differentiation.py:240
phi
Definition: isotropic_damage_automatic_differentiation.py:168
float aux1
Definition: isotropic_damage_automatic_differentiation.py:239
def load(f)
Definition: ode_solve.py:307
int k
Definition: quadrature.py:595
float delta_t
Definition: rotatingcone_PureConvectionBenchmarking.py:129
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31