-
Notifications
You must be signed in to change notification settings - Fork 286
[GeoMechanicsApplication] Implement Calculator-based workflow for Pw line element #12778
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
Merged
rfaasse
merged 52 commits into
master
from
geo/add-extendible-calculators-to-pw-line-element
Nov 6, 2024
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
795259b
Added first unit test and made initialize function public
rfaasse f5d7456
Put element under an angle to allow for fluid body vector
rfaasse 7a2aa3f
Added interface for the Calculator
rfaasse 4244fc0
modified test such that it is more sensitive to compressibility
rfaasse 8ea34cc
Clean up some redundant stuff from the test
rfaasse da2d58f
Format test
rfaasse 1472ace
Moved compressibility terms of both LHS and RHS to calculator
rfaasse baa1ac8
Cleaned up compressibility functions in element
rfaasse 3211586
Minor clean-up
rfaasse 58db729
Clean-up in calculator
rfaasse 23153c9
Made lambdas re-usable
rfaasse 85f0a87
Moved permeability calculation to calculator
rfaasse e82ece8
Clean up
rfaasse 771a576
Renames for clarity
rfaasse 5036387
Removed redundant blank lines
rfaasse fee9607
Remove leftover functions which became redundant
rfaasse b17f37a
Shortening piece of code
rfaasse facdcd5
Add missing include
rfaasse b97a323
Creating the calculators based on a list of enums
rfaasse 7807547
Made it possible to change the number of contributions at registration
rfaasse 8ff26ed
Minor clean-up + formatting
rfaasse d585719
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse 6c435f2
Changed function to return matrix + vector instead of using the argum…
rfaasse 0b54a5d
Moved enum to separate file + formatting
rfaasse f6c457c
Fix gcc build in pipeline
rfaasse 6071333
Made permeability calculator not dependent on local dimension (no har…
rfaasse a411aa8
Removing tests not related to the local system function
rfaasse db01e12
Cleanup and moving private & public functions around
rfaasse 6999330
Fix error for non-void function not returning a value at every path
rfaasse 0416c10
Fix typo in function
rfaasse 8ccffab
Removed some redundant 'else' statements
rfaasse 2f1e944
Adding include for std::size_t (that comes in implicitly now)
rfaasse 753fba3
Moved some variables which were only used in a single function to tha…
rfaasse d4e8a31
Added test and implementation for calculating the RHS
rfaasse 38b9087
Added test and implementation for calculating the LHS in isolation
rfaasse 10144f6
Removed unused function
rfaasse e9ffb18
Formatting
rfaasse 24e923c
Minor formatting
rfaasse ec4b771
Minor clean-up
rfaasse 70cb3eb
Removed redundant entry in matrix constructor and formatted the expec…
rfaasse 22c7baa
Renamed function
rfaasse 891c9de
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse e5e2d50
Fixed three code smells
rfaasse a6f2db3
Processing review comments in the element class itself
rfaasse 69c088e
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse a82a1f0
Processing review comments in the unit tests
rfaasse e5bd016
Did some renaming for the calculator class and its function names
rfaasse 8eab040
Processed review comments for compressibility calculator
rfaasse 670b44a
Processed review comments for permeability calculator
rfaasse 033d8c8
Processed review comments for permeability calculator
rfaasse 4b51ff3
Made if-statements a switch, reverted an unwanted rename and changed …
rfaasse 606111f
Minor last review comment
rfaasse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
applications/GeoMechanicsApplication/custom_elements/calculation_contribution.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Richard Faasse | ||
| // | ||
| #pragma once | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| enum class CalculationContribution { Permeability, Compressibility }; | ||
|
|
||
| } | ||
113 changes: 113 additions & 0 deletions
113
applications/GeoMechanicsApplication/custom_elements/compressibility_calculator.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Richard Faasse | ||
| // | ||
| #include "compressibility_calculator.h" | ||
| #include "custom_utilities/transport_equation_utilities.hpp" | ||
| #include "geo_mechanics_application_variables.h" | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| CompressibilityCalculator::CompressibilityCalculator(InputProvider rInputProvider) | ||
| : mInputProvider(std::move(rInputProvider)) | ||
| { | ||
| } | ||
|
|
||
| Matrix CompressibilityCalculator::LHSContribution() | ||
| { | ||
| return LHSContribution(CalculateCompressibilityMatrix()); | ||
| } | ||
|
|
||
| Vector CompressibilityCalculator::RHSContribution() | ||
| { | ||
| return RHSContribution(CalculateCompressibilityMatrix()); | ||
| } | ||
|
|
||
| Vector CompressibilityCalculator::RHSContribution(const Matrix& rCompressibilityMatrix) const | ||
| { | ||
| return -prod(rCompressibilityMatrix, mInputProvider.GetNodalValues(DT_WATER_PRESSURE)); | ||
| } | ||
|
|
||
| Matrix CompressibilityCalculator::LHSContribution(const Matrix& rCompressibilityMatrix) const | ||
| { | ||
| return mInputProvider.GetMatrixScalarFactor()* rCompressibilityMatrix; | ||
| } | ||
|
|
||
| std::pair<Matrix, Vector> CompressibilityCalculator::LocalSystemContribution() | ||
| { | ||
| const auto compressibility_matrix = CalculateCompressibilityMatrix(); | ||
| return {LHSContribution(compressibility_matrix), RHSContribution(compressibility_matrix)}; | ||
| } | ||
|
|
||
| Matrix CompressibilityCalculator::CalculateCompressibilityMatrix() const | ||
| { | ||
| const auto& r_N_container = mInputProvider.GetNContainer(); | ||
| const auto& integration_coefficients = mInputProvider.GetIntegrationCoefficients(); | ||
| auto result = Matrix{ZeroMatrix{r_N_container.size2(), r_N_container.size2()}}; | ||
| for (unsigned int integration_point_index = 0; | ||
rfaasse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| integration_point_index < integration_coefficients.size(); ++integration_point_index) { | ||
| const auto N = Vector{row(r_N_container, integration_point_index)}; | ||
| result += GeoTransportEquationUtilities::CalculateCompressibilityMatrix( | ||
| N, CalculateBiotModulusInverse(mInputProvider.GetRetentionLaws()[integration_point_index]), | ||
| integration_coefficients[integration_point_index]); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| double CompressibilityCalculator::CalculateBiotModulusInverse(const RetentionLaw::Pointer& rRetentionLaw) const | ||
| { | ||
| const auto& r_properties = mInputProvider.GetElementProperties(); | ||
| const double biot_coefficient = r_properties[BIOT_COEFFICIENT]; | ||
|
|
||
| double bulk_fluid = TINY; | ||
| if (!r_properties[IGNORE_UNDRAINED]) { | ||
markelov208 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bulk_fluid = r_properties[BULK_MODULUS_FLUID]; | ||
| } | ||
| double result = (biot_coefficient - r_properties[POROSITY]) / r_properties[BULK_MODULUS_SOLID] + | ||
| r_properties[POROSITY] / bulk_fluid; | ||
WPK4FEM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| RetentionLaw::Parameters retention_parameters(r_properties); | ||
| result *= rRetentionLaw->CalculateSaturation(retention_parameters); | ||
| result -= rRetentionLaw->CalculateDerivativeOfSaturation(retention_parameters) * r_properties[POROSITY]; | ||
| return result; | ||
| } | ||
|
|
||
| const Properties& CompressibilityCalculator::InputProvider::GetElementProperties() const | ||
| { | ||
| return mGetElementProperties(); | ||
| } | ||
|
|
||
| const std::vector<RetentionLaw::Pointer>& CompressibilityCalculator::InputProvider::GetRetentionLaws() const | ||
| { | ||
| return mGetRetentionLaws(); | ||
| } | ||
|
|
||
| const Matrix& CompressibilityCalculator::InputProvider::GetNContainer() const | ||
| { | ||
| return mGetNContainer(); | ||
| } | ||
|
|
||
| Vector CompressibilityCalculator::InputProvider::GetIntegrationCoefficients() const | ||
| { | ||
| return mGetIntegrationCoefficients(); | ||
| } | ||
|
|
||
| double CompressibilityCalculator::InputProvider::GetMatrixScalarFactor() const | ||
| { | ||
| return mGetMatrixScalarFactor(); | ||
| } | ||
|
|
||
| Vector CompressibilityCalculator::InputProvider::GetNodalValues(const Variable<double>& rVariable) const | ||
| { | ||
| return mGetNodalValues(rVariable); | ||
| } | ||
|
|
||
| } // namespace Kratos | ||
78 changes: 78 additions & 0 deletions
78
applications/GeoMechanicsApplication/custom_elements/compressibility_calculator.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Richard Faasse | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "contribution_calculator.h" | ||
| #include "custom_retention/retention_law.h" | ||
| #include "includes/properties.h" | ||
| #include "includes/ublas_interface.h" | ||
|
|
||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| class CompressibilityCalculator : public ContributionCalculator | ||
| { | ||
| public: | ||
| class InputProvider | ||
| { | ||
| public: | ||
| InputProvider(std::function<const Properties&()> GetElementProperties, | ||
| std::function<const std::vector<RetentionLaw::Pointer>&()> GetRetentionLaws, | ||
| std::function<const Matrix&()> GetNContainer, | ||
| std::function<Vector()> GetIntegrationCoefficients, | ||
| std::function<double()> GetMatrixScalarFactor, | ||
| std::function<Vector(const Variable<double>&)> GetNodalValuesOf) | ||
| : mGetElementProperties(std::move(GetElementProperties)), | ||
| mGetRetentionLaws(std::move(GetRetentionLaws)), | ||
| mGetNContainer(std::move(GetNContainer)), | ||
| mGetIntegrationCoefficients(std::move(GetIntegrationCoefficients)), | ||
| mGetMatrixScalarFactor(std::move(GetMatrixScalarFactor)), | ||
| mGetNodalValues(std::move(GetNodalValuesOf)) | ||
| { | ||
| } | ||
|
|
||
| [[nodiscard]] const Properties& GetElementProperties() const; | ||
| [[nodiscard]] const std::vector<RetentionLaw::Pointer>& GetRetentionLaws() const; | ||
| [[nodiscard]] const Matrix& GetNContainer() const; | ||
| [[nodiscard]] Vector GetIntegrationCoefficients() const; | ||
| [[nodiscard]] double GetMatrixScalarFactor() const; | ||
| [[nodiscard]] Vector GetNodalValues(const Variable<double>& rVariable) const; | ||
|
|
||
| private: | ||
| std::function<const Properties&()> mGetElementProperties; | ||
| std::function<const std::vector<RetentionLaw::Pointer>&()> mGetRetentionLaws; | ||
| std::function<const Matrix&()> mGetNContainer; | ||
| std::function<Vector()> mGetIntegrationCoefficients; | ||
| std::function<double()> mGetMatrixScalarFactor; | ||
| std::function<Vector(const Variable<double>&)> mGetNodalValues; | ||
| }; | ||
|
|
||
| explicit CompressibilityCalculator(InputProvider rInputProvider); | ||
|
|
||
| Matrix LHSContribution() override; | ||
| Vector RHSContribution() override; | ||
| std::pair<Matrix, Vector> LocalSystemContribution() override; | ||
|
|
||
| private: | ||
| [[nodiscard]] Matrix CalculateCompressibilityMatrix() const; | ||
| [[nodiscard]] double CalculateBiotModulusInverse(const RetentionLaw::Pointer& rRetentionLaw) const; | ||
| [[nodiscard]] Vector RHSContribution(const Matrix& rCompressibilityMatrix) const; | ||
| [[nodiscard]] Matrix LHSContribution(const Matrix& rCompressibilityMatrix) const; | ||
|
|
||
| InputProvider mInputProvider; | ||
| }; | ||
|
|
||
| } // namespace Kratos |
29 changes: 29 additions & 0 deletions
29
applications/GeoMechanicsApplication/custom_elements/contribution_calculator.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Richard Faasse | ||
| // | ||
| #pragma once | ||
|
|
||
| #include "includes/ublas_interface.h" | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| class ContributionCalculator | ||
| { | ||
| public: | ||
| virtual ~ContributionCalculator() = default; | ||
|
|
||
| virtual Matrix LHSContribution() = 0; | ||
| virtual Vector RHSContribution() = 0; | ||
| virtual std::pair<Matrix, Vector> LocalSystemContribution() = 0; | ||
| }; | ||
|
|
||
| } // namespace Kratos |
93 changes: 93 additions & 0 deletions
93
applications/GeoMechanicsApplication/custom_elements/permeability_calculator.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Richard Faasse | ||
| // | ||
| #include "permeability_calculator.h" | ||
| #include "custom_retention/retention_law.h" | ||
| #include "custom_utilities/element_utilities.hpp" | ||
| #include "custom_utilities/transport_equation_utilities.hpp" | ||
| #include "includes/cfd_variables.h" | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| PermeabilityCalculator::PermeabilityCalculator(InputProvider InputProvider) | ||
| : mInputProvider{std::move(InputProvider)} | ||
| { | ||
| } | ||
|
|
||
| Matrix PermeabilityCalculator::LHSContribution() { return CalculatePermeabilityMatrix(); } | ||
|
|
||
| Vector PermeabilityCalculator::RHSContribution() | ||
| { | ||
| return RHSContribution(CalculatePermeabilityMatrix()); | ||
| } | ||
|
|
||
| std::pair<Matrix, Vector> PermeabilityCalculator::LocalSystemContribution() | ||
| { | ||
| const auto permeability_matrix = CalculatePermeabilityMatrix(); | ||
| return {permeability_matrix, RHSContribution(permeability_matrix)}; | ||
| } | ||
|
|
||
| Vector PermeabilityCalculator::RHSContribution(const Matrix& rPermeabilityMatrix) const | ||
| { | ||
| return -prod(rPermeabilityMatrix, mInputProvider.GetNodalValues(WATER_PRESSURE)); | ||
| } | ||
|
|
||
| Matrix PermeabilityCalculator::CalculatePermeabilityMatrix() const | ||
| { | ||
| RetentionLaw::Parameters retention_parameters(mInputProvider.GetElementProperties()); | ||
| const auto& r_properties = mInputProvider.GetElementProperties(); | ||
| auto integration_coefficients = mInputProvider.GetIntegrationCoefficients(); | ||
| const auto shape_function_gradients = mInputProvider.GetShapeFunctionGradients(); | ||
| const auto local_dimension = shape_function_gradients[0].size2(); | ||
| const Matrix constitutive_matrix = | ||
| GeoElementUtilities::FillPermeabilityMatrix(r_properties, local_dimension); | ||
|
|
||
| const auto number_of_nodes = shape_function_gradients[0].size1(); | ||
| auto result = Matrix{ZeroMatrix{number_of_nodes, number_of_nodes}}; | ||
|
Contributor
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. This dimension is correct, as there is one D.O.F. per node. The more natural dimension is the number of Pw D.O.F. multiplied with itself. |
||
| const double dynamic_viscosity_inverse = 1.0 / r_properties[DYNAMIC_VISCOSITY]; | ||
| for (unsigned int integration_point_index = 0; | ||
| integration_point_index < integration_coefficients.size(); ++integration_point_index) { | ||
| const double relative_permeability = | ||
| mInputProvider.GetRetentionLaws()[integration_point_index]->CalculateRelativePermeability(retention_parameters); | ||
| result += GeoTransportEquationUtilities::CalculatePermeabilityMatrix( | ||
| shape_function_gradients[integration_point_index], dynamic_viscosity_inverse, constitutive_matrix, | ||
| relative_permeability, integration_coefficients[integration_point_index]); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| const Properties& PermeabilityCalculator::InputProvider::GetElementProperties() const | ||
| { | ||
| return mGetElementProperties(); | ||
| } | ||
|
|
||
| const std::vector<RetentionLaw::Pointer>& PermeabilityCalculator::InputProvider::GetRetentionLaws() const | ||
| { | ||
| return mGetRetentionLaws(); | ||
| } | ||
|
|
||
| Vector PermeabilityCalculator::InputProvider::GetIntegrationCoefficients() const | ||
| { | ||
| return mGetIntegrationCoefficients(); | ||
| } | ||
|
|
||
| Vector PermeabilityCalculator::InputProvider::GetNodalValues(const Variable<double>& rVariable) const | ||
| { | ||
| return mGetNodalValues(rVariable); | ||
| } | ||
|
|
||
| Geometry<Node>::ShapeFunctionsGradientsType PermeabilityCalculator::InputProvider::GetShapeFunctionGradients() const | ||
| { | ||
| return mGetShapeFunctionGradients(); | ||
| } | ||
|
|
||
| } // namespace Kratos | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To be extended with mass, damping, stiffness, UPwCoupling and PwUCoupling when working on the UPw elements.
A similar thought process can perhaps be followed for the geometrical nonlinear contributions
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.
The GeometricStiffness matrix would be a very suitable one indeed, hadn't thought of that but when having a quick look, it seems we can probably remove the updated lagrangian elements from the hierarchy if we have a 'GeometricStiffnessCalculator' 🎉
For the mass and damping, I think it's a good idea to add the calculators, however since adding these terms is the responsibility of the scheme, this will require a bit more discussion.