Commit 07a9fac8 authored by GILLES Sebastien's avatar GILLES Sebastien

#1534 Writing the new MatrixTestOperation test (in progress).

parent 802309ed
......@@ -31,8 +31,8 @@ namespace MoReFEM::TestNS::PetscNS::MatrixOperationsNS
void Model::SupplInitialize()
{
decltype(auto) god_of_dof_manager = GodOfDofManager::GetInstance(__FILE__, __LINE__);
decltype(auto) god_of_dof = god_of_dof_manager.GetGodOfDof(1);
decltype(auto) numbering_subset = god_of_dof.GetNumberingSubset(1);
decltype(auto) god_of_dof = god_of_dof_manager.GetGodOfDof(sole);
decltype(auto) numbering_subset = god_of_dof.GetNumberingSubset(sole);
decltype(auto) mpi = god_of_dof.GetMpi();
vector_init_1_ = std::make_unique<GlobalVector>(numbering_subset);
......@@ -47,7 +47,13 @@ namespace MoReFEM::TestNS::PetscNS::MatrixOperationsNS
AllocateGlobalVector(god_of_dof, vector_init_2);
AllocateGlobalVector(god_of_dof, vector_init_3);
matrix_init_1_ = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
for (auto i = 0ul; i < Utilities::ArraySize<decltype(initialized_matrix_list_)>::GetValue(); ++i)
{
initialized_matrix_list_[i] = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
AllocateGlobalMatrix(god_of_dof, *initialized_matrix_list_[i]);
}
matrix_init_2_ = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
matrix_init_3_ = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
......@@ -59,7 +65,6 @@ namespace MoReFEM::TestNS::PetscNS::MatrixOperationsNS
matrix_9_ = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
matrix_10_ = std::make_unique<GlobalMatrix>(numbering_subset, numbering_subset);
auto& matrix_init_1 = *matrix_init_1_;
auto& matrix_init_2 = *matrix_init_2_;
auto& matrix_init_3 = *matrix_init_3_;
......@@ -73,7 +78,6 @@ namespace MoReFEM::TestNS::PetscNS::MatrixOperationsNS
auto& matrix_10 = *matrix_10_;
// only three matrices allocated, all the others are set to PETSC_NULL
AllocateGlobalMatrix(god_of_dof, matrix_init_1);
AllocateGlobalMatrix(god_of_dof, matrix_init_2);
AllocateGlobalMatrix(god_of_dof, matrix_init_3);
......
......@@ -14,6 +14,8 @@
# include <memory>
# include <vector>
# include "Utilities/Containers/Array.hpp"
# include "Core/InputData/Instances/Result.hpp"
# include "Model/Model.hpp"
......@@ -120,6 +122,32 @@ namespace MoReFEM
*/
void SupplFinalize();
/*!
* \brief Constant access to a matrix that was fully initialized (i.e. with layout also defined, not just the constructor called).
*
* \tparam I Index of the requested matrix (some tests require several so several are stored). There are static check for the consistency of this
* index.
*
* \return Constant accessor to an initialized matrix.
*/
template<std::size_t I>
const GlobalMatrix& GetInitializedMatrix() const noexcept;
/*!
* \brief Non-constant access to a matrix that was fully initialized (i.e. with layout also defined, not just the constructor called).
*
* \tparam I Index of the requested matrix (some tests require several so several are stored). There are static check for the consistency of this
* index.
*
* \return Non-constant accessor to an initialized matrix.
*/
template<std::size_t I>
GlobalMatrix& GetNonCstInitializedMatrix() noexcept;
//! Get the \a NumberingSubset used in the tests.
const NumberingSubset& GetNumberingSubset() const noexcept;
private:
......@@ -154,7 +182,8 @@ namespace MoReFEM
///@{
//! Matrix used in the test.
GlobalMatrix::unique_ptr matrix_init_1_ = nullptr;
GlobalMatrix::array_unique_ptr<2> initialized_matrix_list_
= Utilities::NullptrArray<GlobalMatrix::unique_ptr, 2>();
//! Matrix used in the test.
GlobalMatrix::unique_ptr matrix_init_2_ = nullptr;
......
......@@ -35,6 +35,30 @@ namespace MoReFEM
{ }
template<std::size_t I>
inline const GlobalMatrix& Model::GetInitializedMatrix() const noexcept
{
static_assert(I < Utilities::ArraySize<decltype(initialized_matrix_list_)>::GetValue());
assert(!(!initialized_matrix_list_[I]));
return *initialized_matrix_list_[I];
}
template<std::size_t I>
inline GlobalMatrix& Model::GetNonCstInitializedMatrix() noexcept
{
return const_cast<GlobalMatrix&>(GetInitializedMatrix<I>());
}
inline const NumberingSubset& Model::GetNumberingSubset() const noexcept
{
decltype(auto) god_of_dof_manager = GodOfDofManager::GetInstance(__FILE__, __LINE__);
decltype(auto) god_of_dof = god_of_dof_manager.GetGodOfDof(sole);
return god_of_dof.GetNumberingSubset(sole);
}
} // namespace TestNS::PetscNS::MatrixOperationsNS
......
......@@ -49,6 +49,7 @@ namespace // anonymous
>;
} // namespace anonymous
......@@ -56,29 +57,53 @@ PRAGMA_DIAGNOSTIC(push)
#include "Utilities/Warnings/Internal/IgnoreWarning/disabled-macro-expansion.hpp"
BOOST_FIXTURE_TEST_CASE(creation, fixture_type)
BOOST_FIXTURE_TEST_CASE(model_initialization, fixture_type)
{
decltype(auto) model = GetModel();
static_cast<void>(model);
}
/**
{
BOOST_FIXTURE_TEST_CASE(create_transpose, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) numbering_subset = model.GetNumberingSubset();
GlobalMatrix non_allocated_matrix(numbering_subset, numbering_subset);
Wrappers::Petsc::MatCreateTranspose(model.GetInitializedMatrix<0>(),
non_allocated_matrix,
__FILE__, __LINE__);
}
BOOST_FIXTURE_TEST_CASE(axpy, fixture_type)
{
decltype(auto) model = GetNonCstModel();
// First all wrappers that do not use a DoReuseMatrix policy
Wrappers::Petsc::MatCreateTranspose(matrix_init_1,
matrix_4,
__FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>(1.,
model.GetInitializedMatrix<0>(),
model.GetNonCstInitializedMatrix<1>(),
__FILE__, __LINE__);
}
//BOOST_FIXTURE_TEST_CASE(mat_shift, fixture_type)
//{
// decltype(auto) model = GetModel();
//
// Wrappers::Petsc::MatShift(1.,
// model.GetInitializedMatrix<0>(),
// __FILE__, __LINE__);
//}
/*
{
Wrappers::Petsc::AXPY<NonZeroPattern::same>(1.,
matrix_init_1,
matrix_init_2,
__FILE__, __LINE__);
Wrappers::Petsc::MatShift(1.,
matrix_init_1,
__FILE__, __LINE__);
Wrappers::Petsc::MatMult(matrix_init_1,
vector_init_1,
......
......@@ -107,6 +107,14 @@ namespace MoReFEM
*/
static const ModelT& GetModel();
/*!
* \brief Static method which yields the model considered for the tests.
*
* \return Non constant reference to the \a Model.
*/
static ModelT& GetNonCstModel();
/*!
* \brief Static method which yields the \a MoReFEMData considered for the tests.
*
......
......@@ -83,6 +83,18 @@ namespace MoReFEM
}
template
<
class ModelT,
class LuaFileT,
call_run_method_at_first_call CallRunMethodT
>
ModelT& Model<ModelT, LuaFileT, CallRunMethodT>::GetNonCstModel()
{
return const_cast<ModelT&>(GetModel());
}
template
<
class ModelT,
......
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