Commit 5d20fa66 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1532 MatrixIO: keep going: I am just before the step where MatLoad is called.

parent 23f7b68d
......@@ -33,28 +33,10 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
{
std::string ComputeProcessorWiseAsciiFile(const ToyModel& model)
std::string ComputeAsciiFile(const ToyModel& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/vector_"
<< model.GetMpi().GetRank<int>() << ".hhdata";
return oconv.str();
}
std::string ComputeProcessorWiseBinaryFile(const ToyModel& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/vector_"
<< model.GetMpi().GetRank<int>() << ".bin";
return oconv.str();
}
std::string ComputeProgramWiseAsciiFile(const ToyModel& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/program_wise_vector.m";
oconv << model.GetOutputDirectory() << "/matrix.m";
std::string ret = oconv.str();
oconv.str("");
......@@ -64,10 +46,10 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
}
std::string ComputeProgramWiseBinaryFile(const ToyModel& model)
std::string ComputeBinaryFile(const ToyModel& model)
{
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/program_wise_vector.bin";
oconv << model.GetOutputDirectory() << "/matrix.bin";
std::string ret = oconv.str();
oconv.str("");
......@@ -130,69 +112,31 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
mass_op.Assemble(std::make_tuple(std::ref(matrix_with_coeff)));
const auto matrix_file = GetOutputDirectory().AddFile("matrix.txt");
std::cout << "MATRIX = " << matrix_file << std::endl;
matrix.View(mpi, matrix_file, __FILE__, __LINE__);
// {
// const auto binary_file = GetProcessorWiseBinaryFile();
// if (FilesystemNS::File::DoExist(binary_file))
// FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
// }
//
// {
// 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__);
// }
// }
}
const std::string& ToyModel::GetProcessorWiseBinaryFile() const noexcept
{
static auto ret = ComputeProcessorWiseBinaryFile(*this);
return ret;
}
if (mpi.IsRootProcessor())
{
const auto binary_file = GetBinaryFile();
if (FilesystemNS::File::DoExist(binary_file))
FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
const std::string& ToyModel::GetProcessorWiseAsciiFile() const noexcept
{
static auto ret = ComputeProcessorWiseAsciiFile(*this);
return ret;
const auto ascii_file = GetAsciiFile();
if (FilesystemNS::File::DoExist(ascii_file))
FilesystemNS::File::Remove(ascii_file, __FILE__, __LINE__);
}
}
const std::string& ToyModel::GetProgramWiseBinaryFile() const noexcept
const std::string& ToyModel::GetBinaryFile() const noexcept
{
static auto ret = ComputeProgramWiseBinaryFile(*this);
static auto ret = ComputeBinaryFile(*this);
return ret;
}
const std::string& ToyModel::GetProgramWiseAsciiFile() const noexcept
const std::string& ToyModel::GetAsciiFile() const noexcept
{
static auto ret = ComputeProgramWiseAsciiFile(*this);
static auto ret = ComputeAsciiFile(*this);
return ret;
}
} // namespace MoReFEM::TestNS::PetscNS::MatrixIONS
......@@ -85,17 +85,11 @@ namespace MoReFEM
//! Accessor to the matrix used for tests.
const GlobalMatrix& GetMatrix() const noexcept;
//! Accessor to the path to the binary file for current rank.
const std::string& GetProcessorWiseBinaryFile() const noexcept;
//! Accessor to the path to the ascii file for current rank.
const std::string& GetProcessorWiseAsciiFile() const noexcept;
//! Accessor to the path to the program-wise binary file.
const std::string& GetProgramWiseBinaryFile() const noexcept;
const std::string& GetBinaryFile() const noexcept;
//! Accessor to the path to the program-wise ascii file.
const std::string& GetProgramWiseAsciiFile() const noexcept;
const std::string& GetAsciiFile() const noexcept;
private:
......
......@@ -59,12 +59,35 @@ PRAGMA_DIAGNOSTIC(push)
BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
BOOST_FIXTURE_TEST_CASE(creation, fixture_type)
{
decltype(auto) model = GetModel();
}
BOOST_AUTO_TEST_CASE(creation)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
BOOST_FIXTURE_TEST_CASE(load_ascii, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
decltype(auto) matrix = model.GetMatrix();
decltype(auto) ascii_file = model.GetAsciiFile();
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == false);
matrix.View(mpi,
ascii_file,
__FILE__, __LINE__);
if (mpi.IsRootProcessor())
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == true);
}
// decltype(auto) vector = model.GetVector();
......@@ -90,7 +113,7 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
// BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == true);
// BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true);
// }
}
// BOOST_AUTO_TEST_CASE(load_binary)
......@@ -128,9 +151,6 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
// No load_ascii: not foreseen apparently in PETSc interface!
BOOST_AUTO_TEST_SUITE_END()
PRAGMA_DIAGNOSTIC(pop)
......
......@@ -513,13 +513,17 @@ namespace MoReFEM
/*!
* \brief Wrapper over MatView in the case the viewer is a file.
*
* \a MatView write the content of the matrix only on the root processor; if you need it on several you need to copy the file afterwards
* (for instance in the case of prepartitioned data).
*
* \copydoc doxygen_hide_mpi_param
* \param[in] format Format in which the matrix is written. See Petsc manual pages to get all the
* formats available; relevant ones so far are PETSC_VIEWER_DEFAULT and PETSC_VIEWER_ASCII_MATLAB.
* \param[in] output_file File into which the vector content will be written.
* \copydoc doxygen_hide_invoking_file_and_line
*/
void View(const Mpi& mpi, const std::string& output_file, const char* invoking_file, int invoking_line,
void View(const Mpi& mpi, const std::string& output_file,
const char* invoking_file, int invoking_line,
PetscViewerFormat format = PETSC_VIEWER_DEFAULT) const;
......
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