48 template<
class TSparseSpace,
92 bool UseMaterialDampingFlag =
false
100 mpBuilderAndSolver = pBuilderAndSolver;
103 mpBuilderAndSolver->SetDofSetIsInitializedFlag(
false);
137 mInitializeWasPerformed = val;
142 return mInitializeWasPerformed;
157 mpBuilderAndSolver = pNewBuilderAndSolver;
162 return mpBuilderAndSolver;
177 mUseMaterialDamping = flag;
182 return mUseMaterialDamping;
204 const auto rank = r_model_part.GetCommunicator().MyPID();
207 <<
"Entering Initialize" << std::endl;
209 if( !mInitializeWasPerformed )
211 auto& r_process_info = r_model_part.GetProcessInfo();
215 if (p_scheme->SchemeIsInitialized() ==
false)
216 p_scheme->Initialize(r_model_part);
218 if (p_scheme->ElementsAreInitialized() ==
false)
219 p_scheme->InitializeElements(r_model_part);
221 if (p_scheme->ConditionsAreInitialized() ==
false)
222 p_scheme->InitializeConditions(r_model_part);
230 p_builder_and_solver->SetUpDofSet(p_scheme, r_model_part);
232 << setup_dofs_time << std::endl;
236 p_builder_and_solver->SetUpSystem(r_model_part);
238 << setup_system_time << std::endl;
241 auto& r_force_vector = *mpForceVector;
242 const unsigned int system_size = p_builder_and_solver->GetEquationSystemSize();
245 if (r_force_vector.size() != system_size)
246 r_force_vector.resize(system_size,
false);
248 p_builder_and_solver->BuildRHS(p_scheme,r_model_part,r_force_vector);
251 << force_vector_build_time << std::endl;
254 auto& r_modal_matrix = *mpModalMatrix;
255 const std::size_t n_modes = r_process_info[EIGENVALUE_VECTOR].size();
256 if( r_modal_matrix.size1() != system_size || r_modal_matrix.size2() != n_modes )
257 r_modal_matrix.resize( system_size, n_modes,
false );
258 r_modal_matrix =
ZeroMatrix( system_size, n_modes );
261 for( std::size_t
i = 0;
i < n_modes; ++
i )
263 for(
auto&
node : r_model_part.Nodes() )
266 const std::size_t n_node_dofs = node_dofs.size();
267 const Matrix& r_node_eigenvectors =
node.GetValue(EIGENVECTOR_MATRIX);
275 for( std::size_t
j = 0;
j < n_node_dofs; ++
j )
277 const auto it_dof = std::begin(node_dofs) +
j;
278 r_modal_matrix((*it_dof)->EquationId(),
i) = r_node_eigenvectors(
i,
j);
284 << modal_matrix_build_time << std::endl;
287 for(
auto& property : r_model_part.PropertiesArray() )
289 if( property->Has(SYSTEM_DAMPING_RATIO) )
291 mSystemDamping =
property->GetValue(SYSTEM_DAMPING_RATIO);
294 if( property->Has(RAYLEIGH_ALPHA) && property->Has(RAYLEIGH_BETA) )
296 mRayleighAlpha =
property->GetValue(RAYLEIGH_ALPHA);
297 mRayleighBeta =
property->GetValue(RAYLEIGH_BETA);
302 if( mUseMaterialDamping )
305 KRATOS_ERROR_IF(r_model_part.NumberOfSubModelParts() < 1) <<
"No submodelparts detected!" << std::endl;
308 r_model_part.GetProcessInfo()[BUILD_LEVEL] = 2;
309 mMaterialDampingRatios =
ZeroVector( n_modes );
324 for( std::size_t
i = 0;
i < n_modes; ++
i )
328 auto modal_vector =
column( r_modal_matrix,
i );
329 for(
auto& sub_model_part : r_model_part.SubModelParts() )
331 double damping_coefficient = 0.0;
332 for(
auto& property : sub_model_part.PropertiesArray() )
334 if( property->Has(SYSTEM_DAMPING_RATIO) )
336 damping_coefficient =
property->GetValue(SYSTEM_DAMPING_RATIO);
342 p_builder_and_solver->ResizeAndInitializeVectors(p_scheme,
343 temp_stiffness_matrix,
349 p_builder_and_solver->BuildLHS(p_scheme, sub_model_part, *temp_stiffness_matrix);
352 double strain_energy = 0.5 *
inner_prod(
prod(modal_vector, *temp_stiffness_matrix), modal_vector );
353 down += strain_energy;
354 up += damping_coefficient * strain_energy;
356 KRATOS_ERROR_IF(down < std::numeric_limits<double>::epsilon()) <<
"No valid effective "
357 <<
"material damping ratio could be computed. Are all elements to be damped available "
358 <<
"in the submodelparts? Are the modal vectors available?" << std::endl;
360 mMaterialDampingRatios(
i) = up / down;
364 << material_damping_build_time << std::endl;
366 mInitializeWasPerformed =
true;
370 <<
"Exiting Initialize" << std::endl;
380 const auto rank = r_model_part.GetCommunicator().MyPID();
383 <<
"Entering SolveSolutionStep" << std::endl;
385 auto& r_process_info = r_model_part.GetProcessInfo();
386 double excitation_frequency = r_process_info[TIME];
390 const std::size_t n_modes = eigenvalues.size();
395 auto&
f = *mpForceVector;
402 double modal_damping = 0.0;
404 for( std::size_t
i = 0;
i < n_modes; ++
i )
406 KRATOS_ERROR_IF( eigenvalues[
i] < std::numeric_limits<double>::epsilon() ) <<
"No valid eigenvalue "
407 <<
"for mode " <<
i << std::endl;
408 modal_damping = mSystemDamping + mRayleighAlpha / (2 * std::sqrt(eigenvalues[
i])) + mRayleighBeta * std::sqrt(eigenvalues[
i]) / 2;
410 if( mUseMaterialDamping )
412 modal_damping += mMaterialDampingRatios[
i];
415 auto& r_modal_matrix = *mpModalMatrix;
418 TDenseSpace::GetColumn(
i, r_modal_matrix, modal_vector);
420 ComplexType factor( eigenvalues[
i] - std::pow( excitation_frequency, 2.0 ), 2 * modal_damping * std::sqrt(eigenvalues[
i]) * excitation_frequency );
421 KRATOS_ERROR_IF( std::abs(
factor) < std::numeric_limits<double>::epsilon() ) <<
"No valid modal weight" << std::endl;
425 for(
auto&
node : r_model_part.Nodes() )
427 auto& node_dofs =
node.GetDofs();
428 const std::size_t n_node_dofs = node_dofs.size();
429 const Matrix& r_node_eigenvectors =
node.GetValue(EIGENVECTOR_MATRIX);
437 for (std::size_t
j = 0;
j < n_node_dofs;
j++)
439 auto it_dof = std::begin(node_dofs) +
j;
440 modal_displacement[(*it_dof)->EquationId()] = modal_displacement[(*it_dof)->EquationId()] + mode_weight * r_node_eigenvectors(
i,
j);
445 this->AssignVariables(modal_displacement);
448 <<
"Exiting SolveSolutionStep" << std::endl;
462 p_builder_and_solver->GetLinearSystemSolver()->Clear();
468 p_builder_and_solver->SetDofSetIsInitializedFlag(
false);
470 p_builder_and_solver->Clear();
474 mInitializeWasPerformed =
false;
475 mUseMaterialDamping =
false;
476 mRayleighAlpha = 0.0;
478 mSystemDamping = 0.0;
489 const auto rank = r_model_part.GetCommunicator().MyPID();
492 <<
"Entering Check" << std::endl;
504 <<
"Exiting Check" << std::endl;
567 bool mInitializeWasPerformed =
false;
573 double mRayleighAlpha = 0.0;
575 double mRayleighBeta = 0.0;
577 double mSystemDamping = 0.0;
579 bool mUseMaterialDamping;
581 vector< double > mMaterialDampingRatios;
595 for(
auto&
node : r_model_part.Nodes() )
599 for(
auto it_dof = std::begin(rNodeDofs); it_dof !=
std::end(rNodeDofs); it_dof++ )
601 auto& p_dof = *it_dof;
602 if( !p_dof->IsFixed() )
604 const auto modal_displacement = rModalDisplacement( p_dof->EquationId() );
606 if( std::real( modal_displacement ) < 0 )
608 p_dof->GetSolutionStepValue(
step) = -1 * std::abs( modal_displacement );
612 p_dof->GetSolutionStepValue(
step) = std::abs( modal_displacement );
616 p_dof->GetSolutionStepReactionValue(
step) = std::arg( modal_displacement );
620 p_dof->GetSolutionStepValue(
step) = 0.0;
621 p_dof->GetSolutionStepReactionValue(
step) = 0.0;
Definition: builtin_timer.h:26
Strategy for solving generalized eigenvalue problems.
Definition: harmonic_analysis_strategy.hpp:54
void SetScheme(SchemePointerType pScheme)
Definition: harmonic_analysis_strategy.hpp:145
TDenseSpace::MatrixPointerType DenseMatrixPointerType
Definition: harmonic_analysis_strategy.hpp:73
bool GetIsInitialized() const
Definition: harmonic_analysis_strategy.hpp:140
HarmonicAnalysisStrategy(const HarmonicAnalysisStrategy &Other)=delete
Deleted copy constructor.
SchemePointerType & pGetScheme()
Definition: harmonic_analysis_strategy.hpp:150
void SetIsInitialized(bool val)
Definition: harmonic_analysis_strategy.hpp:135
int Check() override
Check whether initial input is valid.
Definition: harmonic_analysis_strategy.hpp:484
void SetBuilderAndSolver(BuilderAndSolverPointerType pNewBuilderAndSolver)
Definition: harmonic_analysis_strategy.hpp:155
~HarmonicAnalysisStrategy() override
Destructor.
Definition: harmonic_analysis_strategy.hpp:123
HarmonicAnalysisStrategy(ModelPart &rModelPart, SchemePointerType pScheme, BuilderAndSolverPointerType pBuilderAndSolver, bool UseMaterialDampingFlag=false)
Constructor.
Definition: harmonic_analysis_strategy.hpp:88
TSparseSpace::VectorPointerType SparseVectorPointerType
Definition: harmonic_analysis_strategy.hpp:77
DenseVector< ComplexType > ComplexVectorType
Definition: harmonic_analysis_strategy.hpp:81
KRATOS_CLASS_POINTER_DEFINITION(HarmonicAnalysisStrategy)
void SetUseMaterialDampingFlag(bool flag)
Definition: harmonic_analysis_strategy.hpp:175
void SetReformDofSetAtEachStepFlag(bool flag)
Definition: harmonic_analysis_strategy.hpp:165
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: harmonic_analysis_strategy.hpp:61
bool GetUseMaterialDampingFlag() const
Definition: harmonic_analysis_strategy.hpp:180
void SetEchoLevel(int Level) override
Set verbosity level of the solving strategy.
Definition: harmonic_analysis_strategy.hpp:192
TDenseSpace::VectorType DenseVectorType
Definition: harmonic_analysis_strategy.hpp:69
BaseType::TBuilderAndSolverType::Pointer BuilderAndSolverPointerType
Definition: harmonic_analysis_strategy.hpp:65
TDenseSpace DenseSpaceType
Definition: harmonic_analysis_strategy.hpp:67
TDenseSpace::MatrixType DenseMatrixType
Definition: harmonic_analysis_strategy.hpp:71
void Clear() override
Clear the strategy.
Definition: harmonic_analysis_strategy.hpp:456
BuilderAndSolverPointerType & pGetBuilderAndSolver()
Definition: harmonic_analysis_strategy.hpp:160
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: harmonic_analysis_strategy.hpp:375
bool GetReformDofSetAtEachStepFlag() const
Definition: harmonic_analysis_strategy.hpp:170
BaseType::TSchemeType::Pointer SchemePointerType
Definition: harmonic_analysis_strategy.hpp:63
std::complex< double > ComplexType
Definition: harmonic_analysis_strategy.hpp:79
TSparseSpace SparseSpaceType
Definition: harmonic_analysis_strategy.hpp:75
void Initialize() override
Initialization to be performed once before using the strategy.
Definition: harmonic_analysis_strategy.hpp:199
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
Definition: amatrix_interface.h:41
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
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
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 MatrixPointerType CreateEmptyMatrixPointer()
Definition: ublas_space.h:178
static void Clear(MatrixPointerType &pA)
Definition: ublas_space.h:578
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_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
end
Definition: DEM_benchmarks.py:180
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
AMatrix::MatrixColumn< const TExpressionType > column(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t ColumnIndex)
Definition: amatrix_interface.h:637
int step
Definition: face_heat.py:88
f
Definition: generate_convection_diffusion_explicit_element.py:112
n_dofs
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:151
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254
Definition: mesh_converter.cpp:38