Commit 7bb02445 authored by GILLES Sebastien's avatar GILLES Sebastien

#1422 Rename more appropriately the test about vector IO, and rewrite it in...

#1422 Rename more appropriately the test about vector IO, and rewrite it in more appropriate test suites.
parent c8faef82
......@@ -10421,12 +10421,12 @@
isa = PBXGroup;
children = (
BEF795D322DDBDB20054B192 /* CMakeLists.txt */,
BEF795CF22DDBD7A0054B192 /* Binary */,
BEF795CF22DDBD7A0054B192 /* VectorIO */,
);
path = PETSc;
sourceTree = "<group>";
};
BEF795CF22DDBD7A0054B192 /* Binary */ = {
BEF795CF22DDBD7A0054B192 /* VectorIO */ = {
isa = PBXGroup;
children = (
BEF795D522DDBE550054B192 /* CMakeLists.txt */,
......@@ -10437,7 +10437,7 @@
BEF795D822DDBFCD0054B192 /* Model.hpp */,
BEF795DA22DDBFCD0054B192 /* Model.hxx */,
);
path = Binary;
path = VectorIO;
sourceTree = "<group>";
};
BEFC32DB1CB53C3B00C8903C /* Advanced */ = {
/*!
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Fri, 26 Apr 2013 12:18:22 +0200
// Copyright (c) Inria. All rights reserved.
//
*/
#include <cstdlib>
#define BOOST_TEST_MODULE petsc_vector_binary
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
#include "ThirdParty/Wrappers/Tclap/StringPair.hpp"
#include "Utilities/Numeric/Numeric.hpp"
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Test/Tools/Fixture/Model.hpp"
#include "Test/ThirdParty/PETSc/Binary/Model.hpp"
using namespace MoReFEM;
namespace // anonymous
{
struct LuaFile
{
static std::string GetPath();
};
using fixture_type =
TestNS::FixtureNS::Model
<
TestNS::PetscNS::VectorBinaryNS::Model,
LuaFile
>;
} // namespace anonymous
PRAGMA_DIAGNOSTIC(push)
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wdisabled-macro-expansion")
# endif // __clang__
BOOST_FIXTURE_TEST_CASE(processor_wise_creation, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
decltype(auto) vector = model.GetVector();
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);
vector.Print<MpiScale::processor_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);
vector.Print<MpiScale::processor_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);
}
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();
}
BOOST_FIXTURE_TEST_CASE(load_program_wise_binary, fixture_type)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
std::string binary_file = model.GetProgramWiseBinaryFile();
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true); // created in previous test!
decltype(auto) vector = model.GetVector();
Wrappers::Petsc::Vector from_file(mpi,
static_cast<unsigned int>(vector.GetProcessorWiseSize(__FILE__, __LINE__)),
static_cast<unsigned int>(vector.GetProgramWiseSize(__FILE__, __LINE__)),
vector.GetGhostPadding(),
binary_file,
__FILE__, __LINE__);
std::ostringstream oconv;
oconv << model.GetOutputDirectory() << "/from_file_program_wise_vector.m";
from_file.Print<MpiScale::program_wise>(mpi, oconv.str(), __FILE__, __LINE__, binary_or_ascii::ascii);
std::string inequality_description;
Wrappers::Petsc::AreEqual(from_file,
vector,
NumericNS::DefaultEpsilon<double>(),
inequality_description,
__FILE__, __LINE__);
BOOST_CHECK_EQUAL(inequality_description, "");
}
PRAGMA_DIAGNOSTIC(pop)
namespace // anonymous
{
std::string LuaFile::GetPath()
{
decltype(auto) environment = Utilities::Environment::CreateOrGetInstance(__FILE__, __LINE__);
return
environment.SubstituteValues("${MOREFEM_ROOT}/Sources/Test/ThirdParty/PETSc/Binary/demo.lua");
}
} // namespace anonymous
include(${CMAKE_CURRENT_LIST_DIR}/Binary/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/VectorIO/CMakeLists.txt)
......@@ -8,8 +8,8 @@
*/
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_INPUT_DATA_HPP_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_INPUT_DATA_HPP_
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_INPUT_DATA_HPP_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_INPUT_DATA_HPP_
# include "Utilities/Containers/EnumClass.hpp"
# include "Core/InputData/InputData.hpp"
......@@ -25,7 +25,7 @@
# include "Core/InputData/Instances/PrepartitionedData.hpp"
namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
namespace MoReFEM::TestNS::PetscNS::VectorIONS
{
......@@ -57,7 +57,7 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
using morefem_data_type = MoReFEMData<InputData>;
} // namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
} // namespace MoReFEM::TestNS::PetscNS::VectorIONS
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_INPUT_DATA_HPP_
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_INPUT_DATA_HPP_
......@@ -16,10 +16,10 @@
#include "ThirdParty/Wrappers/Petsc/Vector/AccessVectorContent.hpp"
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
#include "Test/ThirdParty/PETSc/Binary/Model.hpp"
#include "Test/ThirdParty/PETSc/VectorIO/Model.hpp"
namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
namespace MoReFEM::TestNS::PetscNS::VectorIONS
{
......@@ -169,4 +169,4 @@ namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
{ }
} // namespace MoReFEM::TestNS::PetscNS::VectorBinaryNS
} // namespace MoReFEM::TestNS::PetscNS::VectorIONS
......@@ -8,8 +8,8 @@
*/
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HPP_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HPP_
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HPP_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HPP_
# include <memory>
# include <vector>
......@@ -18,14 +18,14 @@
# include "Model/Model.hpp"
# include "Test/ThirdParty/PETSc/Binary/InputData.hpp"
# include "Test/ThirdParty/PETSc/VectorIO/InputData.hpp"
namespace MoReFEM
{
namespace TestNS::PetscNS::VectorBinaryNS
namespace TestNS::PetscNS::VectorIONS
{
......@@ -162,13 +162,13 @@ namespace MoReFEM
};
} // namespace TestNS::PetscNS::VectorBinaryNS
} // namespace TestNS::PetscNS::VectorIONS
} // namespace MoReFEM
#include "Test/ThirdParty/PETSc/Binary/Model.hxx"
#include "Test/ThirdParty/PETSc/VectorIO/Model.hxx"
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HPP_
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HPP_
......@@ -8,15 +8,15 @@
*/
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HXX_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HXX_
#ifndef MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HXX_
# define MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HXX_
namespace MoReFEM
{
namespace TestNS::PetscNS::VectorBinaryNS
namespace TestNS::PetscNS::VectorIONS
{
......@@ -44,10 +44,10 @@ namespace MoReFEM
}
} // namespace TestNS::PetscNS::VectorBinaryNS
} // namespace TestNS::PetscNS::VectorIONS
} // namespace MoReFEM
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_BINARY_x_MODEL_HXX_
#endif // MOREFEM_x_TEST_x_THIRD_PARTY_x_P_E_T_SC_x_VECTOR_I_O_x_MODEL_HXX_
/*!
// \file
//
//
// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Fri, 26 Apr 2013 12:18:22 +0200
// Copyright (c) Inria. All rights reserved.
//
*/
#include <cstdlib>
#define BOOST_TEST_MODULE petsc_vector_io
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
#include "ThirdParty/Wrappers/Tclap/StringPair.hpp"
#include "Utilities/Numeric/Numeric.hpp"
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Core/MoReFEMData/MoReFEMData.hpp"
#include "Test/Tools/Fixture/Model.hpp"
#include "Test/ThirdParty/PETSc/VectorIO/Model.hpp"
using namespace MoReFEM;
namespace // anonymous
{
struct LuaFile
{
static std::string GetPath();
};
using fixture_type =
TestNS::FixtureNS::Model
<
TestNS::PetscNS::VectorIONS::Model,
LuaFile
>;
} // namespace anonymous
PRAGMA_DIAGNOSTIC(push)
# ifdef __clang__
PRAGMA_DIAGNOSTIC(ignored "-Wdisabled-macro-expansion")
# endif // __clang__
BOOST_FIXTURE_TEST_SUITE(processor_wise, fixture_type)
BOOST_AUTO_TEST_CASE(creation)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
decltype(auto) vector = model.GetVector();
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);
vector.Print<MpiScale::processor_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);
vector.Print<MpiScale::processor_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);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
BOOST_AUTO_TEST_CASE(creation)
{
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();
}
BOOST_AUTO_TEST_CASE(load_binary)
{
decltype(auto) model = GetModel();
decltype(auto) mpi = model.GetMpi();
std::string binary_file = model.GetProgramWiseBinaryFile();
BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true); // created in previous test!
decltype(auto) vector = model.GetVector();
Wrappers::Petsc::Vector from_file(mpi,
static_cast<unsigned int>(vector.GetProcessorWiseSize(__FILE__, __LINE__)),
static_cast<unsigned int>(vector.GetProgramWiseSize(__FILE__, __LINE__)),
vector.GetGhostPadding(),
binary_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_SUITE_END()
PRAGMA_DIAGNOSTIC(pop)
namespace // anonymous
{
std::string LuaFile::GetPath()
{
decltype(auto) environment = Utilities::Environment::CreateOrGetInstance(__FILE__, __LINE__);
return
environment.SubstituteValues("${MOREFEM_ROOT}/Sources/Test/ThirdParty/PETSc/VectorIO/demo.lua");
}
} // namespace anonymous
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