13 #if !defined(KRATOS_BDF2_TURBULENT_SCHEME_DEM_COUPLED_H_INCLUDED )
14 #define KRATOS_BDF2_TURBULENT_SCHEME_DEM_COUPLED_H_INCLUDED
64 template<
class TSparseSpace,
class TDenseSpace>
106 , mpTurbulenceModel(pTurbulenceModel)
116 , mrPeriodicIdVar(rPeriodicVar)
148 const double tol = 1.0e-12;
151 if(std::abs(
Dt - OldDt) >
tol) {
155 #pragma omp parallel for
156 for(
int i_node = 0; i_node <
n_nodes; ++i_node) {
157 auto it_node = rModelPart.
NodesBegin() + i_node;
158 auto& rMeshVel = it_node->FastGetSolutionStepValue(MESH_VELOCITY);
159 const auto& rDisp0 = it_node->FastGetSolutionStepValue(DISPLACEMENT);
160 const auto& rDisp1 = it_node->FastGetSolutionStepValue(DISPLACEMENT,1);
161 const auto& rDisp2 = it_node->FastGetSolutionStepValue(DISPLACEMENT,2);
162 rMeshVel = BDFcoefs[0] * rDisp0 + BDFcoefs[1] * rDisp1 + BDFcoefs[2] * rDisp2;
174 double Dt = rCurrentProcessInfo[DELTA_TIME];
175 double step = rCurrentProcessInfo[STEP];
177 if (rCurrentProcessInfo[MANUFACTURED] &&
step < 2){
178 OldDt = rCurrentProcessInfo[DELTA_TIME];
184 double Rho = OldDt /
Dt;
185 double TimeCoeff = 1.0 / (
Dt * Rho * Rho +
Dt * Rho);
187 Vector& BDFcoeffs = rCurrentProcessInfo[BDF_COEFFICIENTS];
188 BDFcoeffs.
resize(3,
false);
190 BDFcoeffs[0] = TimeCoeff * (Rho * Rho + 2.0 * Rho);
191 BDFcoeffs[1] = -TimeCoeff * (Rho * Rho + 2.0 * Rho + 1.0);
192 BDFcoeffs[2] = TimeCoeff;
205 #pragma omp parallel for firstprivate(zero_vect)
206 for (
int i_node = 0; i_node <
n_nodes; ++i_node) {
208 noalias(ind->FastGetSolutionStepValue(ADVPROJ)) = zero_vect;
209 ind->FastGetSolutionStepValue(DIVPROJ) = 0.0;
210 ind->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
216 const unsigned int MaxIter = 100;
219 unsigned int iter = 0;
221 double dMassProj = 0.0;
223 double RelMomErr = 1000.0 * RelTol;
224 double RelMassErr = 1000.0 * RelTol;
225 double AbsMomErr = 1000.0 * AbsTol;
226 double AbsMassErr = 1000.0 * AbsTol;
228 while( ( (AbsMomErr > AbsTol && RelMomErr > RelTol) || (AbsMassErr > AbsTol && RelMassErr > RelTol) ) && iter < MaxIter)
231 #pragma omp parallel for firstprivate(zero_vect)
232 for (
int i_node = 0; i_node <
n_nodes; ++i_node)
235 noalias(ind->GetValue(ADVPROJ)) = zero_vect;
236 ind->GetValue(DIVPROJ) = 0.0;
237 ind->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
248 #pragma omp parallel for private(output)
249 for (
int i_elem = 0; i_elem < n_elems; ++i_elem) {
251 it_elem->Calculate(SUBSCALE_VELOCITY,
output, rCurrentProcessInfo);
261 #pragma omp parallel for
262 for (
int i_node = 0; i_node <
n_nodes; ++i_node) {
264 const double Area = ind->FastGetSolutionStepValue(NODAL_AREA);
265 dMomProj = ind->GetValue(ADVPROJ) / Area;
266 dMassProj = ind->GetValue(DIVPROJ) / Area;
268 RelMomErr += std::sqrt(std::pow(dMomProj[0],2) + std::pow(dMomProj[1],2) + std::pow(dMomProj[2],2));
269 RelMassErr += std::fabs(dMassProj);
271 auto& rMomRHS = ind->FastGetSolutionStepValue(ADVPROJ);
272 double& rMassRHS = ind->FastGetSolutionStepValue(DIVPROJ);
274 rMassRHS += dMassProj;
276 AbsMomErr += std::sqrt(std::pow(rMomRHS[0],2) + std::pow(rMomRHS[1],2) + std::pow(rMomRHS[2],2));
277 AbsMassErr += std::fabs(rMassRHS);
280 if(AbsMomErr > 1
e-10)
281 RelMomErr /= AbsMomErr;
285 if(AbsMassErr > 1
e-10)
286 RelMassErr /= AbsMassErr;
293 KRATOS_INFO(
"BDF2TurbulentSchemeDEMCoupled") <<
"Performed OSS Projection in " << iter <<
" iterations" << std::endl;
304 if (mpTurbulenceModel != 0) mpTurbulenceModel->Execute();
309 if (CurrentProcessInfo[OSS_SWITCH] == 1.0)
334 const Vector& BDFcoefs = r_current_process_info[BDF_COEFFICIENTS];
335 double step = r_current_process_info[STEP];
339 double& fluid_fraction_0 = rNode.FastGetSolutionStepValue(FLUID_FRACTION);
340 double& fluid_fraction_1 = rNode.FastGetSolutionStepValue(FLUID_FRACTION_OLD);
341 double& fluid_fraction_2 = rNode.FastGetSolutionStepValue(FLUID_FRACTION_OLD_2);
345 fluid_fraction_2 = fluid_fraction_0;
346 fluid_fraction_1 = fluid_fraction_0;
349 rNode.
FastGetSolutionStepValue(FLUID_FRACTION_RATE) = BDFcoefs[0] * fluid_fraction_0 + BDFcoefs[1] * fluid_fraction_1 + BDFcoefs[2] * fluid_fraction_2;
370 this->mpDofUpdater->Clear();
388 std::string
Info()
const override
390 std::stringstream buffer;
391 buffer <<
"BDF2TurbulentSchemeDEMCoupled";
456 Process::Pointer mpTurbulenceModel =
nullptr;
458 RotationToolPointerType mpRotationTool =
nullptr;
460 typename TSparseSpace::DofUpdaterPointerType mpDofUpdater = TSparseSpace::CreateDofUpdater();
497 BDF2TurbulentSchemeDEMCoupled(BDF2TurbulentSchemeDEMCoupled
const& rOther)
515 template<
class TSparseSpace,
class TDenseSpace>
522 template<
class TSparseSpace,
class TDenseSpace>
526 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
A scheme for BDF2 time integration.
Definition: bdf2_turbulent_schemeDEMCoupled.h:66
BDF2TurbulentSchemeDEMCoupled(Process::Pointer pTurbulenceModel)
Constructor to use the formulation combined with a turbulence model.
Definition: bdf2_turbulent_schemeDEMCoupled.h:104
void FullProjection(ModelPart &rModelPart)
Definition: bdf2_turbulent_schemeDEMCoupled.h:197
BDF2TurbulentSchemeDEMCoupled()
Default constructor.
Definition: bdf2_turbulent_schemeDEMCoupled.h:92
TSparseSpace::DataType TDataType
Definition: bdf2_turbulent_schemeDEMCoupled.h:74
void UpdateFluidFraction(ModelPart &r_model_part, ProcessInfo &r_current_process_info)
Definition: bdf2_turbulent_schemeDEMCoupled.h:329
Dof< TDataType > TDofType
Definition: bdf2_turbulent_schemeDEMCoupled.h:81
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: bdf2_turbulent_schemeDEMCoupled.h:402
TSparseSpace::MatrixType TSystemMatrixType
Definition: bdf2_turbulent_schemeDEMCoupled.h:75
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: bdf2_turbulent_schemeDEMCoupled.h:78
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: bdf2_turbulent_schemeDEMCoupled.h:396
void FinalizeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: bdf2_turbulent_schemeDEMCoupled.h:356
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: bdf2_turbulent_schemeDEMCoupled.h:73
TDenseSpace::VectorType LocalSystemVectorType
Definition: bdf2_turbulent_schemeDEMCoupled.h:79
void SetTimeCoefficients(ProcessInfo &rCurrentProcessInfo)
Definition: bdf2_turbulent_schemeDEMCoupled.h:168
RotationToolType::UniquePointer RotationToolPointerType
Definition: bdf2_turbulent_schemeDEMCoupled.h:85
TSparseSpace::VectorType TSystemVectorType
Definition: bdf2_turbulent_schemeDEMCoupled.h:76
CoordinateTransformationUtils< LocalSystemMatrixType, LocalSystemVectorType, double > RotationToolType
Definition: bdf2_turbulent_schemeDEMCoupled.h:84
KRATOS_CLASS_POINTER_DEFINITION(BDF2TurbulentSchemeDEMCoupled)
Pointer definition of BDF2TurbulentSchemeDEMCoupled.
void InitializeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
unction to be called when it is needed to initialize an iteration. It is designed to be called at the...
Definition: bdf2_turbulent_schemeDEMCoupled.h:296
BDF2TurbulentSchemeDEMCoupled(const Kratos::Variable< int > &rPeriodicVar)
Constructor for periodic boundary conditions.
Definition: bdf2_turbulent_schemeDEMCoupled.h:114
void FinalizeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function to be called when it is needed to finalize an iteration. It is designed to be called at the ...
Definition: bdf2_turbulent_schemeDEMCoupled.h:318
void Clear() override
Free memory allocated by this object.
Definition: bdf2_turbulent_schemeDEMCoupled.h:368
std::string Info() const override
Turn back information as a string.
Definition: bdf2_turbulent_schemeDEMCoupled.h:388
void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Set the time iteration coefficients.
Definition: bdf2_turbulent_schemeDEMCoupled.h:134
~BDF2TurbulentSchemeDEMCoupled() override
Destructor.
Definition: bdf2_turbulent_schemeDEMCoupled.h:121
BaseType::DofsArrayType DofsArrayType
Definition: bdf2_turbulent_schemeDEMCoupled.h:82
A scheme for BDF2 time integration.
Definition: bdf2_turbulent_scheme.h:64
void SetTimeCoefficients(ProcessInfo &rCurrentProcessInfo)
Calculate the coefficients for time iteration.
Definition: bdf2_turbulent_scheme.h:481
virtual bool AssembleNonHistoricalData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:527
virtual bool AssembleCurrentData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:502
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
TVariableType::Type & GetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:406
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
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
ProcessInfo & GetPreviousSolutionStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:258
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
virtual void FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: scheme.h:294
virtual void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the beginning of each solution step.
Definition: scheme.h:272
virtual void FinalizeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function to be called when it is needed to finalize an iteration. It is designed to be called at the ...
Definition: scheme.h:393
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::ostream & operator<<(std::ostream &rOStream, const BDF2TurbulentSchemeDEMCoupled< TSparseSpace, TDenseSpace > &rThis)
output stream function
Definition: bdf2_turbulent_schemeDEMCoupled.h:523
std::istream & operator>>(std::istream &rIStream, BDF2TurbulentSchemeDEMCoupled< TSparseSpace, TDenseSpace > &rThis)
input stream function
Definition: bdf2_turbulent_schemeDEMCoupled.h:516
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
int step
Definition: face_heat.py:88
Dt
Definition: face_heat.py:78
output
Definition: generate_frictional_mortar_condition.py:444
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int n_nodes
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:15
int tol
Definition: hinsberg_optimization.py:138
A
Definition: sensitivityMatrix.py:70
e
Definition: run_cpp_mpi_tests.py:31