15 #if !defined(KRATOS_POROMECHANICS_EXPLICIT_STRATEGY)
16 #define KRATOS_POROMECHANICS_EXPLICIT_STRATEGY
29 template <
class TSparseSpace,
65 typename TSchemeType::Pointer pScheme,
68 bool ReformDofSetAtEachStep =
false,
76 "max_radius_factor": 20.0,
77 "min_radius_factor": 0.5,
78 "initial_radius": 1.0e-12,
79 "characteristic_length": 0.05,
80 "search_neighbours_step": false,
81 "body_domain_sub_model_part_list": [],
82 "loads_sub_model_part_list": [],
83 "loads_variable_list" : []
92 if(rParameters[
"loads_sub_model_part_list"].size() > 0)
98 KRATOS_THROW_ERROR( std::logic_error,
"For each SubModelPart there must be a corresponding nodal Variable",
"" )
134 if (!
mpScheme->ElementsAreInitialized())
mpScheme->InitializeElements(r_model_part);
137 if (!
mpScheme->ConditionsAreInitialized())
mpScheme->InitializeConditions(r_model_part);
146 const auto it_elem_begin = r_elements.begin();
150 #pragma omp parallel for firstprivate(dummy_vector), schedule(guided,512)
151 for (
int i = 0; i < static_cast<int>(r_elements.size()); ++
i) {
155 auto it_elem = it_elem_begin +
i;
156 it_elem->AddExplicitContribution(dummy_vector, RESIDUAL_VECTOR, NODAL_MASS, r_current_process_info);
160 r_current_process_info[IS_CONVERGED] =
true;
184 mpScheme->InitializeSolutionStep(r_model_part, matrix_a_dummy, rDx, rb);
187 ProcessInfo& r_current_process_info = r_model_part.GetProcessInfo();
189 const auto it_elem_begin = r_elements.
begin();
196 #pragma omp parallel for firstprivate(dummy_vector), schedule(guided,512)
197 for (
int i = 0; i < static_cast<int>(r_elements.size()); ++
i) {
201 auto it_elem = it_elem_begin +
i;
202 it_elem->AddExplicitContribution(dummy_vector, RESIDUAL_VECTOR, NODAL_MASS, r_current_process_info);
227 mpScheme->Predict(r_model_part, dof_set_dummy, rA, rDx, rb);
234 mpScheme->Update(r_model_part, dof_set_dummy, rA, rDx, rb);
270 mpScheme->FinalizeSolutionStep(r_model_part, rA, rDx, rb);
296 typename TSchemeType::Pointer pScheme,
301 auto& r_nodes = rModelPart.
Nodes();
305 double flux_residual = 0.0;
308 const unsigned int dim = r_current_process_info[DOMAIN_SIZE];
311 const auto it_node_begin = r_nodes.
begin();
314 #pragma omp parallel for firstprivate(force_residual,flux_residual), schedule(guided,512)
315 for(
int i=0; i<static_cast<int>(r_nodes.size()); ++
i) {
316 auto it_node = it_node_begin +
i;
318 noalias(force_residual) = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL);
319 flux_residual = it_node->FastGetSolutionStepValue(FLUX_RESIDUAL);
321 if( it_node->IsFixed(DISPLACEMENT_X) ==
true ) {
322 double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_X);
323 r_reaction = -force_residual[0];
325 if( it_node->IsFixed(DISPLACEMENT_Y) ==
true ) {
326 double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_Y);
327 r_reaction = -force_residual[1];
329 if( it_node->IsFixed(WATER_PRESSURE) ==
true ) {
330 double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_WATER_PRESSURE);
331 r_reaction = -flux_residual;
334 if( it_node->IsFixed(DISPLACEMENT_Z) ==
true ) {
335 double& r_reaction = it_node->FastGetSolutionStepValue(REACTION_Z);
336 r_reaction = -force_residual[2];
346 const auto it_node_begin = rModelPart.
NodesBegin();
348 double l2_numerator = 0.0;
349 double l2_denominator = 0.0;
350 #pragma omp parallel for reduction(+:l2_numerator,l2_denominator)
351 for (
int i = 0; i < static_cast<int>(r_nodes.size()); ++
i) {
352 auto itCurrentNode = it_node_begin +
i;
353 const array_1d<double, 3>& r_current_displacement = itCurrentNode->FastGetSolutionStepValue(DISPLACEMENT);
354 const array_1d<double, 3>& r_previous_displacement = itCurrentNode->FastGetSolutionStepValue(DISPLACEMENT,1);
355 const double& r_current_water_pressure = itCurrentNode->FastGetSolutionStepValue(WATER_PRESSURE);
356 const double& r_previous_water_pressure = itCurrentNode->FastGetSolutionStepValue(WATER_PRESSURE,1);
358 noalias(delta_displacement) = r_current_displacement - r_previous_displacement;
359 const double delta_water_pressure = r_current_water_pressure - r_previous_water_pressure;
360 const double norm_2_du =
inner_prod(delta_displacement,delta_displacement) + delta_water_pressure*delta_water_pressure;
361 const double norm_2_u_old =
inner_prod(r_previous_displacement,r_previous_displacement) + r_previous_water_pressure*r_previous_water_pressure;
363 l2_numerator += norm_2_du;
364 l2_denominator += norm_2_u_old;
366 if (l2_denominator > 1.0e-12) {
367 double l2_abs_error = std::sqrt(l2_numerator);
368 double l2_rel_error = l2_abs_error/std::sqrt(l2_denominator);
376 if (l2_rel_error <= r_current_process_info[ERROR_RATIO] && l2_abs_error <= r_current_process_info[ERROR_INTEGRATION_POINT]) {
377 KRATOS_INFO(
"EXPLICIT CONVERGENCE CHECK") <<
"The simulation is converging at step: " << r_current_process_info[STEP] << std::endl;
378 KRATOS_INFO(
"EXPLICIT CONVERGENCE CHECK") <<
"L2 Relative Error is: " << l2_rel_error << std::endl;
379 KRATOS_INFO(
"EXPLICIT CONVERGENCE CHECK") <<
"L2 Absolute Error is: " << l2_abs_error << std::endl;
iterator begin()
Iterator pointing to the beginning of the container.
Definition: data_value_container.h:209
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
BaseType::TSystemVectorType TSystemVectorType
Definition: implicit_solving_strategy.h:72
Scheme< TSparseSpace, TDenseSpace > TSchemeType
Definition: implicit_solving_strategy.h:82
void SetRebuildLevel(int Level) override
This sets the build level.
Definition: implicit_solving_strategy.h:207
BaseType::NodesArrayType NodesArrayType
Definition: implicit_solving_strategy.h:92
int mRebuildLevel
Definition: implicit_solving_strategy.h:263
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
BaseType::ElementsArrayType ElementsArrayType
Definition: implicit_solving_strategy.h:94
This strategy is used for the explicit time integration.
Definition: mechanical_explicit_strategy.hpp:54
TSchemeType::Pointer mpScheme
Definition: mechanical_explicit_strategy.hpp:587
bool mInitializeWasPerformed
Flag telling if the initialize was performed.
Definition: mechanical_explicit_strategy.hpp:608
bool mCalculateReactionsFlag
Flag telling if it is needed or not to compute the reactions.
Definition: mechanical_explicit_strategy.hpp:602
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
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
Definition: poromechanics_explicit_strategy.hpp:34
TSchemeType::Pointer mpScheme
Definition: mechanical_explicit_strategy.hpp:587
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: poromechanics_explicit_strategy.hpp:174
virtual void CheckConvergence(ModelPart &rModelPart)
Definition: poromechanics_explicit_strategy.hpp:342
void Initialize() override
Initialization of member variables and prior operations.
Definition: poromechanics_explicit_strategy.hpp:120
PoromechanicsExplicitStrategy(ModelPart &model_part, typename TSchemeType::Pointer pScheme, Parameters &rParameters, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Constructor.
Definition: poromechanics_explicit_strategy.hpp:63
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: poromechanics_explicit_strategy.hpp:50
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: poromechanics_explicit_strategy.hpp:214
std::vector< std::string > mVariableNames
List of every SubModelPart associated to an external load.
Definition: poromechanics_explicit_strategy.hpp:283
KRATOS_CLASS_POINTER_DEFINITION(PoromechanicsExplicitStrategy)
MechanicalExplicitStrategy< TSparseSpace, TDenseSpace, TLinearSolver > MotherType
Definition: poromechanics_explicit_strategy.hpp:40
BaseType::ElementsArrayType ElementsArrayType
Definition: poromechanics_explicit_strategy.hpp:48
~PoromechanicsExplicitStrategy() override
Destructor.
Definition: poromechanics_explicit_strategy.hpp:113
std::vector< ModelPart * > mSubModelPartList
Definition: poromechanics_explicit_strategy.hpp:282
BaseType::ConditionsArrayType ConditionsArrayType
Definition: poromechanics_explicit_strategy.hpp:49
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: poromechanics_explicit_strategy.hpp:45
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: poromechanics_explicit_strategy.hpp:46
bool mInitializeWasPerformed
Flag telling if the initialize was performed.
Definition: mechanical_explicit_strategy.hpp:608
bool mCalculateReactionsFlag
Flag telling if it is needed or not to compute the reactions.
Definition: mechanical_explicit_strategy.hpp:602
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: poromechanics_explicit_strategy.hpp:39
Node::DofType DofType
DoF types definition.
Definition: poromechanics_explicit_strategy.hpp:53
DofType::Pointer DofPointerType
Definition: poromechanics_explicit_strategy.hpp:54
BaseType::DofsArrayType DofsArrayType
Definition: poromechanics_explicit_strategy.hpp:42
virtual void CalculateReactions(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart)
Name of the nodal variable associated to every SubModelPart.
Definition: poromechanics_explicit_strategy.hpp:295
Parameters * mpParameters
Member Variables.
Definition: poromechanics_explicit_strategy.hpp:281
BaseType::TSchemeType TSchemeType
Definition: poromechanics_explicit_strategy.hpp:41
BaseType::TSystemMatrixType TSystemMatrixType
Definition: poromechanics_explicit_strategy.hpp:43
BaseType::TSystemVectorType TSystemVectorType
Definition: poromechanics_explicit_strategy.hpp:44
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: poromechanics_explicit_strategy.hpp:260
BaseType::NodesArrayType NodesArrayType
Definition: poromechanics_explicit_strategy.hpp:47
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition: solving_strategy.h:77
ModelPart::NodesContainerType NodesArrayType
Definition: solving_strategy.h:89
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
ModelPart::ElementsContainerType ElementsArrayType
Definition: solving_strategy.h:91
TSparseSpace::MatrixType TSystemMatrixType
Definition: solving_strategy.h:71
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition: solving_strategy.h:75
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: solving_strategy.h:93
bool MoveMeshFlag()
This function returns the flag that says if the mesh is moved.
Definition: solving_strategy.h:290
TSparseSpace::VectorType TSystemVectorType
Definition: solving_strategy.h:73
virtual void MoveMesh()
This function is designed to move the mesh.
Definition: solving_strategy.h:330
TDenseSpace::VectorType LocalSystemVectorType
Definition: solving_strategy.h:81
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetNonHistoricalVariable(const TVarType &rVariable, const TType &Value, TContainerType &rContainer)
Sets the container value of any type of non historical variable.
Definition: variable_utils.h:790
#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
#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
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
model_part
Definition: face_heat.py:14
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17