From fc5247d072b1ef51400a05a87eaaf315154333de Mon Sep 17 00:00:00 2001 From: rubenzorrilla Date: Tue, 8 Oct 2024 13:42:44 +0200 Subject: [PATCH 1/8] Fixing minor segfaults --- .../custom_elements/U_Pw_base_element.hpp | 8 +- .../U_Pw_small_strain_FIC_element.hpp | 11 ++- .../U_Pw_small_strain_element.hpp | 8 +- ...Pw_small_strain_link_interface_element.hpp | 11 ++- .../U_Pw_updated_lagrangian_FIC_element.hpp | 11 ++- .../U_Pw_updated_lagrangian_element.hpp | 11 ++- .../small_strain_U_Pw_diff_order_element.cpp | 80 +++++++++---------- .../small_strain_U_Pw_diff_order_element.hpp | 20 ++++- .../steady_state_Pw_element.hpp | 11 ++- .../custom_elements/transient_Pw_element.hpp | 11 ++- .../undrained_U_Pw_small_strain_element.hpp | 11 ++- ...ted_lagrangian_U_Pw_diff_order_element.hpp | 11 ++- 12 files changed, 132 insertions(+), 72 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp index 31709eabc97a..a7b655f03f98 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp @@ -138,8 +138,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwBaseElement : public Element std::string Info() const override { + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } return "U-Pw Base class Element #" + std::to_string(Id()) + - "\nConstitutive law: " + mConstitutiveLawVector[0]->Info(); + "\nConstitutive law: " + claw_buffer.str(); } void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp index da623b7d925d..c3474054c25f 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp @@ -105,16 +105,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainFICElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "U-Pw smal strain FIC Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "U-Pw smal strain FIC Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp index c31c63a87e99..e3da56c2dc1b 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp @@ -119,8 +119,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainElement : public UPwBa std::string Info() const override { + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } return "U-Pw small strain Element #" + std::to_string(this->Id()) + - "\nConstitutive law: " + mConstitutiveLawVector[0]->Info(); + "\nConstitutive law: " + claw_buffer.str(); } void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp index 0cecdd0e16eb..57ed04d8b32a 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp @@ -94,16 +94,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainLinkInterfaceElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "U-Pw small strain link interface Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "U-Pw small strain link interface Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp index 55835a7bb8de..d02964b7a9a6 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp @@ -174,16 +174,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwUpdatedLagrangianFICElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "Updated Lagrangian U-Pw FIC Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } /// Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "Updated Lagrangian U-Pw FIC Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } /// Print object's data. diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp index 6346a7919714..61d07d1f2ceb 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp @@ -173,16 +173,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwUpdatedLagrangianElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "Updated Lagrangian U-Pw Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } /// Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "Updated Lagrangian U-Pw Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } /// Print object's data. diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp index 8539144418a1..d5dd5588a39a 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp @@ -170,49 +170,8 @@ void SmallStrainUPwDiffOrderElement::Initialize(const ProcessInfo& rCurrentProce UPwBaseElement::Initialize(rCurrentProcessInfo); - const auto& r_geometry = GetGeometry(); - const auto number_of_U_nodes = r_geometry.PointsNumber(); - const auto dimension = r_geometry.WorkingSpaceDimension(); - - switch (number_of_U_nodes) { - case 6: // 2D T6P3 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2)); - break; - case 8: // 2D Q8P4 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), - r_geometry(2), r_geometry(3)); - break; - case 9: // 2D Q9P4 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), - r_geometry(2), r_geometry(3)); - break; - case 10: // 3D T10P4 //2D T10P6 - if (dimension == 3) - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), - r_geometry(2), r_geometry(3)); - else if (dimension == 2) - mpPressureGeometry = make_shared>( - r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5)); - break; - case 15: // 2D T15P10 - mpPressureGeometry = make_shared>( - r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), - r_geometry(5), r_geometry(6), r_geometry(7), r_geometry(8), r_geometry(9)); - break; - case 20: // 3D H20P8 - mpPressureGeometry = - make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), - r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); - break; - case 27: // 3D H27P8 - mpPressureGeometry = - make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), - r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); - break; - default: - KRATOS_ERROR << "Unexpected geometry type for different order " - "interpolation element" - << this->Id() << std::endl; + if (mpPressureGeometry == nullptr) { + this->SetUpPressureGeometryPointer(); } mIsInitialised = true; @@ -1587,6 +1546,41 @@ Element::DofsVectorType SmallStrainUPwDiffOrderElement::GetDofs() const GetGeometry().WorkingSpaceDimension()); } +void SmallStrainUPwDiffOrderElement::SetUpPressureGeometryPointer() +{ + const auto& r_geometry = GetGeometry(); + const auto number_of_U_nodes = r_geometry.PointsNumber(); + const auto dimension = r_geometry.WorkingSpaceDimension(); + switch (number_of_U_nodes) { + case 6: // 2D T6P3 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2)); + break; + case 8: // 2D Q8P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); + break; + case 9: // 2D Q9P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); + break; + case 10: + if (dimension == 3) // 3D T10P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); + else if (dimension == 2) //2D T10P6 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5)); + break; + case 15: // 2D T15P10 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7), r_geometry(8), r_geometry(9)); + break; + case 20: // 3D H20P8 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); + break; + case 27: // 3D H27P8 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); + break; + default: + KRATOS_ERROR << "Unexpected geometry type for different order interpolation element " << this->Id() << std::endl; + } +} + Vector SmallStrainUPwDiffOrderElement::GetPressureSolutionVector() { Vector result(mpPressureGeometry->PointsNumber()); diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp index 1d527837f50f..9b6be91ea1a4 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp @@ -49,6 +49,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub std::unique_ptr pStressStatePolicy) : UPwBaseElement(NewId, pGeometry, std::move(pStressStatePolicy)) { + this->SetUpPressureGeometryPointer(); } SmallStrainUPwDiffOrderElement(IndexType NewId, @@ -57,6 +58,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub std::unique_ptr pStressStatePolicy) : UPwBaseElement(NewId, pGeometry, pProperties, std::move(pStressStatePolicy)) { + this->SetUpPressureGeometryPointer(); } ~SmallStrainUPwDiffOrderElement() override = default; @@ -109,16 +111,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "U-Pw small strain different order Element #" << Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "U-Pw small strain different order Element #" << Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } protected: @@ -262,6 +269,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub [[nodiscard]] DofsVectorType GetDofs() const override; + /** + * @brief Sets the up the pressure geometry pointer object + * This function sets the pointer for the auxiliary geometry for the pressure problem + * The pressure geometry pointer is set according to the element geometry number of nodes and dimension + */ + void SetUpPressureGeometryPointer(); + // Serialization friend class Serializer; diff --git a/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp b/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp index d05eaa60b071..db38d0b786aa 100644 --- a/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp @@ -95,16 +95,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SteadyStatePwElement : public Transi std::string Info() const override { std::stringstream buffer; + std::stringstream retention_law_buffer; + if (mConstitutiveLawVector.size() != 0) { + retention_law_buffer << mRetentionLawVector[0]->Info(); + } else { + retention_law_buffer << "not defined"; + } buffer << "steady-state Pw flow Element #" << this->Id() - << "\nRetention law: " << mRetentionLawVector[0]->Info(); + << "\nRetention law: " << retention_law_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "steady-state Pw flow Element #" << this->Id() - << "\nRetention law: " << mRetentionLawVector[0]->Info(); + rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp index 4ec4421c1d2a..31b91e03bad7 100644 --- a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp @@ -119,16 +119,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwElement : public UPwSmall std::string Info() const override { std::stringstream buffer; + std::stringstream retention_law_buffer; + if (mConstitutiveLawVector.size() != 0) { + retention_law_buffer << mRetentionLawVector[0]->Info(); + } else { + retention_law_buffer << "not defined"; + } buffer << "transient Pw flow Element #" << this->Id() - << "\nRetention law: " << mRetentionLawVector[0]->Info(); + << "\nRetention law: " << retention_law_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "transient Pw flow Element #" << this->Id() - << "\nRetention law: " << mRetentionLawVector[0]->Info(); + rOStream << Info(); } protected: diff --git a/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp b/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp index 0f41dbc5ffcd..7502a6e6f3ff 100644 --- a/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp @@ -96,16 +96,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UndrainedUPwSmallStrainElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "undrained small strain Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } // Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "undrained small strain Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp index 4f52788b77af..61466d05d540 100644 --- a/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp @@ -162,16 +162,21 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UpdatedLagrangianUPwDiffOrderElement std::string Info() const override { std::stringstream buffer; + std::stringstream claw_buffer; + if (mConstitutiveLawVector.size() != 0) { + claw_buffer << mConstitutiveLawVector[0]->Info(); + } else { + claw_buffer << "not defined"; + } buffer << "Updated Lagrangian U-Pw different order Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + << "\nConstitutive law: " << claw_buffer.str(); return buffer.str(); } /// Print information about this object. void PrintInfo(std::ostream& rOStream) const override { - rOStream << "Updated Lagrangian U-Pw different order Element #" << this->Id() - << "\nConstitutive law: " << mConstitutiveLawVector[0]->Info(); + rOStream << Info(); } /// Print object's data. From 390e93c1e934c158cda7c6cdb17f789e849c4bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Tue, 8 Oct 2024 18:30:40 +0200 Subject: [PATCH 2/8] Update applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp Co-authored-by: Richard Faasse <56549273+rfaasse@users.noreply.github.com> --- .../custom_elements/small_strain_U_Pw_diff_order_element.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp index d5dd5588a39a..0cfa115f7293 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp @@ -170,8 +170,7 @@ void SmallStrainUPwDiffOrderElement::Initialize(const ProcessInfo& rCurrentProce UPwBaseElement::Initialize(rCurrentProcessInfo); - if (mpPressureGeometry == nullptr) { - this->SetUpPressureGeometryPointer(); + KRATOS_DEBUG_ERROR_IF_NOT(mpPressureGeometry) << "Pressure Geometry is not defined\n"; } mIsInitialised = true; From 70edc9a3e0fc85b54cd969a152aed4e9472c92b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Tue, 8 Oct 2024 18:30:48 +0200 Subject: [PATCH 3/8] Update applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp Co-authored-by: Richard Faasse <56549273+rfaasse@users.noreply.github.com> --- .../custom_elements/U_Pw_base_element.hpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp index a7b655f03f98..407ca52bdc19 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp @@ -138,12 +138,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwBaseElement : public Element std::string Info() const override { - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } + const std::string constitutive_info = !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; return "U-Pw Base class Element #" + std::to_string(Id()) + "\nConstitutive law: " + claw_buffer.str(); } From cdbcbe07c4cf840fd8dc4faf6d4dbef4beb29ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Tue, 8 Oct 2024 18:31:46 +0200 Subject: [PATCH 4/8] Update applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp Co-authored-by: Richard Faasse <56549273+rfaasse@users.noreply.github.com> --- .../custom_elements/small_strain_U_Pw_diff_order_element.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp index 9b6be91ea1a4..74001a269265 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp @@ -49,7 +49,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub std::unique_ptr pStressStatePolicy) : UPwBaseElement(NewId, pGeometry, std::move(pStressStatePolicy)) { - this->SetUpPressureGeometryPointer(); + SetUpPressureGeometryPointer(); } SmallStrainUPwDiffOrderElement(IndexType NewId, From 93a72cddf286a03293ebb37eee19ec3552a5ca4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Tue, 8 Oct 2024 18:31:52 +0200 Subject: [PATCH 5/8] Update applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp Co-authored-by: Richard Faasse <56549273+rfaasse@users.noreply.github.com> --- .../custom_elements/small_strain_U_Pw_diff_order_element.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp index 74001a269265..4386f05280c1 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp @@ -58,7 +58,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub std::unique_ptr pStressStatePolicy) : UPwBaseElement(NewId, pGeometry, pProperties, std::move(pStressStatePolicy)) { - this->SetUpPressureGeometryPointer(); + SetUpPressureGeometryPointer(); } ~SmallStrainUPwDiffOrderElement() override = default; From a0ae1f295171861aa5bde2044d3064f3a939b947 Mon Sep 17 00:00:00 2001 From: rubenzorrilla Date: Wed, 9 Oct 2024 06:30:13 +0200 Subject: [PATCH 6/8] Minors --- .../custom_elements/U_Pw_base_element.hpp | 3 +-- .../small_strain_U_Pw_diff_order_element.cpp | 17 +++-------------- .../small_strain_U_Pw_diff_order_element.hpp | 2 -- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp index 407ca52bdc19..f5f3f6879c99 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp @@ -139,8 +139,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwBaseElement : public Element std::string Info() const override { const std::string constitutive_info = !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; - return "U-Pw Base class Element #" + std::to_string(Id()) + - "\nConstitutive law: " + claw_buffer.str(); + return "U-Pw Base class Element #" + std::to_string(Id()) + "\nConstitutive law: " + constitutive_info; } void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp index 0cfa115f7293..1c0fccfcf7db 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp @@ -61,6 +61,9 @@ int SmallStrainUPwDiffOrderElement::Check(const ProcessInfo& rCurrentProcessInfo if (rGeom.DomainSize() < 1.0e-15) KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl; + // check pressure geometry pointer + KRATOS_DEBUG_ERROR_IF_NOT(mpPressureGeometry) << "Pressure Geometry is not defined\n"; + // verify that the variables are correctly initialized // Verify specific properties const PropertiesType& rProp = this->GetProperties(); @@ -164,20 +167,6 @@ int SmallStrainUPwDiffOrderElement::Check(const ProcessInfo& rCurrentProcessInfo KRATOS_CATCH("") } -void SmallStrainUPwDiffOrderElement::Initialize(const ProcessInfo& rCurrentProcessInfo) -{ - KRATOS_TRY - - UPwBaseElement::Initialize(rCurrentProcessInfo); - - KRATOS_DEBUG_ERROR_IF_NOT(mpPressureGeometry) << "Pressure Geometry is not defined\n"; - } - - mIsInitialised = true; - - KRATOS_CATCH("") -} - void SmallStrainUPwDiffOrderElement::InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp index 4386f05280c1..04b166bb19ec 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp @@ -71,8 +71,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub int Check(const ProcessInfo& rCurrentProcessInfo) const override; - void Initialize(const ProcessInfo& rCurrentProcessInfo) override; - void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; From f47e794856e11af05bf9c7c9ede199fc21fa1978 Mon Sep 17 00:00:00 2001 From: Richard Faasse Date: Wed, 9 Oct 2024 16:43:41 +0200 Subject: [PATCH 7/8] Simplified the segfault fixes + clang-format --- .../custom_elements/U_Pw_base_element.hpp | 3 +- .../U_Pw_small_strain_FIC_element.hpp | 18 ++--- .../U_Pw_small_strain_element.hpp | 11 +-- ...Pw_small_strain_link_interface_element.hpp | 19 ++--- .../U_Pw_updated_lagrangian_FIC_element.hpp | 19 ++--- .../U_Pw_updated_lagrangian_element.hpp | 19 ++--- .../small_strain_U_Pw_diff_order_element.cpp | 69 +++++++++++-------- .../small_strain_U_Pw_diff_order_element.hpp | 19 ++--- .../steady_state_Pw_element.hpp | 18 ++--- .../custom_elements/transient_Pw_element.hpp | 17 ++--- .../undrained_U_Pw_small_strain_element.hpp | 19 ++--- ...ted_lagrangian_U_Pw_diff_order_element.hpp | 19 ++--- 12 files changed, 87 insertions(+), 163 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp index f5f3f6879c99..1eb946ce3248 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_base_element.hpp @@ -138,7 +138,8 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwBaseElement : public Element std::string Info() const override { - const std::string constitutive_info = !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; return "U-Pw Base class Element #" + std::to_string(Id()) + "\nConstitutive law: " + constitutive_info; } diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp index c3474054c25f..6c6a0c78584b 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.hpp @@ -104,23 +104,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainFICElement // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "U-Pw smal strain FIC Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "U-Pw smal strain FIC Element #" + std::to_string(this->Id()) + "\nConstitutive law: " + constitutive_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp index e3da56c2dc1b..30171d873dfe 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp @@ -119,14 +119,9 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainElement : public UPwBa std::string Info() const override { - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - return "U-Pw small strain Element #" + std::to_string(this->Id()) + - "\nConstitutive law: " + claw_buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "U-Pw small strain Element #" + std::to_string(this->Id()) + "\nConstitutive law: " + constitutive_info; } void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp index 57ed04d8b32a..c398f532f3dc 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_link_interface_element.hpp @@ -93,23 +93,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwSmallStrainLinkInterfaceElement // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "U-Pw small strain link interface Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "U-Pw small strain link interface Element #" + std::to_string(this->Id()) + + "\nConstitutive law: " + constitutive_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp index d02964b7a9a6..266ef090f898 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.hpp @@ -173,23 +173,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwUpdatedLagrangianFICElement /// Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "Updated Lagrangian U-Pw FIC Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "Updated Lagrangian U-Pw FIC Element #" + std::to_string(this->Id()) + + "\nConstitutive law: " + constitutive_info; } /// Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } /// Print object's data. void PrintData(std::ostream& rOStream) const override diff --git a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp index 61d07d1f2ceb..fdf802f3f699 100644 --- a/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.hpp @@ -172,23 +172,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UPwUpdatedLagrangianElement /// Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "Updated Lagrangian U-Pw Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "Updated Lagrangian U-Pw Element #" + std::to_string(this->Id()) + + "\nConstitutive law: " + constitutive_info; } /// Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } /// Print object's data. void PrintData(std::ostream& rOStream) const override diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp index 1c0fccfcf7db..8c8d588186cd 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp @@ -1536,36 +1536,47 @@ Element::DofsVectorType SmallStrainUPwDiffOrderElement::GetDofs() const void SmallStrainUPwDiffOrderElement::SetUpPressureGeometryPointer() { - const auto& r_geometry = GetGeometry(); - const auto number_of_U_nodes = r_geometry.PointsNumber(); - const auto dimension = r_geometry.WorkingSpaceDimension(); + const auto& r_geometry = GetGeometry(); + const auto number_of_U_nodes = r_geometry.PointsNumber(); + const auto dimension = r_geometry.WorkingSpaceDimension(); switch (number_of_U_nodes) { - case 6: // 2D T6P3 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2)); - break; - case 8: // 2D Q8P4 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); - break; - case 9: // 2D Q9P4 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); - break; - case 10: - if (dimension == 3) // 3D T10P4 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3)); - else if (dimension == 2) //2D T10P6 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5)); - break; - case 15: // 2D T15P10 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7), r_geometry(8), r_geometry(9)); - break; - case 20: // 3D H20P8 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); - break; - case 27: // 3D H27P8 - mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); - break; - default: - KRATOS_ERROR << "Unexpected geometry type for different order interpolation element " << this->Id() << std::endl; + case 6: // 2D T6P3 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), r_geometry(2)); + break; + case 8: // 2D Q8P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), + r_geometry(2), r_geometry(3)); + break; + case 9: // 2D Q9P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), + r_geometry(2), r_geometry(3)); + break; + case 10: + if (dimension == 3) // 3D T10P4 + mpPressureGeometry = make_shared>(r_geometry(0), r_geometry(1), + r_geometry(2), r_geometry(3)); + else if (dimension == 2) // 2D T10P6 + mpPressureGeometry = make_shared>( + r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), r_geometry(5)); + break; + case 15: // 2D T15P10 + mpPressureGeometry = make_shared>( + r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), r_geometry(4), + r_geometry(5), r_geometry(6), r_geometry(7), r_geometry(8), r_geometry(9)); + break; + case 20: // 3D H20P8 + mpPressureGeometry = + make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), + r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); + break; + case 27: // 3D H27P8 + mpPressureGeometry = + make_shared>(r_geometry(0), r_geometry(1), r_geometry(2), r_geometry(3), + r_geometry(4), r_geometry(5), r_geometry(6), r_geometry(7)); + break; + default: + KRATOS_ERROR << "Unexpected geometry type for different order interpolation element " + << this->Id() << std::endl; } } diff --git a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp index 04b166bb19ec..0aaf1fc9febf 100644 --- a/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.hpp @@ -108,23 +108,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SmallStrainUPwDiffOrderElement : pub // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "U-Pw small strain different order Element #" << Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "U-Pw small strain different order Element #" + std::to_string(Id()) + + "\nConstitutive law: " + constitutive_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } protected: struct ElementVariables { diff --git a/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp b/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp index db38d0b786aa..2321e7a11d6f 100644 --- a/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_element.hpp @@ -94,23 +94,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SteadyStatePwElement : public Transi // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream retention_law_buffer; - if (mConstitutiveLawVector.size() != 0) { - retention_law_buffer << mRetentionLawVector[0]->Info(); - } else { - retention_law_buffer << "not defined"; - } - buffer << "steady-state Pw flow Element #" << this->Id() - << "\nRetention law: " << retention_law_buffer.str(); - return buffer.str(); + const std::string retention_info = + !mRetentionLawVector.empty() ? mRetentionLawVector[0]->Info() : "not defined"; + return "steady-state Pw flow Element #" + std::to_string(this->Id()) + "\nRetention law: " + retention_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp index 31b91e03bad7..b9b16903342e 100644 --- a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp @@ -119,22 +119,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwElement : public UPwSmall std::string Info() const override { std::stringstream buffer; - std::stringstream retention_law_buffer; - if (mConstitutiveLawVector.size() != 0) { - retention_law_buffer << mRetentionLawVector[0]->Info(); - } else { - retention_law_buffer << "not defined"; - } - buffer << "transient Pw flow Element #" << this->Id() - << "\nRetention law: " << retention_law_buffer.str(); - return buffer.str(); + const std::string retention_info = + !mRetentionLawVector.empty() ? mRetentionLawVector[0]->Info() : "not defined"; + return "transient Pw flow Element #" + std::to_string(this->Id()) + "\nRetention law: " + retention_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } protected: void CalculateAll(MatrixType& rLeftHandSideMatrix, diff --git a/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp b/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp index 7502a6e6f3ff..950c9132b3ee 100644 --- a/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/undrained_U_Pw_small_strain_element.hpp @@ -95,23 +95,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UndrainedUPwSmallStrainElement // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "undrained small strain Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "undrained small strain Element #" + std::to_string(this->Id()) + + "\nConstitutive law: " + constitutive_info; } // Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } ///---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp b/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp index 61466d05d540..76c1c439efe1 100644 --- a/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.hpp @@ -161,23 +161,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) UpdatedLagrangianUPwDiffOrderElement /// Turn back information as a string. std::string Info() const override { - std::stringstream buffer; - std::stringstream claw_buffer; - if (mConstitutiveLawVector.size() != 0) { - claw_buffer << mConstitutiveLawVector[0]->Info(); - } else { - claw_buffer << "not defined"; - } - buffer << "Updated Lagrangian U-Pw different order Element #" << this->Id() - << "\nConstitutive law: " << claw_buffer.str(); - return buffer.str(); + const std::string constitutive_info = + !mConstitutiveLawVector.empty() ? mConstitutiveLawVector[0]->Info() : "not defined"; + return "Updated Lagrangian U-Pw different order Element #" + std::to_string(this->Id()) + + "\nConstitutive law: " + constitutive_info; } /// Print information about this object. - void PrintInfo(std::ostream& rOStream) const override - { - rOStream << Info(); - } + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } /// Print object's data. void PrintData(std::ostream& rOStream) const override From 3bee49954554da07c7cfbf34c342e62641661bdd Mon Sep 17 00:00:00 2001 From: Richard Faasse Date: Thu, 10 Oct 2024 11:53:36 +0200 Subject: [PATCH 8/8] Removed unused local variable --- .../custom_elements/transient_Pw_element.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp index b9b16903342e..baddcafbf21f 100644 --- a/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp +++ b/applications/GeoMechanicsApplication/custom_elements/transient_Pw_element.hpp @@ -118,7 +118,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwElement : public UPwSmall // Turn back information as a string. std::string Info() const override { - std::stringstream buffer; const std::string retention_info = !mRetentionLawVector.empty() ? mRetentionLawVector[0]->Info() : "not defined"; return "transient Pw flow Element #" + std::to_string(this->Id()) + "\nRetention law: " + retention_info;