Skip to content

Commit

Permalink
[GeoMechanicsApplication] Make sure all 'integration scheme related' …
Browse files Browse the repository at this point in the history
…functions throw an exception (#12642)

* Make sure all 'integration scheme related' functions throw an exception for our line interface geometry
* Added a unit test
  • Loading branch information
rfaasse authored Aug 23, 2024
1 parent 246ca6b commit 85aa661
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,128 @@ class LineInterfaceGeometry : public Geometry<Node>

void PrintData(std::ostream& rOStream) const override { mMidLineGeometry->PrintData(rOStream); }

[[nodiscard]] static std::string IntegrationSchemeFunctionalityNotImplementedMessage()
{
return "This Geometry type does not support functionality related to integration schemes.\n";
}

array_1d<double, 3> Normal(IndexType IntegrationPointIndex) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

array_1d<double, 3> Normal(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

array_1d<double, 3> UnitNormal(IndexType IntegrationPointIndex) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

array_1d<double, 3> UnitNormal(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

JacobiansType& Jacobian(JacobiansType& rResult, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

JacobiansType& Jacobian(JacobiansType& rResult, IntegrationMethod ThisMethod, Matrix& DeltaPosition) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

Matrix& Jacobian(Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

Matrix& Jacobian(Matrix& rResult,
IndexType IntegrationPointIndex,
IntegrationMethod ThisMethod,
const Matrix& rDeltaPosition) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

Vector& DeterminantOfJacobian(Vector& rResult, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

JacobiansType& InverseOfJacobian(JacobiansType& rResult, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

Matrix& InverseOfJacobian(Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType& rResult,
IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType& rResult,
Vector& rDeterminantsOfJacobian,
IntegrationMethod ThisMethod) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType& rResult,
Vector& rDeterminantsOfJacobian,
IntegrationMethod ThisMethod,
Matrix& ShapeFunctionsIntegrationPointsValues) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

IntegrationInfo GetDefaultIntegrationInfo() const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void CreateIntegrationPoints(IntegrationPointsArrayType& rIntegrationPoints,
IntegrationInfo& rIntegrationInfo) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void CreateQuadraturePointGeometries(GeometriesArrayType& rResultGeometries,
IndexType NumberOfShapeFunctionDerivatives,
const IntegrationPointsArrayType& rIntegrationPoints,
IntegrationInfo& rIntegrationInfo) override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void CreateQuadraturePointGeometries(GeometriesArrayType& rResultGeometries,
IndexType NumberOfShapeFunctionDerivatives,
IntegrationInfo& rIntegrationInfo) override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

void GlobalSpaceDerivatives(std::vector<CoordinatesArrayType>& rGlobalSpaceDerivatives,
IndexType IntegrationPointIndex,
const SizeType DerivativeOrder) const override
{
KRATOS_ERROR << IntegrationSchemeFunctionalityNotImplementedMessage();
}

private:
[[nodiscard]] PointerVector<Node> CreatePointsOfMidLine() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//

#include "custom_geometries/line_interface_geometry.h"
#include "geometries/geometry_data.h"
#include "tests/cpp_tests/geo_mechanics_fast_suite.h"

#include <boost/numeric/ublas/assignment.hpp>
Expand Down Expand Up @@ -353,4 +354,60 @@ KRATOS_TEST_CASE_IN_SUITE(InterfaceGeometry_Throws_WhenCallingVolume, KratosGeoM
"one. Please check the definition of derived class. ")
}

KRATOS_TEST_CASE_IN_SUITE(InterfaceGeometry_Throws_WhenCallingFunctionsRelatedToIntegrationPoints,
KratosGeoMechanicsFastSuiteWithoutKernel)
{
auto geometry = CreateThreePlusThreeNodedLineInterfaceGeometry();
Geometry<Node>::JacobiansType dummy_jacobian;
Geometry<Node>::ShapeFunctionsGradientsType dummy_shape_functions_gradients;
Vector dummy_vector;
Matrix dummy_matrix;
IndexType dummy_index = 0;
GeometryData::IntegrationMethod dummy_integration_method = GeometryData::IntegrationMethod::GI_GAUSS_1;
Geometry<Node>::IntegrationPointsArrayType dummy_integration_points;
IntegrationInfo dummy_integration_info(dummy_index, dummy_integration_method);
Geometry<Node>::GeometriesArrayType dummy_geometries;
std::vector<Node::CoordinatesArrayType> dummy_coordinates;
const std::string message =
"This Geometry type does not support functionality related to integration schemes.\n";

KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.Normal(dummy_index), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.Normal(dummy_index, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.UnitNormal(dummy_index), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.UnitNormal(dummy_index, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.Jacobian(dummy_jacobian, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.Jacobian(dummy_jacobian, dummy_integration_method, dummy_matrix), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.Jacobian(dummy_matrix, dummy_index, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.Jacobian(dummy_matrix, dummy_index, dummy_integration_method, dummy_matrix), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.DeterminantOfJacobian(dummy_vector, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.DeterminantOfJacobian(dummy_index, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.InverseOfJacobian(dummy_jacobian, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.InverseOfJacobian(dummy_matrix, dummy_index, dummy_integration_method), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.ShapeFunctionsIntegrationPointsGradients(
dummy_shape_functions_gradients, dummy_integration_method),
message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.ShapeFunctionsIntegrationPointsGradients(
dummy_shape_functions_gradients, dummy_vector, dummy_integration_method),
message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.ShapeFunctionsIntegrationPointsGradients(
dummy_shape_functions_gradients, dummy_vector, dummy_integration_method, dummy_matrix),
message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.CreateIntegrationPoints(dummy_integration_points, dummy_integration_info), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(geometry.GetDefaultIntegrationInfo(), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.CreateQuadraturePointGeometries(dummy_geometries, dummy_index,
dummy_integration_points, dummy_integration_info),
message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.CreateQuadraturePointGeometries(dummy_geometries, dummy_index, dummy_integration_info), message)
KRATOS_EXPECT_EXCEPTION_IS_THROWN(
geometry.GlobalSpaceDerivatives(dummy_coordinates, dummy_index, dummy_index), message)
}
} // namespace Kratos::Testing

0 comments on commit 85aa661

Please sign in to comment.