Commit 1eab000d authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1443 Beef-up the load GodOfDof from prepartitioned data test by adding:

- A vectorial unknown
- A second FEltSpace in which both unknown are in the same NumberingSubset.
- Volume dofs (through P0)
parent ddf2b381
......@@ -119,7 +119,7 @@ namespace MoReFEM::Internal::GodOfDofNS
out << "program_wise_dof_index_for_numbering_subset_" << numbering_subset.GetUniqueId() << " = ";
Utilities::PrintContainer<>::Do(GenerateProgramWiseDofIndexesForNumberingSubset(god_of_dof,
numbering_subset),
out, ", ", "{ ", " }");
out, ", ", "{ ", " }\n");
out << std::endl;
}
}
......
......@@ -110,9 +110,9 @@ namespace MoReFEM
/*!
* \brief This method must be called to fulfill construction of the objet.
*
* \internal The \a Dof are built there as they need weak pointer to current object - which the constructor can't give directly.
*
* \param[in] Ndof Number of dofs to create.
*
* \internal The \a Dof are built there as they need weak pointer to current object - which the constructor can't give directly.
*/
void Init(unsigned int Ndof);
......
......@@ -38,7 +38,7 @@ namespace MoReFEM
//! \copydoc doxygen_hide_mesh_enum
enum class MeshIndex
enum class MeshIndex: unsigned int
{
mesh = 1
};
......@@ -46,10 +46,35 @@ namespace MoReFEM
//! Default value for some input parameter that are required by a MoReFEM model but are actually unused
//! for current test.
constexpr auto original = 1;
constexpr auto original = 1u;
//! Index associated to stuff built from pre-partitioned data (which were themselves written from original ones).
constexpr auto reconstructed = 10;
constexpr auto reconstructed = 11u;
//! We take the convention of adding this quantity to get reconstructed index from original one.
//! For instance the pendant of original separated FEltSpaceIndex (1) is 11 (we add 10).
constexpr auto reconstructed_overhead = 10u;
//! Enum class for unknowns.
enum class UnknownIndex : unsigned int
{
scalar = 1, vectorial
};
//! Enum class for NumberingSubsets
enum class NumberingSubsetIndex: unsigned int
{
scalar = 1, vectorial, mixed
};
//! Enum class for NumberingSubsets
enum class FEltSpaceIndex: unsigned int
{
separated = 1, mixed,
reconstructed_separated = 11, reconstructed_mixed
};
//! \copydoc doxygen_hide_input_data_tuple
......@@ -59,11 +84,19 @@ namespace MoReFEM
InputDataNS::Mesh<EnumUnderlyingType(MeshIndex::mesh)>,
InputDataNS::Unknown<original>,
InputDataNS::Unknown<EnumUnderlyingType(UnknownIndex::scalar)>,
InputDataNS::Unknown<EnumUnderlyingType(UnknownIndex::vectorial)>,
InputDataNS::NumberingSubset<EnumUnderlyingType(NumberingSubsetIndex::scalar)>,
InputDataNS::NumberingSubset<EnumUnderlyingType(NumberingSubsetIndex::vectorial)>,
InputDataNS::NumberingSubset<EnumUnderlyingType(NumberingSubsetIndex::mixed)>,
InputDataNS::Domain<original>,
InputDataNS::Domain<reconstructed>,
InputDataNS::NumberingSubset<original>,
InputDataNS::FEltSpace<original>,
InputDataNS::FEltSpace<EnumUnderlyingType(FEltSpaceIndex::separated)>,
InputDataNS::FEltSpace<EnumUnderlyingType(FEltSpaceIndex::mixed)>,
InputDataNS::Petsc<original>,
InputDataNS::Result,
......
......@@ -26,6 +26,48 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
{
namespace // anonymous
{
FEltSpace::vector_unique_ptr GenerateReconstructedFEltSpaceList()
{
FEltSpace::vector_unique_ptr ret;
decltype(auto) god_of_dof_manager = GodOfDofManager::GetInstance(__FILE__, __LINE__);
decltype(auto) domain_manager = DomainManager::GetInstance(__FILE__, __LINE__);
decltype(auto) original_god_of_dof = god_of_dof_manager.GetGodOfDof(original);
decltype(auto) reconstructed_god_of_dof_ptr = god_of_dof_manager.GetGodOfDofPtr(reconstructed);
decltype(auto) reconstructed_domain = domain_manager.GetDomain(reconstructed, __FILE__, __LINE__);
const auto original_felt_space_index_list = { FEltSpaceIndex::separated, FEltSpaceIndex::mixed };
for (auto original_felt_space_index : original_felt_space_index_list)
{
decltype(auto) original_separated_felt_space =
original_god_of_dof.GetFEltSpace(EnumUnderlyingType(original_felt_space_index));
// Copy on purpose!
auto extended_unknown_list = original_separated_felt_space.GetExtendedUnknownList();
auto felt_space_ptr =
std::make_unique<FEltSpace>(reconstructed_god_of_dof_ptr,
reconstructed_domain,
EnumUnderlyingType(original_felt_space_index) + reconstructed_overhead,
std::move(extended_unknown_list));
ret.emplace_back(std::move(felt_space_ptr));
}
return ret;
}
} // namespace anonymous
Model::Model(const morefem_data_type& morefem_data)
: parent(morefem_data)
{ }
......@@ -36,7 +78,6 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
decltype(auto) mpi = parent::GetMpi();
decltype(auto) mesh_manager = Internal::MeshNS::MeshManager::GetInstance(__FILE__, __LINE__);
decltype(auto) mesh = mesh_manager.GetMesh<1>();
// decltype(auto) output_dir = parent::GetOutputDirectory();
decltype(auto) input_data = parent::GetMoReFEMData().GetInputData();
......@@ -85,25 +126,11 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
god_of_dof_manager.Create(mpi, mesh);
decltype(auto) original_god_of_dof = god_of_dof_manager.GetGodOfDof(1);
decltype(auto) original_felt_space = original_god_of_dof.GetFEltSpace(1);
FilesystemNS::Directory output_directory(GetOutputDirectory(),
"Reconstructed",
__FILE__, __LINE__);
decltype(auto) domain_manager = DomainManager::GetInstance(__FILE__, __LINE__);
// Copy is intended!
auto extended_unknown_list = original_felt_space.GetExtendedUnknownList();
auto felt_space_ptr = std::make_unique<FEltSpace>(god_of_dof_manager.GetGodOfDofPtr(reconstructed),
domain_manager.GetDomain(reconstructed, __FILE__, __LINE__),
reconstructed,
std::move(extended_unknown_list));
FEltSpace::vector_unique_ptr felt_space_list;
felt_space_list.emplace_back(std::move(felt_space_ptr));
FEltSpace::vector_unique_ptr felt_space_list = GenerateReconstructedFEltSpaceList();
decltype(auto) reconstructed_god_of_dof = god_of_dof_manager.GetNonCstGodOfDof(reconstructed);
......@@ -225,9 +252,6 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
BOOST_CHECK_EQUAL(original_god_of_dof.NprogramWiseDof(),
reconstructed_god_of_dof.NprogramWiseDof());
// \todo #1443 Use better indexing here...
decltype(auto) numbering_subset = original_god_of_dof.GetNumberingSubset(original);
{
decltype(auto) original_dof_list = original_god_of_dof.GetProcessorWiseDofList();
decltype(auto) reconstructed_dof_list = reconstructed_god_of_dof.GetProcessorWiseDofList();
......@@ -249,6 +273,40 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
BOOST_CHECK_EQUAL(original_dof.GetInternalProcessorWiseOrGhostIndex(),
reconstructed_dof.GetInternalProcessorWiseOrGhostIndex());
}
}
}
void Model::CheckDofListInGodOfDofForNumberingSubset(NumberingSubsetIndex numbering_subset_index) const
{
decltype(auto) god_of_dof_manager = GodOfDofManager::GetInstance(__FILE__, __LINE__);
decltype(auto) original_god_of_dof = god_of_dof_manager.GetGodOfDof(original);
decltype(auto) reconstructed_god_of_dof = god_of_dof_manager.GetGodOfDof(reconstructed);
decltype(auto) numbering_subset =
original_god_of_dof.GetNumberingSubset(EnumUnderlyingType(numbering_subset_index));
{
decltype(auto) original_dof_list = original_god_of_dof.GetProcessorWiseDofList();
decltype(auto) reconstructed_dof_list = reconstructed_god_of_dof.GetProcessorWiseDofList();
assert(original_dof_list.size() == reconstructed_dof_list.size()
&& "Should have been checked by previous test.");
const auto size = original_dof_list.size();
for (auto i = 0ul; i < size; ++i)
{
decltype(auto) original_dof_ptr = original_dof_list[i];
decltype(auto) reconstructed_dof_ptr = reconstructed_dof_list[i];
assert(!(!original_dof_ptr));
assert(!(!reconstructed_dof_ptr));
const auto& original_dof = *original_dof_ptr;
const auto& reconstructed_dof = *reconstructed_dof_ptr;
if (original_dof.IsInNumberingSubset(numbering_subset))
{
......@@ -269,15 +327,19 @@ namespace MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS
}
void Model::CheckDofListInFEltSpace() const
void Model::CheckDofListInFEltSpace(FEltSpaceIndex felt_space_index) const
{
decltype(auto) god_of_dof_manager = GodOfDofManager::GetInstance(__FILE__, __LINE__);
decltype(auto) original_god_of_dof = god_of_dof_manager.GetGodOfDof(original);
decltype(auto) reconstructed_god_of_dof = god_of_dof_manager.GetGodOfDof(reconstructed);
decltype(auto) original_felt_space = original_god_of_dof.GetFEltSpace(original);
decltype(auto) reconstructed_felt_space = reconstructed_god_of_dof.GetFEltSpace(reconstructed);
decltype(auto) original_felt_space =
original_god_of_dof.GetFEltSpace(EnumUnderlyingType(felt_space_index));
decltype(auto) reconstructed_felt_space =
reconstructed_god_of_dof.GetFEltSpace(EnumUnderlyingType(felt_space_index)
+ reconstructed_overhead);
decltype(auto) original_dof_list = original_felt_space.GetProcessorWiseDofList();
decltype(auto) reconstructed_dof_list = reconstructed_felt_space.GetProcessorWiseDofList();
......
......@@ -136,8 +136,13 @@ namespace MoReFEM
//! Check the \a Dof list is the same as in the original run in \a GodOfDof.
void CheckDofListInGodOfDof() const;
//! Check the indexes of \a Dof related to the \a NumberingSubset indexed by \a numbering_subset_index are on par with original run.
//! \param[in] numbering_subset_index Index of the \a NumberingSubset considered.
void CheckDofListInGodOfDofForNumberingSubset(NumberingSubsetIndex numbering_subset_index) const;
//! Check the \a Dof list is the same as in the original run in \a FEltSpace.
void CheckDofListInFEltSpace() const;
//! \param[in] felt_space_index Index of the \a FEltSpace considered.
void CheckDofListInFEltSpace(FEltSpaceIndex felt_space_index) const;
private:
......
......@@ -87,12 +87,12 @@ Domain1 = {
} -- Domain1
Domain10 = {
Domain11 = {
-- Index of the geometric mesh upon which the domain is defined (as defined in the present file). Might be
-- left empty if domain not limited to one mesh; at most one value is expected here.
-- Expected format: {VALUE1, VALUE2, ...}
mesh_index = { 10 },
mesh_index = { 11 },
-- List of dimensions encompassed by the domain. Might be left empty if no restriction at all upon
-- dimensions.
......@@ -119,23 +119,41 @@ Domain10 = {
-- Expected format: {"VALUE1", "VALUE2", ...}
geometric_element_type_list = {}
} -- Domain10
} -- Domain11
Unknown1 = {
-- Name of the unknown (used for displays in output).
-- Expected format: "VALUE"
name = "scalar",
-- Index of the god of dof into which the finite element space is defined.
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'scalar', 'vectorial'})
nature = "scalar"
} -- Unknown1
Unknown2 = {
-- Name of the unknown (used for displays in output).
-- Expected format: "VALUE"
name = "whatever",
name = "vectorial",
-- Index of the god of dof into which the finite element space is defined.
-- Expected format: "VALUE"
-- Constraint: value_in(v, {'scalar', 'vectorial'})
nature = "scalar"
nature = "vectorial"
} -- Unknown2
} -- Unknown1
NumberingSubset1 = {
......@@ -143,7 +161,7 @@ NumberingSubset1 = {
-- Name of the numbering subset (not really used; at the moment I just need one input parameter to ground
-- the possible values to choose elsewhere).
-- Expected format: "VALUE"
name = "whatever",
name = "scalar",
-- Whether a vector defined on this numbering subset might be used to compute a movemesh. If true, a
......@@ -156,6 +174,44 @@ NumberingSubset1 = {
} -- NumberingSubset1
NumberingSubset2 = {
-- Name of the numbering subset (not really used; at the moment I just need one input parameter to ground
-- the possible values to choose elsewhere).
-- Expected format: "VALUE"
name = "vectorial",
-- Whether a vector defined on this numbering subset might be used to compute a movemesh. If true, a
-- FEltSpace featuring this numbering subset will compute additional quantities to enable fast computation.
-- This should be false for most numbering subsets, and when it's true the sole unknown involved should be a
-- displacement.
-- Expected format: 'true' or 'false' (without the quote)
do_move_mesh = false
} -- NumberingSubset2
NumberingSubset3 = {
-- Name of the numbering subset (not really used; at the moment I just need one input parameter to ground
-- the possible values to choose elsewhere).
-- Expected format: "VALUE"
name = "mixed",
-- Whether a vector defined on this numbering subset might be used to compute a movemesh. If true, a
-- FEltSpace featuring this numbering subset will compute additional quantities to enable fast computation.
-- This should be false for most numbering subsets, and when it's true the sole unknown involved should be a
-- displacement.
-- Expected format: 'true' or 'false' (without the quote)
do_move_mesh = false
} -- NumberingSubset3
FiniteElementSpace1 = {
......@@ -169,23 +225,55 @@ FiniteElementSpace1 = {
domain_index = 1,
-- List of all unknowns defined in the finite element space. Unknowns here must be defined in this file as
-- an 'Unknown' block; expected name/identifier is the name given there.
-- Expected format: {"VALUE1", "VALUE2", ...}
unknown_list = { "whatever" },
-- List of all unknowns defined in the finite element space. Unknowns here must be defined in this file as
-- an 'Unknown' block; expected name/identifier is the name given there.
-- Expected format: {"VALUE1", "VALUE2", ...}
unknown_list = { "scalar", "vectorial" },
-- List of the shape function to use for each unknown;
-- Expected format: {"VALUE1", "VALUE2", ...}
shape_function_list = { "P2" },
-- List of the shape function to use for each unknown;
-- Expected format: {"VALUE1", "VALUE2", ...}
shape_function_list = { "P2", "P1b" },
-- List of the numbering subset to use for each unknown;
-- Expected format: { VALUE1, VALUE2, ...}
numbering_subset_list = { 1 }
-- List of the numbering subset to use for each unknown;
-- Expected format: { VALUE1, VALUE2, ...}
numbering_subset_list = { 1, 2 }
} -- FiniteElementSpace1
FiniteElementSpace2 = {
-- Index of the god of dof into which the finite element space is defined.
-- Expected format: VALUE
god_of_dof_index = 1,
-- Index of the domain onto which the finite element space is defined. This domain must be unidimensional.
-- Expected format: VALUE
domain_index = 1,
-- List of all unknowns defined in the finite element space. Unknowns here must be defined in this file as
-- an 'Unknown' block; expected name/identifier is the name given there.
-- Expected format: {"VALUE1", "VALUE2", ...}
unknown_list = { "scalar", "vectorial" },
-- List of the shape function to use for each unknown;
-- Expected format: {"VALUE1", "VALUE2", ...}
shape_function_list = { "P2", "P1b" },
-- List of the numbering subset to use for each unknown;
-- Expected format: { VALUE1, VALUE2, ...}
numbering_subset_list = { 3, 3 }
} -- FiniteElementSpace2
Petsc1 = {
......
......@@ -111,12 +111,74 @@ BOOST_FIXTURE_TEST_CASE(check_dof_list_in_god_of_dof, fixture_type)
}
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_felt_space, fixture_type)
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_god_of_dof_scalar_numbering_subset, fixture_type)
{
try
{
using namespace TestNS::LoadPrepartitionedGodOfDofNS;
decltype(auto) model = GetModel();
model.CheckDofListInFEltSpace();
model.CheckDofListInGodOfDofForNumberingSubset(NumberingSubsetIndex::scalar);
}
catch(const ExceptionNS::GracefulExit& ) // TMP #1443
{
}
}
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_god_of_dof_vectorial_numbering_subset, fixture_type)
{
try
{
using namespace TestNS::LoadPrepartitionedGodOfDofNS;
decltype(auto) model = GetModel();
model.CheckDofListInGodOfDofForNumberingSubset(NumberingSubsetIndex::vectorial);
}
catch(const ExceptionNS::GracefulExit& ) // TMP #1443
{
}
}
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_god_of_dof_mixed_numbering_subset, fixture_type)
{
try
{
using namespace TestNS::LoadPrepartitionedGodOfDofNS;
decltype(auto) model = GetModel();
model.CheckDofListInGodOfDofForNumberingSubset(NumberingSubsetIndex::mixed);
}
catch(const ExceptionNS::GracefulExit& ) // TMP #1443
{
}
}
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_separated_felt_space, fixture_type)
{
try
{
using namespace TestNS::LoadPrepartitionedGodOfDofNS;
decltype(auto) model = GetModel();
model.CheckDofListInFEltSpace(FEltSpaceIndex::separated);
}
catch(const ExceptionNS::GracefulExit& ) // TMP #1443
{
}
}
BOOST_FIXTURE_TEST_CASE(check_dof_list_in_mixed_felt_space, fixture_type)
{
try
{
using namespace TestNS::LoadPrepartitionedGodOfDofNS;
decltype(auto) model = GetModel();
model.CheckDofListInFEltSpace(FEltSpaceIndex::mixed);
}
catch(const ExceptionNS::GracefulExit& ) // TMP #1443
{
......
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