13 #ifndef KRATOS_FS_HIGH_RE_K_WALL_CONDITION_H
14 #define KRATOS_FS_HIGH_RE_K_WALL_CONDITION_H
53 template <
unsigned int TDim,
unsigned int TNumNodes = TDim>
118 GeometryType::Pointer pGeometry)
131 GeometryType::Pointer pGeometry,
132 PropertiesType::Pointer pProperties)
133 :
Condition(NewId, pGeometry, pProperties)
172 PropertiesType::Pointer pProperties)
const override
174 return Kratos::make_intrusive<FractionalStepKBasedWallCondition>(
180 Condition::GeometryType::Pointer pGeom,
181 PropertiesType::Pointer pProperties)
const override
183 return Kratos::make_intrusive<FractionalStepKBasedWallCondition>(
184 NewId, pGeom, pProperties);
199 Condition::Pointer p_new_condition =
202 p_new_condition->SetData(this->
GetData());
203 p_new_condition->SetFlags(this->
GetFlags());
205 return p_new_condition;
227 const unsigned int step = rCurrentProcessInfo[FRACTIONAL_STEP];
232 if (rLeftHandSideMatrix.size1() !=
local_size) {
236 if (rRightHandSideVector.size() !=
local_size) {
245 this->
ApplyWallLaw(rLeftHandSideMatrix, rRightHandSideVector, rCurrentProcessInfo);
247 if (this->
Is(INTERFACE) &&
step == 5) {
249 const double N = 1.0 /
static_cast<double>(TNumNodes);
252 const double Area =
norm_2(r_normal);
254 if (rLeftHandSideMatrix.size1() != TNumNodes) {
255 rLeftHandSideMatrix.
resize(TNumNodes, TNumNodes,
false);
258 if (rRightHandSideVector.size() != TNumNodes) {
259 rRightHandSideVector.
resize(TNumNodes,
false);
265 const double dt = rCurrentProcessInfo[DELTA_TIME];
266 const double equivalent_structural_density = rCurrentProcessInfo[DENSITY];
267 const double diag_term =
dt * Area *
N / (equivalent_structural_density);
269 for (
unsigned int iNode = 0; iNode < TNumNodes; ++iNode) {
270 rLeftHandSideMatrix(iNode, iNode) = diag_term;
273 if (rLeftHandSideMatrix.size1() != 0) {
274 rLeftHandSideMatrix.
resize(0, 0,
false);
277 if (rRightHandSideVector.size() != 0) {
278 rRightHandSideVector.
resize(0,
false);
298 if (this->
GetGeometry()[
i].SolutionStepsDataHas(VELOCITY) ==
false)
300 "missing VELOCITY variable on solution "
301 "step data for node ",
303 if (this->
GetGeometry()[
i].SolutionStepsDataHas(MESH_VELOCITY) ==
false)
305 "missing MESH_VELOCITY variable on "
306 "solution step data for node ",
308 if (this->
GetGeometry()[
i].SolutionStepsDataHas(NORMAL) ==
false)
310 "missing NORMAL variable on solution "
311 "step data for node ",
313 if (this->
GetGeometry()[
i].HasDofFor(VELOCITY_X) ==
false ||
314 this->
GetGeometry()[
i].HasDofFor(VELOCITY_Y) ==
false ||
317 std::invalid_argument,
318 "missing VELOCITY component degree of freedom on node ",
335 <<
"NORMAL must be calculated before using this "
336 << this->
Info() <<
"\n";
339 << this->
Info() <<
" cannot find parent element\n";
354 const ProcessInfo& rCurrentProcessInfo)
const override;
363 const ProcessInfo& CurrentProcessInfo)
const override;
372 int Step = 0)
const override
375 unsigned int LocalIndex = 0;
381 for (
unsigned int iNode = 0; iNode < TNumNodes; ++iNode) {
383 this->
GetGeometry()[iNode].FastGetSolutionStepValue(VELOCITY, Step);
384 for (
unsigned int d = 0;
d < TDim; ++
d) {
385 Values[LocalIndex++] = rVelocity[
d];
396 if (rVariable == NORMAL) {
407 rValues[0] = const_this->
GetValue(rVariable);
413 std::vector<double>& rValues,
425 rValues[0] = const_this->
GetValue(rVariable);
436 rValues[0] = const_this->
GetValue(rVariable);
441 std::vector<Vector>& rValues,
447 rValues[0] = const_this->
GetValue(rVariable);
452 std::vector<Matrix>& rValues,
458 rValues[0] = const_this->
GetValue(rVariable);
466 std::string
Info()
const override
468 std::stringstream buffer;
476 rOStream <<
"FractionalStepKBasedWallCondition" << TDim <<
"D #" << this->
Id();
503 using namespace RansCalculationUtilities;
511 gauss_weights, shape_functions);
512 const IndexType num_gauss_points = gauss_weights.size();
513 const double eps = std::numeric_limits<double>::epsilon();
514 const double c_mu_25 = std::pow(rCurrentProcessInfo[TURBULENCE_RANS_C_MU], 0.25);
515 const double kappa = rCurrentProcessInfo[VON_KARMAN];
518 auto& r_parent_element = this->
GetValue(NEIGHBOUR_ELEMENTS)[0];
519 auto p_constitutive_law = r_parent_element.GetValue(CONSTITUTIVE_LAW);
522 const auto& r_elem_properties = r_parent_element.GetProperties();
523 const double rho = r_elem_properties[DENSITY];
528 const double beta = r_cond_properties.
GetValue(WALL_SMOOTHNESS_BETA);
529 const double y_plus_limit = r_cond_properties.
GetValue(RANS_LINEAR_LOG_LAW_Y_PLUS_LIMIT);
530 const double inv_kappa = 1.0 /
kappa;
535 for (
size_t g = 0; g < num_gauss_points; ++g)
537 const Vector& gauss_shape_functions =
row(shape_functions, g);
540 p_constitutive_law->CalculateValue(cl_parameters, EFFECTIVE_VISCOSITY,
nu);
544 r_geometry, gauss_shape_functions,
545 std::tie(tke, TURBULENT_KINETIC_ENERGY),
546 std::tie(wall_velocity, VELOCITY));
548 const double wall_velocity_magnitude =
norm_2(wall_velocity);
550 double y_plus{0.0}, u_tau{0.0};
553 y_plus =
std::max(y_plus, y_plus_limit);
556 wall_velocity_magnitude /
557 (inv_kappa * std::log(y_plus) + beta));
559 if (wall_velocity_magnitude > eps) {
560 const double value =
rho * std::pow(u_tau, 2) *
561 gauss_weights[g] / wall_velocity_magnitude;
562 for (
size_t a = 0;
a < r_geometry.PointsNumber(); ++
a) {
563 for (
size_t dim = 0;
dim < TDim; ++
dim) {
564 for (
size_t b = 0;
b < r_geometry.PointsNumber(); ++
b) {
565 rLocalMatrix(
a * TDim +
dim,
b * TDim +
dim) +=
566 gauss_shape_functions[
a] *
567 gauss_shape_functions[
b] * value;
569 rLocalVector[
a * TDim +
dim] -=
570 gauss_shape_functions[
a] * value * wall_velocity[
dim];
602 void save(
Serializer& rSerializer)
const override
628 template <
unsigned int TDim,
unsigned int TNumNodes>
630 std::istream& rIStream,
637 template <
unsigned int TDim,
unsigned int TNumNodes>
639 std::ostream& rOStream,
643 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
std::size_t SizeType
Definition: condition.h:94
std::vector< std::size_t > EquationIdVectorType
Definition: condition.h:98
PropertiesType & GetProperties()
Definition: condition.h:974
std::vector< DofType::Pointer > DofsVectorType
Definition: condition.h:100
virtual int Check(const ProcessInfo &rCurrentProcessInfo) const
Definition: condition.h:854
Condition & operator=(Condition const &rOther)
Assignment operator.
Definition: condition.h:181
PropertiesType::Pointer pGetProperties()
returns the pointer to the property of the condition. Does not throw an error, to allow copying of co...
Definition: condition.h:964
virtual IntegrationMethod GetIntegrationMethod() const
Definition: condition.h:288
std::size_t IndexType
Definition: flags.h:74
bool Is(Flags const &rOther) const
Definition: flags.h:274
Implements a wall condition for the monolithic formulation.
Definition: fractional_step_k_based_wall_condition.h:55
Condition::Pointer Create(IndexType NewId, Condition::GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Definition: fractional_step_k_based_wall_condition.h:178
void CalculateOnIntegrationPoints(const Variable< Vector > &rVariable, std::vector< Vector > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:439
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: fractional_step_k_based_wall_condition.h:474
FractionalStepKBasedWallCondition(IndexType NewId=0)
Default constructor.
Definition: fractional_step_k_based_wall_condition.h:93
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Check that all data required by this condition is available and reasonable.
Definition: fractional_step_k_based_wall_condition.h:285
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: fractional_step_k_based_wall_condition.h:480
Condition::Pointer Clone(IndexType NewId, NodesArrayType const &rThisNodes) const override
Definition: fractional_step_k_based_wall_condition.h:195
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:208
FractionalStepKBasedWallCondition(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using Geometry.
Definition: fractional_step_k_based_wall_condition.h:116
void GetValuesVector(Vector &Values, int Step=0) const override
Returns VELOCITY_X, VELOCITY_Y, (VELOCITY_Z,) for each node.
Definition: fractional_step_k_based_wall_condition.h:370
Condition::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new FractionalStepKBasedWallCondition object.
Definition: fractional_step_k_based_wall_condition.h:169
FractionalStepKBasedWallCondition(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using Properties.
Definition: fractional_step_k_based_wall_condition.h:129
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Calculate wall stress term for all nodes with SLIP set.
Definition: fractional_step_k_based_wall_condition.h:222
Matrix MatrixType
Definition: fractional_step_k_based_wall_condition.h:73
void CalculateOnIntegrationPoints(const Variable< array_1d< double, 3 >> &rVariable, std::vector< array_1d< double, 3 >> &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:390
~FractionalStepKBasedWallCondition() override=default
Destructor.
FractionalStepKBasedWallCondition(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: fractional_step_k_based_wall_condition.h:104
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(FractionalStepKBasedWallCondition)
Pointer definition of FractionalStepKBasedWallCondition.
void ApplyWallLaw(MatrixType &rLocalMatrix, VectorType &rLocalVector, const ProcessInfo &rCurrentProcessInfo)
Commpute the wall stress and add corresponding terms to the system contributions.
Definition: fractional_step_k_based_wall_condition.h:498
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Provides the global indices for each one of this element's local rows.
void CalculateOnIntegrationPoints(const Variable< array_1d< double, 6 >> &rVariable, std::vector< array_1d< double, 6 >> &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:428
void ApplyNeumannCondition(MatrixType &rLocalMatrix, VectorType &rLocalVector)
Apply boundary terms to allow imposing a pressure (normal stress), with a correction to prevent inflo...
Definition: fractional_step_k_based_wall_condition.cpp:224
void CalculateOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:411
void CalculateNormal(array_1d< double, 3 > &An) const
void CalculateOnIntegrationPoints(const Variable< Matrix > &rVariable, std::vector< Matrix > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:450
std::string Info() const override
Turn back information as a string.
Definition: fractional_step_k_based_wall_condition.h:466
FractionalStepKBasedWallCondition & operator=(FractionalStepKBasedWallCondition const &rOther)
Copy constructor.
Definition: fractional_step_k_based_wall_condition.h:152
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Definition: fractional_step_k_based_wall_condition.h:328
void GetDofList(DofsVectorType &ConditionDofList, const ProcessInfo &CurrentProcessInfo) const override
Returns a list of the element's Dofs.
FractionalStepKBasedWallCondition(FractionalStepKBasedWallCondition const &rOther)
Copy constructor.
Definition: fractional_step_k_based_wall_condition.h:138
GeometryType::Pointer pGetGeometry()
Returns the pointer to the geometry.
Definition: geometrical_object.h:140
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometrical_object.h:248
Flags & GetFlags()
Returns the flags of the object.
Definition: geometrical_object.h:176
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
DataValueContainer & GetData()
Definition: geometrical_object.h:212
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
This object defines an indexed object.
Definition: indexed_object.h:54
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
This class defines the node.
Definition: node.h:65
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
TVariableType::Type & GetValue(const TVariableType &rVariable)
Definition: properties.h:228
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#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 void EvaluateInPoint(const GeometryType &rGeometry, const Vector &rShapeFunction, const int Step, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates given list of variable pairs at gauss point locations at step.
Definition: fluid_calculation_utilities.h:75
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
dt
Definition: DEM_benchmarks.py:173
static double max(double a, double b)
Definition: GeometryFunctions.h:79
bool IsWallFunctionActive(const ConditionType &rCondition)
Definition: rans_calculation_utilities.cpp:292
void CalculateConditionGeometryData(const GeometryType &rGeometry, const GeometryData::IntegrationMethod &rIntegrationMethod, Vector &rGaussWeights, Matrix &rNContainer)
Definition: rans_calculation_utilities.cpp:62
double CalculateWallHeight(const ConditionType &rCondition, const array_1d< double, 3 > &rNormal)
Definition: rans_calculation_utilities.cpp:195
void CalculateYPlusAndUtau(double &rYPlus, double &rUTau, const double WallVelocity, const double WallHeight, const double KinematicViscosity, const double Kappa, const double Beta, const int MaxIterations, const double Tolerance)
Definition: rans_calculation_utilities.cpp:247
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
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
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
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int step
Definition: face_heat.py:88
rho
Definition: generate_droplet_dynamics.py:86
a
Definition: generate_stokes_twofluid_element.py:77
int local_size
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:17
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
nu
Definition: isotropic_damage_automatic_differentiation.py:135
def load(f)
Definition: ode_solve.py:307
kappa
Definition: ode_solve.py:416
int d
Definition: ode_solve.py:397
N
Definition: sensitivityMatrix.py:29
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17
Definition: constitutive_law.h:189
void SetShapeFunctionsValues(const Vector &rShapeFunctionsValues)
Definition: constitutive_law.h:396