Skip to content

Conversation

@markelov208
Copy link
Contributor

@markelov208 markelov208 commented Dec 22, 2025

📝 Description
A brief description of the PR.

  • moved some code from retention_law.h to retention_law.cpp. only inline functions are kept in the header.
  • created retention_law_factory.cpp to place Clone() definition there.

Copy link
Contributor

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

Thanks for making the retention laws consistent! I only have two minor questions 👍

KRATOS_CLASS_POINTER_DEFINITION(RetentionLaw);

class Parameters
class KRATOS_API(GEO_MECHANICS_APPLICATION) Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen this used on internal classes (defined within another class). Is it necessary to add the KRATOS_API macro 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.

Yes, it is necessary because I moved the definitions to cpp file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, but then it's also necessary for the internal class? I know it's necessary for classes in general, but this parameters class is defined within the retention_law class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not linkable without KRATOS_API(GEO_MECHANICS_APPLICATION) because the functions have been moved to cpp file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh apologies, I had missed the functions of this internal object had indeed also moved, thanks for the explanation!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it has to do with the fact that this inner class is being referenced from the unit tests. Since the unit tests are in a separate executable, when building the unit tests the class and all of its members must be accessible. Previously, since the entire class and its definitions were in the header file, this requirement was met (resulting in duplicated machine code: one as part of the GeoMechanicsCore library and the other one as part of the unit test executable). After all, we include that header in the unit tests. Now that the definitions have been moved to the implementation file, that mechanism no longer worked. And also linking to the GeoMechanicsCore library didn't work, since the entire class wasn't exposed. Now that this class is exposed (by using KRATOS_API(GEO_MECHANICS_APPLICATION)), linking will work (and we have a single binary representation of this inner class, which is nice).

Copy link
Contributor

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

Good to go! I have a question left, but it's more for curiosity and isn't blocking

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] Move all non-template code to .cpp files and make sure any .h file does not contain any implementations

4 participants