15 #if !defined(KRATOS_POROMECHANICS_NEWTON_RAPHSON_STRATEGY)
16 #define KRATOS_POROMECHANICS_NEWTON_RAPHSON_STRATEGY
32 template<
class TSparseSpace,
class TDenseSpace,
class TLinearSolver>
62 typename TSchemeType::Pointer pScheme,
63 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
64 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
66 int MaxIterations = 30,
67 bool CalculateReactions =
false,
68 bool ReformDofSetAtEachStep =
false,
71 pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag)
76 "desired_iterations": 4,
77 "max_radius_factor": 20.0,
78 "min_radius_factor": 0.5,
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",
"" )
139 this->SetLoadsToZero();
153 this->RestoreLoadsValue();
183 TSparseSpace::SetToZero(mA);
184 TSparseSpace::SetToZero(
mb);
185 TSparseSpace::SetToZero(mDx);
196 unsigned int iteration_number = 0;
197 bool is_converged =
false;
198 double dofs_ratio = 1000.0;
199 double ReferenceDofsNorm;
207 iteration_number += 1;
212 TSparseSpace::SetToZero(mA);
213 TSparseSpace::SetToZero(
mb);
214 TSparseSpace::SetToZero(mDx);
227 dofs_ratio = NormDx/ReferenceDofsNorm;
228 KRATOS_INFO(
"Newton Raphson Strategy") <<
"TEST ITERATION: " << iteration_number << std::endl;
229 KRATOS_INFO(
"Newton Raphson Strategy") <<
" Dofs Ratio = " << dofs_ratio << std::endl;
231 if(dofs_ratio <= 1.0e-3)
242 double ReferenceDofsNorm = 0.0;
248 #pragma omp parallel reduction(+:ReferenceDofsNorm)
259 const double&
temp = itDof->GetSolutionStepValue();
265 return sqrt(ReferenceDofsNorm);
272 void SetLoadsToZero()
291 double& rvalue = itNode->FastGetSolutionStepValue(var);
292 itNode->FastGetSolutionStepValue(var,1) = rvalue;
297 else if( KratosComponents< Variable<array_1d<double,3> > >::
Has(VariableName) )
299 typedef Variable<double> component_type;
312 double& rvaluex = itNode->FastGetSolutionStepValue(varx);
313 itNode->FastGetSolutionStepValue(varx,1) = rvaluex;
316 double& rvaluey = itNode->FastGetSolutionStepValue(vary);
317 itNode->FastGetSolutionStepValue(vary,1) = rvaluey;
320 double& rvaluez = itNode->FastGetSolutionStepValue(varz);
321 itNode->FastGetSolutionStepValue(varz,1) = rvaluez;
328 KRATOS_THROW_ERROR( std::logic_error,
"One variable of the applied loads has a non supported type. Variable: ", VariableName )
335 void RestoreLoadsValue()
342 if( KratosComponents< Variable<double> >::
Has( VariableName ) )
344 const Variable<double>& var = KratosComponents< Variable<double> >::Get( VariableName );
354 itNode->FastGetSolutionStepValue(var) = itNode->FastGetSolutionStepValue(var,1);
358 else if( KratosComponents< Variable<array_1d<double,3> > >::
Has(VariableName) )
360 typedef Variable<double> component_type;
373 itNode->FastGetSolutionStepValue(varx) = itNode->FastGetSolutionStepValue(varx,1);
375 itNode->FastGetSolutionStepValue(vary) = itNode->FastGetSolutionStepValue(vary,1);
377 itNode->FastGetSolutionStepValue(varz) = itNode->FastGetSolutionStepValue(varz,1);
383 KRATOS_THROW_ERROR( std::logic_error,
"One variable of the applied loads has a non supported type. Variable: ", VariableName )
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
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
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > TBuilderAndSolverType
Definition: implicit_solving_strategy.h:84
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
static void DivideInPartitions(const int NumTerms, const int NumThreads, PartitionVector &Partitions)
Divide an array of length NumTerms between NumThreads threads.
Definition: openmp_utils.h:158
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
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
std::vector< int > PartitionVector
Vector type for the output of DivideInPartitions method.
Definition: openmp_utils.h:53
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
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
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
Definition: poromechanics_newton_raphson_strategy.hpp:35
BaseType::TSchemeType TSchemeType
Definition: poromechanics_newton_raphson_strategy.hpp:45
bool IsConverged() override
This should be considered as a "post solution" convergence check which is useful for coupled analysis...
Definition: poromechanics_newton_raphson_strategy.hpp:132
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: poromechanics_newton_raphson_strategy.hpp:44
ResidualBasedNewtonRaphsonStrategy< TSparseSpace, TDenseSpace, TLinearSolver > MotherType
Definition: poromechanics_newton_raphson_strategy.hpp:42
unsigned int mMaxIterationNumber
Definition: residualbased_newton_raphson_strategy.h:1261
ConvergenceCriteria< TSparseSpace, TDenseSpace > TConvergenceCriteriaType
Definition: poromechanics_newton_raphson_strategy.hpp:43
std::vector< ModelPart * > mSubModelPartList
Definition: poromechanics_newton_raphson_strategy.hpp:166
TSystemVectorPointerType mpb
The increment in the solution.
Definition: residualbased_newton_raphson_strategy.h:1237
KRATOS_CLASS_POINTER_DEFINITION(PoromechanicsNewtonRaphsonStrategy)
PoromechanicsNewtonRaphsonStrategy(ModelPart &model_part, typename TSchemeType::Pointer pScheme, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, Parameters &rParameters, int MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Constructor.
Definition: poromechanics_newton_raphson_strategy.hpp:60
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: poromechanics_newton_raphson_strategy.hpp:41
BaseType::TSystemMatrixType TSystemMatrixType
Definition: poromechanics_newton_raphson_strategy.hpp:47
TSystemMatrixPointerType mpA
The RHS vector of the system of equations.
Definition: residualbased_newton_raphson_strategy.h:1238
Parameters * mpParameters
Member Variables.
Definition: poromechanics_newton_raphson_strategy.hpp:165
TSystemVectorPointerType mpDx
The pointer to the convergence criteria employed.
Definition: residualbased_newton_raphson_strategy.h:1236
TBuilderAndSolverType::Pointer mpBuilderAndSolver
The pointer to the time scheme employed.
Definition: residualbased_newton_raphson_strategy.h:1233
void Initialize() override
Initialization of member variables and prior operations.
Definition: poromechanics_newton_raphson_strategy.hpp:115
TSchemeType::Pointer mpScheme
Definition: residualbased_newton_raphson_strategy.h:1232
BaseType::TSystemVectorType TSystemVectorType
Definition: poromechanics_newton_raphson_strategy.hpp:48
~PoromechanicsNewtonRaphsonStrategy() override
Destructor.
Definition: poromechanics_newton_raphson_strategy.hpp:111
std::vector< std::string > mVariableNames
List of every SubModelPart associated to an external load.
Definition: poromechanics_newton_raphson_strategy.hpp:167
bool mInitializeWasPerformed
The maximum number of iterations, 30 by default.
Definition: residualbased_newton_raphson_strategy.h:1263
virtual bool CheckConvergence()
Name of the nodal variable associated to every SubModelPart.
Definition: poromechanics_newton_raphson_strategy.hpp:171
BaseType::DofsArrayType DofsArrayType
Definition: poromechanics_newton_raphson_strategy.hpp:46
double CalculateReferenceDofsNorm(DofsArrayType &rDofSet)
Definition: poromechanics_newton_raphson_strategy.hpp:240
This is the base Newton Raphson strategy.
Definition: residualbased_newton_raphson_strategy.h:66
unsigned int mMaxIterationNumber
Definition: residualbased_newton_raphson_strategy.h:1261
TSystemVectorPointerType mpb
The increment in the solution.
Definition: residualbased_newton_raphson_strategy.h:1237
TSystemMatrixPointerType mpA
The RHS vector of the system of equations.
Definition: residualbased_newton_raphson_strategy.h:1238
TSystemVectorPointerType mpDx
The pointer to the convergence criteria employed.
Definition: residualbased_newton_raphson_strategy.h:1236
TBuilderAndSolverType::Pointer mpBuilderAndSolver
The pointer to the time scheme employed.
Definition: residualbased_newton_raphson_strategy.h:1233
void Initialize() override
Initialization of member variables and prior operations.
Definition: residualbased_newton_raphson_strategy.h:672
TSchemeType::Pointer mpScheme
Definition: residualbased_newton_raphson_strategy.h:1232
void Predict() override
Operation to predict the solution ... if it is not called a trivial predictor is used in which the va...
Definition: residualbased_newton_raphson_strategy.h:625
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: residualbased_newton_raphson_strategy.h:781
bool mInitializeWasPerformed
The maximum number of iterations, 30 by default.
Definition: residualbased_newton_raphson_strategy.h:1263
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: residualbased_newton_raphson_strategy.h:848
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
TSparseSpace::MatrixType TSystemMatrixType
Definition: solving_strategy.h:71
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
#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
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
model_part
Definition: face_heat.py:14
int k
Definition: quadrature.py:595
float temp
Definition: rotating_cone.py:85
integer i
Definition: TensorModule.f:17
double precision function mb(a)
Definition: TensorModule.f:849