Commit d8eefd1a authored by GILLES Sebastien's avatar GILLES Sebastien

#1246 Test Pk2 operator: I've found out how to use different tests in the same...

#1246 Test Pk2 operator: I've found out how to use different tests in the same main. Needs to be cleant-up.
parent a316ec2a
......@@ -71,6 +71,8 @@ namespace MoReFEM
// Required to enable construction of an operator after initialization step.
parent::SetClearGodOfDofTemporaryDataToFalse();
std::cout << "SUPPL INITIALIZE DONE" << std::endl;
}
......
......@@ -157,7 +157,7 @@ namespace MoReFEM
* \brief Case when the test function uses up the same \a Unknown.
*
*/
void SameUnknown();
void SameUnknown() const;
/*!
* \brief Case when the test function uses up a different \a Unknown with the same shape label.
......@@ -165,13 +165,13 @@ namespace MoReFEM
* As the tests are only sequential, the expected result should be the same as for \a SameUnknown (it would
* be another story in parallel...)
*/
void UnknownP1TestP1();
void UnknownP1TestP1() const;
/*!
* \brief Case with a P2 unknown and a P1 test function.
*
*/
void UnknownP2TestP1();
void UnknownP2TestP1() const;
private:
......
......@@ -23,7 +23,7 @@ namespace MoReFEM
{
void Model::SameUnknown()
void Model::SameUnknown() const
{
const auto& god_of_dof = GetGodOfDof(EnumUnderlyingType(MeshIndex::mesh));
......
......@@ -23,7 +23,7 @@ namespace MoReFEM
{
void Model::UnknownP1TestP1()
void Model::UnknownP1TestP1() const
{
const auto& god_of_dof = GetGodOfDof(EnumUnderlyingType(MeshIndex::mesh));
......
......@@ -23,7 +23,7 @@ namespace MoReFEM
{
void Model::UnknownP2TestP1()
void Model::UnknownP2TestP1() const
{
const auto& god_of_dof = GetGodOfDof(EnumUnderlyingType(MeshIndex::mesh));
......
......@@ -21,23 +21,88 @@
using namespace MoReFEM;
TEST_CASE("Operator Pk2")
namespace // anonymous
{
using type = TestNS::InitializeTestMoReFEMData<TestNS::Pk2::InputParameterList>;
type helper(Utilities::EnvironmentNS::SubstituteValues("${MOREFEM_ROOT}/Sources/Test/Operators/"
"VariationalInstances/Pk2/"
"demo_input_parameter_3D.lua"));
struct Fixture
{
Fixture();
~Fixture() = default;
decltype(auto) morefem_data = helper.GetMoReFEMData();
const auto& mpi = morefem_data.GetMpi();
using type = TestNS::InitializeTestMoReFEMData<TestNS::Pk2::InputParameterList>;
TestNS::Pk2::Model model(morefem_data);
model.Run(morefem_data);
static const type& StaticInitMoReFEMData();
model.SameUnknown();
model.UnknownP1TestP1();
model.UnknownP2TestP1();
const TestNS::Pk2::Model& GetModel() const noexcept;
std::unique_ptr<TestNS::Pk2::Model> model_ = nullptr;
};
} // namespace anonymous
TEST_CASE_METHOD(Fixture, "Unknown and test function unknown are identical")
{
std::cout << "BEGIN SAME Unknown" << std::endl;
GetModel().SameUnknown();
std::cout << "END SAME Unknown" << std::endl;
}
TEST_CASE_METHOD(Fixture, "Unknown and test function unknown are different but share the same P1 shape function label")
{
std::cout << "BEGIN DIFF Unknown" << std::endl;
GetModel().UnknownP1TestP1();
std::cout << "END DIFF Unknown" << std::endl;
}
TEST_CASE_METHOD(Fixture, "Unknown and test function unknown are different; unknown is P2 and test function P1")
{
std::cout << "BEGIN DIFF 2 Unknown" << std::endl;
GetModel().UnknownP2TestP1();
std::cout << "END DIFF 2 Unknown" << std::endl;
}
namespace // anonymous
{
const Fixture::type& Fixture::StaticInitMoReFEMData()
{
static auto ptr =
std::make_unique<type>(Utilities::EnvironmentNS::SubstituteValues("${MOREFEM_ROOT}/Sources/Test/Operators/"
"VariationalInstances/Pk2/"
"demo_input_parameter_3D.lua"));
return *ptr;
}
Fixture::Fixture()
{
std::cout << "FIXTURE CONSTRUCTOR" << std::endl;
decltype(auto) morefem_data = StaticInitMoReFEMData().GetMoReFEMData();
const auto& mpi = morefem_data.GetMpi();
model_ = std::make_unique<TestNS::Pk2::Model>(morefem_data);
assert(!(!model_));
model_->Run(morefem_data);
std::cout << "FIXTURE CONSTRUCTOR DONE" << std::endl;
}
const TestNS::Pk2::Model& Fixture::GetModel() const noexcept
{
assert(!(!model_));
return *model_;
}
} // namespace anonymous
......@@ -62,7 +62,7 @@ namespace MoReFEM
explicit InitializeTestMoReFEMData(std::string&& lua_file);
//! Destructor.
~InitializeTestMoReFEMData();
~InitializeTestMoReFEMData() = default;
//! Copy constructor.
InitializeTestMoReFEMData(const InitializeTestMoReFEMData&) = delete;
......@@ -78,15 +78,13 @@ namespace MoReFEM
///@}
void Destroy();
//! Accessor to the \a MoReFEMData object.
const morefem_data_type& GetMoReFEMData() const noexcept;
private:
//! Storage of the \a MoReFEMData object.
morefem_data_type* morefem_data_ = nullptr;
typename morefem_data_type::const_unique_ptr morefem_data_ = nullptr;
//! Generated argv.
char** argv_;
......
......@@ -34,24 +34,7 @@ namespace MoReFEM
argv_ = dummy_args;
//morefem_data_ = std::make_unique<morefem_data_type>(3, argv_);
morefem_data_ = new morefem_data_type(3, argv_);
}
template<class InputParameterListT>
InitializeTestMoReFEMData<InputParameterListT>
::~InitializeTestMoReFEMData()
{
//Destroy();
}
template<class InputParameterListT>
void InitializeTestMoReFEMData<InputParameterListT>
::Destroy()
{
delete morefem_data_;
morefem_data_ = std::make_unique<morefem_data_type>(3, argv_);
}
......
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