Skip to content
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 stiffness matrix utility #12388

Merged
merged 9 commits into from
May 17, 2024

Conversation

markelov208
Copy link
Contributor

@markelov208 markelov208 commented May 17, 2024

📝 Description

  • Calculation of stiffness matrix is extracted as utility functions
  • CalculateStiffnessMatrixGPoint provides the matrix for a specific integration point because some functions like CalculateAndAddLHS still work on this level
  • CalculateStiffnessMatrix provides the matrix on the element level
  • the function is documented and unit tested.

@markelov208 markelov208 self-assigned this May 17, 2024
@markelov208 markelov208 requested review from rfaasse, WPK4FEM and avdg81 May 17, 2024 13:41
Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for extracting the calculation of the stiffness matrix to a utility function. It is a bit unfortunate that we still need to have this calculation at two levels: element level (final goal) and integration point level. However, after examining your code I understand why that is needed. As far as I can see this was the best you could do for now (considering that we'd like to keep PRs small enough to be manageable), so well done! What I like in particular is that some duplication has been removed. Much better! I only have a few minor remarks, nothing major or blocking.


// Distribute stiffness block matrix into the elemental matrix
GeoElementUtilities::AssembleUUBlockMatrix(rLeftHandSideMatrix, rVariables.UUMatrix);
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
const auto stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment at line 1334 no longer makes sense. Please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Matrix StiffnessMatrix =
prod(trans(rVariables.B), Matrix(prod(rVariables.ConstitutiveMatrix, rVariables.B))) *
rVariables.IntegrationCoefficient;
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
const auto stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

prod(trans(rVariables.B), Matrix(prod(rVariables.ConstitutiveMatrix, rVariables.B))) *
rVariables.IntegrationCoefficient;
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
rVariables.B, rVariables.ConstitutiveMatrix, rVariables.IntegrationCoefficient);

// Distribute stiffness block matrix into the elemental matrix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, you could remove this redundant comment (like you did for the small strain element).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

- CalculateMassMatrix function
- CalculateStiffnessMatrixGPoint provides a stiffness matrix for a specific integration point
- CalculateStiffnessMatrix provides a stiffness matrix for all integration points
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps rephrase this, to emphasize that this function works on element level?

Suggested change
- CalculateStiffnessMatrix provides a stiffness matrix for all integration points
- CalculateStiffnessMatrix provides a stiffness matrix for an element

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was my first option but then I made it like others. ;( Changed.

Comment on lines 48 to 50
static Matrix CalculateStiffnessMatrix(const std::vector<Matrix>& b_matrices,
const std::vector<Matrix>& constitutive_matrices,
const std::vector<double>& integration_coefficients);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To comply with the KratosStyle Guide, we need to rename the parameters as follows:

Suggested change
static Matrix CalculateStiffnessMatrix(const std::vector<Matrix>& b_matrices,
const std::vector<Matrix>& constitutive_matrices,
const std::vector<double>& integration_coefficients);
static Matrix CalculateStiffnessMatrix(const std::vector<Matrix>& rBMatrices,
const std::vector<Matrix>& rConstitutiveMatrices,
const std::vector<double>& rIntegrationCoefficients);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps.

Copy link
Contributor Author

@markelov208 markelov208 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anne, many thanks for the sharp eyes. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


// Distribute stiffness block matrix into the elemental matrix
GeoElementUtilities::AssembleUUBlockMatrix(rLeftHandSideMatrix, rVariables.UUMatrix);
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

Matrix StiffnessMatrix =
prod(trans(rVariables.B), Matrix(prod(rVariables.ConstitutiveMatrix, rVariables.B))) *
rVariables.IntegrationCoefficient;
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

prod(trans(rVariables.B), Matrix(prod(rVariables.ConstitutiveMatrix, rVariables.B))) *
rVariables.IntegrationCoefficient;
Matrix stiffness_matrix = GeoEquationOfMotionUtilities::CalculateStiffnessMatrixGPoint(
rVariables.B, rVariables.ConstitutiveMatrix, rVariables.IntegrationCoefficient);

// Distribute stiffness block matrix into the elemental matrix
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

- CalculateMassMatrix function
- CalculateStiffnessMatrixGPoint provides a stiffness matrix for a specific integration point
- CalculateStiffnessMatrix provides a stiffness matrix for all integration points
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was my first option but then I made it like others. ;( Changed.

Comment on lines 48 to 50
static Matrix CalculateStiffnessMatrix(const std::vector<Matrix>& b_matrices,
const std::vector<Matrix>& constitutive_matrices,
const std::vector<double>& integration_coefficients);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps.

Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is ready to go.

@markelov208 markelov208 enabled auto-merge May 17, 2024 15:21
@markelov208 markelov208 merged commit 328250d into master May 17, 2024
11 checks passed
@markelov208 markelov208 deleted the geo/12371-extract-stiffness-matrix-utility branch May 17, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Extract a static utility function for the calculation of the Stiffness Matrix (K)
2 participants