Commit 2357eca4 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1332 Add a test case for solid.

parent 55c2ce29
......@@ -4755,6 +4755,10 @@
BEDEDE04212FFB4C0060F00E /* Solid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Solid.cpp; sourceTree = "<group>"; };
BEDEDE05212FFB4C0060F00E /* Solid.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Solid.hxx; sourceTree = "<group>"; };
BEDEDE06212FFB4C0060F00E /* Solid.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Solid.hpp; sourceTree = "<group>"; };
BEDEDE0B213002990060F00E /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEDEDE0F2130029A0060F00E /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEDEDE1E2130029A0060F00E /* test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = test.cpp; sourceTree = "<group>"; };
BEDEDE22213025C30060F00E /* demo_solid_all_defined.lua */ = {isa = PBXFileReference; lastKnownFileType = text; path = demo_solid_all_defined.lua; sourceTree = "<group>"; };
BEDFFB52204EE3E200A52F86 /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch.hpp; sourceTree = "<group>"; };
BEDFFB7C204EE4F400A52F86 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEDFFB7D204EE4F400A52F86 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
......@@ -7127,6 +7131,7 @@
BE372DCE18C47F1100127212 /* Geometry */,
BE5A4E1F1B677AE0006822DD /* Operators */,
BE6A983D1BC66CDC004184F2 /* Parameter */,
BEDEDE0A213002990060F00E /* ParameterInstances */,
);
name = Test;
path = Sources/Test;
......@@ -10309,6 +10314,25 @@
path = Exceptions;
sourceTree = "<group>";
};
BEDEDE0A213002990060F00E /* ParameterInstances */ = {
isa = PBXGroup;
children = (
BEDEDE0B213002990060F00E /* CMakeLists.txt */,
BEDEDE0C213002990060F00E /* Solid */,
);
path = ParameterInstances;
sourceTree = "<group>";
};
BEDEDE0C213002990060F00E /* Solid */ = {
isa = PBXGroup;
children = (
BEDEDE0F2130029A0060F00E /* CMakeLists.txt */,
BEDEDE22213025C30060F00E /* demo_solid_all_defined.lua */,
BEDEDE1E2130029A0060F00E /* test.cpp */,
);
path = Solid;
sourceTree = "<group>";
};
BEDFFB51204EE3E200A52F86 /* Catch */ = {
isa = PBXGroup;
children = (
......@@ -126,7 +126,7 @@ namespace MoReFEM
void Print(std::ostream& stream) const;
//! Constant accessor to the volumic mass.
const scalar_parameter& GetVolumicMass() const noexcept;
const scalar_parameter& GetVolumicMass() const;
/*!
* \class doxygen_hide_solid_optional_for_accessor
......
......@@ -183,9 +183,11 @@ namespace MoReFEM
}
inline const Solid::scalar_parameter& Solid::GetVolumicMass() const noexcept
inline const Solid::scalar_parameter& Solid::GetVolumicMass() const
{
assert(!(!volumic_mass_));
if (!volumic_mass_)
throw SolidNS::UndefinedData("Volumic mass", __FILE__, __LINE__);
return *volumic_mass_;
}
......
......@@ -7,5 +7,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/Geometry/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Ondomatic/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Operators/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Parameter/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/ParameterInstances/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/ThirdParty/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Solid/CMakeLists.txt)
add_executable(MoReFEMTestSolid
${CMAKE_CURRENT_LIST_DIR}/test.cpp)
target_link_libraries(MoReFEMTestSolid
${ALL_LOAD_BEGIN_FLAG}
${MOREFEM_PARAM_INSTANCES}
${ALL_LOAD_END_FLAG})
add_test(Solid
MoReFEMTestSolid
--root_dir ${MOREFEM_ROOT}
--test_output_dir ${MOREFEM_TEST_OUTPUT_DIR})
-- Comment lines are introduced by "--".
-- In a section (i.e. within braces), all entries must be separated by a comma.
Solid = {
VolumicMass = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 10.4
}, -- VolumicMass
HyperelasticBulk = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 1750000.
}, -- HyperelasticBulk
Kappa1 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 500.
}, -- Kappa1
Kappa2 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 403346.1538461538,
}, -- Kappa2
PoissonRatio = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = .3
}, -- PoissonRatio
YoungModulus = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 21.e5
}, -- YoungModulus
LameLambda = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 1211538.4615384615,
}, -- LameLambda
LameMu = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 807692.3076923076,
}, -- LameMu
Viscosity = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 8.
}, -- Viscosity
Mu1 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 9.
}, -- Mu1
Mu2 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 10.
}, -- Mu2
C0 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 11.
}, -- C0
C1 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 12.
}, -- C1
C2 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 13.
}, -- C2
C3 = {
-- How is given the parameter (as a constant, as a Lua function, per quadrature point, etc...). Choose
-- "ignore" if you do not want this parameter (in this case it will stay at nullptr).
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'ignore', 'constant', 'lua_function','piecewise_constant_by_domain'})
nature = "constant",
-- The value for the parameter, which type depends directly on the nature chosen:
-- If nature is 'constant', expected format is VALUE
-- If nature is 'piecewise_constant_by_domain', expected format is {[KEY1] = VALUE1, [KEY2] = VALUE2, ...}
-- If nature is 'lua_function', expected format is a Lua function with prototype function(x, y, z)
-- return x + y - z
-- end
-- where x, y and z are global coordinates. sin, cos, tan, exp and so forth require a 'math.' preffix.
-- Expected format: see the variant description...
value = 14.
}, -- C3
-- For 2D operators, which approximation to use.
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'irrelevant', 'plane_strain', 'plane_stress'})
PlaneStressStrain = "plane_strain"
} -- Solid
Result = {
-- Directory in which all the results will be written. This path may use the environment variable
-- MOREFEM_RESULT_DIR, which is either provided in user's environment or automatically set to
-- '/Volumes/Data/${USER}/MoReFEM/Results' in MoReFEM initialization step. Please do not read this value
-- directly: it might have been extended in MoReFEMData class! Rather call the GetResultDirectory() from
-- this class.
-- Expected format: "VALUE"
output_directory = "${MOREFEM_TEST_OUTPUT_DIR}/Test/ParameterInstances/Solid",
-- Enables to skip some printing in the console. Can be used to WriteSolution every n time.
-- Expected format: VALUE
-- Constraint: v > 0
display_value = 1
} -- Result
/// \file
///
///
/// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Fri, 26 Apr 2013 12:18:22 +0200
/// Copyright (c) Inria. All rights reserved.
///
#include <cstdlib>
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Test/Tools/CatchMainTest.hpp"
#include "Test/Tools/Fixture.hpp"
#include "Test/Operators/VariationalInstances/GradGrad/Model.hpp"
#include "Test/Operators/VariationalInstances/GradGrad/InputParameterList.hpp"
using namespace MoReFEM;
namespace // anonymous
{
struct LuaFile
{
static std::string GetPath();
};
using fixture_type =
TestNS::Fixture
<
TestNS::GradGrad::Model,
LuaFile
>;
} // namespace anonymous
TEST_CASE_METHOD(fixture_type, "Unknown and test function unknown are identical")
{
SECTION("P1 case")
{
GetModel().SameUnknownP1(UnknownNS::Nature::scalar);
}
SECTION("P1 case, vectorial unknown")
{
GetModel().SameUnknownP1(UnknownNS::Nature::vectorial);
}
SECTION("P2 case")
{
GetModel().SameUnknownP2();
}
}
TEST_CASE_METHOD(fixture_type, "Unknown and test function unknown are different but share the same P1 shape function label")
{
GetModel().UnknownP1TestP1();
}
TEST_CASE_METHOD(fixture_type, "Unknown and test function unknown are different; unknown is P2 and test function P1")
{
GetModel().UnknownP2TestP1();
}
namespace // anonymous
{
std::string LuaFile::GetPath()
{
decltype(auto) environment = Utilities::Environment::CreateOrGetInstance(__FILE__, __LINE__);
return
environment.SubstituteValues("${MOREFEM_ROOT}/Sources/Test/Operators/"
"VariationalInstances/GradGrad/"
"demo_input_parameter_1D.lua");
}
} // namespace anonymous
/// \file
///
///
/// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Fri, 26 Apr 2013 12:18:22 +0200
/// Copyright (c) Inria. All rights reserved.
///
#include <cstdlib>
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/Numeric/Numeric.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Geometry/Mesh/Internal/MeshManager.hpp"
#include "Geometry/Domain/DomainManager.hpp"
#include "ParameterInstances/Compound/Solid/Solid.hpp"
#include "Test/Tools/CatchMainTest.hpp"
#include "Test/Tools/InitializeTestMoReFEMData.hpp"
using namespace MoReFEM;
namespace MoReFEM
{
struct TestHelper
{
TestHelper()
{
DomainManager::CreateOrGetInstance(__FILE__, __LINE__).Create(1,
{ 1 },
{ 2 },
{ }, { });
}
};
} // namespace MoReFEM
namespace // anonymous
{