Skip to content

Commit

Permalink
[GeoMechanicsApplication] A 3D elastic constitutive law is lacking in…
Browse files Browse the repository at this point in the history
… GeoMechanicsApplication (#12816)

* renamed GeoLinearElasticPlaneStrain2DLaw to GeoIncrementalLinerLaw

* added elastic_3D law and unit tests

* clang-format

* used GeoLinearElastic3DLaw

* fixed comments

* used GeoIncrementalLinearElastic3DLaw

* response to reviews

* formatted

* fixed an

* removed two lines with ///
  • Loading branch information
markelov208 authored Nov 8, 2024
1 parent 3a22e36 commit 8cdabbc
Show file tree
Hide file tree
Showing 30 changed files with 349 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
// Main authors: Wijtze Pieter Kikstra
// Richard Faasse

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

namespace Kratos
{

GeoLinearElasticPlaneStrain2DLaw::GeoLinearElasticPlaneStrain2DLaw() = default;
GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw() = default;

GeoLinearElasticPlaneStrain2DLaw::GeoLinearElasticPlaneStrain2DLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw(std::unique_ptr<ConstitutiveLawDimension> pConstitutiveDimension)
: GeoLinearElasticLaw{},
mpConstitutiveDimension(std::move(pConstitutiveDimension)),
mStressVector(ZeroVector(mpConstitutiveDimension->GetStrainSize())),
Expand All @@ -29,7 +29,7 @@ GeoLinearElasticPlaneStrain2DLaw::GeoLinearElasticPlaneStrain2DLaw(std::unique_p
{
}

GeoLinearElasticPlaneStrain2DLaw::GeoLinearElasticPlaneStrain2DLaw(const GeoLinearElasticPlaneStrain2DLaw& rOther)
GeoIncrementalLinearElasticLaw::GeoIncrementalLinearElasticLaw(const GeoIncrementalLinearElasticLaw& rOther)
: GeoLinearElasticLaw(rOther),
mStressVector(rOther.mStressVector),
mStressVectorFinalized(rOther.mStressVectorFinalized),
Expand All @@ -41,7 +41,7 @@ GeoLinearElasticPlaneStrain2DLaw::GeoLinearElasticPlaneStrain2DLaw(const GeoLine
mpConstitutiveDimension = rOther.mpConstitutiveDimension->Clone();
}

GeoLinearElasticPlaneStrain2DLaw& GeoLinearElasticPlaneStrain2DLaw::operator=(const GeoLinearElasticPlaneStrain2DLaw& rOther)
GeoIncrementalLinearElasticLaw& GeoIncrementalLinearElasticLaw::operator=(const GeoIncrementalLinearElasticLaw& rOther)
{
GeoLinearElasticLaw::operator=(rOther);
mStressVector = rOther.mStressVector;
Expand All @@ -55,24 +55,23 @@ GeoLinearElasticPlaneStrain2DLaw& GeoLinearElasticPlaneStrain2DLaw::operator=(co
return *this;
}

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

ConstitutiveLaw::Pointer GeoLinearElasticPlaneStrain2DLaw::Clone() const
ConstitutiveLaw::Pointer GeoIncrementalLinearElasticLaw::Clone() const
{
return Kratos::make_shared<GeoLinearElasticPlaneStrain2DLaw>(*this);
return Kratos::make_shared<GeoIncrementalLinearElasticLaw>(*this);
}

bool& GeoLinearElasticPlaneStrain2DLaw::GetValue(const Variable<bool>& rThisVariable, bool& rValue)
bool& GeoIncrementalLinearElasticLaw::GetValue(const Variable<bool>& rThisVariable, bool& rValue)
{
// This Constitutive Law has been checked with Stenberg Stabilization
if (rThisVariable == STENBERG_SHEAR_STABILIZATION_SUITABLE) rValue = true;
return rValue;
}

void GeoLinearElasticPlaneStrain2DLaw::GetLawFeatures(Features& rFeatures)
void GeoIncrementalLinearElasticLaw::GetLawFeatures(Features& rFeatures)
{
rFeatures.mOptions.Set(mpConstitutiveDimension->GetSpatialType());
rFeatures.mOptions.Set(INFINITESIMAL_STRAINS);
Expand All @@ -85,19 +84,19 @@ void GeoLinearElasticPlaneStrain2DLaw::GetLawFeatures(Features& rFeatures)
rFeatures.mSpaceDimension = WorkingSpaceDimension();
}

SizeType GeoLinearElasticPlaneStrain2DLaw::WorkingSpaceDimension()
SizeType GeoIncrementalLinearElasticLaw::WorkingSpaceDimension()
{
return mpConstitutiveDimension->GetDimension();
}

SizeType GeoLinearElasticPlaneStrain2DLaw::GetStrainSize() const
SizeType GeoIncrementalLinearElasticLaw::GetStrainSize() const
{
return mpConstitutiveDimension->GetStrainSize();
}

bool GeoLinearElasticPlaneStrain2DLaw::IsIncremental() { return true; }
bool GeoIncrementalLinearElasticLaw::IsIncremental() { return true; }

void GeoLinearElasticPlaneStrain2DLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
void GeoIncrementalLinearElasticLaw::CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY

Expand All @@ -115,9 +114,9 @@ void GeoLinearElasticPlaneStrain2DLaw::CalculateElasticMatrix(Matrix& C, Constit
KRATOS_CATCH("")
}

void GeoLinearElasticPlaneStrain2DLaw::CalculatePK2Stress(const Vector& rStrainVector,
Vector& rStressVector,
ConstitutiveLaw::Parameters& rValues)
void GeoIncrementalLinearElasticLaw::CalculatePK2Stress(const Vector& rStrainVector,
Vector& rStressVector,
ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY

Expand All @@ -134,9 +133,9 @@ void GeoLinearElasticPlaneStrain2DLaw::CalculatePK2Stress(const Vector& rStrainV
KRATOS_CATCH("")
}

bool GeoLinearElasticPlaneStrain2DLaw::RequiresInitializeMaterialResponse() { return true; }
bool GeoIncrementalLinearElasticLaw::RequiresInitializeMaterialResponse() { return true; }

void GeoLinearElasticPlaneStrain2DLaw::InitializeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues)
void GeoIncrementalLinearElasticLaw::InitializeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues)
{
KRATOS_TRY
if (!mIsModelInitialized) {
Expand All @@ -148,21 +147,21 @@ void GeoLinearElasticPlaneStrain2DLaw::InitializeMaterialResponseCauchy(Constitu
KRATOS_CATCH("")
}

bool GeoLinearElasticPlaneStrain2DLaw::RequiresFinalizeMaterialResponse() { return true; }
bool GeoIncrementalLinearElasticLaw::RequiresFinalizeMaterialResponse() { return true; }

void GeoLinearElasticPlaneStrain2DLaw::FinalizeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues)
void GeoIncrementalLinearElasticLaw::FinalizeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues)
{
mStrainVectorFinalized = rValues.GetStrainVector();
mStressVectorFinalized = mStressVector;
}

void GeoLinearElasticPlaneStrain2DLaw::FinalizeMaterialResponsePK2(ConstitutiveLaw::Parameters& rValues)
void GeoIncrementalLinearElasticLaw::FinalizeMaterialResponsePK2(ConstitutiveLaw::Parameters& rValues)
{
// Small deformation so we can call the Cauchy method
FinalizeMaterialResponseCauchy(rValues);
}

void GeoLinearElasticPlaneStrain2DLaw::save(Serializer& rSerializer) const
void GeoIncrementalLinearElasticLaw::save(Serializer& rSerializer) const
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, GeoLinearElasticLaw)
rSerializer.save("StressVector", mStressVector);
Expand All @@ -172,7 +171,7 @@ void GeoLinearElasticPlaneStrain2DLaw::save(Serializer& rSerializer) const
rSerializer.save("mIsModelInitialized", mIsModelInitialized);
}

void GeoLinearElasticPlaneStrain2DLaw::load(Serializer& rSerializer)
void GeoIncrementalLinearElasticLaw::load(Serializer& rSerializer)
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, GeoLinearElasticLaw)
rSerializer.load("StressVector", mStressVector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ namespace Kratos
class ConstitutiveLawDimension;

/**
* @class GeoLinearElasticPlaneStrain2DLaw
* @class GeoIncrementalLinearElasticLaw
* @ingroup GeoMechanicsApplication
* @brief This class defines a small deformation linear elastic constitutive model for plane strain cases
* @brief This class defines an incremental linear elastic constitutive model for plane strain and 3D cases
* @author Vahid Galavi
*/
class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoLinearElasticPlaneStrain2DLaw : public GeoLinearElasticLaw
class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoIncrementalLinearElasticLaw : public GeoLinearElasticLaw
{
public:
using BaseType = GeoLinearElasticLaw;
using SizeType = std::size_t;

KRATOS_CLASS_POINTER_DEFINITION(GeoLinearElasticPlaneStrain2DLaw);
GeoLinearElasticPlaneStrain2DLaw();
KRATOS_CLASS_POINTER_DEFINITION(GeoIncrementalLinearElasticLaw);
GeoIncrementalLinearElasticLaw();

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

GeoLinearElasticPlaneStrain2DLaw(GeoLinearElasticPlaneStrain2DLaw&& rOther) noexcept;
GeoLinearElasticPlaneStrain2DLaw& operator=(GeoLinearElasticPlaneStrain2DLaw&& rOther) noexcept;
~GeoLinearElasticPlaneStrain2DLaw() override;
GeoIncrementalLinearElasticLaw(GeoIncrementalLinearElasticLaw&& rOther) noexcept;
GeoIncrementalLinearElasticLaw& operator=(GeoIncrementalLinearElasticLaw&& rOther) noexcept;
~GeoIncrementalLinearElasticLaw() override;

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

Expand Down Expand Up @@ -112,6 +112,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoLinearElasticPlaneStrain2DLaw : p
friend class Serializer;
void save(Serializer& rSerializer) const override;
void load(Serializer& rSerializer) override;
}; // Class GeoLinearElasticPlaneStrain2DLaw
}; // Class GeoIncrementalLinearElasticLaw

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma once

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

namespace Kratos
{
Expand Down Expand Up @@ -43,17 +43,16 @@ namespace Kratos
* @details This class derives from the linear elastic case on 3D
* @author Vahid Galavi
*/
class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DBeamLaw : public GeoLinearElasticPlaneStrain2DLaw
class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DBeamLaw : public GeoIncrementalLinearElasticLaw
{
public:
///@name Type Definitions
///@{

/// The base class ConstitutiveLaw type definition
using CLBaseType = ConstitutiveLaw;

/// The base class ElasticIsotropicK03DLaw type definition
using BaseType = GeoLinearElasticPlaneStrain2DLaw;
/// The base class GeoIncrementalLinearElasticLaw type definition
using BaseType = GeoIncrementalLinearElasticLaw;

/// The size type definition
using SizeType = std::size_t;
Expand Down Expand Up @@ -171,12 +170,12 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DBeamLaw : public GeoL

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma once

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

namespace Kratos
{
Expand Down Expand Up @@ -43,17 +43,16 @@ namespace Kratos
* @details This class derives from the linear elastic case on 3D
* @author Vahid Galavi
*/
class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public GeoLinearElasticPlaneStrain2DLaw
class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public GeoIncrementalLinearElasticLaw
{
public:
///@name Type Definitions
///@{

/// The base class ConstitutiveLaw type definition
using CLBaseType = ConstitutiveLaw;

/// The base class ElasticIsotropicK03DLaw type definition
using BaseType = GeoLinearElasticPlaneStrain2DLaw;
/// The base class GeoIncrementalLinearElasticLaw type definition
using BaseType = GeoIncrementalLinearElasticLaw;

/// The size type definition
using SizeType = std::size_t;
Expand Down Expand Up @@ -120,7 +119,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public
* @param rValue a reference to the returned value
* @param rValue output: the value of the specified variable
*/
using GeoLinearElasticPlaneStrain2DLaw::GetValue;
using GeoIncrementalLinearElasticLaw::GetValue;
bool& GetValue(const Variable<bool>& rThisVariable, bool& rValue) override;

///@}
Expand Down Expand Up @@ -189,12 +188,12 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) LinearElastic2DInterfaceLaw : public

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Richard Faasse
// Gennady Markelov
//

#include "three_dimensional.h"

#include "geo_mechanics_application_constants.h"
#include "includes/constitutive_law.h"

namespace Kratos
{

Matrix ThreeDimensional::FillConstitutiveMatrix(double c1, double c2, double c3) const
{
Matrix result = ZeroMatrix(GetStrainSize(), GetStrainSize());

result(INDEX_3D_XX, INDEX_3D_XX) = c1;
result(INDEX_3D_XX, INDEX_3D_YY) = c2;
result(INDEX_3D_XX, INDEX_3D_ZZ) = c2;

result(INDEX_3D_YY, INDEX_3D_XX) = c2;
result(INDEX_3D_YY, INDEX_3D_YY) = c1;
result(INDEX_3D_YY, INDEX_3D_ZZ) = c2;

result(INDEX_3D_ZZ, INDEX_3D_XX) = c2;
result(INDEX_3D_ZZ, INDEX_3D_YY) = c2;
result(INDEX_3D_ZZ, INDEX_3D_ZZ) = c1;

result(INDEX_3D_XY, INDEX_3D_XY) = c3;
result(INDEX_3D_YZ, INDEX_3D_YZ) = c3;
result(INDEX_3D_XZ, INDEX_3D_XZ) = c3;

return result;
}

std::unique_ptr<ConstitutiveLawDimension> ThreeDimensional::Clone() const
{
return std::make_unique<ThreeDimensional>();
}

std::size_t ThreeDimensional::GetStrainSize() const { return VOIGT_SIZE_3D; }

std::size_t ThreeDimensional::GetDimension() const { return N_DIM_3D; }

Flags ThreeDimensional::GetSpatialType() const { return ConstitutiveLaw::THREE_DIMENSIONAL_LAW; }

} // namespace Kratos
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Richard Faasse
// Gennady Markelov
//

#pragma once

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

namespace Kratos
{

class KRATOS_API(GEO_MECHANICS_APPLICATION) ThreeDimensional : public ConstitutiveLawDimension
{
public:
[[nodiscard]] Matrix FillConstitutiveMatrix(double c1, double c2, double c3) const override;
[[nodiscard]] std::unique_ptr<ConstitutiveLawDimension> Clone() const override;
[[nodiscard]] std::size_t GetStrainSize() const override;
[[nodiscard]] std::size_t GetDimension() const override;
[[nodiscard]] Flags GetSpatialType() const override;
};

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ void KratosGeoMechanicsApplication::Register()
KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticPlaneStrainK02DLaw", mLinearPlaneStrainK0Law)
KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElasticK03DLaw", mElasticIsotropicK03DLaw)
KRATOS_REGISTER_CONSTITUTIVE_LAW("GeoLinearElasticPlaneStrain2DLaw", mLinearElasticPlaneStrain2DLaw)
KRATOS_REGISTER_CONSTITUTIVE_LAW("GeoIncrementalLinearElastic3DLaw", mLinearElastic3DLaw)

KRATOS_REGISTER_CONSTITUTIVE_LAW("GeoLinearElasticPlaneStress2DLaw", mLinearElasticPlaneStress2DLaw)

Expand Down
Loading

0 comments on commit 8cdabbc

Please sign in to comment.