Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@
//

#include "incremental_linear_elastic_interface_law.h"
#include "constitutive_law_dimension.h"
#include "custom_utilities/check_utilities.h"
#include "geo_mechanics_application_constants.h"
#include "geo_mechanics_application_variables.h"

namespace Kratos
{

GeoIncrementalLinearElasticInterfaceLaw::~GeoIncrementalLinearElasticInterfaceLaw() = default;

GeoIncrementalLinearElasticInterfaceLaw::GeoIncrementalLinearElasticInterfaceLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveLawDimension)
: mpConstitutiveLawDimension(std::move(pConstitutiveLawDimension))
{
}

ConstitutiveLaw::Pointer GeoIncrementalLinearElasticInterfaceLaw::Clone() const
{
return std::make_shared<GeoIncrementalLinearElasticInterfaceLaw>(mpConstitutiveLawDimension->Clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@

#pragma once

#include "constitutive_law_dimension.h"
#include "includes/constitutive_law.h"
#include "includes/kratos_export_api.h"

namespace Kratos
{
class ConstitutiveLawDimension;

class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoIncrementalLinearElasticInterfaceLaw : public ConstitutiveLaw
{
public:
using BaseType = ConstitutiveLaw;

explicit GeoIncrementalLinearElasticInterfaceLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveLawDimension)
: mpConstitutiveLawDimension(std::move(pConstitutiveLawDimension))
{
}
explicit GeoIncrementalLinearElasticInterfaceLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveLawDimension);

~GeoIncrementalLinearElasticInterfaceLaw() override = default;
~GeoIncrementalLinearElasticInterfaceLaw() override;
GeoIncrementalLinearElasticInterfaceLaw(const GeoIncrementalLinearElasticInterfaceLaw&) = delete;
GeoIncrementalLinearElasticInterfaceLaw& operator=(const GeoIncrementalLinearElasticInterfaceLaw&) = delete;
GeoIncrementalLinearElasticInterfaceLaw(GeoIncrementalLinearElasticInterfaceLaw&&) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Richard Faasse

#include "custom_constitutive/incremental_linear_elastic_law.h"
#include "constitutive_law_dimension.h"
#include "geo_mechanics_application_variables.h"

namespace
Expand Down Expand Up @@ -49,8 +48,6 @@ void SetShearEntriesToZero(Matrix& rMatrix, std::size_t NumberOfNormalComponents
namespace Kratos
{

GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw() = default;

GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
: GeoLinearElasticLaw{},
mpConstitutiveDimension(std::move(pConstitutiveDimension)),
Expand Down Expand Up @@ -87,10 +84,6 @@ GeoIncrementalLinearElasticLaw& GeoIncrementalLinearElasticLaw::operator=(const
return *this;
}

GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw(GeoIncrementalLinearElasticLaw&& rOther) noexcept = default;
GeoIncrementalLinearElasticLaw& GeoIncrementalLinearElasticLaw::operator=(GeoIncrementalLinearElasticLaw&& rOther) noexcept = default;
GeoIncrementalLinearElasticLaw::~GeoIncrementalLinearElasticLaw() = default;

ConstitutiveLaw::Pointer GeoIncrementalLinearElasticLaw::Clone() const
{
return Kratos::make_shared<GeoIncrementalLinearElasticLaw>(*this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

#pragma once

#include "constitutive_law_dimension.h"
#include "custom_constitutive/linear_elastic_law.h"
#include "geo_mechanics_application_constants.h"

namespace Kratos
{

class ConstitutiveLawDimension;

/**
* @class GeoIncrementalLinearElasticLaw
* @ingroup GeoMechanicsApplication
Expand All @@ -33,15 +30,15 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoIncrementalLinearElasticLaw : pub
using SizeType = std::size_t;

KRATOS_CLASS_POINTER_DEFINITION(GeoIncrementalLinearElasticLaw);
GeoIncrementalLinearElasticLaw();
GeoIncrementalLinearElasticLaw() = default;

explicit GeoIncrementalLinearElasticLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension);
GeoIncrementalLinearElasticLaw(const GeoIncrementalLinearElasticLaw& rOther);
GeoIncrementalLinearElasticLaw& operator=(const GeoIncrementalLinearElasticLaw& rOther);

GeoIncrementalLinearElasticLaw(GeoIncrementalLinearElasticLaw&& rOther) noexcept;
GeoIncrementalLinearElasticLaw& operator=(GeoIncrementalLinearElasticLaw&& rOther) noexcept;
~GeoIncrementalLinearElasticLaw() override;
GeoIncrementalLinearElasticLaw(GeoIncrementalLinearElasticLaw&& rOther) noexcept = default;
GeoIncrementalLinearElasticLaw& operator=(GeoIncrementalLinearElasticLaw&& rOther) noexcept = default;
~GeoIncrementalLinearElasticLaw() override = default;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed in the other thread, the default destructor in case of forward declaration is the exception, that one needs to be in the cpp file, such that we can forward declare ConstitutiveLawDimension and have the include in the cpp file instead of here in the header (and improve compilation times)

I added comments to explain this in other places (see e.g. https://github.com/KratosMultiphysics/Kratos/blob/master/applications/GeoMechanicsApplication/custom_workflows/time_loop_executor.cpp#L24-L26), but here it might've been unclear, apologies.

So if you could move the relevant default destructors to the cpp (so only the ones that are needed to be able to compile forward declared unique pointer member variables), I think this PR is good to go!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Richard, I move the destructor for GeoIncrementalLinearElasticInterfaceLaw. As well I removed a false forward declaration in small_strain_udsm/umat_law.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Richard, please could you take a look on code smells due to my recent changes? Thank you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi Gennady, yes, having the destructor in the cpp file results in a code smell, but in my opinion it's worth it due to being able to forward declare classes. If you and/or @avdg81 disagree, we could discuss or revert.


[[nodiscard]] ConstitutiveLaw::Pointer Clone() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ void LinearElastic2DBeamLaw::GetLawFeatures(Features& rFeatures)
rFeatures.mSpaceDimension = WorkingSpaceDimension();
}

SizeType LinearElastic2DBeamLaw::WorkingSpaceDimension() { return N_DIM_2D; }

SizeType LinearElastic2DBeamLaw::GetStrainSize() const { return VOIGT_SIZE_2D_PLANE_STRESS; }

void LinearElastic2DBeamLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY
Expand Down Expand Up @@ -90,4 +94,13 @@ void LinearElastic2DBeamLaw::CalculatePK2Stress(const Vector& rSt
KRATOS_CATCH("")
}

void LinearElastic2DBeamLaw::save(Serializer& rSerializer) const
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}

void LinearElastic2DBeamLaw::load(Serializer& rSerializer)
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DBeamLaw : public GeoI
* @brief Dimension of the law:
* @return The dimension were the law is working
*/
SizeType WorkingSpaceDimension() override { return N_DIM_2D; }
SizeType WorkingSpaceDimension() override;

/**
* @brief Voigt tensor size:
* @return The size of the strain vector in Voigt notation
*/
SizeType GetStrainSize() const override { return VOIGT_SIZE_2D_PLANE_STRESS; }
SizeType GetStrainSize() const override;

///@}
///@name Access
Expand Down Expand Up @@ -168,15 +168,10 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DBeamLaw : public GeoI
///@{
friend class Serializer;

void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}
void save(Serializer& rSerializer) const override;

void load(Serializer& rSerializer) override;

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
}; // Class LinearElastic2DBeamLaw

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ void LinearElastic2DInterfaceLaw::GetLawFeatures(Features& rFeatures)
rFeatures.mSpaceDimension = WorkingSpaceDimension();
}

SizeType LinearElastic2DInterfaceLaw::WorkingSpaceDimension() { return Dimension; }

SizeType LinearElastic2DInterfaceLaw::GetStrainSize() const { return VOIGT_SIZE_2D_INTERFACE; }

void LinearElastic2DInterfaceLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY
Expand Down Expand Up @@ -84,4 +88,13 @@ void LinearElastic2DInterfaceLaw::CalculatePK2Stress(const Vector&
KRATOS_CATCH("")
}

void LinearElastic2DInterfaceLaw::save(Serializer& rSerializer) const
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}

void LinearElastic2DInterfaceLaw::load(Serializer& rSerializer)
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
} // Namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// Project includes
#include "custom_constitutive/incremental_linear_elastic_law.h"
#include "geo_mechanics_application_constants.h"

namespace Kratos
{
Expand Down Expand Up @@ -89,13 +90,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public
* @brief Dimension of the law:
* @return The dimension were the law is working
*/
SizeType WorkingSpaceDimension() override { return Dimension; }
SizeType WorkingSpaceDimension() override;

/**
* @brief Voigt tensor size:
* @return The size of the strain vector in Voigt notation
*/
SizeType GetStrainSize() const override { return VOIGT_SIZE_2D_INTERFACE; }
SizeType GetStrainSize() const override;

///@}
///@name Access
Expand Down Expand Up @@ -186,15 +187,10 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public
///@{
friend class Serializer;

void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}
void save(Serializer& rSerializer) const override;

void load(Serializer& rSerializer) override;

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
}; // Class LinearElastic2DInterfaceLaw

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ void LinearElastic3DInterfaceLaw::GetLawFeatures(Features& rFeatures)
rFeatures.mSpaceDimension = WorkingSpaceDimension();
}

SizeType LinearElastic3DInterfaceLaw::WorkingSpaceDimension() { return Dimension; }

SizeType LinearElastic3DInterfaceLaw::GetStrainSize() const { return VOIGT_SIZE_3D_INTERFACE; }

void LinearElastic3DInterfaceLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY
Expand Down Expand Up @@ -86,4 +90,13 @@ void LinearElastic3DInterfaceLaw::CalculatePK2Stress(const Vector&
KRATOS_CATCH("")
}

void LinearElastic3DInterfaceLaw::save(Serializer& rSerializer) const
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, LinearElastic2DInterfaceLaw)
}

void LinearElastic3DInterfaceLaw::load(Serializer& rSerializer)
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, LinearElastic2DInterfaceLaw)
}
} // Namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic3DInterfaceLaw : public
* @brief Dimension of the law:
* @return The dimension were the law is working
*/
SizeType WorkingSpaceDimension() override { return Dimension; }
SizeType WorkingSpaceDimension() override;

/**
* @brief Voigt tensor size:
* @return The size of the strain vector in Voigt notation
*/
SizeType GetStrainSize() const override { return VOIGT_SIZE_3D_INTERFACE; }
SizeType GetStrainSize() const override;

///@}
///@name Access
Expand Down Expand Up @@ -187,14 +187,9 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic3DInterfaceLaw : public
///@{
friend class Serializer;

void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, LinearElastic2DInterfaceLaw)
}
void save(Serializer& rSerializer) const override;

void load(Serializer& rSerializer) override;

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, LinearElastic2DInterfaceLaw)
}
}; // Class LinearElastic2DInterfaceLaw
} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ void GeoLinearElasticPlaneStress2DLaw::GetLawFeatures(Features& rFeatures)
rFeatures.mSpaceDimension = 2;
}

SizeType GeoLinearElasticPlaneStress2DLaw::WorkingSpaceDimension() { return Dimension; };

SizeType GeoLinearElasticPlaneStress2DLaw::GetStrainSize() const { return VoigtSize; }

void GeoLinearElasticPlaneStress2DLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
{
const Properties& r_material_properties = rValues.GetMaterialProperties();
Expand Down Expand Up @@ -76,4 +80,13 @@ void GeoLinearElasticPlaneStress2DLaw::CalculatePK2Stress(const Vector& rStrainV
noalias(rStressVector) = prod(C, rStrainVector);
}

void GeoLinearElasticPlaneStress2DLaw::save(Serializer& rSerializer) const
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}

void GeoLinearElasticPlaneStress2DLaw::load(Serializer& rSerializer)
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoLinearElasticPlaneStress2DLaw : p
/**
* Dimension of the law:
*/
SizeType WorkingSpaceDimension() override { return Dimension; };
SizeType WorkingSpaceDimension() override;

/**
* Voigt tensor size:
*/
SizeType GetStrainSize() const override { return VoigtSize; }
SizeType GetStrainSize() const override;

///@}
///@name Access
Expand Down Expand Up @@ -181,15 +181,10 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoLinearElasticPlaneStress2DLaw : p
///@{
friend class Serializer;

void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType)
}
void save(Serializer& rSerializer) const override;

void load(Serializer& rSerializer) override;

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType)
}
}; // Class GeoLinearElasticPlaneStress2DLaw

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace
{

using namespace Kratos;
using namespace std::string_literals;

indexStress3D GetIndex3D(const indexStress2DInterface Index2D)
{
Expand Down Expand Up @@ -138,7 +139,7 @@ SizeType SmallStrainUDSM2DInterfaceLaw::WorkingSpaceDimension() { return N_DIM_2

SizeType SmallStrainUDSM2DInterfaceLaw::GetStrainSize() const { return VOIGT_SIZE_2D_INTERFACE; }

std::string SmallStrainUDSM2DInterfaceLaw::Info() const { return "SmallStrainUDSM2DInterfaceLaw"; }
std::string SmallStrainUDSM2DInterfaceLaw::Info() const { return "SmallStrainUDSM2DInterfaceLaw"s; }

void SmallStrainUDSM2DInterfaceLaw::PrintData(std::ostream& rOStream) const
{
Expand Down
Loading
Loading