Commit 391ec85b authored by DIAZ Jerome's avatar DIAZ Jerome Committed by GILLES Sebastien

#20 Added a test which assembles the Piola-Kirchhoff operator in a way that...

#20 Added a test which assembles the Piola-Kirchhoff operator in a way that throws an exception as it corresponds to a displacement that would lead to inverted elements.
parent 95c5ff23
...@@ -68,6 +68,14 @@ namespace MoReFEM ...@@ -68,6 +68,14 @@ namespace MoReFEM
GlobalVector previous_iteration_p1(vector_p1); GlobalVector previous_iteration_p1(vector_p1);
GlobalMatrix matrix_inverted_elements_p1_p1(numbering_subset_p1, numbering_subset_p1);
AllocateGlobalMatrix(god_of_dof, matrix_inverted_elements_p1_p1);
GlobalVector vector_inverted_elements_p1(numbering_subset_p1);
AllocateGlobalVector(god_of_dof, vector_inverted_elements_p1);
GlobalVector previous_iteration_inverted_elements_p1(vector_inverted_elements_p1);
const auto& mesh = god_of_dof.GetMesh(); const auto& mesh = god_of_dof.GetMesh();
const auto dimension = mesh.GetDimension(); const auto dimension = mesh.GetDimension();
...@@ -76,19 +84,27 @@ namespace MoReFEM ...@@ -76,19 +84,27 @@ namespace MoReFEM
vector_p1.ZeroEntries(__FILE__, __LINE__); vector_p1.ZeroEntries(__FILE__, __LINE__);
previous_iteration_p1.ZeroEntries(__FILE__, __LINE__); previous_iteration_p1.ZeroEntries(__FILE__, __LINE__);
matrix_inverted_elements_p1_p1.ZeroEntries(__FILE__, __LINE__);
vector_inverted_elements_p1.ZeroEntries(__FILE__, __LINE__);
previous_iteration_inverted_elements_p1.ZeroEntries(__FILE__, __LINE__);
switch(dimension) switch(dimension)
{ {
case 3: case 3:
previous_iteration_p1.SetValue(3, 2., INSERT_VALUES, __FILE__, __LINE__); previous_iteration_p1.SetValue(3, 2., INSERT_VALUES, __FILE__, __LINE__);
previous_iteration_inverted_elements_p1.SetValue(3, -2., INSERT_VALUES, __FILE__, __LINE__);
[[fallthrough]]; [[fallthrough]];
case 2: case 2:
previous_iteration_p1.SetValue(2, 2., INSERT_VALUES, __FILE__, __LINE__); previous_iteration_p1.SetValue(2, 2., INSERT_VALUES, __FILE__, __LINE__);
previous_iteration_inverted_elements_p1.SetValue(2, -2., INSERT_VALUES, __FILE__, __LINE__);
[[fallthrough]]; [[fallthrough]];
case 1: case 1:
previous_iteration_p1.SetValue(0, 1., INSERT_VALUES, __FILE__, __LINE__); previous_iteration_inverted_elements_p1.SetValue(0, 1., INSERT_VALUES, __FILE__, __LINE__);
previous_iteration_p1.SetValue(1, 2., INSERT_VALUES, __FILE__, __LINE__); previous_iteration_inverted_elements_p1.SetValue(1, 2., INSERT_VALUES, __FILE__, __LINE__);
previous_iteration_p1.SetValue(0, -1., INSERT_VALUES, __FILE__, __LINE__);
previous_iteration_p1.SetValue(1, -2., INSERT_VALUES, __FILE__, __LINE__);
break; break;
} }
previous_iteration_p1.Assembly(__FILE__, __LINE__); previous_iteration_p1.Assembly(__FILE__, __LINE__);
...@@ -96,6 +112,11 @@ namespace MoReFEM ...@@ -96,6 +112,11 @@ namespace MoReFEM
GlobalMatrixWithCoefficient matrix(matrix_p1_p1, 1.); GlobalMatrixWithCoefficient matrix(matrix_p1_p1, 1.);
GlobalVectorWithCoefficient vec(vector_p1, 1.); GlobalVectorWithCoefficient vec(vector_p1, 1.);
previous_iteration_inverted_elements_p1.Assembly(__FILE__, __LINE__);
GlobalMatrixWithCoefficient matrix_inverted_elements(matrix_inverted_elements_p1_p1, 1.);
GlobalVectorWithCoefficient vec_inverted_elements(vector_inverted_elements_p1, 1.);
if (do_assemble_into_matrix == assemble_into_matrix::yes if (do_assemble_into_matrix == assemble_into_matrix::yes
&& do_assemble_into_vector == assemble_into_vector::yes) && do_assemble_into_vector == assemble_into_vector::yes)
...@@ -103,6 +124,9 @@ namespace MoReFEM ...@@ -103,6 +124,9 @@ namespace MoReFEM
pk2_operator.Assemble(std::make_tuple(std::ref(matrix), std::ref(vec)), pk2_operator.Assemble(std::make_tuple(std::ref(matrix), std::ref(vec)),
previous_iteration_p1); previous_iteration_p1);
BOOST_CHECK_THROW(pk2_operator.Assemble(std::make_tuple(std::ref(matrix_inverted_elements), std::ref(vec_inverted_elements)),
previous_iteration_inverted_elements_p1), Exception);
/* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof, /* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof,
matrix_p1_p1, matrix_p1_p1,
GetExpectedMatrixP1P1(dimension), GetExpectedMatrixP1P1(dimension),
...@@ -120,6 +144,9 @@ namespace MoReFEM ...@@ -120,6 +144,9 @@ namespace MoReFEM
{ {
pk2_operator.Assemble(std::make_tuple(std::ref(matrix)), pk2_operator.Assemble(std::make_tuple(std::ref(matrix)),
previous_iteration_p1); previous_iteration_p1);
BOOST_CHECK_THROW(pk2_operator.Assemble(std::make_tuple(std::ref(matrix_inverted_elements)),
previous_iteration_inverted_elements_p1), Exception);
/* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof, /* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof,
matrix_p1_p1, matrix_p1_p1,
...@@ -132,6 +159,9 @@ namespace MoReFEM ...@@ -132,6 +159,9 @@ namespace MoReFEM
{ {
pk2_operator.Assemble(std::make_tuple(std::ref(vec)), pk2_operator.Assemble(std::make_tuple(std::ref(vec)),
previous_iteration_p1); previous_iteration_p1);
BOOST_CHECK_THROW(pk2_operator.Assemble(std::make_tuple(std::ref(vec_inverted_elements)),
previous_iteration_inverted_elements_p1), Exception);
/* BOOST_CHECK_NO_THROW */(CheckVector(god_of_dof, /* BOOST_CHECK_NO_THROW */(CheckVector(god_of_dof,
vector_p1, vector_p1,
......
...@@ -414,7 +414,7 @@ Solid = { ...@@ -414,7 +414,7 @@ Solid = {
-- This means that the resulting deformed mesh is no longer valid. -- This means that the resulting deformed mesh is no longer valid.
-- This parameter enables a computationally expensive test on all quadrature points to check that the volume -- This parameter enables a computationally expensive test on all quadrature points to check that the volume
-- of all finite elements remains positive throughout the computation. -- of all finite elements remains positive throughout the computation.
CheckInvertedElements = false CheckInvertedElements = true
} -- Solid } -- Solid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment