Skip to content

Commit

Permalink
Addressed changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
mnabideltares committed May 16, 2024
1 parent 18493b1 commit f5a2a2e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@
namespace Kratos
{

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

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

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

Matrix GeoThermalDispersionLaw::CalculateThermalDispersionMatrix(const Properties& rProp,
const ProcessInfo& rProcessInfo) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalDispersionLaw : public Geo

~GeoThermalDispersionLaw() override = default;

GeoThermalLaw::Pointer Clone() const override;

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

private:
std::size_t mNumberOfDimensions = 0;

friend class Serializer;

void save(Serializer& rSerializer) const override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@
namespace Kratos
{

GeoThermalFilterLaw::GeoThermalFilterLaw() { mNumberOfDimensions = 1; }
GeoThermalFilterLaw::GeoThermalFilterLaw() : mNumberOfDimensions{1} {}

GeoThermalFilterLaw::GeoThermalFilterLaw(SizeType NumberOfDimensions)
: mNumberOfDimensions{NumberOfDimensions}
{
mNumberOfDimensions = NumberOfDimensions;
KRATOS_ERROR_IF(mNumberOfDimensions != 1)
<< "Got invalid number of dimensions. The dimension has to be 1, but got: " << mNumberOfDimensions
<< std::endl;
}

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

Matrix GeoThermalFilterLaw::CalculateThermalDispersionMatrix(const Properties& rProp, const ProcessInfo&) const
{
return ScalarMatrix(1, 1, rProp[THERMAL_CONDUCTIVITY_WATER]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalFilterLaw : public GeoTher

~GeoThermalFilterLaw() override = default;

GeoThermalLaw::Pointer Clone() const override;

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

private:
std::size_t mNumberOfDimensions = 0;

friend class Serializer;

void save(Serializer& rSerializer) const override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,14 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoThermalLaw

virtual ~GeoThermalLaw() = default;

virtual GeoThermalLaw::Pointer Clone() const = 0;

std::size_t WorkingSpaceDimension() const { return mNumberOfDimensions; }

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

protected:
std::size_t mNumberOfDimensions = 0;

private:
friend class Serializer;

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

virtual void load(Serializer& rSerializer)
{
rSerializer.load("NumberOfDimensions", mNumberOfDimensions);
}
virtual void load(Serializer& rSerializer) {}
};
} // namespace Kratos.
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,22 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientThermalElement : public Ele
const ProcessInfo& rCurrentProcessInfo) const
{
const std::size_t number_of_dimensions = GetGeometry().LocalSpaceDimension();
unique_ptr<GeoThermalLaw> law;
std::unique_ptr<GeoThermalLaw> law;

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

const auto constitutive_matrix = law->CalculateThermalDispersionMatrix(GetProperties(), rCurrentProcessInfo);
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)
{
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(GeoThermalFilterLaw law{0}, "Got invalid number of dimensions: 0")
}

} // namespace Kratos::Testing
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateThermalFilterLawMatrix, KratosGeoMechanicsFas
KRATOS_EXPECT_NEAR(thermal_filter_matrix(0, 0), expected_solution(0, 0), tolerance);
}

KRATOS_TEST_CASE_IN_SUITE(GetWorkingSpaceDimension_ReturnsFilterDimensionValue, KratosGeoMechanicsFastSuite)
KRATOS_TEST_CASE_IN_SUITE(TestFilterLawThrowsWhenDimensionInvalid, KratosGeoMechanicsFastSuite)
{
constexpr SizeType dimension = 1;
GeoThermalFilterLaw geo_thermal_filter_law(dimension);

KRATOS_EXPECT_EQ(geo_thermal_filter_law.WorkingSpaceDimension(), dimension);
}

KRATOS_TEST_CASE_IN_SUITE(TestFilterThrowsWhenDimensionInvalid, KratosGeoMechanicsFastSuite)
{
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
GeoThermalFilterLaw law{2},
KRATOS_EXPECT_EXCEPTION_IS_THROWN(GeoThermalFilterLaw law{2},
"Got invalid number of dimensions. The dimension has to be 1, but got: 2")
}

Expand Down

0 comments on commit f5a2a2e

Please sign in to comment.