KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
prebuckling_strategy.hpp
Go to the documentation of this file.
1 // KRATOS ___| | | |
2 // \___ \ __| __| | | __| __| | | __| _` | |
3 // | | | | | ( | | | | ( | |
4 // _____/ \__|_| \__,_|\___|\__|\__,_|_| \__,_|_| MECHANICS
5 //
6 // License: BSD License
7 // license: StructuralMechanicsApplication/license.txt
8 //
9 // Main author: Manuel Messmer
10 //
11 
12 #pragma once
13 
14 // System includes
15 
16 // External includes
17 
18 // Project includes
21 
22 // Application includes
24 
25 namespace Kratos
26 {
27 
30 
34 
38 
42 
46 
53 template <class TSparseSpace,
54  class TDenseSpace,
55  class TLinearSolver>
57  : public ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver>
58 {
59 public:
62 
64 
66 
67  typedef typename BaseType::TSchemeType::Pointer SchemePointerType;
68 
69  typedef typename BaseType::TBuilderAndSolverType::Pointer BuilderAndSolverPointerType;
70 
72 
74 
75  typedef TSparseSpace SparseSpaceType;
76 
77  typedef typename TSparseSpace::VectorPointerType SparseVectorPointerType;
78 
79  typedef typename TSparseSpace::MatrixPointerType SparseMatrixPointerType;
80 
82 
84 
86 
90 
106  ModelPart &rModelPart,
107  SchemePointerType pScheme,
108  BuilderAndSolverPointerType pEigenSolver,
109  BuilderAndSolverPointerType pBuilderAndSolver,
110  typename ConvergenceCriteriaType::Pointer pConvergenceCriteria,
111  int MaxIteration,
112  Parameters BucklingSettings )
113  : ImplicitSolvingStrategy<TSparseSpace, TDenseSpace, TLinearSolver>(rModelPart)
114  {
115  KRATOS_TRY
116 
117  mpScheme = pScheme;
118 
119  mpEigenSolver = pEigenSolver;
120 
121  mpBuilderAndSolver = pBuilderAndSolver;
122 
123  mpConvergenceCriteria = pConvergenceCriteria;
124 
125  mMaxIteration = MaxIteration;
126 
127  mInitialLoadIncrement = BucklingSettings["initial_load_increment"].GetDouble();
128 
129  mSmallLoadIncrement = BucklingSettings["small_load_increment"].GetDouble();
130 
131  mPathFollowingStep = BucklingSettings["path_following_step"].GetDouble();
132 
133  mConvergenceRatio = BucklingSettings["convergence_ratio"].GetDouble();
134 
135  mMakeMatricesSymmetricFlag = BucklingSettings["make_matrices_symmetric"].GetBool();
136 
137  // Set Eigensolver flags
138  mpEigenSolver->SetDofSetIsInitializedFlag(false);
139  mpEigenSolver->SetReshapeMatrixFlag(false);
140  mpEigenSolver->SetCalculateReactionsFlag(false);
141  // Set Static Builder and Solver flags
142  mpBuilderAndSolver->SetDofSetIsInitializedFlag(false);
143  mpBuilderAndSolver->SetCalculateReactionsFlag(false);
144  mpBuilderAndSolver->SetReshapeMatrixFlag(false);
145 
146  // Set EchoLevel to the default value (only time is displayed)
147  this->SetEchoLevel(1);
148 
149  // Default rebuild level (build at each solution step)
150  this->SetRebuildLevel(1);
151 
152  // Set Matrices and Vectors to empty pointers
153  mpStiffnessMatrix = TSparseSpace::CreateEmptyMatrixPointer();
154  mpStiffnessMatrixPrevious = TSparseSpace::CreateEmptyMatrixPointer();
157 
158  rModelPart.GetProcessInfo()[TIME] = 1.0;
159 
160  KRATOS_CATCH("")
161  }
162 
164  PrebucklingStrategy(const PrebucklingStrategy &Other) = delete;
165 
170  {
171  this->Clear();
172  }
173 
177 
181 
186  SchemePointerType &pGetScheme()
187  {
188  return mpScheme;
189  };
190 
196  {
197  return mpEigenSolver;
198  };
199 
205  {
206  return mpBuilderAndSolver;
207  };
208 
214  {
215  return mpConvergenceCriteria;
216  }
217 
223  {
224  return mSolutionFound;
225  }
226 
238  void SetEchoLevel(int Level) override
239  {
240  BaseType::SetEchoLevel(Level);
241  this->pGetEigenSolver()->SetEchoLevel(Level);
242  this->pGetBuilderAndSolver()->SetEchoLevel(Level);
243  }
244 
248  void Initialize() override
249  {
250  KRATOS_TRY
251 
252  ModelPart &rModelPart = BaseType::GetModelPart();
253 
254  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
255  << "Entering Initialize" << std::endl;
256 
257  if (!mInitializeWasPerformed)
258  {
259  SchemePointerType &pScheme = this->pGetScheme();
260 
261  if ( !pScheme->SchemeIsInitialized() )
262  pScheme->Initialize(rModelPart);
263 
264  if ( !pScheme->ElementsAreInitialized() )
265  pScheme->InitializeElements(rModelPart);
266 
267  if ( !pScheme->ConditionsAreInitialized() )
268  pScheme->InitializeConditions(rModelPart);
269  }
270  // Initialization of the convergence criteria
271  mpConvergenceCriteria->Initialize(BaseType::GetModelPart());
272 
273  mInitializeWasPerformed = true;
274 
275  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
276  << "Exiting Initialize" << std::endl;
277 
278  KRATOS_CATCH("")
279  }
280 
284  void Clear() override
285  {
286  KRATOS_TRY
287 
288  BuilderAndSolverPointerType &pBuilderAndSolver = this->pGetBuilderAndSolver();
289  pBuilderAndSolver->GetLinearSystemSolver()->Clear();
290  BuilderAndSolverPointerType &pEigenSolver = this->pGetEigenSolver();
291  pEigenSolver->GetLinearSystemSolver()->Clear();
292 
293  if (mpStiffnessMatrix != nullptr)
294  mpStiffnessMatrix = nullptr;
295 
296  if (mpStiffnessMatrixPrevious != nullptr)
297  mpStiffnessMatrixPrevious = nullptr;
298 
299  if (mpRHS != nullptr)
300  mpRHS = nullptr;
301 
302  if (mpDx != nullptr)
303  mpDx = nullptr;
304 
305  // Re-setting internal flag to ensure that the dof sets are recalculated
306  pBuilderAndSolver->SetDofSetIsInitializedFlag(false);
307  pEigenSolver->SetDofSetIsInitializedFlag(false);
308 
309  pBuilderAndSolver->Clear();
310  pEigenSolver->Clear();
311 
312  this->pGetScheme()->Clear();
313 
314  mInitializeWasPerformed = false;
315  mSolutionStepIsInitialized = false;
316 
317 
318  KRATOS_CATCH("")
319  }
320 
325  void InitializeSolutionStep() override
326  {
327  KRATOS_TRY
328  if (!mSolutionStepIsInitialized){
329  ModelPart &rModelPart = BaseType::GetModelPart();
330 
331  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
332  << "Entering InitializeSolutionStep" << std::endl;
333 
334  // Solver
335  BuilderAndSolverPointerType &pBuilderAndSolver = this->pGetBuilderAndSolver();
336  // Scheme
337  SchemePointerType &pScheme = this->pGetScheme();
338  // Convergence Criteria
339  typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
340  // Member Matrices and Vectors
341  SparseMatrixType& rStiffnessMatrix = *mpStiffnessMatrix;
342  SparseVectorType& rRHS = *mpRHS;
343  SparseVectorType& rDx = *mpDx;
344 
345  // Initialize dummy vectors
348 
349  // Reset solution dofs
350  BuiltinTimer system_construction_time;
351  if ( !pBuilderAndSolver->GetDofSetIsInitializedFlag() ||
352  pBuilderAndSolver->GetReshapeMatrixFlag() )
353  {
354  // Set up list of dofs
355  BuiltinTimer setup_dofs_time;
356 
357  pBuilderAndSolver->SetUpDofSet(pScheme, rModelPart);
358 
359  KRATOS_INFO_IF("Setup Dofs Time", BaseType::GetEchoLevel() > 0 )
360  << setup_dofs_time << std::endl;
361 
362  // Set global equation ids
363  BuiltinTimer setup_system_time;
364 
365  pBuilderAndSolver->SetUpSystem(rModelPart);
366 
367  KRATOS_INFO_IF("Setup System Time", BaseType::GetEchoLevel() > 0 )
368  << setup_system_time << std::endl;
369 
370  // Resize and initialize system matrices
371  BuiltinTimer system_matrix_resize_time;
372 
373  // Elastic Stiffness matrix; Solution Vector; RHS Vector
374  pBuilderAndSolver->ResizeAndInitializeVectors(
375  pScheme, mpStiffnessMatrix, mpDx, mpRHS, rModelPart);
376  // Previous Stiffness Matrix
377  pBuilderAndSolver->ResizeAndInitializeVectors(
378  pScheme, mpStiffnessMatrixPrevious, _pDx, _pb, rModelPart);
379 
380  KRATOS_INFO_IF("System Matrix Resize Time", BaseType::GetEchoLevel() > 0 )
381  << system_matrix_resize_time << std::endl;
382 
383  }
384 
385  KRATOS_INFO_IF("System Construction Time", BaseType::GetEchoLevel() > 0 )
386  << system_construction_time << std::endl;
387 
388  // Initial operations ... things that are constant over the solution
389  // step
390  pBuilderAndSolver->InitializeSolutionStep(BaseType::GetModelPart(),
391  rStiffnessMatrix, rDx, rRHS);
392 
393  // Initial operations ... things that are constant over the solution
394  // step
395  pScheme->InitializeSolutionStep(BaseType::GetModelPart(), rStiffnessMatrix, rDx, rRHS);
396 
397  pConvergenceCriteria->InitializeSolutionStep(BaseType::GetModelPart(), pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
398 
399  mSolutionStepIsInitialized = true;
400 
401  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
402  << "Exiting InitializeSolutionStep" << std::endl;
403  }
404  KRATOS_CATCH("")
405  }
406 
413  bool SolveSolutionStep() override
414  {
415  KRATOS_TRY
416 
417  ModelPart& rModelPart = BaseType::GetModelPart();
418  SchemePointerType& pScheme = this->pGetScheme();
419  BuilderAndSolverPointerType& pBuilderAndSolver = this->pGetBuilderAndSolver();
420  SparseMatrixType& rStiffnessMatrix = *mpStiffnessMatrix;
421  SparseMatrixType& rStiffnessMatrixPrevious = *mpStiffnessMatrixPrevious;
422  SparseVectorType& rRHS = *mpRHS;
423  SparseVectorType& rDx = *mpDx;
424 
425  typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
426 
427  // Initializing the parameters of the Newton-Raphson cycle
428  unsigned int iteration_number = 1;
429  rModelPart.GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
430  bool is_converged = false;
431 
432  // Update loadfactor increment
433  double delta_load_multiplier = 0.0;
434  if( mLoadStepIteration == 1) // inital load increment
435  {
436  delta_load_multiplier = mInitialLoadIncrement*(mLambda + mLambdaPrev);
437  }
438  else if( mLoadStepIteration % 2 == 1 ) //small load increment
439  {
440  delta_load_multiplier = mSmallLoadIncrement*(mLambdaPrev );
441  }
442 
443  BuiltinTimer system_solve_time;
444  // Initialize nonlinear iteration
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);
448 
449  TSparseSpace::SetToZero(rStiffnessMatrix);
450  TSparseSpace::SetToZero(rRHS);
451  TSparseSpace::SetToZero(rDx);
452  // Build system and solve system
453  pBuilderAndSolver->BuildAndSolve(pScheme, rModelPart, rStiffnessMatrix, rDx, rRHS);
454  // Update internal variables
455  pScheme->Update(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS );
457  // Finalize nonlinear solution step
458  pScheme->FinalizeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
459  pConvergenceCriteria->FinalizeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
460 
461  if (is_converged){
462  is_converged = mpConvergenceCriteria->PostCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
463  }
464 
465  // Start iteration cycle
466  while ( !is_converged &&
467  iteration_number++ < mMaxIteration)
468  {
469  // Setting the number of iteration
470  rModelPart.GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
471 
472  // Initialize nonlinear iteration step
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);
476 
477  TSparseSpace::SetToZero(rStiffnessMatrix);
478  TSparseSpace::SetToZero(rDx);
479  TSparseSpace::SetToZero(rRHS);
480  // Build and solve system
481  pBuilderAndSolver->BuildAndSolve(pScheme, rModelPart, rStiffnessMatrix,rDx, rRHS);
482 
483  // Update internal variables
484  this->pGetScheme()->Update(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
486 
487  // Finalize nonlinear iteration step
488  this->pGetScheme()->FinalizeNonLinIteration( rModelPart,rStiffnessMatrix, rDx, rRHS );
489  pConvergenceCriteria->FinalizeNonLinearIteration(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
490 
491  if (is_converged){
492  is_converged = mpConvergenceCriteria->PostCriteria(rModelPart, pBuilderAndSolver->GetDofSet(), rStiffnessMatrix, rDx, rRHS);
493  }
494  }
495  KRATOS_INFO_IF("Nonlinear Loadstep Time: ", BaseType::GetEchoLevel() > 0)
496  << system_solve_time << std::endl;
497 
498  if ( !is_converged ) {
499  KRATOS_INFO_IF("Nonlinear Loadstep: ", this->GetEchoLevel() > 0)
500  << "Convergence not achieved after ( " << mMaxIteration
501  << " ) Iterations !" << std::endl;
502  } else {
503  KRATOS_INFO_IF("Nonlinear Loadstep: ", this->GetEchoLevel() > 0)
504  << "Convergence achieved after " << iteration_number << " / "
505  << mMaxIteration << " iterations" << std::endl;
506  }
507 
508  // Vector and matrix are initialized by eigensolver
509  DenseVectorType Eigenvalues;
510  DenseMatrixType Eigenvectors;
511 
512  if( mLoadStepIteration % 2 == 0 ){
513  //Copy matrices after path following step and initial step
514  rStiffnessMatrixPrevious = rStiffnessMatrix;
515 
516  if( mLoadStepIteration > 0){
517  // Update mLambdaPrev
518  mLambdaPrev = mLambdaPrev + mPathFollowingStep*mLambda;
519  }
520  }
521  else if( mLoadStepIteration % 2 == 1 ){
522  // Evaluate eigenvalue problem after small load increment
523  //#####################################################################################
524  //Method 1
525  //Poy, Denise Lori-eng; On the Buckling Finite Element Analysis of Beam Structures
526  //#####################################################################################
527  // Solve Eigenvalue Problem
528  // BuiltinTimer eigen_solve_time;
529  // this->pGetEigenSolver()->GetLinearSystemSolver()->Solve(
530  // rStiffnessMatrix,
531  // rStiffnessMatrixPrevious,
532  // Eigenvalues,
533  // Eigenvectors);
534 
535  // mLambda = 1.0 / ( 1.0 - Eigenvalues(0) ) * delta_load_multiplier;
536  // for(int i = 0; i < Eigenvalues.size(); i++ )
537  // {
538  // Eigenvalues[i] = mLambdaPrev + 1.0 / ( 1.0 - Eigenvalues[i] )*delta_load_multiplier;
539  // }
540  // this->AssignVariables(Eigenvalues, Eigenvectors);
541  //End Method 1#########################################################################
542 
543  //#####################################################################################
544  //Method 2:
545  // Jia, X.Mang, H. A.; Assessment of solutions from the consistently linearized eigenproblem
546  // by means of finite difference approximations
547  //#####################################################################################
548  // Solve Eigenvalue Problem
549 
550  // This implementation of the eigenvalue problem relies on the difference of the stiffness matrix
551  // between the current and previous step
552  rStiffnessMatrix = rStiffnessMatrixPrevious - rStiffnessMatrix;
553 
554  // Symmetrice matrices if enabled
555  // The ublas transpose function is called manually, because it is missing in the corresponding space
556  if( mMakeMatricesSymmetricFlag ){
557  rStiffnessMatrix = 0.5 * ( rStiffnessMatrix + boost::numeric::ublas::trans(rStiffnessMatrix) );
558  rStiffnessMatrixPrevious = 0.5 * ( rStiffnessMatrixPrevious + boost::numeric::ublas::trans(rStiffnessMatrixPrevious) );
559  }
560 
561  this->pGetEigenSolver()->GetLinearSystemSolver()->Solve(
562  rStiffnessMatrixPrevious,
563  rStiffnessMatrix,
564  Eigenvalues,
565  Eigenvectors);
566 
567  // Update eigenvalues to loadfactors (Instead of dividing matrix by delta_load_multiplier, here eigenvalues are multiplied)
568  mLambda = Eigenvalues(0)*delta_load_multiplier;
569  for(unsigned int i = 0; i < Eigenvalues.size(); i++ )
570  {
571  Eigenvalues[i] = mLambdaPrev + Eigenvalues[i]*delta_load_multiplier;
572  }
573 
574  this->AssignVariables(Eigenvalues, Eigenvectors);
575 
576  // Reset elastic stiffness matrix for next loadstep
577  mpStiffnessMatrix = nullptr;
578  pBuilderAndSolver->ResizeAndInitializeVectors(
579  pScheme, mpStiffnessMatrix, mpDx, mpRHS, rModelPart);
580  // End Method 2#########################################################################
581 
582  // Convergence criteria for buckling analysis
583  if( std::abs(mLambda/mLambdaPrev) < mConvergenceRatio ){
584  mSolutionFound = true;
585  KRATOS_INFO_IF("Prebuckling Analysis: ", BaseType::GetEchoLevel() > 0)
586  << "Convergence achieved in " << mLoadStepIteration + 1 << " Load Iterations!" << std::endl;
587  }
588  }
589 
590  mLoadStepIteration++;
591  // Prepare load conditions for next solution step
592  UpdateLoadConditions();
593 
594  return true;
595  KRATOS_CATCH("")
596  }
597 
601  void FinalizeSolutionStep() override
602  {
603  KRATOS_TRY;
604 
605  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
606  << "Entering FinalizeSolutionStep" << std::endl;
607 
608  typename ConvergenceCriteriaType::Pointer pConvergenceCriteria = mpConvergenceCriteria;
609  // Member Matrices and Vectors
610  SparseMatrixType& rStiffnessMatrix = *mpStiffnessMatrix;
611  SparseVectorType& rRHS = *mpRHS;
612  SparseVectorType& rDx = *mpDx;
613 
614  pGetBuilderAndSolver()->FinalizeSolutionStep(
615  BaseType::GetModelPart(), rStiffnessMatrix, rDx, rRHS);
616 
617  pGetScheme()->FinalizeSolutionStep(BaseType::GetModelPart(),
618  rStiffnessMatrix, rDx, rRHS);
619 
620  pConvergenceCriteria->FinalizeSolutionStep(BaseType::GetModelPart(), pGetBuilderAndSolver()->GetDofSet(), rStiffnessMatrix, rDx, rRHS );
621 
622  // Cleaning memory after the solution
623  pGetScheme()->Clean();
624  // Reset flags for next step
625  mSolutionStepIsInitialized = false;
626 
627  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
628  << "Exiting FinalizeSolutionStep" << std::endl;
629 
630  KRATOS_CATCH("");
631  }
632 
637  int Check() override
638  {
639  KRATOS_TRY
640 
641  ModelPart &rModelPart = BaseType::GetModelPart();
642 
643  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
644  << "Entering Check" << std::endl;
645 
646  // Check the model part
647  BaseType::Check();
648 
649  // Check the scheme
650  this->pGetScheme()->Check(rModelPart);
651 
652  // Check the builder and solver
653  this->pGetBuilderAndSolver()->Check(rModelPart);
654 
655  KRATOS_INFO_IF("PrebucklingStrategy", BaseType::GetEchoLevel() > 2 )
656  << "Exiting Check" << std::endl;
657 
658  return 0;
659 
660  KRATOS_CATCH("")
661  }
662 
666 
670 
674 
676 
677 protected:
680 
684 
688 
692 
696 
700 
704 
706 
707 private:
710 
714 
715  SchemePointerType mpScheme;
716 
717  BuilderAndSolverPointerType mpEigenSolver;
718 
719  BuilderAndSolverPointerType mpBuilderAndSolver;
720 
721  // SparseMatrixPointerType mpMassMatrix;
722 
723  SparseMatrixPointerType mpStiffnessMatrix;
724 
725  SparseMatrixPointerType mpStiffnessMatrixPrevious;
726 
728 
730 
731  typename ConvergenceCriteriaType::Pointer mpConvergenceCriteria;
733 
734  bool mInitializeWasPerformed = false;
735 
736  bool mSolutionStepIsInitialized = false;
737 
738  bool mSolutionFound = false;
739 
740  unsigned int mLoadStepIteration = 0;
741 
742  unsigned int mMaxIteration;
743 
744  std::vector<array_1d<double,3>> mpInitialLoads;
745 
746  double mInitialLoadIncrement;
747  double mSmallLoadIncrement;
748  double mPathFollowingStep;
749  double mConvergenceRatio;
750 
751  double mLambda = 0.0;
752  double mLambdaPrev = 1.0;
753 
754  bool mMakeMatricesSymmetricFlag;
755 
759 
763 
768  void UpdateLoadConditions()
769  {
770  ModelPart &rModelPart = BaseType::GetModelPart();
771 
772  if( mLoadStepIteration == 1){
773  // Initial load increment
774  rModelPart.GetProcessInfo()[TIME] = ( 1.0 + mInitialLoadIncrement );
775  }
776  else if( mLoadStepIteration % 2 == 0){
777  // Do path following step
778  rModelPart.GetProcessInfo()[TIME] = ( mLambdaPrev + mPathFollowingStep * mLambda );
779  }
780  else{
781  // Do small load increment
782  rModelPart.GetProcessInfo()[TIME] = (1 + mSmallLoadIncrement) * mLambdaPrev;
783  }
784  }
785 
790  void AssignVariables(DenseVectorType &rEigenvalues, DenseMatrixType &rEigenvectors )
791  {
792  ModelPart &rModelPart = BaseType::GetModelPart();
793  const std::size_t NumEigenvalues = rEigenvalues.size();
794 
795  // Store eigenvalues in process info
796  rModelPart.GetProcessInfo()[EIGENVALUE_VECTOR] = rEigenvalues;
797 
798  for (ModelPart::NodeIterator itNode = rModelPart.NodesBegin(); itNode != rModelPart.NodesEnd(); itNode++)
799  {
800  ModelPart::NodeType::DofsContainerType &NodeDofs = itNode->GetDofs();
801  const std::size_t NumNodeDofs = NodeDofs.size();
802 
803  Matrix &rNodeEigenvectors = itNode->GetValue(EIGENVECTOR_MATRIX);
804  if (rNodeEigenvectors.size1() != NumEigenvalues || rNodeEigenvectors.size2() != NumNodeDofs){
805  rNodeEigenvectors.resize(NumEigenvalues, NumNodeDofs, false);
806  }
807 
808  // TO BE VERIFIED!! In the current implmentation of Dofs there are nor reordered and only pushec back.
809  // // the jth column index of EIGENVECTOR_MATRIX corresponds to the jth nodal dof. therefore,
810  // // the dof ordering must not change.
811  // if (NodeDofs.IsSorted() == false)
812  // {
813  // NodeDofs.Sort();
814  // }
815 
816  // Fill the EIGENVECTOR_MATRIX
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());
822  }
823  else{
824  rNodeEigenvectors(i, j) = 0.0;
825  }
826  }
827  }
828  }
829  }
830 
834 
838 
840 
841 }; /* Class PrebucklingStrategy */
842 
844 
847 
849 
850 } /* namespace Kratos */
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
Vector VectorType
Definition: geometrical_transformation_utilities.h:56
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
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