10 #if !defined(KRATOS_EIGENSOLVER_NITSCHE_STABILIZATION_STRATEGY )
11 #define KRATOS_EIGENSOLVER_NITSCHE_STABILIZATION_STRATEGY
50 template<
class TSparseSpace,
94 mpScheme(pScheme), mpBuilderAndSolver(pBuilderAndSolver)
99 mpBuilderAndSolver->SetDofSetIsInitializedFlag(
false);
137 mInitializeWasPerformed = val;
142 return mInitializeWasPerformed;
157 mpBuilderAndSolver = pNewBuilderAndSolver;
162 return mpBuilderAndSolver;
167 return *mpStiffnessMatrix;
172 return *mpStabilizationMatrix;
177 return mpStiffnessMatrix;
182 return mpStabilizationMatrix;
216 const int rank = rModelPart.GetCommunicator().MyPID();
219 <<
"Entering Initialize" << std::endl;
221 if (mInitializeWasPerformed ==
false)
225 if (pScheme->SchemeIsInitialized() ==
false)
226 pScheme->Initialize(rModelPart);
228 if (pScheme->ElementsAreInitialized() ==
false)
229 pScheme->InitializeElements(rModelPart);
231 if (pScheme->ConditionsAreInitialized() ==
false)
232 pScheme->InitializeConditions(rModelPart);
236 <<
"Exiting Initialize" << std::endl;
250 pBuilderAndSolver->GetLinearSystemSolver()->Clear();
259 pBuilderAndSolver->SetDofSetIsInitializedFlag(
false);
261 pBuilderAndSolver->Clear();
265 mInitializeWasPerformed =
false;
280 const int rank = rModelPart.GetCommunicator().MyPID();
283 <<
"Entering InitializeSolutionStep" << std::endl;
286 SchemePointerType& pScheme = this->
pGetScheme();
298 if (pBuilderAndSolver->GetDofSetIsInitializedFlag() ==
false ||
299 pBuilderAndSolver->GetReshapeMatrixFlag() ==
true)
303 pBuilderAndSolver->SetUpDofSet(pScheme, rModelPart);
310 pBuilderAndSolver->SetUpSystem(rModelPart);
320 pBuilderAndSolver->ResizeAndInitializeVectors(
321 pScheme, pStiffnessMatrix, pDx, pb, rModelPart);
324 pBuilderAndSolver->ResizeAndInitializeVectors(
325 pScheme, pStabilizationMatrix, pDx, pb, rModelPart);
344 rStabilizationMatrix, rDx, rb);
351 <<
"Exiting InitializeSolutionStep" << std::endl;
375 TSparseSpace::SetToZero(rStiffnessMatrix);
384 TSparseSpace::SetToZero(rStabilizationMatrix);
395 if(rModelPart.
ConditionsBegin()->GetGeometry().NumberOfGeometryParts() != 0)
398 Model reduced_model_master;
401 for (
auto& r_cond : rModelPart.
Conditions()) {
407 if(r_N_master(0,
i) > 1
e-6)
409 reduced_model_part_master.
AddNode(r_geom_master.pGetPoint(
i));
413 const std::size_t number_of_nodes_master = reduced_model_part_master.
NumberOfNodes();
415 Model reduced_model_slave;
418 for (
auto& r_cond : rModelPart.
Conditions()) {
424 if(r_N_slave(0,
i) > 1
e-6)
426 reduced_model_part_slave.
AddNode(r_geom_slave.pGetPoint(
i));
430 const std::size_t number_of_nodes_slave = reduced_model_part_slave.
NumberOfNodes();
434 rResult.
resize((number_of_nodes_master+number_of_nodes_slave)*3);
437 for (
auto& r_node : reduced_model_part_master.
Nodes()) {
440 rResult[index] = r_node.GetDof(DISPLACEMENT_X).EquationId();
441 rResult[index + 1] = r_node.GetDof(DISPLACEMENT_Y).EquationId();
442 rResult[index + 2] = r_node.GetDof(DISPLACEMENT_Z).EquationId();
448 for (
auto& r_node : reduced_model_part_slave.
Nodes()) {
449 const IndexType index = i_slave * 3 + 3 * number_of_nodes_master;
451 rResult[index] = r_node.GetDof(DISPLACEMENT_X).EquationId();
452 rResult[index + 1] = r_node.GetDof(DISPLACEMENT_Y).EquationId();
453 rResult[index + 2] = r_node.GetDof(DISPLACEMENT_Z).EquationId();
459 reduced_stabilization_matrix =
ZeroMatrix((number_of_nodes_master+number_of_nodes_slave)*3,(number_of_nodes_master+number_of_nodes_slave)*3);
461 for (
IndexType i = 0;
i < (number_of_nodes_master+number_of_nodes_slave)*3;
i++)
465 reduced_stabilization_matrix(
i,
j) = rStabilizationMatrix(rResult(
i),rResult(
j));
468 reduced_stabilization_matrix(
j,
i) = rStabilizationMatrix(rResult(
i),rResult(
j));
473 reduced_stiffness_matrix =
ZeroMatrix((number_of_nodes_master+number_of_nodes_slave)*3,(number_of_nodes_master+number_of_nodes_slave)*3);
475 for (
IndexType i = 0;
i < (number_of_nodes_master+number_of_nodes_slave)*3;
i++)
479 reduced_stiffness_matrix(
i,
j) = rStiffnessMatrix(rResult(
i),rResult(
j));
482 reduced_stiffness_matrix(
j,
i) = rStiffnessMatrix(rResult(
i),rResult(
j));
493 for (
auto& r_cond : rModelPart.
Conditions()) {
501 reduced_model_part.
AddNode(r_geom.pGetPoint(
i));
505 const std::size_t number_of_nodes = reduced_model_part.
NumberOfNodes();
509 rResult.
resize((number_of_nodes)*3);
512 for (
auto& r_node : reduced_model_part.
Nodes()) {
515 rResult[index] = r_node.GetDof(DISPLACEMENT_X).EquationId();
516 rResult[index + 1] = r_node.GetDof(DISPLACEMENT_Y).EquationId();
517 rResult[index + 2] = r_node.GetDof(DISPLACEMENT_Z).EquationId();
523 reduced_stabilization_matrix =
ZeroMatrix((number_of_nodes)*3,(number_of_nodes)*3);
529 reduced_stabilization_matrix(
i,
j) = rStabilizationMatrix(rResult(
i),rResult(
j));
531 reduced_stabilization_matrix(
j,
i) = rStabilizationMatrix(rResult(
i),rResult(
j));
535 reduced_stiffness_matrix =
ZeroMatrix((number_of_nodes)*3,(number_of_nodes)*3);
541 reduced_stiffness_matrix(
i,
j) = rStiffnessMatrix(rResult(
i),rResult(
j));
543 reduced_stiffness_matrix(
j,
i) = rStiffnessMatrix(rResult(
i),rResult(
j));
555 reduced_stabilization_matrix,
556 reduced_stiffness_matrix,
563 rModelPart.
GetProcessInfo()[EIGENVALUE_NITSCHE_STABILIZATION_VECTOR] = Eigenvalues;
574 <<
"Entering FinalizeSolutionStep" << std::endl;
582 rStabilizationMatrix, *pDx, *pb);
584 <<
"Exiting FinalizeSolutionStep" << std::endl;
598 const int rank = rModelPart.GetCommunicator().MyPID();
601 <<
"Entering Check" << std::endl;
613 <<
"Exiting Check" << std::endl;
638 bool mInitializeWasPerformed =
false;
Definition: builtin_timer.h:26
double ElapsedSeconds() const
Definition: builtin_timer.h:40
virtual int MyPID() const
Definition: communicator.cpp:91
Strategy for solving generalized eigenvalue problems to obtain Nitsche stabilization factor.
Definition: eigensolver_nitsche_stabilization_strategy.hpp:56
SparseMatrixType & GetStiffnessMatrix()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:165
bool GetIsInitialized() const
Definition: eigensolver_nitsche_stabilization_strategy.hpp:140
bool GetReformDofSetAtEachStepFlag() const
Definition: eigensolver_nitsche_stabilization_strategy.hpp:190
void SetBuilderAndSolver(BuilderAndSolverPointerType pNewBuilderAndSolver)
Definition: eigensolver_nitsche_stabilization_strategy.hpp:155
EigensolverNitscheStabilizationStrategy(const EigensolverNitscheStabilizationStrategy &Other)=delete
Deleted copy constructor.
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: eigensolver_nitsche_stabilization_strategy.hpp:568
SchemePointerType & pGetScheme()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:150
TSparseSpace::VectorType SparseVectorType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:81
SparseMatrixPointerType & pGetStabilizationMatrix()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:180
SparseMatrixPointerType & pGetStiffnessMatrix()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:175
BaseType::TBuilderAndSolverType::Pointer BuilderAndSolverPointerType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:67
TSparseSpace SparseSpaceType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:73
void SetReformDofSetAtEachStepFlag(bool flag)
Definition: eigensolver_nitsche_stabilization_strategy.hpp:185
int Check() override
Definition: eigensolver_nitsche_stabilization_strategy.hpp:593
void Initialize() override
Definition: eigensolver_nitsche_stabilization_strategy.hpp:211
~EigensolverNitscheStabilizationStrategy() override
Destructor.
Definition: eigensolver_nitsche_stabilization_strategy.hpp:119
SparseMatrixType & GetStabilizationMatrix()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:170
BaseType::TSchemeType::Pointer SchemePointerType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:65
void InitializeSolutionStep() override
Definition: eigensolver_nitsche_stabilization_strategy.hpp:275
TDenseSpace::VectorType DenseVectorType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:69
void SetIsInitialized(bool val)
Definition: eigensolver_nitsche_stabilization_strategy.hpp:135
TSparseSpace::MatrixType SparseMatrixType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:79
void SetScheme(SchemePointerType pScheme)
Definition: eigensolver_nitsche_stabilization_strategy.hpp:145
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:63
EigensolverNitscheStabilizationStrategy(ModelPart &rModelPart, SchemePointerType pScheme, BuilderAndSolverPointerType pBuilderAndSolver)
Constructor.
Definition: eigensolver_nitsche_stabilization_strategy.hpp:88
KRATOS_CLASS_POINTER_DEFINITION(EigensolverNitscheStabilizationStrategy)
TSparseSpace::MatrixPointerType SparseMatrixPointerType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:77
TDenseSpace::MatrixType DenseMatrixType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:71
BuilderAndSolverPointerType & pGetBuilderAndSolver()
Definition: eigensolver_nitsche_stabilization_strategy.hpp:160
TSparseSpace::VectorPointerType SparseVectorPointerType
Definition: eigensolver_nitsche_stabilization_strategy.hpp:75
bool SolveSolutionStep() override
Definition: eigensolver_nitsche_stabilization_strategy.hpp:360
void SetEchoLevel(int Level) override
Set verbosity level of the solving strategy.
Definition: eigensolver_nitsche_stabilization_strategy.hpp:202
void Clear() override
Definition: eigensolver_nitsche_stabilization_strategy.hpp:244
const Matrix & ShapeFunctionsValues() const
Definition: geometry.h:3393
virtual GeometryType & GetGeometryPart(const IndexType Index)
Used for composite geometries. It returns the the geometry part, corresponding to the Index.
Definition: geometry.h:1060
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 different model parts across multi-physics simulations.
Definition: model.h:60
ModelPart & CreateModelPart(const std::string &ModelPartName, IndexType NewBufferSize=1)
This method creates a new model part contained in the current Model with a given name and buffer size...
Definition: model.cpp:37
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
Communicator & GetCommunicator()
Definition: model_part.h:1821
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
GeometryType & GetGeometry(IndexType GeometryId)
Returns a reference geometry corresponding to the id.
Definition: model_part.h:1584
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
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
static void Set(VectorType &rX, TDataType A)
rX = A
Definition: ublas_space.h:553
static void Resize(MatrixType &rA, SizeType m, SizeType n)
Definition: ublas_space.h:558
static IndexType Size1(MatrixType const &rM)
return number of rows of rM
Definition: ublas_space.h:197
static VectorPointerType CreateEmptyVectorPointer()
Definition: ublas_space.h:183
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
bool WriteMatrixMarketMatrix(const char *FileName, CompressedMatrixType &M, bool Symmetric)
Definition: matrix_market_interface.h:308
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31