Skip to content
Merged
Show file tree
Hide file tree
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 Oct 22, 2024
f5d7456
Put element under an angle to allow for fluid body vector
rfaasse Oct 22, 2024
7a2aa3f
Added interface for the Calculator
rfaasse Oct 22, 2024
4244fc0
modified test such that it is more sensitive to compressibility
rfaasse Oct 22, 2024
8ea34cc
Clean up some redundant stuff from the test
rfaasse Oct 22, 2024
da2d58f
Format test
rfaasse Oct 22, 2024
1472ace
Moved compressibility terms of both LHS and RHS to calculator
rfaasse Oct 22, 2024
baa1ac8
Cleaned up compressibility functions in element
rfaasse Oct 22, 2024
3211586
Minor clean-up
rfaasse Oct 22, 2024
58db729
Clean-up in calculator
rfaasse Oct 22, 2024
23153c9
Made lambdas re-usable
rfaasse Oct 22, 2024
85f0a87
Moved permeability calculation to calculator
rfaasse Oct 22, 2024
e82ece8
Clean up
rfaasse Oct 22, 2024
771a576
Renames for clarity
rfaasse Oct 22, 2024
5036387
Removed redundant blank lines
rfaasse Oct 22, 2024
fee9607
Remove leftover functions which became redundant
rfaasse Oct 22, 2024
b17f37a
Shortening piece of code
rfaasse Oct 22, 2024
facdcd5
Add missing include
rfaasse Oct 22, 2024
b97a323
Creating the calculators based on a list of enums
rfaasse Oct 23, 2024
7807547
Made it possible to change the number of contributions at registration
rfaasse Oct 23, 2024
8ff26ed
Minor clean-up + formatting
rfaasse Oct 23, 2024
d585719
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse Oct 23, 2024
6c435f2
Changed function to return matrix + vector instead of using the argum…
rfaasse Oct 23, 2024
0b54a5d
Moved enum to separate file + formatting
rfaasse Oct 23, 2024
f6c457c
Fix gcc build in pipeline
rfaasse Oct 23, 2024
6071333
Made permeability calculator not dependent on local dimension (no har…
rfaasse Oct 23, 2024
a411aa8
Removing tests not related to the local system function
rfaasse Oct 23, 2024
db01e12
Cleanup and moving private & public functions around
rfaasse Oct 24, 2024
6999330
Fix error for non-void function not returning a value at every path
rfaasse Oct 24, 2024
0416c10
Fix typo in function
rfaasse Oct 24, 2024
8ccffab
Removed some redundant 'else' statements
rfaasse Oct 24, 2024
2f1e944
Adding include for std::size_t (that comes in implicitly now)
rfaasse Oct 24, 2024
753fba3
Moved some variables which were only used in a single function to tha…
rfaasse Oct 24, 2024
d4e8a31
Added test and implementation for calculating the RHS
rfaasse Oct 24, 2024
38b9087
Added test and implementation for calculating the LHS in isolation
rfaasse Oct 24, 2024
10144f6
Removed unused function
rfaasse Oct 24, 2024
e9ffb18
Formatting
rfaasse Oct 24, 2024
24e923c
Minor formatting
rfaasse Oct 24, 2024
ec4b771
Minor clean-up
rfaasse Oct 24, 2024
70cb3eb
Removed redundant entry in matrix constructor and formatted the expec…
rfaasse Oct 24, 2024
22c7baa
Renamed function
rfaasse Oct 24, 2024
891c9de
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse Oct 24, 2024
e5e2d50
Fixed three code smells
rfaasse Oct 25, 2024
a6f2db3
Processing review comments in the element class itself
rfaasse Nov 1, 2024
69c088e
Merge remote-tracking branch 'origin/master' into geo/add-extendible-…
rfaasse Nov 1, 2024
a82a1f0
Processing review comments in the unit tests
rfaasse Nov 1, 2024
e5bd016
Did some renaming for the calculator class and its function names
rfaasse Nov 1, 2024
8eab040
Processed review comments for compressibility calculator
rfaasse Nov 1, 2024
670b44a
Processed review comments for permeability calculator
rfaasse Nov 1, 2024
033d8c8
Processed review comments for permeability calculator
rfaasse Nov 1, 2024
4b51ff3
Made if-statements a switch, reverted an unwanted rename and changed …
rfaasse Nov 5, 2024
606111f
Minor last review comment
rfaasse Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.


}
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;
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]) {
bulk_fluid = r_properties[BULK_MODULUS_FLUID];
}
double result = (biot_coefficient - r_properties[POROSITY]) / r_properties[BULK_MODULUS_SOLID] +
r_properties[POROSITY] / bulk_fluid;

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
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
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
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}};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
Loading