-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GeoMechanicsApplication] Extract a static utility function for the calculation of the Damping Matrix (D) #12368
Changes from all commits
8e045e7
500b6dd
528c509
4b87c12
5edec92
28420e3
eb7d6e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
// Application includes | ||
#include "custom_elements/geo_structural_base_element.hpp" | ||
#include "custom_utilities/dof_utilities.h" | ||
#include "custom_utilities/equation_of_motion_utilities.h" | ||
#include "geo_mechanics_application_variables.h" | ||
|
||
namespace Kratos | ||
|
@@ -265,25 +266,14 @@ void GeoStructuralBaseElement<TDim, TNumNodes>::CalculateDampingMatrix(MatrixTyp | |
{ | ||
KRATOS_TRY | ||
|
||
// Rayleigh Method: Damping Matrix = alpha*M + beta*K | ||
MatrixType mass_matrix(N_DOF_ELEMENT, N_DOF_ELEMENT); | ||
this->CalculateMassMatrix(mass_matrix, rCurrentProcessInfo); | ||
|
||
// Compute Mass Matrix | ||
MatrixType MassMatrix(N_DOF_ELEMENT, N_DOF_ELEMENT); | ||
MatrixType stiffness_matrix(N_DOF_ELEMENT, N_DOF_ELEMENT); | ||
this->CalculateStiffnessMatrix(stiffness_matrix, rCurrentProcessInfo); | ||
|
||
this->CalculateMassMatrix(MassMatrix, rCurrentProcessInfo); | ||
|
||
// Compute Stiffness matrix | ||
MatrixType StiffnessMatrix(N_DOF_ELEMENT, N_DOF_ELEMENT); | ||
|
||
this->CalculateStiffnessMatrix(StiffnessMatrix, rCurrentProcessInfo); | ||
|
||
// Compute Damping Matrix | ||
if (rDampingMatrix.size1() != N_DOF_ELEMENT) | ||
rDampingMatrix.resize(N_DOF_ELEMENT, N_DOF_ELEMENT, false); | ||
noalias(rDampingMatrix) = ZeroMatrix(N_DOF_ELEMENT, N_DOF_ELEMENT); | ||
|
||
noalias(rDampingMatrix) += rCurrentProcessInfo[RAYLEIGH_ALPHA] * MassMatrix; | ||
noalias(rDampingMatrix) += rCurrentProcessInfo[RAYLEIGH_BETA] * StiffnessMatrix; | ||
rDampingMatrix = GeoEquationOfMotionUtilities::CalculateDampingMatrix( | ||
rCurrentProcessInfo[RAYLEIGH_ALPHA], rCurrentProcessInfo[RAYLEIGH_BETA], mass_matrix, stiffness_matrix); | ||
Comment on lines
+275
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing that struck me here was that apparently for "geo structural" elements the element properties need not be checked for the Rayleigh coefficients (contrary to the U-Pw elements). They are always taken from the "current process info". |
||
|
||
KRATOS_CATCH("") | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,4 +58,12 @@ Vector GeoEquationOfMotionUtilities::CalculateDetJsInitialConfiguration(const Ge | |
return det_Js_initial_configuration; | ||
} | ||
|
||
Matrix GeoEquationOfMotionUtilities::CalculateDampingMatrix(double RayleighAlpha, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we ever want to check the inputs for the damping matrix (e.g. in this case I'd expect alpha and beta to be This might also be a broader discussion, since we don't do input validation for the jsons now, we might want to do that in a central place and avoid expensive checks for each time we call this function (which is done for each time step and each element of course) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checks should be as early as possible and once, so not here but at element initialization and once per material property/constitutive law. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fully agreed with Wijtze-Pieter. |
||
double RayleighBeta, | ||
const Matrix& rMassMatrix, | ||
const Matrix& rStiffnessMatrix) | ||
{ | ||
return RayleighAlpha * rMassMatrix + RayleighBeta * rStiffnessMatrix; | ||
} | ||
|
||
} /* namespace Kratos.*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
// Main authors: Gennady Markelov | ||
// | ||
|
||
#include "custom_elements/plane_strain_stress_state.h" | ||
#include "custom_utilities/element_utilities.hpp" | ||
#include "custom_utilities/equation_of_motion_utilities.h" | ||
#include "testing/testing.h" | ||
|
@@ -120,4 +119,43 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix3D4NGivesCorrectResults, KratosGeoM | |
KRATOS_CHECK_MATRIX_NEAR(mass_matrix, expected_mass_matrix, 1e-4) | ||
} | ||
|
||
KRATOS_TEST_CASE_IN_SUITE(CalculateDampingMatrixGivesCorrectResults, KratosGeoMechanicsFastSuite) | ||
{ | ||
constexpr std::size_t n = 10; | ||
|
||
constexpr double mass_matrix_value = 10; | ||
const auto mass_matrix = scalar_matrix(n, n, mass_matrix_value); | ||
|
||
constexpr double stiffness_matrix_value = 20; | ||
const auto stiffness_matrix = scalar_matrix(n, n, stiffness_matrix_value); | ||
|
||
double rayleigh_alpha = 0.0; | ||
double rayleigh_beta = 1.0; | ||
auto damping_matrix = GeoEquationOfMotionUtilities::CalculateDampingMatrix( | ||
rayleigh_alpha, rayleigh_beta, mass_matrix, stiffness_matrix); | ||
|
||
auto expected_damping_matrix = scalar_matrix(n, n, stiffness_matrix_value); | ||
|
||
KRATOS_CHECK_MATRIX_NEAR(damping_matrix, expected_damping_matrix, 1e-4) | ||
|
||
rayleigh_alpha = 1.0; | ||
rayleigh_beta = 0.0; | ||
damping_matrix = GeoEquationOfMotionUtilities::CalculateDampingMatrix( | ||
rayleigh_alpha, rayleigh_beta, mass_matrix, stiffness_matrix); | ||
|
||
expected_damping_matrix = scalar_matrix(n, n, mass_matrix_value); | ||
|
||
KRATOS_CHECK_MATRIX_NEAR(damping_matrix, expected_damping_matrix, 1e-4) | ||
|
||
rayleigh_alpha = 0.5; | ||
rayleigh_beta = 0.5; | ||
damping_matrix = GeoEquationOfMotionUtilities::CalculateDampingMatrix( | ||
rayleigh_alpha, rayleigh_beta, mass_matrix, stiffness_matrix); | ||
|
||
const double expected_matrix_value = rayleigh_alpha * mass_matrix_value + rayleigh_beta * stiffness_matrix_value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent unit test! The only thing I'm a bit hesitant about is repeating the implementation of the damping matrix computation here. Instead, we could also express the expected matrix like you did in the unit test above this one (see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the expected matrix only has a single value, I would not express the matrix in the same way as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed with Richard. Now the calculated damping matrix is compared with expected damping matrix only. Each time the expected matrix is filled with a specific single value. |
||
expected_damping_matrix = scalar_matrix(n, n, expected_matrix_value); | ||
|
||
KRATOS_CHECK_MATRIX_NEAR(damping_matrix, expected_damping_matrix, 1e-4) | ||
} | ||
|
||
} // namespace Kratos::Testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for eliminating the duplication; this looks much better. I have the same suggestions about code comments as for the previous file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the comments