Commit 6138319e authored by GILLES Sebastien's avatar GILLES Sebastien

#1422 Enrich the test to also check program-wise vector files.

parent 7a093211
......@@ -27,7 +27,7 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
{
std::string ComputeAsciiFile(const Model& model)
std::string ComputeProcessorWiseAsciiFile(const Model& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/vector_" << model.GetMpi().GetRank<int>() << ".hhdata";
......@@ -36,7 +36,7 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
}
std::string ComputeBinaryFile(const Model& model)
std::string ComputeProcessorWiseBinaryFile(const Model& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/vector_" << model.GetMpi().GetRank<int>() << ".bin";
......@@ -45,6 +45,24 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
}
std::string ComputeProgramWiseAsciiFile(const Model& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/program_wise_vector.m";
return oconv.str();
}
std::string ComputeProgramWiseBinaryFile(const Model& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/program_wise_vector.bin";
return oconv.str();
}
} // namespace anonymous
......@@ -54,16 +72,30 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
{ }
const std::string& Model::GetBinaryFile() const noexcept
const std::string& Model::GetProcessorWiseBinaryFile() const noexcept
{
static auto ret = ComputeBinaryFile(*this);
static auto ret = ComputeProcessorWiseBinaryFile(*this);
return ret;
}
const std::string& Model::GetAsciiFile() const noexcept
const std::string& Model::GetProcessorWiseAsciiFile() const noexcept
{
static auto ret = ComputeAsciiFile(*this);
static auto ret = ComputeProcessorWiseAsciiFile(*this);
return ret;
}
const std::string& Model::GetProgramWiseBinaryFile() const noexcept
{
static auto ret = ComputeProgramWiseBinaryFile(*this);
return ret;
}
const std::string& Model::GetProgramWiseAsciiFile() const noexcept
{
static auto ret = ComputeProgramWiseAsciiFile(*this);
return ret;
}
......@@ -94,17 +126,34 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
}
{
const auto binary_file = GetBinaryFile();
const auto binary_file = GetProcessorWiseBinaryFile();
if (FilesystemNS::File::DoExist(binary_file))
FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
}
{
const auto ascii_file = GetAsciiFile();
const auto ascii_file = GetProcessorWiseAsciiFile();
if (FilesystemNS::File::DoExist(ascii_file))
FilesystemNS::File::Remove(ascii_file, __FILE__, __LINE__);
}
if (mpi.IsRootProcessor())
{
{
const auto binary_file = GetProgramWiseBinaryFile();
if (FilesystemNS::File::DoExist(binary_file))
FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
}
{
const auto ascii_file = GetProgramWiseAsciiFile();
if (FilesystemNS::File::DoExist(ascii_file))
FilesystemNS::File::Remove(ascii_file, __FILE__, __LINE__);
}
}
mpi.Barrier();
}
......
......@@ -124,10 +124,16 @@ namespace MoReFEM
const GlobalVector& GetVector() const noexcept;
//! Accessor to the path to the binary file for current rank.
const std::string& GetBinaryFile() const noexcept;
const std::string& GetProcessorWiseBinaryFile() const noexcept;
//! Accessor to the path to the ascii file for current rank.
const std::string& GetAsciiFile() const noexcept;
const std::string& GetProcessorWiseAsciiFile() const noexcept;
//! Accessor to the path to the program-wise binary file.
const std::string& GetProgramWiseBinaryFile() const noexcept;
//! Accessor to the path to the program-wise ascii file.
const std::string& GetProgramWiseAsciiFile() const noexcept;
......
......@@ -57,16 +57,15 @@ PRAGMA_DIAGNOSTIC(ignored "-Wdisabled-macro-expansion")
# endif // __clang__
BOOST_FIXTURE_TEST_CASE(file_creation, fixture_type)
BOOST_FIXTURE_TEST_CASE(processor_wise_creation, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
BOOST_REQUIRE(mpi.Nprocessor<int>() == 4);
decltype(auto) vector = model.GetVector();
std::string ascii_file = model.GetAsciiFile();
std::string binary_file = model.GetBinaryFile();
std::string ascii_file = model.GetProcessorWiseAsciiFile();
std::string binary_file = model.GetProcessorWiseBinaryFile();
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == false);
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == false);
......@@ -84,6 +83,39 @@ BOOST_FIXTURE_TEST_CASE(file_creation, fixture_type)
}
BOOST_FIXTURE_TEST_CASE(program_wise_creation, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
decltype(auto) vector = model.GetVector();
std::string ascii_file = model.GetProgramWiseAsciiFile();
std::string binary_file = model.GetProgramWiseBinaryFile();
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == false);
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == false);
mpi.Barrier();
vector.Print<MpiScale::program_wise>(mpi, binary_file, __FILE__, __LINE__);
// As Lua file is set to ask binary file.
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == false);
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true);
mpi.Barrier();
vector.Print<MpiScale::program_wise>(mpi, ascii_file, __FILE__, __LINE__, binary_or_ascii::ascii);
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == true);
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true);
mpi.Barrier();
}
PRAGMA_DIAGNOSTIC(pop)
......
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