Commit e759a348 authored by GILLES Sebastien's avatar GILLES Sebastien

#1303 Adapt the interface of non linear operator test to make room for the pretension case.

parent bb32ab58
......@@ -4351,6 +4351,7 @@
BE90633C1CABF05200E69200 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = "<group>"; };
BE90633D1CABF05200E69200 /* Model.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hxx; sourceTree = "<group>"; };
BE915A151AAF514900B4C474 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
BE9217F222F1EC1600C5660C /* Enum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Enum.hpp; sourceTree = "<group>"; };
BE93B3191F052CFC004F84CF /* Format.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Format.hpp; sourceTree = "<group>"; };
BE93B31C1F0536DA004F84CF /* OutputDeformedMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OutputDeformedMesh.cpp; sourceTree = "<group>"; };
BE93B31D1F0536DA004F84CF /* OutputDeformedMesh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OutputDeformedMesh.hpp; sourceTree = "<group>"; };
......@@ -8724,6 +8725,7 @@
BE7E686D2065615100AA2FB3 /* demo.lua */,
BE7E68702065615100AA2FB3 /* main.cpp */,
BE7E68682065615100AA2FB3 /* InputData.hpp */,
BE9217F222F1EC1600C5660C /* Enum.hpp */,
BE7E686E2065615100AA2FB3 /* Model.cpp */,
BE7E688A206B71F200AA2FB3 /* TestP1P1.cpp */,
BE7E686A2065615100AA2FB3 /* Model.hpp */,
/*!
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Sun, 18 Nov 2018 22:29:38 +0100
// Copyright (c) Inria. All rights reserved.
//
*/
#ifndef MOREFEM_x_TEST_x_OPERATORS_x_VARIATIONAL_INSTANCES_x_NONLINEAR_MEMBRANE_x_ENUM_HPP_
# define MOREFEM_x_TEST_x_OPERATORS_x_VARIATIONAL_INSTANCES_x_NONLINEAR_MEMBRANE_x_ENUM_HPP_
namespace MoReFEM
{
namespace TestNS::NonLinearMembraneOperatorNS
{
//! Whether pretension is considered or not.
enum class pretension { no, yes };
} // namespace CardiacMechanicsPrestressNS
} // namespace MoReFEM
#endif // MOREFEM_x_TEST_x_OPERATORS_x_VARIATIONAL_INSTANCES_x_NONLINEAR_MEMBRANE_x_ENUM_HPP_
......@@ -20,6 +20,8 @@
# include "Core/LinearAlgebra/GlobalMatrix.hpp"
# include "Core/LinearAlgebra/GlobalVector.hpp"
# include "Test/Operators/VariationalInstances/NonlinearMembrane/Enum.hpp"
namespace MoReFEM
{
......@@ -63,17 +65,21 @@ namespace MoReFEM
/*!
* \brief Returns the expected matrix when unknown and test unknowns are both P1.
*
* \param[in] is_pretension Whether a pretension is used or not.
*
* \return The expected content of the matrix, in \a content_type format. The pre-filled matrix is dense.
*/
expected_results_type<IsMatrixOrVector::matrix> GetExpectedMatrixP1P1();
expected_results_type<IsMatrixOrVector::matrix> GetExpectedMatrixP1P1(pretension is_pretension);
/*!
* \brief Returns the expected vector when test unknown is P1.
*
* \param[in] is_pretension Whether a pretension is used or not.
*
* \return The expected content of the vector, in \a content_type format.
*/
expected_results_type<IsMatrixOrVector::vector> GetExpectedVectorP1P1();
expected_results_type<IsMatrixOrVector::vector> GetExpectedVectorP1P1(pretension is_pretension);
} // namespace TestNS::NonLinearMembraneOperatorNS
......
......@@ -55,22 +55,29 @@ namespace MoReFEM::TestNS::NonLinearMembraneOperatorNS
expected_results_type<IsMatrixOrVector::matrix> GetExpectedMatrixP1P1()
expected_results_type<IsMatrixOrVector::matrix> GetExpectedMatrixP1P1(pretension is_pretension)
{
// The values below have been computed independantly in Matlab by Dominique Chapelle.
expected_results_type<IsMatrixOrVector::matrix> ret;
FillMatrix fill_matrix(1.e9, ret);
fill_matrix.AddRow({ 3.1217, -2.8516, -0.2701, -0.5325, 0.4134, 0.1191, -0.3028, 0.2113, 0.0914 });
fill_matrix.AddRow({ -2.8516, 3.0204, -0.1688, 0.4339, -0.3198, -0.1141, 0.2183, -0.1612, -0.0571 });
fill_matrix.AddRow({ -0.2701, -0.1688, 0.4389, 0.0986, -0.0936, -0.0050, 0.0844, -0.0502, -0.0343 });
fill_matrix.AddRow({ -0.5325, 0.4339, 0.0986, 8.0441, -7.4416, -0.6025, 2.2840, -2.0490, -0.2350 });
fill_matrix.AddRow({ 0.4134, -0.3198, -0.0936, -7.4416, 8.0378, -0.5961, -2.0270, 2.0660, -0.0390 });
fill_matrix.AddRow({ 0.1191, -0.1141, -0.0050, -0.6025, -0.5961, 1.1986, -0.2571, -0.0170, 0.2740 });
fill_matrix.AddRow({ -0.3028, 0.2183, 0.0844, 2.2840, -2.0270, -0.2571, 4.1101, -3.7093, -0.4008 });
fill_matrix.AddRow({ 0.2113, -0.1612, -0.0502, -2.0490, 2.0660, -0.0170, -3.7093, 3.8471, -0.1378 });
fill_matrix.AddRow({ 0.0914, -0.0571, -0.0343, -0.2350, -0.0390, 0.2740, -0.4008, -0.1378, 0.5385 });
if (is_pretension == pretension::no)
{
fill_matrix.AddRow({ 3.1217, -2.8516, -0.2701, -0.5325, 0.4134, 0.1191, -0.3028, 0.2113, 0.0914 });
fill_matrix.AddRow({ -2.8516, 3.0204, -0.1688, 0.4339, -0.3198, -0.1141, 0.2183, -0.1612, -0.0571 });
fill_matrix.AddRow({ -0.2701, -0.1688, 0.4389, 0.0986, -0.0936, -0.0050, 0.0844, -0.0502, -0.0343 });
fill_matrix.AddRow({ -0.5325, 0.4339, 0.0986, 8.0441, -7.4416, -0.6025, 2.2840, -2.0490, -0.2350 });
fill_matrix.AddRow({ 0.4134, -0.3198, -0.0936, -7.4416, 8.0378, -0.5961, -2.0270, 2.0660, -0.0390 });
fill_matrix.AddRow({ 0.1191, -0.1141, -0.0050, -0.6025, -0.5961, 1.1986, -0.2571, -0.0170, 0.2740 });
fill_matrix.AddRow({ -0.3028, 0.2183, 0.0844, 2.2840, -2.0270, -0.2571, 4.1101, -3.7093, -0.4008 });
fill_matrix.AddRow({ 0.2113, -0.1612, -0.0502, -2.0490, 2.0660, -0.0170, -3.7093, 3.8471, -0.1378 });
fill_matrix.AddRow({ 0.0914, -0.0571, -0.0343, -0.2350, -0.0390, 0.2740, -0.4008, -0.1378, 0.5385 });
}
else
{
}
ConvertLocal2Global(ret);
......@@ -78,21 +85,30 @@ namespace MoReFEM::TestNS::NonLinearMembraneOperatorNS
}
expected_results_type<IsMatrixOrVector::vector> GetExpectedVectorP1P1()
expected_results_type<IsMatrixOrVector::vector> GetExpectedVectorP1P1(pretension is_pretension)
{
// The values below have been computed independantly in Matlab by Dominique Chapelle.
expected_results_type<IsMatrixOrVector::vector> ret
expected_results_type<IsMatrixOrVector::vector> ret;
if (is_pretension == pretension::no)
{
0.3342,
-0.2507,
-0.0835,
-3.7759,
4.2108,
-0.4349,
-1.6428,
1.7009,
-0.0582,
};
ret =
{
0.3342,
-0.2507,
-0.0835,
-3.7759,
4.2108,
-0.4349,
-1.6428,
1.7009,
-0.0582,
};
}
else
{
}
ApplyFactorToVector(1.e11, ret);
......
......@@ -25,6 +25,8 @@
# include "Core/InputData/Instances/Solver/Petsc.hpp"
# include "Core/InputData/Instances/DirichletBoundaryCondition/DirichletBoundaryCondition.hpp"
# include "Test/Operators/VariationalInstances/NonlinearMembrane/Enum.hpp"
namespace MoReFEM
{
......
......@@ -124,22 +124,18 @@ namespace MoReFEM
///@}
/*!
* \brief Test with p1 unknown (and same for test function).
* \brief Test with p1 unknown (and same for test function) and no pretension.
*
* \param[in] do_assemble_into_matrix Whether we're assembling into a matrix or not.
* \param[in] do_assemble_into_vector Whether we're assembling into a vector or not.
* \param[in] pretension Whether a pretension is applied or not.
*
* The three cases yes/yes, yes/no and no/yes are considered in the unit tests.
*/
void TestP1P1(::MoReFEM::Internal::assemble_into_matrix do_assemble_into_matrix,
void TestP1P1(pretension is_pretension,
::MoReFEM::Internal::assemble_into_matrix do_assemble_into_matrix,
::MoReFEM::Internal::assemble_into_vector do_assemble_into_vector) const;
/*!
* \brief Test with p2 unknown and p1 test function.
*
*/
void TestP2P1() const;
private:
......
......@@ -34,11 +34,16 @@ namespace MoReFEM
using ::MoReFEM::Internal::assemble_into_vector;
double thickness_value = 1.; // 4.2375
double pretension_value = 17.984152;
} // namespace anonymous
void Model::TestP1P1(assemble_into_matrix do_assemble_into_matrix,
void Model::TestP1P1(pretension is_pretension,
assemble_into_matrix do_assemble_into_matrix,
assemble_into_vector do_assemble_into_vector) const
{
const auto& god_of_dof = GetGodOfDof(EnumUnderlyingType(MeshIndex::mesh));
......@@ -80,11 +85,14 @@ namespace MoReFEM
scalar_parameter_type thickness("Thickness",
domain_surface,
1.);
thickness_value);
const double pretension_to_use
= is_pretension == pretension::yes ? pretension_value : 0.;
scalar_parameter_type pretension("Pretension",
domain_surface,
0.);
scalar_parameter_type pretension_param("Pretension",
domain_surface,
pretension_to_use);
GVO::NonlinearMembrane stiffness_operator(felt_space_surface,
displacement_ptr,
......@@ -92,7 +100,7 @@ namespace MoReFEM
solid.GetYoungModulus(),
solid.GetPoissonRatio(),
thickness,
pretension);
pretension_param);
GlobalMatrix matrix_tangent_stiffness(displacement_numbering_subset, displacement_numbering_subset);
AllocateGlobalMatrix(god_of_dof, matrix_tangent_stiffness);
......@@ -129,13 +137,13 @@ namespace MoReFEM
/* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof,
matrix_tangent_stiffness,
GetExpectedMatrixP1P1(),
GetExpectedMatrixP1P1(is_pretension),
__FILE__, __LINE__,
1.e6));
/* BOOST_CHECK_NO_THROW */(CheckVector(god_of_dof,
vector_stiffness_residual,
GetExpectedVectorP1P1(),
GetExpectedVectorP1P1(is_pretension),
__FILE__, __LINE__,
1.e7));
}
......@@ -147,7 +155,7 @@ namespace MoReFEM
/* BOOST_CHECK_NO_THROW */(CheckMatrix(god_of_dof,
matrix_tangent_stiffness,
GetExpectedMatrixP1P1(),
GetExpectedMatrixP1P1(is_pretension),
__FILE__, __LINE__,
1.e6));
}
......@@ -159,7 +167,7 @@ namespace MoReFEM
/* BOOST_CHECK_NO_THROW */(CheckVector(god_of_dof,
vector_stiffness_residual,
GetExpectedVectorP1P1(),
GetExpectedVectorP1P1(is_pretension),
__FILE__, __LINE__,
1.e7));
}
......
......@@ -20,6 +20,7 @@
#include "Test/Tools/Fixture/Model.hpp"
#include "Test/Operators/VariationalInstances/NonlinearMembrane/Model.hpp"
#include "Test/Operators/VariationalInstances/NonlinearMembrane/Enum.hpp"
#include "Test/Operators/VariationalInstances/NonlinearMembrane/InputData.hpp"
using namespace MoReFEM;
......@@ -60,23 +61,26 @@ PRAGMA_DIAGNOSTIC(ignored "-Wdisabled-macro-expansion")
#endif // __clang__
BOOST_FIXTURE_TEST_SUITE(same_unknown_for_test, fixture_type)
BOOST_FIXTURE_TEST_SUITE(no_pretension, fixture_type)
BOOST_AUTO_TEST_CASE(same_unknown_for_test_matrix_only)
BOOST_AUTO_TEST_CASE(matrix_only)
{
GetModel().TestP1P1(assemble_into_matrix::yes, assemble_into_vector::no);
GetModel().TestP1P1(TestNS::NonLinearMembraneOperatorNS::pretension::no,
assemble_into_matrix::yes, assemble_into_vector::no);
}
BOOST_AUTO_TEST_CASE(same_unknown_for_test_vector_only)
BOOST_AUTO_TEST_CASE(vector_only)
{
GetModel().TestP1P1(assemble_into_matrix::no, assemble_into_vector::yes);
GetModel().TestP1P1(TestNS::NonLinearMembraneOperatorNS::pretension::no,
assemble_into_matrix::no, assemble_into_vector::yes);
}
BOOST_AUTO_TEST_CASE(same_unknown_for_test_matrix_and_vector)
BOOST_AUTO_TEST_CASE(matrix_and_vector)
{
GetModel().TestP1P1(assemble_into_matrix::yes, assemble_into_vector::yes);
GetModel().TestP1P1(TestNS::NonLinearMembraneOperatorNS::pretension::no,
assemble_into_matrix::yes, assemble_into_vector::yes);
}
BOOST_AUTO_TEST_SUITE_END()
......
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