KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
991 stars 244 forks source link

[GeoMechanicsApplication] Refactor Linear Elastic law to extract a policy for 2D behavior #12396

Open rfaasse opened 1 month ago

rfaasse commented 1 month ago

As a developer, I would like to move the GeoLinearElasticPlaneStrain2DLaw to a more suitable place in the inheritance structure and extract the 2D specific behavior, such that I can conveniently add 3D functionality to this class.

Required for 3D soil-structure interaction

Successor: #12336

Proposed steps:

  1. Make sure the GeoLinearElasticPlaneStrain2DLaw does not derive from a K0 law anymore
  2. Identify the behavior that's dimension specific (should that be part of the refinement?)
  3. Create a policy we can inject into the GeoLinearElasticPlaneStrain2DLaw (which should then be renamed to something more generic)
  4. Capture the 2D plane strain behavior in the policy, later on easily extendible to 3D and maybe axisymmetric
  5. Register the laws with an abstract pointer to the policy.

Acceptance Criteria

Background information Functions the GeoLinearElasticPlaneStrain2DLaw overrides:

public:
ConstitutiveLaw::Pointer Clone() const override;
bool RequiresInitializeMaterialResponse() override;
void InitializeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override;
bool RequiresFinalizeMaterialResponse() override;
void FinalizeMaterialResponseCauchy(ConstitutiveLaw::Parameters& rValues) override;
void FinalizeMaterialResponsePK2(ConstitutiveLaw::Parameters& rValues) override;
void GetLawFeatures(Features& rFeatures) override;
SizeType WorkingSpaceDimension() override;
SizeType GetStrainSize() const override;
bool IsIncremental() override;
bool& GetValue(const Variable<bool>& rThisVariable, bool& rValue) override;

protected:
void CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues) override;
void CalculatePK2Stress(const Vector&                rStrainVector,
                        Vector&                      rStressVector,
                        ConstitutiveLaw::Parameters& rValues) override;

Functions its base LinearPlaneStrainK0Law overrides:

public:
ConstitutiveLaw::Pointer Clone() const override;
void GetLawFeatures(Features& rFeatures) override;
SizeType WorkingSpaceDimension() override { return Dimension; };
SizeType GetStrainSize() const override { return VoigtSize; }
bool& GetValue(const Variable<bool>& rThisVariable, bool& rValue) override;

protected:    
void CalculateElasticMatrix(Matrix& C, ConstitutiveLaw::Parameters& rValues) override;
void CalculatePK2Stress(const Vector&                rStrainVector,
                        Vector&                      rStressVector,
                        ConstitutiveLaw::Parameters& rValues) override;
void CalculateCauchyGreenStrain(ConstitutiveLaw::Parameters& rValues, Vector& rStrainVector) override;

The only one the K0 version has, that the 2D version doesn't have is the CalculateCauchyGreenStrain function. If it would have that function, we could move it in the inheritance structure to derive from GeoLinearElasticLaw directly. This should be relatively small effort, so we could look at the possibility of extending this class to have 3D functionality.