-
Notifications
You must be signed in to change notification settings - Fork 248
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 Mass Matrix (M) #12299
Changes from 16 commits
50f3582
ea4cc17
0dd0c5a
fc82a72
83f27a1
122e145
d1ea2e1
27b872a
561390d
2802e2b
db42ede
f632a3b
1fec4e6
4e56457
684103f
bf235ca
d8abb63
1e5a696
7d7ac07
cfd8da6
a14951c
3d5bd1f
6417b44
f59640e
4d877be
99beebb
516b822
3172490
065e3ff
e418105
af39cf6
5162f11
6738424
e865caa
02cd28d
419de5f
b413a81
be659ba
5e159f3
6c60525
961954c
66551cd
3921b67
d29c4b5
e53ba8c
419bbfe
35d8b43
1e64d18
56b5828
de3af9a
500d098
63cc3dd
f22c8a4
3c04353
5879c6b
2e1ed28
fc15f3e
8ed6b14
7f10d5f
99b0fba
19559c6
383176a
c5c44ba
1572298
9012aeb
cf9f0d9
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 | ||||
---|---|---|---|---|---|---|
|
@@ -429,87 +429,6 @@ void SmallStrainUPwDiffOrderElement::CalculateRightHandSide(VectorType& r | |||||
KRATOS_CATCH("") | ||||||
} | ||||||
|
||||||
void SmallStrainUPwDiffOrderElement::CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) | ||||||
{ | ||||||
KRATOS_TRY | ||||||
|
||||||
const GeometryType& rGeom = GetGeometry(); | ||||||
const SizeType Dim = rGeom.WorkingSpaceDimension(); | ||||||
const SizeType NumUNodes = rGeom.PointsNumber(); | ||||||
const SizeType BlockElementSize = NumUNodes * Dim; | ||||||
const GeometryType::IntegrationPointsArrayType& IntegrationPoints = | ||||||
rGeom.IntegrationPoints(this->GetIntegrationMethod()); | ||||||
|
||||||
ElementVariables Variables; | ||||||
this->InitializeElementVariables(Variables, rCurrentProcessInfo); | ||||||
|
||||||
// create general parameters of retention law | ||||||
RetentionLaw::Parameters RetentionParameters(this->GetProperties(), rCurrentProcessInfo); | ||||||
|
||||||
Matrix MassMatrixContribution = ZeroMatrix(BlockElementSize, BlockElementSize); | ||||||
|
||||||
// Defining shape functions and the determinant of the jacobian at all integration points | ||||||
|
||||||
// Loop over integration points | ||||||
Matrix Nu = ZeroMatrix(Dim, NumUNodes * Dim); | ||||||
Matrix AuxDensityMatrix = ZeroMatrix(Dim, NumUNodes * Dim); | ||||||
Matrix DensityMatrix = ZeroMatrix(Dim, Dim); | ||||||
|
||||||
for (unsigned int GPoint = 0; GPoint < IntegrationPoints.size(); ++GPoint) { | ||||||
// compute element kinematics (Np, gradNpT, |J|, B) | ||||||
this->CalculateKinematics(Variables, GPoint); | ||||||
|
||||||
// calculating weighting coefficient for integration | ||||||
Variables.IntegrationCoefficientInitialConfiguration = this->CalculateIntegrationCoefficient( | ||||||
IntegrationPoints, GPoint, Variables.detJInitialConfiguration); | ||||||
|
||||||
CalculateRetentionResponse(Variables, RetentionParameters, GPoint); | ||||||
|
||||||
this->CalculateSoilDensity(Variables); | ||||||
|
||||||
// Setting the shape function matrix | ||||||
SizeType Index = 0; | ||||||
for (SizeType i = 0; i < NumUNodes; ++i) { | ||||||
for (SizeType iDim = 0; iDim < Dim; ++iDim) { | ||||||
Nu(iDim, Index++) = Variables.Nu(i); | ||||||
} | ||||||
} | ||||||
|
||||||
GeoElementUtilities::AssembleDensityMatrix(DensityMatrix, Variables.Density); | ||||||
|
||||||
noalias(AuxDensityMatrix) = prod(DensityMatrix, Nu); | ||||||
|
||||||
// Adding contribution to Mass matrix | ||||||
noalias(MassMatrixContribution) += | ||||||
prod(trans(Nu), AuxDensityMatrix) * Variables.IntegrationCoefficientInitialConfiguration; | ||||||
} | ||||||
|
||||||
// Distribute mass block matrix into the elemental matrix | ||||||
const SizeType NumPNodes = mpPressureGeometry->PointsNumber(); | ||||||
|
||||||
const SizeType ElementSize = BlockElementSize + NumPNodes; | ||||||
|
||||||
if (rMassMatrix.size1() != ElementSize || rMassMatrix.size2() != ElementSize) | ||||||
rMassMatrix.resize(ElementSize, ElementSize, false); | ||||||
noalias(rMassMatrix) = ZeroMatrix(ElementSize, ElementSize); | ||||||
|
||||||
for (SizeType i = 0; i < NumUNodes; ++i) { | ||||||
SizeType Index_i = i * Dim; | ||||||
|
||||||
for (SizeType j = 0; j < NumUNodes; ++j) { | ||||||
SizeType Index_j = j * Dim; | ||||||
for (SizeType idim = 0; idim < Dim; ++idim) { | ||||||
for (SizeType jdim = 0; jdim < Dim; ++jdim) { | ||||||
rMassMatrix(Index_i + idim, Index_j + jdim) += | ||||||
MassMatrixContribution(Index_i + idim, Index_j + jdim); | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
KRATOS_CATCH("") | ||||||
} | ||||||
|
||||||
void SmallStrainUPwDiffOrderElement::CalculateDampingMatrix(MatrixType& rDampingMatrix, | ||||||
const ProcessInfo& rCurrentProcessInfo) | ||||||
{ | ||||||
|
@@ -523,10 +442,9 @@ void SmallStrainUPwDiffOrderElement::CalculateDampingMatrix(MatrixType& r | |||||
|
||||||
const SizeType ElementSize = NumUNodes * Dim + NumPNodes; | ||||||
|
||||||
// Compute Mass Matrix | ||||||
MatrixType MassMatrix(ElementSize, ElementSize); | ||||||
|
||||||
this->CalculateMassMatrix(MassMatrix, rCurrentProcessInfo); | ||||||
MatrixType MassMatrix = GeoTransportEquationUtilities::CalculateMassMatrixDiffOrder( | ||||||
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 this is a local variable, this should be snake case (problem of course is that it seems this class very inconsistent with that right now, maybe we can fix it only in the functions we touch?)
Suggested change
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. Thank you. Yesterday I made the same comments to Mohamed ;( |
||||||
this->GetGeometry(), mpPressureGeometry, this->GetIntegrationMethod(), *mpStressStatePolicy, | ||||||
mRetentionLawVector, this->GetProperties(), rCurrentProcessInfo); | ||||||
|
||||||
// Compute Stiffness matrix | ||||||
MatrixType StiffnessMatrix(ElementSize, ElementSize); | ||||||
|
@@ -1865,7 +1783,8 @@ void SmallStrainUPwDiffOrderElement::CalculateAndAddMixBodyForce(VectorType& rRi | |||||
const SizeType Dim = rGeom.WorkingSpaceDimension(); | ||||||
const SizeType NumUNodes = rGeom.PointsNumber(); | ||||||
|
||||||
this->CalculateSoilDensity(rVariables); | ||||||
rVariables.Density = GeoTransportEquationUtilities::CalculateSoilDensity( | ||||||
rVariables.DegreeOfSaturation, this->GetProperties()); | ||||||
|
||||||
Vector BodyAcceleration = ZeroVector(Dim); | ||||||
SizeType Index = 0; | ||||||
|
@@ -1887,18 +1806,6 @@ void SmallStrainUPwDiffOrderElement::CalculateAndAddMixBodyForce(VectorType& rRi | |||||
KRATOS_CATCH("") | ||||||
} | ||||||
|
||||||
void SmallStrainUPwDiffOrderElement::CalculateSoilDensity(ElementVariables& rVariables) | ||||||
{ | ||||||
KRATOS_TRY | ||||||
|
||||||
const PropertiesType& rProp = this->GetProperties(); | ||||||
|
||||||
rVariables.Density = (rVariables.DegreeOfSaturation * rProp[POROSITY] * rProp[DENSITY_WATER]) + | ||||||
(1.0 - rProp[POROSITY]) * rProp[DENSITY_SOLID]; | ||||||
|
||||||
KRATOS_CATCH("") | ||||||
} | ||||||
|
||||||
void SmallStrainUPwDiffOrderElement::CalculateAndAddCouplingTerms(VectorType& rRightHandSideVector, | ||||||
ElementVariables& rVariables) | ||||||
{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,26 @@ The mathematical definition is: | |
$$Q = \int_\Omega B^T \alpha \xi m N_p d\Omega$$ | ||
where $B$ is the B-matrix, $\alpha$ is the Biot-alpha (relation between pressure and displacements, material parameter), $\xi$ is the Bishop coefficient, $m$ is the Voigt-vector ($[1,1,1,0,0,0]$) and $N_p$ is the pressure shape function. | ||
|
||
### Mass Matrix (M) | ||
|
||
The mathematical definition is: | ||
$$M = \int_\Omega N_{u}^T \rho N_u d\Omega$$ | ||
|
||
Where $\Omega$ is the domain, $N_u$ is the displacement shape function and $\rho$ is the density matrix that holds density for all directions. | ||
|
||
### Soil density | ||
|
||
The soil density is calculated as | ||
$$\rho= S_r \Phi \rho_w + \Phi \rho_s$$ | ||
where $S_r$ is the degree of saturation, $\Phi$ is the porosity, $\rho_w$ is the water density, $\rho_s$ is the solid density. | ||
|
||
File transport_equation_utilities.hpp includes | ||
|
||
- CalculatePermeabilityMatrix function | ||
- CalculateCompressibilityMatrix function | ||
- CalculateCouplingMatrix function | ||
- CalculateMassMatrix function | ||
- CalculateSoilDensity function | ||
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. Currently correct, maybe we can put those in a more logical place. 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. README file is updated. Now CalculateMassMatrix is moved to equation_of_motion_utilities.hpp |
||
|
||
|
||
## Stress strain utilities | ||
|
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.
As the mass matrix is not part of the transport equation, but part of the (displacement) equation of motion, I wonder if GeoTransportEquationUtilities is the best place to put this.
Its call I would expect after the retention law things have been computed as probably its fill depends on the saturation values in the integration points.
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.
A very good suggestion, as a result the CalculateMassMatrix is split into three functions. This also helps to have the same functions for U_Pw and U_Pw_DiffOrder elements.