53 template <
class TSparseSpace,
110 typename ConvergenceCriteriaType::Pointer pConvergenceCriteria,
119 mpEigenSolver = pEigenSolver;
121 mpBuilderAndSolver = pBuilderAndSolver;
123 mpConvergenceCriteria = pConvergenceCriteria;
125 mMaxIteration = MaxIteration;
127 mInitialLoadIncrement = BucklingSettings[
"initial_load_increment"].
GetDouble();
129 mSmallLoadIncrement = BucklingSettings[
"small_load_increment"].
GetDouble();
131 mPathFollowingStep = BucklingSettings[
"path_following_step"].
GetDouble();
133 mConvergenceRatio = BucklingSettings[
"convergence_ratio"].
GetDouble();
135 mMakeMatricesSymmetricFlag = BucklingSettings[
"make_matrices_symmetric"].
GetBool();
138 mpEigenSolver->SetDofSetIsInitializedFlag(
false);
139 mpEigenSolver->SetReshapeMatrixFlag(
false);
140 mpEigenSolver->SetCalculateReactionsFlag(
false);
142 mpBuilderAndSolver->SetDofSetIsInitializedFlag(
false);
143 mpBuilderAndSolver->SetCalculateReactionsFlag(
false);
144 mpBuilderAndSolver->SetReshapeMatrixFlag(
false);
197 return mpEigenSolver;
206 return mpBuilderAndSolver;
215 return mpConvergenceCriteria;
224 return mSolutionFound;
255 <<
"Entering Initialize" << std::endl;
257 if (!mInitializeWasPerformed)
261 if ( !pScheme->SchemeIsInitialized() )
262 pScheme->Initialize(rModelPart);
264 if ( !pScheme->ElementsAreInitialized() )
265 pScheme->InitializeElements(rModelPart);
267 if ( !pScheme->ConditionsAreInitialized() )
268 pScheme->InitializeConditions(rModelPart);
273 mInitializeWasPerformed =
true;
276 <<
"Exiting Initialize" << std::endl;
289 pBuilderAndSolver->GetLinearSystemSolver()->Clear();
291 pEigenSolver->GetLinearSystemSolver()->Clear();
293 if (mpStiffnessMatrix !=
nullptr)
294 mpStiffnessMatrix =
nullptr;
296 if (mpStiffnessMatrixPrevious !=
nullptr)
297 mpStiffnessMatrixPrevious =
nullptr;
299 if (mpRHS !=
nullptr)
306 pBuilderAndSolver->SetDofSetIsInitializedFlag(
false);
307 pEigenSolver->SetDofSetIsInitializedFlag(
false);
309 pBuilderAndSolver->Clear();
310 pEigenSolver->Clear();
314 mInitializeWasPerformed =
false;
315 mSolutionStepIsInitialized =
false;
328 if (!mSolutionStepIsInitialized){
332 <<
"Entering InitializeSolutionStep" << std::endl;
337 SchemePointerType &pScheme = this->
pGetScheme();
339 typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
351 if ( !pBuilderAndSolver->GetDofSetIsInitializedFlag() ||
352 pBuilderAndSolver->GetReshapeMatrixFlag() )
357 pBuilderAndSolver->SetUpDofSet(pScheme, rModelPart);
360 << setup_dofs_time << std::endl;
365 pBuilderAndSolver->SetUpSystem(rModelPart);
368 << setup_system_time << std::endl;
374 pBuilderAndSolver->ResizeAndInitializeVectors(
375 pScheme, mpStiffnessMatrix, mpDx, mpRHS, rModelPart);
377 pBuilderAndSolver->ResizeAndInitializeVectors(
378 pScheme, mpStiffnessMatrixPrevious, _pDx, _pb, rModelPart);
381 << system_matrix_resize_time << std::endl;
386 << system_construction_time << std::endl;
391 rStiffnessMatrix, rDx, rRHS);
397 pConvergenceCriteria->InitializeSolutionStep(
BaseType::GetModelPart(), pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
399 mSolutionStepIsInitialized =
true;
402 <<
"Exiting InitializeSolutionStep" << std::endl;
420 SparseMatrixType& rStiffnessMatrix = *mpStiffnessMatrix;
425 typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
428 unsigned int iteration_number = 1;
429 rModelPart.GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
430 bool is_converged =
false;
433 double delta_load_multiplier = 0.0;
434 if( mLoadStepIteration == 1)
436 delta_load_multiplier = mInitialLoadIncrement*(mLambda + mLambdaPrev);
438 else if( mLoadStepIteration % 2 == 1 )
440 delta_load_multiplier = mSmallLoadIncrement*(mLambdaPrev );
445 this->
pGetScheme()->InitializeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
446 pConvergenceCriteria->InitializeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
447 is_converged = mpConvergenceCriteria->PreCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
449 TSparseSpace::SetToZero(rStiffnessMatrix);
450 TSparseSpace::SetToZero(rRHS);
451 TSparseSpace::SetToZero(rDx);
453 pBuilderAndSolver->BuildAndSolve(pScheme, rModelPart, rStiffnessMatrix, rDx, rRHS);
455 pScheme->Update(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS );
458 pScheme->FinalizeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
459 pConvergenceCriteria->FinalizeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
462 is_converged = mpConvergenceCriteria->PostCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
466 while ( !is_converged &&
467 iteration_number++ < mMaxIteration)
470 rModelPart.GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
473 pScheme->InitializeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
474 pConvergenceCriteria->InitializeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
475 is_converged = mpConvergenceCriteria->PreCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
477 TSparseSpace::SetToZero(rStiffnessMatrix);
478 TSparseSpace::SetToZero(rDx);
479 TSparseSpace::SetToZero(rRHS);
481 pBuilderAndSolver->BuildAndSolve(pScheme, rModelPart, rStiffnessMatrix,rDx, rRHS);
484 this->
pGetScheme()->Update(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
488 this->
pGetScheme()->FinalizeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
489 pConvergenceCriteria->FinalizeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
492 is_converged = mpConvergenceCriteria->PostCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
496 << system_solve_time << std::endl;
498 if ( !is_converged ) {
500 <<
"Convergence not achieved after ( " << mMaxIteration
501 <<
" ) Iterations !" << std::endl;
504 <<
"Convergence achieved after " << iteration_number <<
" / "
505 << mMaxIteration <<
" iterations" << std::endl;
512 if( mLoadStepIteration % 2 == 0 ){
514 rStiffnessMatrixPrevious = rStiffnessMatrix;
516 if( mLoadStepIteration > 0){
518 mLambdaPrev = mLambdaPrev + mPathFollowingStep*mLambda;
521 else if( mLoadStepIteration % 2 == 1 ){
552 rStiffnessMatrix = rStiffnessMatrixPrevious - rStiffnessMatrix;
556 if( mMakeMatricesSymmetricFlag ){
562 rStiffnessMatrixPrevious,
568 mLambda = Eigenvalues(0)*delta_load_multiplier;
569 for(
unsigned int i = 0;
i < Eigenvalues.size();
i++ )
571 Eigenvalues[
i] = mLambdaPrev + Eigenvalues[
i]*delta_load_multiplier;
574 this->AssignVariables(Eigenvalues, Eigenvectors);
577 mpStiffnessMatrix =
nullptr;
578 pBuilderAndSolver->ResizeAndInitializeVectors(
579 pScheme, mpStiffnessMatrix, mpDx, mpRHS, rModelPart);
583 if( std::abs(mLambda/mLambdaPrev) < mConvergenceRatio ){
584 mSolutionFound =
true;
586 <<
"Convergence achieved in " << mLoadStepIteration + 1 <<
" Load Iterations!" << std::endl;
590 mLoadStepIteration++;
592 UpdateLoadConditions();
606 <<
"Entering FinalizeSolutionStep" << std::endl;
608 typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
618 rStiffnessMatrix, rDx, rRHS);
625 mSolutionStepIsInitialized =
false;
628 <<
"Exiting FinalizeSolutionStep" << std::endl;
644 <<
"Entering Check" << std::endl;
656 <<
"Exiting Check" << std::endl;
731 typename ConvergenceCriteriaType::Pointer mpConvergenceCriteria;
734 bool mInitializeWasPerformed =
false;
736 bool mSolutionStepIsInitialized =
false;
738 bool mSolutionFound =
false;
740 unsigned int mLoadStepIteration = 0;
742 unsigned int mMaxIteration;
744 std::vector<array_1d<double,3>> mpInitialLoads;
746 double mInitialLoadIncrement;
747 double mSmallLoadIncrement;
748 double mPathFollowingStep;
749 double mConvergenceRatio;
751 double mLambda = 0.0;
752 double mLambdaPrev = 1.0;
754 bool mMakeMatricesSymmetricFlag;
768 void UpdateLoadConditions()
772 if( mLoadStepIteration == 1){
774 rModelPart.
GetProcessInfo()[TIME] = ( 1.0 + mInitialLoadIncrement );
776 else if( mLoadStepIteration % 2 == 0){
778 rModelPart.
GetProcessInfo()[TIME] = ( mLambdaPrev + mPathFollowingStep * mLambda );
782 rModelPart.
GetProcessInfo()[TIME] = (1 + mSmallLoadIncrement) * mLambdaPrev;
793 const std::size_t NumEigenvalues = rEigenvalues.size();
796 rModelPart.GetProcessInfo()[EIGENVALUE_VECTOR] = rEigenvalues;
801 const std::size_t NumNodeDofs = NodeDofs.size();
803 Matrix &rNodeEigenvectors = itNode->GetValue(EIGENVECTOR_MATRIX);
804 if (rNodeEigenvectors.size1() != NumEigenvalues || rNodeEigenvectors.size2() != NumNodeDofs){
805 rNodeEigenvectors.
resize(NumEigenvalues, NumNodeDofs,
false);
817 for (std::size_t
i = 0;
i < NumEigenvalues;
i++){
818 for (std::size_t
j = 0;
j < NumNodeDofs;
j++){
819 auto itDof = std::begin(NodeDofs) +
j;
820 if( !(*itDof)->IsFixed() ){
821 rNodeEigenvectors(
i,
j) = rEigenvectors(
i, (*itDof)->EquationId());
824 rNodeEigenvectors(
i,
j) = 0.0;
Definition: builtin_timer.h:26
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
void SetRebuildLevel(int Level) override
This sets the build level.
Definition: implicit_solving_strategy.h:207
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
Strategy for linearized prebuckling analysis.
Definition: prebuckling_strategy.hpp:58
BuilderAndSolverPointerType & pGetBuilderAndSolver()
Get method for the builder and solver.
Definition: prebuckling_strategy.hpp:204
TDenseSpace::VectorType DenseVectorType
Definition: prebuckling_strategy.hpp:71
BaseType::TBuilderAndSolverType::Pointer BuilderAndSolverPointerType
Definition: prebuckling_strategy.hpp:69
TSparseSpace::MatrixPointerType SparseMatrixPointerType
Definition: prebuckling_strategy.hpp:79
TSparseSpace SparseSpaceType
Definition: prebuckling_strategy.hpp:75
BaseType::TSchemeType::Pointer SchemePointerType
Definition: prebuckling_strategy.hpp:67
SchemePointerType & pGetScheme()
Get method for the scheme.
Definition: prebuckling_strategy.hpp:186
PrebucklingStrategy(ModelPart &rModelPart, SchemePointerType pScheme, BuilderAndSolverPointerType pEigenSolver, BuilderAndSolverPointerType pBuilderAndSolver, typename ConvergenceCriteriaType::Pointer pConvergenceCriteria, int MaxIteration, Parameters BucklingSettings)
Constructor.
Definition: prebuckling_strategy.hpp:105
ConvergenceCriteria< TSparseSpace, TDenseSpace > ConvergenceCriteriaType
Definition: prebuckling_strategy.hpp:85
PrebucklingStrategy(const PrebucklingStrategy &Other)=delete
Deleted copy constructor.
BuilderAndSolverPointerType & pGetEigenSolver()
Get method for the generalized eigenvalue problme solver.
Definition: prebuckling_strategy.hpp:195
void Clear() override
Clears the internal storage.
Definition: prebuckling_strategy.hpp:284
TSparseSpace::MatrixType SparseMatrixType
Definition: prebuckling_strategy.hpp:81
TSparseSpace::VectorType SparseVectorType
Definition: prebuckling_strategy.hpp:83
TDenseSpace::MatrixType DenseMatrixType
Definition: prebuckling_strategy.hpp:73
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: prebuckling_strategy.hpp:413
void SetEchoLevel(int Level) override
This sets the level of echo for the solving strategy.
Definition: prebuckling_strategy.hpp:238
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: prebuckling_strategy.hpp:325
void Initialize() override
Initialization of member variables and prior operation.
Definition: prebuckling_strategy.hpp:248
bool GetSolutionFoundFlag()
Get method for solution found flag.
Definition: prebuckling_strategy.hpp:222
TSparseSpace::VectorPointerType SparseVectorPointerType
Definition: prebuckling_strategy.hpp:77
KRATOS_CLASS_POINTER_DEFINITION(PrebucklingStrategy)
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: prebuckling_strategy.hpp:601
int Check() override
Function to perform expensive checks.
Definition: prebuckling_strategy.hpp:637
~PrebucklingStrategy() override
Destructor.
Definition: prebuckling_strategy.hpp:169
ConvergenceCriteriaType & GetConvergenceCriteria()
Get method for the convergence criteria.
Definition: prebuckling_strategy.hpp:213
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: prebuckling_strategy.hpp:65
virtual void SetEchoLevel(const int Level)
This sets the level of echo for the solving strategy.
Definition: solving_strategy.h:255
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
virtual int Check()
Function to perform expensive checks.
Definition: solving_strategy.h:377
virtual void MoveMesh()
This function is designed to move the mesh.
Definition: solving_strategy.h:330
static VectorPointerType CreateEmptyVectorPointer()
Definition: ublas_space.h:183
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
TSpaceType::VectorPointerType CreateEmptyVectorPointer(TSpaceType &dummy)
Definition: add_strategies_to_python.cpp:187
TSpaceType::MatrixPointerType CreateEmptyMatrixPointer(TSpaceType &dummy)
Definition: add_strategies_to_python.cpp:181
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17