Commit ca698493 authored by GILLES Sebastien's avatar GILLES Sebastien

#1453 PetscVector: ad a method to load parallel vector from ascii files.

parent 2bb3755c
......@@ -95,17 +95,27 @@ BOOST_FIXTURE_TEST_SUITE(processor_wise, fixture_type)
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true); // created in previous test!
decltype(auto) vector = model.GetVector();
std::vector<PetscInt> ghost_padding;
if (mpi.Nprocessor<int>() > 1)
ghost_padding = vector.GetGhostPadding();
Wrappers::Petsc::Vector from_file;
from_file.InitParallelFromProcessorWiseAsciiFile(mpi,
static_cast<unsigned int>(vector.GetProcessorWiseSize(__FILE__, __LINE__)),
static_cast<unsigned int>(vector.GetProgramWiseSize(__FILE__, __LINE__)),
ghost_padding,
binary_file,
__FILE__, __LINE__);
std::string inequality_description;
Wrappers::Petsc::AreEqual(from_file,
vector,
NumericNS::DefaultEpsilon<double>(),
inequality_description,
__FILE__, __LINE__);
//
//
// std::string inequality_description;
// Wrappers::Petsc::AreEqual(from_file,
// vector,
// NumericNS::DefaultEpsilon<double>(),
// inequality_description,
// __FILE__, __LINE__);
//
// BOOST_CHECK_EQUAL(inequality_description, "");
BOOST_CHECK_EQUAL(inequality_description, "");
}
BOOST_AUTO_TEST_CASE(load_binary)
......@@ -175,10 +185,10 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
std::string inequality_description;
Wrappers::Petsc::AreEqual(from_file,
vector,
NumericNS::DefaultEpsilon<double>(),
inequality_description,
__FILE__, __LINE__);
vector,
NumericNS::DefaultEpsilon<double>(),
inequality_description,
__FILE__, __LINE__);
BOOST_CHECK_EQUAL(inequality_description, "");
}
......@@ -189,6 +199,51 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_SUITE(sequential_only, fixture_type)
BOOST_AUTO_TEST_CASE(load_ascii)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
if (mpi.Nprocessor<int>() == 1)
{
std::string ascii_file = model.GetProgramWiseAsciiFile();
std::cout << "ASC II FILE = " << ascii_file << std::endl;
BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == true); // created in previous test!
decltype(auto) vector = model.GetVector();
Wrappers::Petsc::Vector from_file;
std::vector<PetscInt> ghost_padding;
BOOST_CHECK_EQUAL(vector.GetProcessorWiseSize(__FILE__, __LINE__),
vector.GetProgramWiseSize(__FILE__, __LINE__));
from_file.InitSequentialFromFile(mpi,
ascii_file,
__FILE__, __LINE__);
std::string inequality_description;
Wrappers::Petsc::AreEqual(from_file,
vector,
NumericNS::DefaultEpsilon<double>(),
inequality_description,
__FILE__, __LINE__);
BOOST_CHECK_EQUAL(inequality_description, "");
}
}
BOOST_AUTO_TEST_CASE(load_binary)
{
}
BOOST_AUTO_TEST_SUITE_END()
PRAGMA_DIAGNOSTIC(pop)
......
......@@ -43,8 +43,6 @@ namespace MoReFEM
const char* invoking_file, int invoking_line,
binary_or_ascii binary_or_ascii_choice)
{
::MoReFEM::Wrappers::Petsc
::AccessVectorContent<Utilities::Access::read_only> content(vector,
invoking_file, invoking_line);
......
......@@ -219,8 +219,6 @@ namespace MoReFEM
*
* This file is assumed to have been created with Print() method for a sequential vector.
*
* Parallel case is not handled at all at the moment!
*
* \param[in] file File from which vector content is read.
* \copydoc doxygen_hide_invoking_file_and_line
* \copydetails doxygen_hide_mpi_param
......@@ -229,6 +227,27 @@ namespace MoReFEM
const std::string& file,
const char* invoking_file, int invoking_line);
/*!
* \brief Init a vector from the data read in the file.
*
* This file is assumed to have been created with Print() method.
*
* Current method is in fact able to create a sequential vector as well, but use rather
* InitSequentialFromFile() with its more friendly API if you need only the sequential case.
*
* \param[in] file File from which vector content is read.
* \copydetails doxygen_hide_parallel_with_ghosts_arg
* \copydoc doxygen_hide_invoking_file_and_line
* \copydetails doxygen_hide_mpi_param
*/
void InitParallelFromProcessorWiseAsciiFile(const Mpi& mpi,
unsigned int processor_wise_size,
unsigned int program_wise_size,
const std::vector<PetscInt>& ghost_padding,
const std::string& file,
const char* invoking_file, int invoking_line);
/*!
* \brief Init from a program-wise binary file: load a vector dumped with View() method.
*
......
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