19 #include <Eigen/Dense>
79 template <
class TSparseSpace,
class TDenseSpace,
class TLinearSolver>
116 using DofQueue = moodycamel::ConcurrentQueue<DofType::Pointer>;
126 typename TLinearSolver::Pointer pNewLinearSystemSolver,
150 typename TSchemeType::Pointer pScheme,
175 double time = assembling_timer.ElapsedSeconds();
200 if (mRightRomBasisInitialized==
false){
202 mRightRomBasisInitialized =
true;
205 if (mLeftRomBasisInitialized==
false){
207 mLeftRomBasisInitialized =
true;
213 const auto& eigen_rA = a_wrapper.matrix();
214 Eigen::Map<EigenDynamicVector> eigen_rb(rb.data().begin(), rb.size());
215 Eigen::Map<EigenDynamicMatrix> eigen_mPhiGlobal(mPhiGlobal.data().
begin(), mPhiGlobal.size1(), mPhiGlobal.size2());
216 Eigen::Map<EigenDynamicMatrix> eigen_mPsiGlobal(mPsiGlobal.data().
begin(), mPsiGlobal.size1(), mPsiGlobal.size2());
221 mEigenRomA = eigen_mPsiGlobal.transpose() * eigen_rA_times_mPhiGlobal;
222 mEigenRomB = eigen_mPsiGlobal.transpose() * eigen_rb;
234 const auto& r_node = rModelPart.
GetNode(r_dof.
Id());
235 const Matrix& r_rom_nodal_basis = r_node.GetValue(ROM_LEFT_BASIS);
239 noalias(row(rPsiGlobal, r_dof.EquationId())) = ZeroVector(r_rom_nodal_basis.size2());
242 noalias(row(rPsiGlobal, r_dof.EquationId())) = row(r_rom_nodal_basis, row_id);
248 typename TSchemeType::Pointer pScheme,
267 "name" : "global_petrov_galerkin_rom_builder_and_solver",
268 "nodal_unknowns" : [],
269 "number_of_rom_dofs" : 10,
270 "petrov_galerkin_number_of_rom_dofs" : 10,
271 "rom_bns_settings": {
272 "monotonicity_preserving" : false
277 return default_parameters;
282 return "global_petrov_galerkin_rom_builder_and_solver";
300 virtual std::string
Info()
const override
302 return "GlobalPetrovGalerkinROMBuilderAndSolver";
306 virtual void PrintInfo(std::ostream &rOStream)
const override
312 virtual void PrintData(std::ostream &rOStream)
const override
347 mNumberOfPetrovGalerkinRomModes = ThisParameters[
"petrov_galerkin_number_of_rom_dofs"].
GetInt();
365 SizeType mNumberOfPetrovGalerkinRomModes;
370 bool mRightRomBasisInitialized =
false;
371 bool mLeftRomBasisInitialized =
false;
372 std::unordered_set<std::size_t> mSelectedDofs;
373 bool mIsSelectedDofsInitialized =
false;
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
std::size_t IndexType
Definition of the index type.
Definition: builder_and_solver.h:76
TSparseSpace::VectorType TSystemVectorType
Definition of the vector size.
Definition: builder_and_solver.h:85
TSparseSpace::MatrixType TSystemMatrixType
Definition of the sparse matrix.
Definition: builder_and_solver.h:82
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: builder_and_solver.h:111
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: builder_and_solver.h:767
TDenseSpace::MatrixType LocalSystemMatrixType
The local matrix definition.
Definition: builder_and_solver.h:94
TDenseSpace::VectorType LocalSystemVectorType
The local vector definition.
Definition: builder_and_solver.h:97
std::size_t SizeType
Definition of the size type.
Definition: builder_and_solver.h:73
int GetEchoLevel() const
It returns the echo level.
Definition: builder_and_solver.h:674
virtual DofsArrayType & GetDofSet()
It allows to get the list of Dofs from the element.
Definition: builder_and_solver.h:507
unsigned int mEquationSystemSize
Flag taking in account if it is needed or not to calculate the reactions.
Definition: builder_and_solver.h:747
ModelPart::ElementsContainerType ElementsArrayType
Definition: builder_and_solver.h:110
Definition: builtin_timer.h:26
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
const VariableData & GetVariable() const
Definition: dof.h:303
IndexType Id() const
Definition: dof.h:292
bool IsFixed() const
Definition: dof.h:376
This class provides an implementation for the GlobalPetrovGalerkinROM builder and solver operations....
Definition: global_petrov_galerkin_rom_builder_and_solver.h:81
GlobalPetrovGalerkinROMBuilderAndSolver(typename TLinearSolver::Pointer pNewLinearSystemSolver, Parameters ThisParameters)
Definition: global_petrov_galerkin_rom_builder_and_solver.h:125
void BuildLeftROMBasis(const ModelPart &rModelPart, Matrix &rPsiGlobal)
Definition: global_petrov_galerkin_rom_builder_and_solver.h:227
virtual void PrintData(std::ostream &rOStream) const override
Print object's.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:312
virtual void BuildAndProjectROM(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rb, TSystemVectorType &rDx) override
Definition: global_petrov_galerkin_rom_builder_and_solver.h:149
~GlobalPetrovGalerkinROMBuilderAndSolver()=default
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:263
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > EigenDynamicMatrix
Definition: global_petrov_galerkin_rom_builder_and_solver.h:109
Eigen::Matrix< double, Eigen::Dynamic, 1 > EigenDynamicVector
Definition: global_petrov_galerkin_rom_builder_and_solver.h:110
static std::string Name()
Definition: global_petrov_galerkin_rom_builder_and_solver.h:280
Eigen::SparseMatrix< double, Eigen::RowMajor, int > EigenSparseMatrix
Definition: global_petrov_galerkin_rom_builder_and_solver.h:111
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:306
void BuildAndSolve(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function to perform the building and solving phase at the same time.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:247
void GetRightROMBasis(const ModelPart &rModelPart, Matrix &rPhiGlobal)
Definition: global_petrov_galerkin_rom_builder_and_solver.h:181
KRATOS_CLASS_POINTER_DEFINITION(GlobalPetrovGalerkinROMBuilderAndSolver)
moodycamel::ConcurrentQueue< DofType::Pointer > DofQueue
Definition: global_petrov_galerkin_rom_builder_and_solver.h:116
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:342
virtual void ProjectROM(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rb) override
Definition: global_petrov_galerkin_rom_builder_and_solver.h:192
virtual std::string Info() const override
Turn back information as a string.
Definition: global_petrov_galerkin_rom_builder_and_solver.h:300
Definition: global_rom_builder_and_solver.h:64
bool GetMonotonicityPreservingFlag() const noexcept
Definition: global_rom_builder_and_solver.h:238
virtual void ProjectROM(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rb)
Definition: global_rom_builder_and_solver.h:749
typename BaseBuilderAndSolverType::TSystemVectorType TSystemVectorType
Definition: global_rom_builder_and_solver.h:95
std::unordered_map< Kratos::VariableData::KeyType, Matrix::size_type > mMapPhi
Definition: global_rom_builder_and_solver.h:456
void BuildRightROMBasis(const ModelPart &rModelPart, Matrix &rPhiGlobal)
Definition: global_rom_builder_and_solver.h:258
virtual void SolveROM(ModelPart &rModelPart, EigenDynamicMatrix &rEigenRomA, EigenDynamicVector &rEigenRomB, TSystemVectorType &rDx)
Definition: global_rom_builder_and_solver.h:780
void Build(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &b) override
Function to perform the build of the LHS and RHS multiplied by its corresponding hrom weight.
Definition: global_rom_builder_and_solver.h:668
SizeType GetNumberOfROMModes() const noexcept
Definition: global_rom_builder_and_solver.h:233
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: global_rom_builder_and_solver.h:390
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: global_rom_builder_and_solver.h:471
void MonotonicityPreserving(TSystemMatrixType &rA, TSystemVectorType &rB)
Definition: global_rom_builder_and_solver.h:278
typename BaseBuilderAndSolverType::TSystemMatrixType TSystemMatrixType
Definition: global_rom_builder_and_solver.h:94
typename BaseBuilderAndSolverType::ConditionsArrayType ConditionsArrayType
Definition: global_rom_builder_and_solver.h:101
typename BaseBuilderAndSolverType::TSchemeType TSchemeType
Definition: global_rom_builder_and_solver.h:92
typename BaseBuilderAndSolverType::ElementsArrayType ElementsArrayType
Definition: global_rom_builder_and_solver.h:100
iterator begin()
Definition: amatrix_interface.h:241
std::size_t size_type
Definition: amatrix_interface.h:57
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeType & GetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:433
Dof< double > DofType
Dof type.
Definition: node.h:83
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
Parameters Clone() const
Generates a clone of the current document.
Definition: kratos_parameters.cpp:397
void AddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1369
virtual void ConstructMatrixStructure(typename TSchemeType::Pointer pScheme, TSystemMatrixType &A, ModelPart &rModelPart)
Definition: residualbased_block_builder_and_solver.h:1457
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
Definition: ublas_wrapper.h:32
KeyType Key() const
Definition: variable_data.h:187
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#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
Eigen::Matrix< _Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > EigenDynamicMatrix
Definition: linear_solvers_define.h:32
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
Eigen::Matrix< _Scalar, Eigen::Dynamic, 1 > EigenDynamicVector
Definition: linear_solvers_define.h:33
time
Definition: face_heat.py:85
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
A
Definition: sensitivityMatrix.py:70