Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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 @@ -13,6 +13,7 @@

// Application includes
#include "custom_elements/U_Pw_small_strain_element.hpp"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/constitutive_law_utilities.h"
#include "custom_utilities/equation_of_motion_utilities.h"
#include "custom_utilities/linear_nodal_extrapolator.h"
Expand Down Expand Up @@ -57,8 +58,7 @@ int UPwSmallStrainElement<TDim, TNumNodes>::Check(const ProcessInfo& rCurrentPro
const PropertiesType& r_properties = this->GetProperties();
const GeometryType& r_geometry = this->GetGeometry();

KRATOS_ERROR_IF(r_geometry.DomainSize() < 1.0e-15)
<< "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(r_geometry.DomainSize(), this->Id());

// Verify specific properties
KRATOS_ERROR_IF_NOT(r_properties.Has(IGNORE_UNDRAINED))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// Application includes
#include "custom_elements/drained_U_Pw_small_strain_element.hpp"
#include "custom_utilities/check_utilities.hpp"

namespace Kratos
{
Expand Down Expand Up @@ -56,8 +57,7 @@ int DrainedUPwSmallStrainElement<TDim, TNumNodes>::Check(const ProcessInfo& rCur
const PropertiesType& Prop = this->GetProperties();
const GeometryType& Geom = this->GetGeometry();

if (Geom.DomainSize() < 1.0e-15)
KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(Geom.DomainSize(), this->Id());

// Verify specific properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <numeric>

#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/dof_utilities.h"
#include "custom_utilities/element_utilities.hpp"
#include "custom_utilities/math_utilities.h"
Expand Down Expand Up @@ -99,7 +100,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoSteadyStatePwPipingElement : publ
int Check(const ProcessInfo&) const override
{
KRATOS_TRY
CheckDomainSize();
CheckUtilities::CheckDomainSize(GetGeometry().DomainSize(), Id());
CheckHasSolutionStepsDataFor(WATER_PRESSURE);
CheckHasDofsFor(WATER_PRESSURE);
CheckProperties();
Expand Down Expand Up @@ -225,14 +226,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoSteadyStatePwPipingElement : publ
std::string Info() const override { return "GeoSteadyStatePwPipingElement"; }

private:
void CheckDomainSize() const
{
constexpr auto min_domain_size = 1.0e-15;
KRATOS_ERROR_IF(GetGeometry().DomainSize() < min_domain_size)
<< "DomainSize (" << GetGeometry().DomainSize() << ") is smaller than "
<< min_domain_size << " for element " << Id() << std::endl;
}

void CheckHasSolutionStepsDataFor(const Variable<double>& rVariable) const
{
for (const auto& node : GetGeometry()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

// Application includes
#include "custom_elements/small_strain_U_Pw_diff_order_element.hpp"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/constitutive_law_utilities.h"
#include "custom_utilities/dof_utilities.h"
#include "custom_utilities/element_utilities.hpp"
Expand Down Expand Up @@ -61,8 +62,7 @@ int SmallStrainUPwDiffOrderElement::Check(const ProcessInfo& rCurrentProcessInfo

const auto& r_geom = GetGeometry();

if (r_geom.DomainSize() < 1.0e-15)
KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(r_geom.DomainSize(), this->Id());

// check pressure geometry pointer
KRATOS_DEBUG_ERROR_IF_NOT(mpPressureGeometry) << "Pressure Geometry is not defined\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// Application includes
#include "custom_elements/steady_state_Pw_element.hpp"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/transport_equation_utilities.hpp"
#include "includes/cfd_variables.h"

Expand Down Expand Up @@ -44,8 +45,7 @@ int SteadyStatePwElement<TDim, TNumNodes>::Check(const ProcessInfo& rCurrentProc
const PropertiesType& Prop = this->GetProperties();
const GeometryType& Geom = this->GetGeometry();

if (Geom.DomainSize() < 1.0e-15)
KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(Geom.DomainSize(), this->Id());

for (unsigned int i = 0; i < TNumNodes; ++i) {
if (Geom[i].SolutionStepsDataHas(WATER_PRESSURE) == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// Application includes
#include "custom_elements/transient_Pw_element.hpp"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/dof_utilities.h"
#include "custom_utilities/transport_equation_utilities.hpp"
#include "includes/cfd_variables.h"
Expand Down Expand Up @@ -151,8 +152,7 @@ int TransientPwElement<TDim, TNumNodes>::Check(const ProcessInfo& rCurrentProces
const PropertiesType& r_properties = this->GetProperties();
const GeometryType& r_geom = this->GetGeometry();

if (r_geom.DomainSize() < 1.0e-15)
KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(r_geom.DomainSize(), this->Id());

for (unsigned int i = 0; i < TNumNodes; ++i) {
if (r_geom[i].SolutionStepsDataHas(WATER_PRESSURE) == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "calculation_contribution.h"
#include "compressibility_calculator.h"
#include "custom_retention/retention_law_factory.h"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/dof_utilities.h"
#include "custom_utilities/element_utilities.hpp"
#include "filter_compressibility_calculator.h"
Expand Down Expand Up @@ -138,7 +139,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwLineElement : public Elem
{
KRATOS_TRY

CheckElementLength();
CheckUtilities::CheckDomainSize(GetGeometry().DomainSize(), Id(), "Length");
CheckHasSolutionStepsDataFor(WATER_PRESSURE);
CheckHasSolutionStepsDataFor(DT_WATER_PRESSURE);
CheckHasSolutionStepsDataFor(VOLUME_ACCELERATION);
Expand All @@ -156,13 +157,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientPwLineElement : public Elem
std::vector<RetentionLaw::Pointer> mRetentionLawVector;
std::vector<CalculationContribution> mContributions;

void CheckElementLength() const
{
constexpr auto min_domain_size = 1.0e-15;
KRATOS_ERROR_IF(GetGeometry().DomainSize() < min_domain_size)
<< "Length smaller than " << min_domain_size << " for element " << Id() << std::endl;
}

void CheckHasSolutionStepsDataFor(const VariableData& rVariable) const
{
for (const auto& node : GetGeometry()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "custom_constitutive/thermal_dispersion_law.h"
#include "custom_constitutive/thermal_filter_law.h"
#include "custom_retention/retention_law_factory.h"
#include "custom_utilities/check_utilities.hpp"
#include "custom_utilities/dof_utilities.h"
#include "geo_mechanics_application_variables.h"
#include "includes/element.h"
Expand Down Expand Up @@ -114,7 +115,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientThermalElement : public Ele
{
KRATOS_TRY

CheckDomainSize();
CheckUtilities::CheckDomainSize(GetGeometry().DomainSize(), Id());
CheckHasSolutionStepsDataFor(TEMPERATURE);
CheckHasSolutionStepsDataFor(DT_TEMPERATURE);
CheckHasDofsFor(TEMPERATURE);
Expand All @@ -127,13 +128,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) TransientThermalElement : public Ele
}

private:
void CheckDomainSize() const
{
constexpr auto min_domain_size = 1.0e-15;
KRATOS_ERROR_IF(GetGeometry().DomainSize() < min_domain_size)
<< "DomainSize smaller than " << min_domain_size << " for element " << Id() << std::endl;
}

void CheckHasSolutionStepsDataFor(const Variable<double>& rVariable) const
{
for (const auto& node : GetGeometry()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// Application includes
#include "custom_elements/undrained_U_Pw_small_strain_element.hpp"
#include "custom_utilities/check_utilities.hpp"

namespace Kratos
{
Expand Down Expand Up @@ -46,8 +47,7 @@ int UndrainedUPwSmallStrainElement<TDim, TNumNodes>::Check(const ProcessInfo& rC
int ierr = Element::Check(rCurrentProcessInfo);
if (ierr != 0) return ierr;

if (Geom.DomainSize() < 1.0e-15)
KRATOS_ERROR << "DomainSize < 1.0e-15 for the element " << this->Id() << std::endl;
CheckUtilities::CheckDomainSize(Geom.DomainSize(), this->Id());

// Verify generic variables
ierr = UPwBaseElement::Check(rCurrentProcessInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Gennady Markelov
//

#pragma once

// Project includes
#include "includes/exception.h"

#include <optional>
#include <string>

namespace Kratos
{

class CheckUtilities
{
public:
static void CheckDomainSize(double DomainSize, std::size_t Id, const std::optional<std::string>& PrintName = std::nullopt)
{
constexpr auto min_domain_size = 1.0e-15;
KRATOS_ERROR_IF(DomainSize < min_domain_size)
<< (PrintName.has_value() ? PrintName.value() : "DomainSize")
<< " (" << DomainSize << ") is smaller than " << min_domain_size << " for element " << Id << std::endl;
}

}; /* Class CheckUtilities*/
} /* namespace Kratos.*/
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ KRATOS_TEST_CASE_IN_SUITE(TransientPwLineElementCheckThrowsOnFaultyInput, Kratos
// Act and Assert
const auto dummy_process_info = ProcessInfo{};
KRATOS_EXPECT_EXCEPTION_IS_THROWN(element_with_coincident_nodes.Check(dummy_process_info),
"Error: Length smaller than 1e-15 for element 1")
"Error: Length (0) is smaller than 1e-15 for element 1")
nodes.erase(nodes.begin() + 1);
nodes.push_back(make_intrusive<Node>(1, 1.0, 1.0, 0.0));
const auto p_geometry = std::make_shared<Line2D2<Node>>(nodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ KRATOS_TEST_CASE_IN_SUITE(TransientPwElement_CheckThrowsOnFaultyInput, KratosGeo
// Act and Assert
const auto dummy_process_info = ProcessInfo{};
KRATOS_EXPECT_EXCEPTION_IS_THROWN(element_with_coincident_nodes.Check(dummy_process_info),
"Error: DomainSize < 1.0e-15 for the element 1")
"Error: DomainSize (0) is smaller than 1e-15 for element 1")

const TransientPwElement<2, 3> element_with_correct_domain_size(
1, std::make_shared<Triangle2D3<Node>>(CreateThreeNodes()), p_properties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDomainSizeIsInvalid, KratosGeo
Element::Pointer p_element = GenerateTransientThermalElementWithZeroDomainSize();

KRATOS_EXPECT_EXCEPTION_IS_THROWN(p_element->Check(ProcessInfo()),
"DomainSize smaller than 1e-15 for element 1")
"DomainSize (0) is smaller than 1e-15 for element 1")
}

void GenerateTransientThermalElement2D3N(ModelPart& rModelPart)
Expand Down
Loading