16 #ifndef KRATOS_FS_STRATEGY_FOR_CHIMERA_H
17 #define KRATOS_FS_STRATEGY_FOR_CHIMERA_H
59 template<
class TSparseSpace,
82 bool PredictorCorrector):
83 BaseType(rModelPart,rSolverConfig,PredictorCorrector)
85 KRATOS_WARNING(
"FractionalStepStrategyForChimera") <<
"This constructor is deprecated. Use the one with the \'CalculateReactionsFlag\' instead." << std::endl;
86 this->InitializeStrategy(rSolverConfig,PredictorCorrector);
92 bool PredictorCorrector,
93 bool CalculateReactionsFlag)
94 :
BaseType(rModelPart, rSolverConfig, PredictorCorrector, CalculateReactionsFlag)
96 this->InitializeStrategy(rSolverConfig,PredictorCorrector);
135 std::string
Info()
const override
137 std::stringstream buffer;
138 buffer <<
"FractionalStepStrategyForChimera" ;
143 void PrintInfo(std::ostream& rOStream)
const override {rOStream <<
"FractionalStepStrategyForChimera";}
146 void PrintData(std::ostream& rOStream)
const override {}
184 double start_solve_time = OpenMPUtils::GetCurrentTime();
190 bool converged =
false;
194 KRATOS_INFO(
"FRACTIONAL STEP :: ")<<it+1<<std::endl;
205 "Fractional velocity converged in " << it+1 <<
" iterations." << std::endl;
211 "Fractional velocity iterations did not converge "<< std::endl;
228 const double old_press = it_node->FastGetSolutionStepValue(PRESSURE);
229 it_node->FastGetSolutionStepValue(PRESSURE_OLD_IT) = -old_press;
234 "Calculating Pressure."<< std::endl;
245 it_node->FastGetSolutionStepValue(PRESSURE_OLD_IT) += it_node->FastGetSolutionStepValue(PRESSURE);
257 (*iExtraSteps)->Execute();
259 const double stop_solve_time = OpenMPUtils::GetCurrentTime();
263 return std::make_tuple(converged, norm_dp);
282 it_node->FastGetSolutionStepValue(CONV_PROJ) =
zero;
283 it_node->FastGetSolutionStepValue(PRESS_PROJ) =
zero;
284 it_node->FastGetSolutionStepValue(DIVPROJ) = 0.0;
285 it_node->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
317 const double nodal_area = it_node->FastGetSolutionStepValue(NODAL_AREA);
318 if( nodal_area > mAreaTolerance )
320 it_node->FastGetSolutionStepValue(CONV_PROJ) /= nodal_area;
321 it_node->FastGetSolutionStepValue(PRESS_PROJ) /= nodal_area;
322 it_node->FastGetSolutionStepValue(DIVPROJ) /= nodal_area;
329 auto &r_pre_modelpart = rModelPart.
GetSubModelPart(rModelPart.
Name()+
"fs_pressure_model_part");
331 for(
const auto& constraint : r_constraints_container)
333 const auto& master_dofs = constraint.GetMasterDofsVector();
334 const auto& slave_dofs = constraint.GetSlaveDofsVector();
337 constraint.CalculateLocalSystem(r_relation_matrix,r_constant_vector,rModelPart.
GetProcessInfo());
340 for(
const auto& slave_dof : slave_dofs)
342 const auto slave_node_id = slave_dof->Id();
343 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
345 for(
const auto& master_dof : master_dofs)
347 const auto master_node_id = master_dof->Id();
348 const double weight = r_relation_matrix(slave_i, master_j);
349 auto& r_master_node = rModelPart.
Nodes()[master_node_id];
350 auto& conv_proj = r_slave_node.FastGetSolutionStepValue(CONV_PROJ);
351 auto& pres_proj = r_slave_node.FastGetSolutionStepValue(PRESS_PROJ);
352 auto& dive_proj = r_slave_node.FastGetSolutionStepValue(DIVPROJ);
353 auto& nodal_area = r_slave_node.FastGetSolutionStepValue(NODAL_AREA);
354 conv_proj += (r_master_node.FastGetSolutionStepValue(CONV_PROJ))*weight;
355 pres_proj += (r_master_node.FastGetSolutionStepValue(PRESS_PROJ))*weight;
356 dive_proj += (r_master_node.FastGetSolutionStepValue(DIVPROJ))*weight;
357 nodal_area += (r_master_node.FastGetSolutionStepValue(NODAL_AREA))*weight;
381 it_node->FastGetSolutionStepValue(FRACT_VEL) =
zero;
411 auto &r_pre_modelpart = rModelPart.
GetSubModelPart(rModelPart.
Name()+
"fs_pressure_model_part");
413 for(
const auto& constraint : r_constraints_container)
415 const auto& slave_dofs = constraint.GetSlaveDofsVector();
416 for(
const auto& slave_dof : slave_dofs)
418 const auto slave_node_id = slave_dof->Id();
419 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
420 r_slave_node.GetValue(NODAL_AREA)= 0;
423 r_slave_node.GetValue(DIVPROJ)= 0 ;
427 for(
const auto& constraint : r_constraints_container)
429 const auto& master_dofs = constraint.GetMasterDofsVector();
430 const auto& slave_dofs = constraint.GetSlaveDofsVector();
433 constraint.CalculateLocalSystem(r_relation_matrix,r_constant_vector,rModelPart.
GetProcessInfo());
436 for(
const auto& slave_dof : slave_dofs)
438 const IndexType slave_node_id = slave_dof->Id();
439 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
441 for(
const auto& master_dof : master_dofs)
443 const IndexType master_node_id = master_dof->Id();
444 const double weight = r_relation_matrix(slave_i, master_j);
445 auto& r_master_node = rModelPart.
Nodes()[master_node_id];
447 r_slave_node.GetValue(NODAL_AREA) +=(r_master_node.FastGetSolutionStepValue(NODAL_AREA))*weight;
448 r_slave_node.GetValue(CONV_PROJ) +=(r_master_node.FastGetSolutionStepValue(CONV_PROJ))*weight;
449 r_slave_node.GetValue(PRESS_PROJ) +=(r_master_node.FastGetSolutionStepValue(PRESS_PROJ))*weight;
450 r_slave_node.GetValue(DIVPROJ) +=(r_master_node.FastGetSolutionStepValue(DIVPROJ))*weight;
463 for (
auto it_node = rModelPart.
NodesBegin(); it_node != rModelPart.
NodesEnd(); it_node++)
465 if (it_node->GetValue(NODAL_AREA) > mAreaTolerance)
467 it_node->FastGetSolutionStepValue(NODAL_AREA) = it_node->GetValue(NODAL_AREA);
468 it_node->FastGetSolutionStepValue(CONV_PROJ) = it_node->GetValue(CONV_PROJ);
469 it_node->FastGetSolutionStepValue(PRESS_PROJ) = it_node->GetValue(PRESS_PROJ);
470 it_node->FastGetSolutionStepValue(DIVPROJ) = it_node->GetValue(DIVPROJ);
472 it_node->GetValue(NODAL_AREA) = 0.0;
475 it_node->GetValue(DIVPROJ) = 0.0;
482 auto &r_pre_modelpart = rModelPart.
GetSubModelPart(rModelPart.
Name()+
"fs_pressure_model_part");
484 for(
const auto& constraint : r_constraints_container)
486 const auto& slave_dofs = constraint.GetSlaveDofsVector();
487 for(
const auto& slave_dof : slave_dofs)
489 const auto slave_node_id = slave_dof->Id();
490 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
491 r_slave_node.FastGetSolutionStepValue(FRACT_VEL_X)=0;
492 r_slave_node.FastGetSolutionStepValue(FRACT_VEL_Y)=0;
496 for(
const auto& constraint : r_constraints_container)
498 const auto& master_dofs = constraint.GetMasterDofsVector();
499 const auto& slave_dofs = constraint.GetSlaveDofsVector();
502 constraint.CalculateLocalSystem(r_relation_matrix,r_constant_vector,rModelPart.
GetProcessInfo());
505 for(
const auto& slave_dof : slave_dofs)
507 const auto slave_node_id = slave_dof->Id();
508 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
510 for(
const auto& master_dof : master_dofs)
512 const auto master_node_id = master_dof->Id();
513 const double weight = r_relation_matrix(slave_i, master_j);
514 auto& r_master_node = rModelPart.
Nodes()[master_node_id];
516 r_slave_node.GetValue(FRACT_VEL) +=(r_master_node.FastGetSolutionStepValue(FRACT_VEL))*weight;
529 if ( r_delta_vel[0]*r_delta_vel[0] + r_delta_vel[1]*r_delta_vel[1] + r_delta_vel[2]*r_delta_vel[2] != 0.0)
531 it_node->FastGetSolutionStepValue(FRACT_VEL) = it_node->GetValue(FRACT_VEL);
563 const double mAreaTolerance=1
E-12;
575 void InterpolateVelocity(
ModelPart& rModelPart)
584 const double NodalArea = it_node->FastGetSolutionStepValue(NODAL_AREA);
585 if (NodalArea > mAreaTolerance) {
586 if (!it_node->IsFixed(VELOCITY_X))
587 it_node->FastGetSolutionStepValue(VELOCITY_X) +=
588 it_node->FastGetSolutionStepValue(FRACT_VEL_X) / NodalArea;
589 if (!it_node->IsFixed(VELOCITY_Y))
590 it_node->FastGetSolutionStepValue(VELOCITY_Y) +=
591 it_node->FastGetSolutionStepValue(FRACT_VEL_Y) / NodalArea;
592 if constexpr (TDim > 2)
593 if (!it_node->IsFixed(VELOCITY_Z))
594 it_node->FastGetSolutionStepValue(VELOCITY_Z) +=
595 it_node->FastGetSolutionStepValue(FRACT_VEL_Z) / NodalArea;
600 auto& r_pre_modelpart =
601 rModelPart.GetSubModelPart(rModelPart.
Name()+"fs_pressure_model_part");
602 const auto& r_constraints_container = r_pre_modelpart.MasterSlaveConstraints();
603 for (
const auto& constraint : r_constraints_container) {
604 const auto& slave_dofs = constraint.GetSlaveDofsVector();
605 for (
const auto& slave_dof : slave_dofs) {
606 const auto slave_node_id =
608 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
609 r_slave_node.FastGetSolutionStepValue(VELOCITY_X) = 0;
610 r_slave_node.FastGetSolutionStepValue(VELOCITY_Y) = 0;
611 if constexpr (TDim > 2)
612 r_slave_node.FastGetSolutionStepValue(VELOCITY_Z) = 0;
616 for (
const auto& constraint : r_constraints_container) {
617 const auto& master_dofs = constraint.GetMasterDofsVector();
618 const auto& slave_dofs = constraint.GetSlaveDofsVector();
621 constraint.CalculateLocalSystem(r_relation_matrix, r_constant_vector,
625 for (
const auto& slave_dof : slave_dofs) {
626 const auto slave_node_id =
628 auto& r_slave_node = rModelPart.
Nodes()[slave_node_id];
630 for (
const auto& master_dof : master_dofs) {
631 const auto master_node_id = master_dof->Id();
632 const double weight = r_relation_matrix(slave_i, master_j);
633 auto& r_master_node = rModelPart.
Nodes()[master_node_id];
635 r_slave_node.FastGetSolutionStepValue(VELOCITY_X) +=
636 (r_master_node.FastGetSolutionStepValue(VELOCITY_X)) * weight;
637 r_slave_node.FastGetSolutionStepValue(VELOCITY_Y) +=
638 (r_master_node.FastGetSolutionStepValue(VELOCITY_Y)) * weight;
639 if constexpr (TDim > 2)
640 r_slave_node.FastGetSolutionStepValue(VELOCITY_Z) +=
641 (r_master_node.FastGetSolutionStepValue(VELOCITY_Z)) * weight;
651 bool PredictorCorrector)
679 KRATOS_INFO(
"FractionalStepStrategyForChimera ")<<
"Velcoity strategy successfully set !"<<std::endl;
683 KRATOS_THROW_ERROR(std::runtime_error,
"FS_Strategy error: No Velocity strategy defined in FractionalStepSettings",
"");
688 if (HavePressStrategy)
693 KRATOS_INFO(
"FractionalStepStrategyForChimera ")<<
"Pressure strategy successfully set !"<<std::endl;
697 KRATOS_THROW_ERROR(std::runtime_error,
"FS_Strategy error: No Pressure strategy defined in FractionalStepSettings",
"");
virtual bool AssembleNonHistoricalData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:527
virtual bool AssembleCurrentData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:502
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
Helper class to define solution strategies for FS_Strategy.
Definition: fractional_step_settings_for_chimera.h:78
Definition: fs_strategy_for_chimera.h:64
std::string Info() const override
Turn back information as a string.
Definition: fs_strategy_for_chimera.h:135
void ChimeraProjectionCorrection(ModelPart &rModelPart)
Definition: fs_strategy_for_chimera.h:409
void ComputeSplitOssProjections(ModelPart &rModelPart) override
Definition: fs_strategy_for_chimera.h:268
FractionalStepSettingsForChimera< TSparseSpace, TDenseSpace, TLinearSolver > SolverSettingsType
Definition: fs_strategy_for_chimera.h:74
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: fs_strategy_for_chimera.h:143
KRATOS_CLASS_POINTER_DEFINITION(FractionalStepStrategyForChimera)
Counted pointer of FractionalStepStrategyForChimera.
std::tuple< bool, double > SolveStep() override
Definition: fs_strategy_for_chimera.h:181
FractionalStepStrategyForChimera(ModelPart &rModelPart, SolverSettingsType &rSolverConfig, bool PredictorCorrector)
Definition: fs_strategy_for_chimera.h:80
FractionalStepStrategyForChimera(FractionalStepStrategyForChimera const &rOther)=delete
Copy constructor.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: fs_strategy_for_chimera.h:146
void CalculateEndOfStepVelocity() override
Definition: fs_strategy_for_chimera.h:366
FractionalStepStrategyForChimera & operator=(FractionalStepStrategyForChimera const &rOther)=delete
Assignment operator.
~FractionalStepStrategyForChimera()=default
Destructor.
void ChimeraVelocityCorrection(ModelPart &rModelPart)
Definition: fs_strategy_for_chimera.h:480
FractionalStepStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: fs_strategy_for_chimera.h:72
FractionalStepStrategyForChimera(ModelPart &rModelPart, SolverSettingsType &rSolverConfig, bool PredictorCorrector, bool CalculateReactionsFlag)
Definition: fs_strategy_for_chimera.h:89
Fractional-step strategy for incompressible Navier-Stokes formulation This strategy implements a spli...
Definition: fractional_step_strategy.h:77
double mVelocityTolerance
Definition: fractional_step_strategy.h:413
unsigned int mMaxPressureIter
Definition: fractional_step_strategy.h:421
int Check() override
Function to perform expensive checks.
Definition: fractional_step_strategy.h:183
std::vector< Process::Pointer > mExtraIterationSteps
Definition: fractional_step_strategy.h:441
StrategyPointerType mpMomentumStrategy
Scheme for the solution of the momentum equation.
Definition: fractional_step_strategy.h:436
void EnforceSlipCondition(const Kratos::Flags &rSlipWallFlag)
Substract wall-normal component of velocity update to ensure that the final velocity satisfies slip c...
Definition: fractional_step_strategy.h:730
double mPressureTolerance
Definition: fractional_step_strategy.h:415
bool CheckFractionalStepConvergence(const double NormDv)
Definition: fractional_step_strategy.h:578
StrategyPointerType mpPressureStrategy
Scheme for the solution of the mass equation.
Definition: fractional_step_strategy.h:439
void SetEchoLevel(int Level) override
This sets the level of echo for the solving strategy.
Definition: fractional_step_strategy.h:341
bool mReformDofSet
Definition: fractional_step_strategy.h:431
unsigned int mMaxVelocityIter
Definition: fractional_step_strategy.h:419
bool mPredictorCorrector
Definition: fractional_step_strategy.h:427
unsigned int mTimeOrder
Definition: fractional_step_strategy.h:425
bool mUseSlipConditions
Definition: fractional_step_strategy.h:429
unsigned int mDomainSize
Definition: fractional_step_strategy.h:423
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: implicit_solving_strategy.h:188
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MasterSlaveConstraintContainerType & MasterSlaveConstraints(IndexType ThisIndex=0)
Definition: model_part.h:654
Communicator & GetCommunicator()
Definition: model_part.h:1821
std::string & Name()
Definition: model_part.h:1811
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
static void PartitionedIterators(TVector &rVector, typename TVector::iterator &rBegin, typename TVector::iterator &rEnd)
Generate a partition for an std::vector-like array, providing iterators to the begin and end position...
Definition: openmp_utils.h:179
@ Velocity
Definition: solver_settings.h:66
@ Pressure
Definition: solver_settings.h:66
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
int GetEchoLevel()
This returns the level of echo for the solving strategy.
Definition: solving_strategy.h:271
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_INFO(label)
Definition: logger.h:250
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_WARNING(label)
Definition: logger.h:265
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
E
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:26
out
Definition: isotropic_damage_automatic_differentiation.py:200
tuple const
Definition: ode_solve.py:403
zero
Definition: test_pureconvectionsolver_benchmarking.py:94