diff --git a/applications/GeoMechanicsApplication/custom_retention/retention_law.cpp b/applications/GeoMechanicsApplication/custom_retention/retention_law.cpp index bd5a4aed50bf..130775b40222 100644 --- a/applications/GeoMechanicsApplication/custom_retention/retention_law.cpp +++ b/applications/GeoMechanicsApplication/custom_retention/retention_law.cpp @@ -14,9 +14,12 @@ #include "custom_retention/retention_law.h" #include "geo_mechanics_application_variables.h" +#include + +using namespace std::string_literals; + namespace Kratos { - double& RetentionLaw::CalculateValue(Parameters& rParameters, const Variable& rThisVariable, double& rValue) const { if (rThisVariable == DEGREE_OF_SATURATION) { @@ -63,4 +66,45 @@ void RetentionLaw::load(Serializer& rSerializer) // there is no member variables to be loaded } +int RetentionLaw::Check(const std::vector& 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); +} + +std::string RetentionLaw::Info() const { return "RetentionLaw"s; } + +void RetentionLaw::PrintInfo(std::ostream& rOStream) const { rOStream << Info(); } + +void RetentionLaw::PrintData(std::ostream& rOStream) const +{ + rOStream << "RetentionLaw has no data"; +} + +RetentionLaw::Parameters::Parameters(const Properties& rMaterialProperties) + : mrMaterialProperties(rMaterialProperties) +{ +} + +void RetentionLaw::Parameters::SetFluidPressure(double FluidPressure) +{ + mFluidPressure = FluidPressure; +}; + +double RetentionLaw::Parameters::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(); +} + +const Properties& RetentionLaw::Parameters::GetMaterialProperties() const +{ + return mrMaterialProperties; +} + } // namespace Kratos \ No newline at end of file diff --git a/applications/GeoMechanicsApplication/custom_retention/retention_law.h b/applications/GeoMechanicsApplication/custom_retention/retention_law.h index c8b14b32ffc0..84368486a4ca 100644 --- a/applications/GeoMechanicsApplication/custom_retention/retention_law.h +++ b/applications/GeoMechanicsApplication/custom_retention/retention_law.h @@ -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 { 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 mFluidPressure; @@ -115,38 +102,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw static int Check(const std::vector& 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; diff --git a/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.cpp b/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.cpp new file mode 100644 index 000000000000..6f2d301fd9b0 --- /dev/null +++ b/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.cpp @@ -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 RetentionLawFactory::Clone(const Properties& rMaterialProperties) +{ + if (rMaterialProperties.Has(RETENTION_LAW)) { + const std::string& RetentionLawName = rMaterialProperties[RETENTION_LAW]; + if (RetentionLawName == "VanGenuchtenLaw") return std::make_unique(); + + if (RetentionLawName == "SaturatedLaw") return std::make_unique(); + + if (RetentionLawName == "SaturatedBelowPhreaticLevelLaw") + return std::make_unique(); + + if (RetentionLawName == "PressureFilterLaw") return std::make_unique(); + + KRATOS_ERROR << "Undefined RETENTION_LAW! " << RetentionLawName << std::endl; + + return nullptr; + } + + // default is saturated law + return std::make_unique(); +} + +} // namespace Kratos. diff --git a/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.h b/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.h index b4874e5b097e..c4b9637c7639 100644 --- a/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.h +++ b/applications/GeoMechanicsApplication/custom_retention/retention_law_factory.h @@ -13,23 +13,12 @@ #pragma once // System includes -#include "includes/define.h" -#include -#include - -// External includes - -// Project includes #include "custom_retention/retention_law.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" +#include "includes/define.h" namespace Kratos { +class Properties; /** * @class RetentionLawFactory @@ -42,27 +31,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLawFactory /// Counted pointer of RetentionLawFactory KRATOS_CLASS_POINTER_DEFINITION(RetentionLawFactory); - static unique_ptr Clone(const Properties& rMaterialProperties) - { - if (rMaterialProperties.Has(RETENTION_LAW)) { - const std::string& RetentionLawName = rMaterialProperties[RETENTION_LAW]; - if (RetentionLawName == "VanGenuchtenLaw") return std::make_unique(); - - if (RetentionLawName == "SaturatedLaw") return std::make_unique(); - - if (RetentionLawName == "SaturatedBelowPhreaticLevelLaw") - return std::make_unique(); - - if (RetentionLawName == "PressureFilterLaw") return std::make_unique(); - - KRATOS_ERROR << "Undefined RETENTION_LAW! " << RetentionLawName << std::endl; - - return nullptr; - } - - // default is saturated law - return std::make_unique(); - } + static std::unique_ptr Clone(const Properties& rMaterialProperties); }; // Class RetentionLawFactory } // namespace Kratos. diff --git a/applications/GeoMechanicsApplication/geo_mechanics_application.cpp b/applications/GeoMechanicsApplication/geo_mechanics_application.cpp index 695c599f48b0..0fa6b09725c1 100644 --- a/applications/GeoMechanicsApplication/geo_mechanics_application.cpp +++ b/applications/GeoMechanicsApplication/geo_mechanics_application.cpp @@ -14,6 +14,7 @@ // Application includes #include "geo_mechanics_application.h" +#include "custom_retention/saturated_below_phreatic_level_law.h" namespace Kratos { diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_pw_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_pw_element.cpp index 3fdc81a31dbd..d8871671af96 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_pw_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_pw_element.cpp @@ -14,6 +14,7 @@ #include "custom_elements/Pw_element.h" #include "custom_elements/calculation_contribution.h" #include "custom_elements/integration_coefficient_modifier_for_line_element.h" +#include "custom_retention/saturated_law.h" #include "geometries/line_2d_4.h" #include "geometries/line_2d_5.h" #include "tests/cpp_tests/geo_mechanics_fast_suite.h" diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_small_strain_u_pw_diff_order_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_small_strain_u_pw_diff_order_element.cpp index 5f9525028710..49682f3560cd 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_small_strain_u_pw_diff_order_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_small_strain_u_pw_diff_order_element.cpp @@ -14,6 +14,7 @@ #include "custom_constitutive/plane_strain.h" #include "custom_elements/plane_strain_stress_state.h" #include "custom_elements/small_strain_U_Pw_diff_order_element.hpp" +#include "custom_retention/saturated_law.h" #include "custom_utilities/registration_utilities.h" #include "custom_utilities/ublas_utilities.h" #include "geo_mechanics_application_variables.h" diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_transient_Pw_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_transient_Pw_element.cpp index 354a8a0f147c..8c3b60233dfb 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_transient_Pw_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_transient_Pw_element.cpp @@ -14,6 +14,7 @@ #include "custom_elements/plane_strain_stress_state.h" #include "custom_elements/three_dimensional_stress_state.h" #include "custom_elements/transient_Pw_element.hpp" +#include "custom_retention/saturated_law.h" #include "tests/cpp_tests/geo_mechanics_fast_suite.h" #include "tests/cpp_tests/test_utilities.h" diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_u_pw_small_strain_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_u_pw_small_strain_element.cpp index e9e6baf90821..f69845076950 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_u_pw_small_strain_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_elements/test_u_pw_small_strain_element.cpp @@ -16,6 +16,7 @@ #include "custom_constitutive/small_strain_udsm_law.h" #include "custom_elements/U_Pw_small_strain_element.hpp" #include "custom_elements/plane_strain_stress_state.h" +#include "custom_retention/saturated_law.h" #include "custom_utilities/registration_utilities.h" #include "includes/variables.h" #include "test_setup_utilities/element_setup_utilities.h"