13 #if !defined(KRATOS_GLS_STRATEGY)
14 #define KRATOS_GLS_STRATEGY
19 #include "boost/smart_ptr.hpp"
24 #include "utilities/geometry_utilities.h"
103 template<
class TSparseSpace,
162 double velocity_toll = 0.01,
163 double pressure_toll = 0.01,
164 int MaxVelocityIterations = 3,
165 int MaxPressureIterations = 1,
183 this->proj_is_initialized =
false;
187 bool CalculateReactions =
false;
188 bool CalculateNormDxFlag =
true;
218 mHasSlipProcess =
false;
245 double Dp_norm = 1.00;
274 double Dp_norm = 1.00;
277 rCurrentProcessInfo[VISCOSITY] = 1.0;
281 i->FastGetSolutionStepValue(VELOCITY_X,1) =
i->FastGetSolutionStepValue(VELOCITY_X);
282 i->FastGetSolutionStepValue(VELOCITY_Y,1) =
i->FastGetSolutionStepValue(VELOCITY_Y);
283 i->FastGetSolutionStepValue(VELOCITY_Z,1) =
i->FastGetSolutionStepValue(VELOCITY_Z);
308 if (fabs(p_norm) > 1
e-10){
329 double local_p_norm = 0.0;
334 const double&
p = (
i)->FastGetSolutionStepValue(PRESSURE);
338 double p_norm = local_p_norm;
341 p_norm = sqrt(p_norm);
355 const double dt =
model_part.GetProcessInfo()[DELTA_TIME];
359 (
i)->FastGetSolutionStepValue(PRESSURE_OLD_IT) = 0.0;
360 (
i)->FastGetSolutionStepValue(PRESSURE) = 0.0;
361 (
i)->FastGetSolutionStepValue(PRESSURE,1) = 0.0;
384 bool is_converged =
false;
389 while (is_converged ==
false &&
iteration++<3)
395 if (is_converged ==
false)
396 if (rank == 0) std::cout <<
"ATTENTION: convergence NOT achieved" << std::endl;
406 rCurrentProcessInfo[FRACTIONAL_STEP] = 1;
434 double & nodal_mass = (
i)->FastGetSolutionStepValue(NODAL_MASS);
439 rCurrentProcessInfo[FRACTIONAL_STEP] = 6;
448 double A = (
i)->FastGetSolutionStepValue(NODAL_MASS);
449 if(
A<0.0000000000000001){
453 double dt_Minv = 0.005 /
A ;
455 force_temp *= dt_Minv;
458 if(!
i->IsFixed(VELOCITY_X))
460 i->FastGetSolutionStepValue(VELOCITY_X) += force_temp[0] ;
462 if(!
i->IsFixed(VELOCITY_Y))
464 i->FastGetSolutionStepValue(VELOCITY_Y) +=force_temp[1];
466 if(!
i->IsFixed(VELOCITY_Z))
468 i->FastGetSolutionStepValue(VELOCITY_Z) +=force_temp[2] ;
470 if(
i->IsFixed(VELOCITY_X))
472 i->FastGetSolutionStepValue(VELOCITY_X)=0.0;
474 if(
i->IsFixed(VELOCITY_Y))
476 i->FastGetSolutionStepValue(VELOCITY_Y)= 0.0;
478 if(
i->IsFixed(VELOCITY_Z))
480 i->FastGetSolutionStepValue(VELOCITY_Z)=0.0;
494 int number_of_threads = omp_get_max_threads();
496 int number_of_threads = 1;
501 vector<unsigned int> partition;
504 #pragma omp parallel for schedule(static,1)
505 for (
int k = 0;
k < number_of_threads;
k++)
511 for (
typename ModelPart::NodesContainerType::iterator it=it_begin; it!=it_end; ++it)
513 it->FastGetSolutionStepValue(PRESSURE_OLD_IT)=it->FastGetSolutionStepValue(PRESSURE);
537 const double dt =
model_part.GetProcessInfo()[DELTA_TIME];
542 int number_of_threads = omp_get_max_threads();
544 int number_of_threads = 1;
547 vector<unsigned int> partition;
552 #pragma omp parallel for schedule(static,1)
553 for (
int k = 0;
k < number_of_threads;
k++)
564 double & nodal_mass = (
i)->FastGetSolutionStepValue(NODAL_MASS);
574 rCurrentProcessInfo[FRACTIONAL_STEP] = 5;
576 vector<unsigned int> elem_partition;
579 #pragma omp parallel for schedule(static,1)
580 for (
int k = 0;
k < number_of_threads;
k++)
589 #pragma omp parallel for schedule(static,1)
590 for (
int k = 0;
k < number_of_threads;
k++)
599 force_temp *=(1.0/
i->FastGetSolutionStepValue(NODAL_MASS));
602 i->FastGetSolutionStepValue(VELOCITY) =
i->FastGetSolutionStepValue(VELOCITY,1) +
dt * force_temp;
620 int number_of_threads = omp_get_max_threads();
622 int number_of_threads = 1;
626 vector<unsigned int> partition;
629 #pragma omp parallel for schedule(static,1)
630 for (
int k = 0;
k < number_of_threads;
k++)
639 double & nodal_mass = (
i)->FastGetSolutionStepValue(NODAL_MASS);
641 i->FastGetSolutionStepValue(PRESSUREAUX)=0.0;
642 i->FastGetSolutionStepValue(PRESSURE)=0.0;
648 rCurrentProcessInfo[FRACTIONAL_STEP] = 7;
650 vector<unsigned int> elem_partition;
652 #pragma omp parallel for schedule(static,1)
653 for (
int k = 0;
k < number_of_threads;
k++)
664 #pragma omp parallel for schedule(static,1)
665 for (
int k = 0;
k < number_of_threads;
k++)
672 if(
i->FastGetSolutionStepValue(NODAL_MASS)==0.0)
674 i->FastGetSolutionStepValue(PRESSURE)=0.0;
679 i->FastGetSolutionStepValue(PRESSURE)=
i->FastGetSolutionStepValue(PRESSUREAUX) * (1.0/
i->FastGetSolutionStepValue(NODAL_MASS));
702 double norm_v = 0.00;
710 norm_v +=
v[0] *
v[0];
711 norm_v +=
v[1] *
v[1];
712 norm_v +=
v[2] *
v[2];
717 double norm_v1 = sqrt(norm_v);
719 if (norm_v1 == 0.0) norm_v1 = 1.00;
721 double ratio = normDx / norm_v1;
724 if (rank == 0) std::cout <<
"velocity ratio = " << ratio << std::endl;
729 if (rank == 0) std::cout <<
"convergence achieved" << std::endl;
745 int number_of_threads = omp_get_max_threads();
747 int number_of_threads = 1;
754 const double dt =
model_part.GetProcessInfo()[DELTA_TIME];
757 vector<unsigned int> partition;
762 #pragma omp parallel for schedule(static,1)
763 for (
int k = 0;
k < number_of_threads;
k++)
775 (
i)->FastGetSolutionStepValue(NODAL_MASS)=0.0;
780 rCurrentProcessInfo[FRACTIONAL_STEP] = 6;
783 vector<unsigned int> elem_partition;
786 #pragma omp parallel for schedule(static,1)
787 for (
int k = 0;
k < number_of_threads;
k++)
803 #pragma omp parallel for schedule(static,1)
804 for (
int k = 0;
k < number_of_threads;
k++)
816 force_temp -=
i->FastGetSolutionStepValue(NODAL_MASS) * ((
i)->FastGetSolutionStepValue(VELOCITY)-(
i)->FastGetSolutionStepValue(VELOCITY,1))/
dt;
838 if (rank == 0)
KRATOS_WATCH(
"FracStepStrategy Clear Function called");
943 unsigned int mdomain_size;
944 bool proj_is_initialized;
947 bool mHasSlipProcess;
949 std::vector< Process::Pointer > mInitializeIterationProcesses;
951 inline void CreatePartition(
unsigned int number_of_threads,
const int number_of_rows, vector<unsigned int>& partitions)
953 partitions.resize(number_of_threads + 1);
954 int partition_size = number_of_rows / number_of_threads;
956 partitions[number_of_threads] = number_of_rows;
957 for (
unsigned int i = 1;
i < number_of_threads;
i++)
958 partitions[
i] = partitions[
i - 1] + partition_size;
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
virtual int MyPID() const
Definition: communicator.cpp:91
Short class definition.
Definition: fracstep_GLS_strategy.h:109
unsigned int mtime_order
Definition: fracstep_GLS_strategy.h:897
unsigned int mprediction_order
Definition: fracstep_GLS_strategy.h:898
BaseType::DofsArrayType DofsArrayType
Definition: fracstep_GLS_strategy.h:123
bool mpredictor_corrector
Definition: fracstep_GLS_strategy.h:899
FracStepStrategy(ModelPart &model_part, typename TLinearSolver::Pointer pNewVelocityLinearSolver, typename TLinearSolver::Pointer pNewPressureLinearSolver, bool ReformDofAtEachIteration=true, double velocity_toll=0.01, double pressure_toll=0.01, int MaxVelocityIterations=3, int MaxPressureIterations=1, unsigned int time_order=2, unsigned int domain_size=2, bool predictor_corrector=false)
Definition: fracstep_GLS_strategy.h:160
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: fracstep_GLS_strategy.h:117
bool muse_dt_in_stabilization
Definition: fracstep_GLS_strategy.h:903
virtual double GetStageResidualNorm(unsigned int step)
Definition: fracstep_GLS_strategy.h:843
virtual void Clear() override
Clears the internal storage.
Definition: fracstep_GLS_strategy.h:835
double SavePressureIteration()
Definition: fracstep_GLS_strategy.h:325
void AssignInitialStepValues()
Definition: fracstep_GLS_strategy.h:349
BaseType::TDataType TDataType
Definition: fracstep_GLS_strategy.h:119
double Solve() override
Definition: fracstep_GLS_strategy.h:232
void SolveStepaux()
Definition: fracstep_GLS_strategy.h:609
bool ConvergenceCheck(const double &normDx, double tol)
Definition: fracstep_GLS_strategy.h:699
void SolveStep1(double velocity_toll, int MaxIterations)
Definition: fracstep_GLS_strategy.h:373
double IterativeSolve()
Definition: fracstep_GLS_strategy.h:268
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: fracstep_GLS_strategy.h:129
double mpressure_toll
Definition: fracstep_GLS_strategy.h:894
BaseType::TSystemMatrixType TSystemMatrixType
Definition: fracstep_GLS_strategy.h:125
void SolveStep3()
Definition: fracstep_GLS_strategy.h:532
double FractionalVelocityIteration()
Definition: fracstep_GLS_strategy.h:402
int mMaxPressIterations
Definition: fracstep_GLS_strategy.h:896
double SolveStep2()
Definition: fracstep_GLS_strategy.h:519
virtual ~FracStepStrategy()
Definition: fracstep_GLS_strategy.h:225
KRATOS_CLASS_POINTER_DEFINITION(FracStepStrategy)
double SolvePressure()
Definition: fracstep_GLS_strategy.h:256
BaseType::TSystemVectorType TSystemVectorType
Definition: fracstep_GLS_strategy.h:127
bool mReformDofAtEachIteration
Definition: fracstep_GLS_strategy.h:900
void Compute()
Definition: fracstep_GLS_strategy.h:740
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: fracstep_GLS_strategy.h:131
void SolveStep7()
Definition: fracstep_GLS_strategy.h:486
void SolveStep4()
Definition: fracstep_GLS_strategy.h:412
BaseType::Pointer mppressurestep
Definition: fracstep_GLS_strategy.h:891
OpenMPUtils::PartitionVector PartitionVector
Definition: fracstep_GLS_strategy.h:133
int mecho_level
Definition: fracstep_GLS_strategy.h:901
double mvelocity_toll
Definition: fracstep_GLS_strategy.h:893
virtual void SetEchoLevel(int Level) override
Definition: fracstep_GLS_strategy.h:827
int mMaxVelIterations
Definition: fracstep_GLS_strategy.h:895
BaseType::Pointer mpfracvel_strategy
Definition: fracstep_GLS_strategy.h:890
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
std::vector< int > PartitionVector
Vector type for the output of DivideInPartitions method.
Definition: openmp_utils.h:53
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
Current class provides an implementation for standard builder and solving operations.
Definition: residualbased_block_builder_and_solver.h:82
This class provides the implementation of a static scheme.
Definition: residualbased_incrementalupdate_static_scheme.h:57
This is a very simple strategy to solve linearly the problem.
Definition: residualbased_linear_strategy.h:64
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: solving_strategy.h:79
virtual void InitializeSolutionStep()
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: solving_strategy.h:224
TSparseSpace::DataType TDataType
Definition: solving_strategy.h:69
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
TSparseSpace::MatrixType TSystemMatrixType
Definition: solving_strategy.h:71
TSparseSpace::VectorType TSystemVectorType
Definition: solving_strategy.h:73
TDenseSpace::VectorType LocalSystemVectorType
Definition: solving_strategy.h:81
This utility can be used to compute the time employed on computations.
Definition: timer.h:63
static void Start(std::string const &rIntervalName)
This method starts the timer meassures.
Definition: timer.cpp:109
static void Stop(std::string const &rIntervalName)
This method stops the timer meassures.
Definition: timer.cpp:125
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
dt
Definition: DEM_benchmarks.py:173
iteration
Definition: DEM_benchmarks.py:172
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int time_order
Definition: ProjectParameters.py:51
int domain_size
Definition: face_heat.py:4
time
Definition: face_heat.py:85
int step
Definition: face_heat.py:88
model_part
Definition: face_heat.py:14
bool predictor_corrector
Definition: fluid_only_var.py:8
v
Definition: generate_convection_diffusion_explicit_element.py:114
int tol
Definition: hinsberg_optimization.py:138
float aux1
Definition: isotropic_damage_automatic_differentiation.py:239
int k
Definition: quadrature.py:595
A
Definition: sensitivityMatrix.py:70
p
Definition: sensitivityMatrix.py:52
integer i
Definition: TensorModule.f:17
zero
Definition: test_pureconvectionsolver_benchmarking.py:94
ReformDofAtEachIteration
Definition: test_pureconvectionsolver_benchmarking.py:131
e
Definition: run_cpp_mpi_tests.py:31