-
Notifications
You must be signed in to change notification settings - Fork 278
[GeoMechanicsApplication] Move all non-template code to .cpp files and make sure any .h file does not contain any implementations (retention) #14082
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
Changes from all commits
1f64cd4
d271290
24dca6f
a6dce2a
1b94aff
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 |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw | |
| // Counted pointer of RetentionLaw | ||
| KRATOS_CLASS_POINTER_DEFINITION(RetentionLaw); | ||
|
|
||
| class Parameters | ||
| class KRATOS_API(GEO_MECHANICS_APPLICATION) Parameters | ||
|
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. I haven't seen this used on internal classes (defined within another class). Is it necessary to add the KRATOS_API macro here?
Contributor
Author
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. Yes, it is necessary because I moved the definitions to cpp file.
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. 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
Contributor
Author
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. It is not linkable without
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. Ahh apologies, I had missed the functions of this internal object had indeed also moved, thanks for the explanation!
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. 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_CLASS_POINTER_DEFINITION(Parameters); | ||
|
|
||
|
|
@@ -41,27 +41,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw | |
| */ | ||
|
|
||
| public: | ||
| explicit Parameters(const Properties& rMaterialProperties) | ||
| : mrMaterialProperties(rMaterialProperties) | ||
| { | ||
| } | ||
|
|
||
| explicit Parameters(const Properties& rMaterialProperties); | ||
| ~Parameters() = default; | ||
|
|
||
| void SetFluidPressure(double FluidPressure) { mFluidPressure = FluidPressure; }; | ||
| void SetFluidPressure(double FluidPressure); | ||
|
|
||
| [[nodiscard]] double GetFluidPressure() const | ||
| { | ||
| KRATOS_ERROR_IF_NOT(mFluidPressure.has_value()) | ||
| << "Fluid pressure is not yet set in the retention " | ||
| "law when trying to retrieve it, aborting.\n"; | ||
| return mFluidPressure.value(); | ||
| } | ||
| [[nodiscard]] double GetFluidPressure() const; | ||
|
|
||
| [[nodiscard]] const Properties& GetMaterialProperties() const | ||
| { | ||
| return mrMaterialProperties; | ||
| } | ||
| [[nodiscard]] const Properties& GetMaterialProperties() const; | ||
|
|
||
| private: | ||
| std::optional<double> mFluidPressure; | ||
|
|
@@ -115,38 +102,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw | |
|
|
||
| static int Check(const std::vector<RetentionLaw::Pointer>& rRetentionLawVector, | ||
| const Properties& rProperties, | ||
| const ProcessInfo& rCurrentProcessInfo) | ||
| { | ||
| KRATOS_ERROR_IF(rRetentionLawVector.empty()) << "A retention law has to be provided." << std::endl; | ||
|
|
||
| return rRetentionLawVector[0]->Check(rProperties, rCurrentProcessInfo); | ||
| } | ||
|
|
||
| /** | ||
| * @brief This method is used to check that two Retention Laws are the same type (references) | ||
| * @param rLHS The first argument | ||
| * @param rRHS The second argument | ||
| */ | ||
| inline static bool HasSameType(const RetentionLaw& rLHS, const RetentionLaw& rRHS) | ||
| { | ||
| return (typeid(rLHS) == typeid(rRHS)); | ||
| } | ||
|
|
||
| /** | ||
| * @brief This method is used to check that tow Retention Laws are the same type (pointers) | ||
| * @param rLHS The first argument | ||
| * @param rRHS The second argument | ||
| */ | ||
| inline static bool HasSameType(const RetentionLaw* rLHS, const RetentionLaw* rRHS) | ||
| { | ||
| return HasSameType(*rLHS, *rRHS); | ||
| } | ||
| const ProcessInfo& rCurrentProcessInfo); | ||
|
|
||
| [[nodiscard]] virtual std::string Info() const { return "RetentionLaw"; } | ||
| [[nodiscard]] virtual std::string Info() const; | ||
|
|
||
| virtual void PrintInfo(std::ostream& rOStream) const { rOStream << Info(); } | ||
| virtual void PrintInfo(std::ostream& rOStream) const; | ||
|
|
||
| virtual void PrintData(std::ostream& rOStream) const { rOStream << "RetentionLaw has no data"; } | ||
| virtual void PrintData(std::ostream& rOStream) const; | ||
|
|
||
| private: | ||
| friend class Serializer; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Vahid Galavi | ||
| // | ||
|
|
||
| // Project includes | ||
| #include "custom_retention/retention_law_factory.h" | ||
| #include "custom_retention/saturated_below_phreatic_level_law.h" | ||
| #include "custom_retention/saturated_law.h" | ||
| #include "custom_retention/van_genuchten_law.h" | ||
|
|
||
| // Application includes | ||
| #include "geo_mechanics_application_variables.h" | ||
|
|
||
| namespace Kratos | ||
| { | ||
| std::unique_ptr<RetentionLaw> RetentionLawFactory::Clone(const Properties& rMaterialProperties) | ||
| { | ||
| if (rMaterialProperties.Has(RETENTION_LAW)) { | ||
| const std::string& RetentionLawName = rMaterialProperties[RETENTION_LAW]; | ||
| if (RetentionLawName == "VanGenuchtenLaw") return std::make_unique<VanGenuchtenLaw>(); | ||
|
|
||
| if (RetentionLawName == "SaturatedLaw") return std::make_unique<SaturatedLaw>(); | ||
|
|
||
| if (RetentionLawName == "SaturatedBelowPhreaticLevelLaw") | ||
| return std::make_unique<SaturatedBelowPhreaticLevelLaw>(); | ||
|
|
||
| if (RetentionLawName == "PressureFilterLaw") return std::make_unique<SaturatedLaw>(); | ||
|
|
||
| KRATOS_ERROR << "Undefined RETENTION_LAW! " << RetentionLawName << std::endl; | ||
|
|
||
| return nullptr; | ||
| } | ||
|
|
||
| // default is saturated law | ||
| return std::make_unique<SaturatedLaw>(); | ||
| } | ||
|
|
||
| } // namespace Kratos. |
Uh oh!
There was an error while loading. Please reload this page.