Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GeoMechanicsApplication] Implement well constitutive behaviour for line thermal element #12370

Merged
merged 24 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab61bc8
Merge branch 'master' into geo/12322-implement-well-element
mnabideltares May 7, 2024
ec7889a
Added constutative behaviour
mnabideltares May 9, 2024
f684843
Merge branch 'master' into geo/12322-implement-well-element
mnabideltares May 9, 2024
22bbea7
Added test cases for the filter element
mnabideltares May 10, 2024
12a2a88
A fix in test case
mnabideltares May 10, 2024
888f3af
README.md is added for the test cases
mnabideltares May 10, 2024
507de31
Fix in readme
mnabideltares May 10, 2024
a318f95
modifications based on review
mnabideltares May 11, 2024
33eabb4
Modifications based on review comments
mnabideltares May 13, 2024
9550840
Fix based on review
mnabideltares May 13, 2024
77a23f9
fixes based on review comments
mnabideltares May 13, 2024
765bdbe
fixes based or review
mnabideltares May 13, 2024
d09c3ba
Fix in unit-test for thermal filter constitutive law
mnabideltares May 13, 2024
6be0896
Addressed review comments
mnabideltares May 14, 2024
370b2a4
clang format
mnabideltares May 14, 2024
8a45f84
THERMAL_LAW is added, GeoThermalLaw base class is defined. Dispersion…
mnabideltares May 15, 2024
03b58e8
In the case of missing thermal_law, the dispersion-law is set as default
mnabideltares May 15, 2024
7f2d444
fixed code smells
mnabideltares May 15, 2024
06b93a9
fixes to avoid WError
mnabideltares May 16, 2024
18493b1
Fixes for WError's
mnabideltares May 16, 2024
f5a2a2e
Addressed changes based on review
mnabideltares May 16, 2024
9831df4
Modifications based on review
mnabideltares May 16, 2024
0a76620
minor fixes based on review
mnabideltares May 17, 2024
ff656e0
minor fix for code smell
mnabideltares May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,16 @@
namespace Kratos
{

GeoThermalDispersionLaw::GeoThermalDispersionLaw() : mNumberOfDimensions{2} {}

GeoThermalDispersionLaw::GeoThermalDispersionLaw(std::size_t NumberOfDimensions)
: mNumberOfDimensions{NumberOfDimensions}
{
KRATOS_ERROR_IF(mNumberOfDimensions < 1 || mNumberOfDimensions > 3)
<< "Got invalid number of dimensions: " << mNumberOfDimensions << std::endl;
}

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

SizeType GeoThermalDispersionLaw::WorkingSpaceDimension() { return mNumberOfDimensions; }

Matrix GeoThermalDispersionLaw::CalculateThermalDispersionMatrix(const Properties& rProp,
const ProcessInfo& rProcessInfo) const
{
KRATOS_TRY

Matrix result = ZeroMatrix(mNumberOfDimensions, mNumberOfDimensions);

RetentionLaw::Parameters parameters(rProp, rProcessInfo);
Expand All @@ -53,7 +42,7 @@ Matrix GeoThermalDispersionLaw::CalculateThermalDispersionMatrix(const Propertie
water_fraction * rProp[THERMAL_CONDUCTIVITY_WATER];

if (mNumberOfDimensions >= 2) {
const auto y = static_cast<int>(indexThermalFlux::Y);
const auto y = static_cast<int>(indexThermalFlux::Y);
result(x, y) = solid_fraction * rProp[THERMAL_CONDUCTIVITY_SOLID_XY];
result(y, y) = solid_fraction * rProp[THERMAL_CONDUCTIVITY_SOLID_YY] +
water_fraction * rProp[THERMAL_CONDUCTIVITY_WATER];
Expand All @@ -70,8 +59,6 @@ Matrix GeoThermalDispersionLaw::CalculateThermalDispersionMatrix(const Propertie
}

return result;

KRATOS_CATCH("")
}

} // Namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,36 @@

#pragma once

#include "includes/constitutive_law.h"
#include "custom_constitutive/thermal_law.h"

namespace Kratos
{

class RetentionLaw;

/**
* @class GeoThermalDispersionLaw
* @ingroup GeoMechanicsApplication
* @brief This class defines the thermal dispersion for heat cases
*/
class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalDispersionLaw : public ConstitutiveLaw
class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalDispersionLaw : public GeoThermalLaw
{
public:
/// Counted pointer of GeoThermalDispersionLaw
KRATOS_CLASS_POINTER_DEFINITION(GeoThermalDispersionLaw);

GeoThermalDispersionLaw();
GeoThermalDispersionLaw() = default;

explicit GeoThermalDispersionLaw(SizeType NumberOfDimensions);

ConstitutiveLaw::Pointer Clone() const override;

SizeType WorkingSpaceDimension() override;

Matrix CalculateThermalDispersionMatrix(const Properties& rProp, const ProcessInfo& rProcessInfo) const;
Matrix CalculateThermalDispersionMatrix(const Properties& rProp, const ProcessInfo& rProcessInfo) const override;

private:
SizeType mNumberOfDimensions;
std::size_t mNumberOfDimensions = 2;

friend class Serializer;

void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, ConstitutiveLaw)
rSerializer.save("NumberOfDimensions", mNumberOfDimensions);
}

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, ConstitutiveLaw)
rSerializer.load("NumberOfDimensions", mNumberOfDimensions);
mnabideltares marked this conversation as resolved.
Show resolved Hide resolved
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Mohamed Nabi
// John van Esch
//

#include "custom_constitutive/thermal_filter_law.h"
#include "geo_mechanics_application_variables.h"

namespace Kratos
{

Matrix GeoThermalFilterLaw::CalculateThermalDispersionMatrix(const Properties& rProp, const ProcessInfo&) const
{
return ScalarMatrix(1, 1, rProp[THERMAL_CONDUCTIVITY_WATER]);
}

} // Namespace Kratos
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Mohamed Nabi
// John van Esch
//

#pragma once

#include "custom_constitutive/thermal_law.h"

namespace Kratos
{

class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalFilterLaw : public GeoThermalLaw
{
public:
KRATOS_CLASS_POINTER_DEFINITION(GeoThermalFilterLaw);

Matrix CalculateThermalDispersionMatrix(const Properties& rProp, const ProcessInfo&) const override;

private:
friend class Serializer;

void save(Serializer&) const override
{
// Nothing to serialize, since there are no data members, and its base class is abstract
}

void load(Serializer&) override
{
// Nothing to serialize, since there are no data members, and its base class is abstract
}
};
} // namespace Kratos.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Mohamed Nabi
// John van Esch
// Gennady Markelov
//

#pragma once

#include "geo_mechanics_application_variables.h"
#include "includes/serializer.h"

namespace Kratos
{

class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalLaw
{
public:
KRATOS_CLASS_POINTER_DEFINITION(GeoThermalLaw);

virtual ~GeoThermalLaw() = default;

virtual Matrix CalculateThermalDispersionMatrix(const Properties& rProp,
const ProcessInfo& rProcessInfo) const = 0;

private:
friend class Serializer;

virtual void save(Serializer& rSerializer) const = 0;

virtual void load(Serializer& rSerializer) = 0;
};
} // namespace Kratos.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "custom_constitutive/thermal_dispersion_law.h"
#include "custom_constitutive/thermal_filter_law.h"
#include "custom_retention/retention_law_factory.h"
#include "custom_utilities/dof_utilities.h"
#include "geo_mechanics_application_variables.h"
Expand Down Expand Up @@ -268,10 +269,8 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientThermalElement : public Ele
const Vector& rIntegrationCoefficients,
const ProcessInfo& rCurrentProcessInfo) const
{
const std::size_t number_of_dimensions = GetGeometry().LocalSpaceDimension();

GeoThermalDispersionLaw law{number_of_dimensions};
const auto constitutive_matrix = law.CalculateThermalDispersionMatrix(GetProperties(), rCurrentProcessInfo);
const auto law = CreateThermalLaw();
const auto constitutive_matrix = law->CalculateThermalDispersionMatrix(GetProperties(), rCurrentProcessInfo);

auto result = BoundedMatrix<double, TNumNodes, TNumNodes>{ZeroMatrix{TNumNodes, TNumNodes}};
for (unsigned int integration_point_index = 0;
Expand Down Expand Up @@ -320,6 +319,29 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientThermalElement : public Ele
return result;
}

std::unique_ptr<GeoThermalLaw> CreateThermalLaw() const
{
const std::size_t number_of_dimensions = GetGeometry().LocalSpaceDimension();
std::unique_ptr<GeoThermalLaw> law;

if (GetProperties().Has(THERMAL_LAW_NAME)) {
const std::string& rThermalLawName = GetProperties()[THERMAL_LAW_NAME];
if (rThermalLawName == "GeoThermalDispersionLaw") {
law = std::make_unique<GeoThermalDispersionLaw>(number_of_dimensions);
}
else if (rThermalLawName == "GeoThermalFilterLaw") {
law = std::make_unique<GeoThermalFilterLaw>();
}
else {
KRATOS_ERROR << "Undefined THERMAL_LAW_NAME! " << rThermalLawName << std::endl;
}
}
else {
law = std::make_unique<GeoThermalDispersionLaw>(number_of_dimensions);
}
return law;
}

[[nodiscard]] DofsVectorType GetDofs() const
{
return Geo::DofUtilities::ExtractDofsFromNodes(GetGeometry(), TEMPERATURE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ void KratosGeoMechanicsApplication::Register() {

KRATOS_REGISTER_CONSTITUTIVE_LAW("LinearElastic2DBeamLaw", mLinearElastic2DBeamLaw)

KRATOS_REGISTER_CONSTITUTIVE_LAW("GeoThermalDispersion2DLaw", mGeoThermalDispersion2DLaw)
KRATOS_REGISTER_CONSTITUTIVE_LAW("GeoThermalDispersion3DLaw", mGeoThermalDispersion3DLaw)

//Register Variables
KRATOS_REGISTER_VARIABLE( VELOCITY_COEFFICIENT )
Expand All @@ -378,6 +376,7 @@ void KratosGeoMechanicsApplication::Register() {
KRATOS_REGISTER_VARIABLE( DT_TEMPERATURE_COEFFICIENT )
KRATOS_REGISTER_VARIABLE( DT_TEMPERATURE )
KRATOS_REGISTER_VARIABLE( NORMAL_HEAT_FLUX )
KRATOS_REGISTER_VARIABLE( THERMAL_LAW_NAME)

// Variables for Micro-Climate boundary
KRATOS_REGISTER_VARIABLE( AIR_TEMPERATURE )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
#include "custom_constitutive/small_strain_umat_2D_plane_strain_law.hpp"
#include "custom_constitutive/small_strain_umat_3D_interface_law.hpp"
#include "custom_constitutive/small_strain_umat_3D_law.hpp"
#include "custom_constitutive/thermal_dispersion_law.h"

namespace Kratos {

Expand Down Expand Up @@ -598,9 +597,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) KratosGeoMechanicsApplication : publ

const LinearElastic2DBeamLaw mLinearElastic2DBeamLaw;

const GeoThermalDispersionLaw mGeoThermalDispersion2DLaw{ConstitutiveLaw::SizeType(2)};
const GeoThermalDispersionLaw mGeoThermalDispersion3DLaw{ConstitutiveLaw::SizeType(3)};

///@}

}; // Class KratosGeoMechanicsApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ KRATOS_CREATE_VARIABLE( double, SOLID_COMPRESSIBILITY )
KRATOS_CREATE_VARIABLE( double, DT_TEMPERATURE_COEFFICIENT )
KRATOS_CREATE_VARIABLE( double, DT_TEMPERATURE )
KRATOS_CREATE_VARIABLE( double, NORMAL_HEAT_FLUX )
KRATOS_CREATE_VARIABLE( std::string, THERMAL_LAW_NAME )

// Variables for Micro-Climate boundary
KRATOS_CREATE_VARIABLE( double, AIR_TEMPERATURE )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace Kratos
KRATOS_DEFINE_APPLICATION_VARIABLE( GEO_MECHANICS_APPLICATION, double, DT_TEMPERATURE_COEFFICIENT )
KRATOS_DEFINE_APPLICATION_VARIABLE( GEO_MECHANICS_APPLICATION, double, DT_TEMPERATURE )
KRATOS_DEFINE_APPLICATION_VARIABLE( GEO_MECHANICS_APPLICATION, double, NORMAL_HEAT_FLUX )
KRATOS_DEFINE_APPLICATION_VARIABLE( GEO_MECHANICS_APPLICATION, std::string, THERMAL_LAW_NAME )

// Variables for Micro-Climate boundary
KRATOS_DEFINE_APPLICATION_VARIABLE( GEO_MECHANICS_APPLICATION, double, AIR_TEMPERATURE )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,9 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateThermalDispersionMatrix3D, KratosGeoMechanics
}
}

KRATOS_TEST_CASE_IN_SUITE(GetWorkingSpaceDimension_ReturnsCorrectValue, KratosGeoMechanicsFastSuite)
KRATOS_TEST_CASE_IN_SUITE(TestDispersionLawThrowsWhenDimensionInvalid, KratosGeoMechanicsFastSuite)
mnabideltares marked this conversation as resolved.
Show resolved Hide resolved
{
constexpr SizeType dimension = 3;
GeoThermalDispersionLaw geo_thermal_dispersion_3D_law(dimension);

KRATOS_EXPECT_EQ(geo_thermal_dispersion_3D_law.WorkingSpaceDimension(), dimension);
KRATOS_EXPECT_EXCEPTION_IS_THROWN(GeoThermalDispersionLaw law{0}, "Got invalid number of dimensions: 0")
}

} // namespace Kratos::Testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Mohamed Nabi
//

#include "custom_constitutive/thermal_filter_law.h"
#include "geo_mechanics_application.h"
#include "includes/ublas_interface.h"
#include "testing/testing.h"

namespace Kratos::Testing
{

KRATOS_TEST_CASE_IN_SUITE(CalculateThermalFilterLawMatrix, KratosGeoMechanicsFastSuite)
mnabideltares marked this conversation as resolved.
Show resolved Hide resolved
{
Model current_model;
auto& r_model_part = current_model.CreateModelPart("ModelPart");

auto p_cond_prop = r_model_part.CreateNewProperties(0);
p_cond_prop->SetValue(THERMAL_CONDUCTIVITY_WATER, 1000.0);

GeoThermalFilterLaw geo_thermal_filter_law;
ProcessInfo info;

const Matrix thermal_filter_matrix = geo_thermal_filter_law.CalculateThermalDispersionMatrix(*p_cond_prop, info);

Matrix expected_solution = ScalarMatrix(1, 1, 1000.0);

constexpr double tolerance{1.0e-6};

KRATOS_EXPECT_MATRIX_NEAR(thermal_filter_matrix, expected_solution, tolerance)
}

} // namespace Kratos::Testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading