Skip to content

[GeoMechanicsApplication] Extend functionality for user soil model for interface elements#13630

Merged
rfaasse merged 23 commits intomasterfrom
geo/13568-link-user-soil-model-for-interface-element
Jul 17, 2025
Merged

[GeoMechanicsApplication] Extend functionality for user soil model for interface elements#13630
rfaasse merged 23 commits intomasterfrom
geo/13568-link-user-soil-model-for-interface-element

Conversation

@rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Jul 15, 2025

📝 Description
This PR extends the existing UMAT laws, using a template parameter and ConstitutiveLawDimension instance, such that they can be used with the correct dimensions needed by the new interfaces.

Note that the existing functionality is kept identical. It might seem counterintuitive, but the existing 2D/interface UMAT laws need to have stress/strain vectors and a D matrix with sizes consistent with 3D models. This is because most UMATs we encounter, assume these sizes (hard-coded), meaning they will write in out-of-bounds memory if the sizes are smaller.

For our newly registered UMAT law, the sizes are as expected.

@rfaasse rfaasse self-assigned this Jul 15, 2025
@rfaasse rfaasse changed the title [GeoMechanicsApplication] Link user soil model for interface element [GeoMechanicsApplication] Implement functionality for user soil model for interface elements Jul 15, 2025
@rfaasse rfaasse added the GeoMechanics Issues related to the GeoMechanicsApplication label Jul 15, 2025
@rfaasse rfaasse changed the title [GeoMechanicsApplication] Implement functionality for user soil model for interface elements [GeoMechanicsApplication] Extend functionality for user soil model for interface elements Jul 15, 2025
@rfaasse rfaasse marked this pull request as ready for review July 15, 2025 07:42
@rfaasse rfaasse requested a review from a team as a code owner July 15, 2025 07:42
@aronnoordam
Copy link
Member

makes sense to me

markelov208
markelov208 previously approved these changes Jul 15, 2025
Copy link
Contributor

@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.

Hi Richard, thank you for the clear PR. I have a non-blocking comment.

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.

Hi Richard,

Thanks a lot for generalizing the primary UMAT constitutive law and for adding a proper UMAT constitutive law for two-dimensional line interfaces. I feel the changes are clear, especially with the comments explaining about the wrong size assumptions in most (if not all) of our UMAT libraries.
I have several suggestions, but none of them is blocking in my opinion.

One more thing: can you please rerun Clang-format before merging this branch into master? Thanks.

/// Pointer definition of SmallStrainUMAT2DInterfaceLaw
KRATOS_CLASS_POINTER_DEFINITION(SmallStrainUMAT2DInterfaceLaw);

SmallStrainUMAT2DInterfaceLaw() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity: does the default constructor need to be publicly available? I'm aware that the default constructor is used for deserialization, but since the Serializer class is a friend, it will have access to the private members of the befriended class. How do you see that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary indeed, moved

Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed that the save and load member functions supply the incorrect base class: we should use SmallStrainUMATLaw<VOIGT_SIZE_3D> rather than ConstitutiveLaw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// Pointer definition of SmallStrainUMAT2DPlaneStrainLaw
KRATOS_CLASS_POINTER_DEFINITION(SmallStrainUMAT2DPlaneStrainLaw);

SmallStrainUMAT2DPlaneStrainLaw() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've got the same question here about the access specifier of the default constructor: can we make it private rather than public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved

Comment on lines +71 to +74
explicit SmallStrainUMAT2DInterfaceLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
: SmallStrainUMATLaw<VOIGT_SIZE_3D>(std::move(pConstitutiveDimension))
{
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather move the implementation of this constructor to the .cpp file, and only keep the declaration here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +72 to +75
explicit SmallStrainUMAT2DPlaneStrainLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
: SmallStrainUMATLaw<VOIGT_SIZE_3D>(std::move(pConstitutiveDimension))
{
}
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 I'd rather move the constructor's implementation to the .cpp file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved

rValue.resize(mStressVectorFinalized.size());

noalias(rValue) = mStressVectorFinalized;
if (rValue.size() != TVoigtSize) rValue.resize(TVoigtSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

The size check is also carried out by the resize operation, so we don't need to do it here:

Suggested change
if (rValue.size() != TVoigtSize) rValue.resize(TVoigtSize);
rValue.resize(TVoigtSize);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +703 to +705
for (unsigned int i = 0; i < TVoigtSize; ++i) {
rValue[i] = mStressVectorFinalized[i];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can use std::copy_n here, I'd prefer that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to just assignment

Comment on lines +241 to +242
std::vector<Matrix> LineInterfaceElement::CalculateConstitutiveMatricesAtIntegrationPoints(
const ProcessInfo& rProcessInfo, const std::vector<Vector>& rRelativeDisplacements)
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, we normally have a reference-to-const ProcessInfo instance as the final function parameter. I would suggest to apply that order here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +40 to +43
std::vector<Matrix> CalculateConstitutiveMatricesAtIntegrationPoints(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws,
const Properties& rProperties,
const ProcessInfo& rProcessInfo,
const std::vector<Vector>& rRelativeDisplacements)
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, we normally have a reference-to-const ProcessInfo instance as the final function parameter. I would suggest to apply that order here as well:

Suggested change
std::vector<Matrix> CalculateConstitutiveMatricesAtIntegrationPoints(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws,
const Properties& rProperties,
const ProcessInfo& rProcessInfo,
const std::vector<Vector>& rRelativeDisplacements)
std::vector<Matrix> CalculateConstitutiveMatricesAtIntegrationPoints(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws,
const Properties& rProperties,
const std::vector<Vector>& rRelativeDisplacements,
const ProcessInfo& rProcessInfo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed this is a copy of the MaterialParameters.json file used for the multi-stage analysis. Perhaps we can share this file across both analyses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll wait with this last one until Mohameds integration tests are also in.

Copy link
Contributor Author

@rfaasse rfaasse left a comment

Choose a reason for hiding this comment

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

Processed review comments

/// Pointer definition of SmallStrainUMAT2DInterfaceLaw
KRATOS_CLASS_POINTER_DEFINITION(SmallStrainUMAT2DInterfaceLaw);

SmallStrainUMAT2DInterfaceLaw() = default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary indeed, moved

Comment on lines +71 to +74
explicit SmallStrainUMAT2DInterfaceLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
: SmallStrainUMATLaw<VOIGT_SIZE_3D>(std::move(pConstitutiveDimension))
{
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// We compute the stress
SmallStrainUMAT3DLaw::CalculateMaterialResponseCauchy(rParameterValues);
SmallStrainUMATLaw<TVoigtSize>::CalculateMaterialResponseCauchy(rParameterValues);
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

rValue.resize(mStressVectorFinalized.size());

noalias(rValue) = mStressVectorFinalized;
if (rValue.size() != TVoigtSize) rValue.resize(TVoigtSize);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* @brief Dimension of the law:
*/
SizeType WorkingSpaceDimension() override { return Dimension; }
SizeType WorkingSpaceDimension() override { return mpConstitutiveDimension->GetDimension(); }
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

Comment on lines +40 to +43
std::vector<Matrix> CalculateConstitutiveMatricesAtIntegrationPoints(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws,
const Properties& rProperties,
const ProcessInfo& rProcessInfo,
const std::vector<Vector>& rRelativeDisplacements)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +241 to +242
std::vector<Matrix> LineInterfaceElement::CalculateConstitutiveMatricesAtIntegrationPoints(
const ProcessInfo& rProcessInfo, const std::vector<Vector>& rRelativeDisplacements)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll wait with this last one until Mohameds integration tests are also in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@rfaasse rfaasse requested review from avdg81 and markelov208 July 17, 2025 13:51
@rfaasse rfaasse enabled auto-merge (squash) July 17, 2025 13:57
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.

Thank you very much for processing the review suggestions. I have one very minor suggestion, but feel free to not apply it (now). If that's the only thing left, please merge this PR.

///@}

///@} addtogroup block
///@} addtogroup blocksmal
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking: this change was probably not intended. No need to revert it when there are no other things to be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, seems like the start of a search command that ended up here. I'll fix it when we add the 3D umat interface version 👍

@rfaasse rfaasse merged commit c8d5975 into master Jul 17, 2025
10 checks passed
@rfaasse rfaasse deleted the geo/13568-link-user-soil-model-for-interface-element branch July 17, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GeoMechanics Issues related to the GeoMechanicsApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Link the user soil model for interface element

4 participants