Commit 316a6c3b authored by GILLES Sebastien's avatar GILLES Sebastien

#1480 Fix some issues, and extend Directory API.

parent 7ef974c7
......@@ -80,7 +80,7 @@ set_tests_properties(ElasticityModel2D-mpi PROPERTIES TIMEOUT 20)
add_test(ElasticityModel3DEnsightOutput
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Ascii/Elasticity/3D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Ascii/Elasticity/3D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq/Ascii)
set_tests_properties(ElasticityModel3DEnsightOutput PROPERTIES TIMEOUT 5)
......@@ -88,7 +88,7 @@ set_tests_properties(ElasticityModel3DEnsightOutput PROPERTIES TIMEOUT 5)
add_test(ElasticityModel3DEnsightOutput-mpi
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/3D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/3D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii)
set_tests_properties(ElasticityModel3DEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......@@ -96,7 +96,7 @@ set_tests_properties(ElasticityModel3DEnsightOutput-mpi PROPERTIES TIMEOUT 10)
add_test(ElasticityModel2DEnsightOutput
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq/Ascii)
set_tests_properties(ElasticityModel2DEnsightOutput PROPERTIES TIMEOUT 10)
......@@ -104,7 +104,7 @@ set_tests_properties(ElasticityModel2DEnsightOutput PROPERTIES TIMEOUT 10)
add_test(ElasticityModel2DEnsightOutput-mpi
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii/Elasticity/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Ascii)
set_tests_properties(ElasticityModel2DEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......@@ -152,7 +152,7 @@ set_tests_properties(ElasticityModel2D-mpi-bin PROPERTIES TIMEOUT 20)
add_test(ElasticityModel3DEnsightOutput-bin
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Binary/Elasticity/3D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Binary/Elasticity/3D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq/Binary)
set_tests_properties(ElasticityModel3DEnsightOutput-bin PROPERTIES TIMEOUT 10)
......@@ -160,7 +160,7 @@ set_tests_properties(ElasticityModel3DEnsightOutput-bin PROPERTIES TIMEOUT 10)
add_test(ElasticityModel3DEnsightOutput-mpi-bin
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/3D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/3D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary)
set_tests_properties(ElasticityModel3DEnsightOutput-mpi-bin PROPERTIES TIMEOUT 10)
......@@ -168,7 +168,7 @@ set_tests_properties(ElasticityModel3DEnsightOutput-mpi-bin PROPERTIES TIMEOUT 1
add_test(ElasticityModel2DEnsightOutput-bin
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq/Binary)
set_tests_properties(ElasticityModel2DEnsightOutput-bin PROPERTIES TIMEOUT 10)
......@@ -176,7 +176,7 @@ set_tests_properties(ElasticityModel2DEnsightOutput-bin PROPERTIES TIMEOUT 10)
add_test(ElasticityModel2DEnsightOutput-mpi-bin
MoReFEM4ElasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary/Elasticity/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Binary)
set_tests_properties(ElasticityModel2DEnsightOutput-mpi-bin PROPERTIES TIMEOUT 10)
......
......@@ -109,11 +109,19 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/Elasticity/ExpectedResults/" + ascii_or_bin
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Elasticity/ExpectedResults/" + ascii_or_bin
+ std::string("/") + dimension;
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/") + ascii_or_bin
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/") + ascii_or_bin
+ std::string("/Elasticity/") + dimension;
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
/* BOOST_REQUIRE_NO_THROW */(TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua",
__FILE__, __LINE__));
/* BOOST_REQUIRE_NO_THROW */(TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata",
......@@ -121,14 +129,15 @@ namespace // anonymous
/* BOOST_REQUIRE_NO_THROW */(TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata",
__FILE__, __LINE__));
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
ref_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
/* BOOST_REQUIRE_NO_THROW */(TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata",
__FILE__, __LINE__));
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
ref_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
/* BOOST_REQUIRE_NO_THROW */(TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo",
__FILE__, __LINE__));
......
......@@ -50,7 +50,7 @@ set_tests_properties(HeatModel2D PROPERTIES TIMEOUT 10)
add_test(HeatModel2DEnsightOutput
MoReFEM4HeatEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Heat/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Heat/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(HeatModel2DEnsightOutput PROPERTIES TIMEOUT 10)
......@@ -69,7 +69,7 @@ set_tests_properties(HeatModel2D-mpi PROPERTIES TIMEOUT 10)
add_test(HeatModel2DEnsightOutput-mpi
MoReFEM4HeatEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Heat/2D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Heat/2D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(HeatModel2DEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......@@ -86,7 +86,7 @@ set_tests_properties(HeatModel1D PROPERTIES TIMEOUT 4)
add_test(HeatModel1DEnsightOutput
MoReFEM4HeatEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Heat/1D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Heat/1D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(HeatModel1DEnsightOutput PROPERTIES TIMEOUT 10)
......@@ -105,7 +105,7 @@ set_tests_properties(HeatModel1D-mpi PROPERTIES TIMEOUT 10)
add_test(HeatModel1DEnsightOutput-mpi
MoReFEM4HeatEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Heat/1D/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Heat/1D/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(HeatModel1DEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......
......@@ -83,20 +83,28 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/Heat/ExpectedResults/" + dimension;
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/Heat/") + dimension;
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Heat/ExpectedResults/" + dimension;
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/Heat/") + dimension;
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata", __FILE__, __LINE__);
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
ref_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata", __FILE__, __LINE__);
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
ref_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "problem.case", __FILE__, __LINE__);
......
......@@ -60,7 +60,7 @@ set_tests_properties(Hyperelasticity-mpi PROPERTIES TIMEOUT 80)
add_test(HyperelasticityModelEnsightOutput
MoReFEM4HyperelasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/MidpointHyperelasticity/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/MidpointHyperelasticity/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(HyperelasticityModelEnsightOutput PROPERTIES TIMEOUT 10)
......@@ -68,7 +68,7 @@ set_tests_properties(HyperelasticityModelEnsightOutput PROPERTIES TIMEOUT 10)
add_test(HyperelasticityModelEnsightOutput-mpi
MoReFEM4HyperelasticityEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/MidpointHyperelasticity/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/MidpointHyperelasticity/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(HyperelasticityModelEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......
......@@ -68,20 +68,29 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/Hyperelasticity/ExpectedResults/";
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/MidpointHyperelasticity/");
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Hyperelasticity/ExpectedResults/";
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/MidpointHyperelasticity/");
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata", __FILE__, __LINE__);
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
ref_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata", __FILE__, __LINE__);
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
ref_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "problem.case", __FILE__, __LINE__);
......
......@@ -53,13 +53,13 @@ add_test(Laplacian-mpi
add_test(LaplacianModelEnsightOutput
MoReFEM4LaplacianEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Laplacian/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Laplacian/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
add_test(LaplacianModelEnsightOutput-mpi
MoReFEM4LaplacianEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Laplacian/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Laplacian/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
add_executable(MoReFEM4LaplacianCheckResults ${CMAKE_CURRENT_LIST_DIR}/test_results.cpp)
......
......@@ -67,25 +67,33 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/Laplacian/ExpectedResults/";
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/Laplacian/");
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Laplacian/ExpectedResults/";
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/Laplacian/");
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata", __FILE__, __LINE__);
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
FilesystemNS::Directory ref_mesh_dir(ref_dir, "Mesh_1", __FILE__, __LINE__);
FilesystemNS::Directory obtained_mesh_dir(ref_dir, "Mesh_1", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_mesh_dir, obtained_mesh_dir, "interfaces.hhdata", __FILE__, __LINE__);
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
FilesystemNS::Directory ref_ensight_dir(ref_mesh_dir, "Ensight6", __FILE__, __LINE__);
FilesystemNS::Directory obtained_ensight_dir(obtained_mesh_dir, "Ensight6", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "problem.case", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_ensight_dir, obtained_ensight_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_ensight_dir, obtained_ensight_dir, "problem.case", __FILE__, __LINE__);
TestNS::CompareEnsightFiles(ref_dir, obtained_dir, "pressure.00000.scl", __FILE__, __LINE__);
TestNS::CompareEnsightFiles(ref_ensight_dir, obtained_ensight_dir, "pressure.00000.scl", __FILE__, __LINE__);
}
......
......@@ -80,7 +80,7 @@ set_tests_properties(RivlinCubeTetra-mpi PROPERTIES TIMEOUT 10)
add_test(RivlinCubeModelEnsightOutputHexa
MoReFEM4RivlinCubeEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/RivlinCube/Hexahedra/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/RivlinCube/Hexahedra/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(RivlinCubeModelEnsightOutputHexa PROPERTIES TIMEOUT 10)
......@@ -88,7 +88,7 @@ set_tests_properties(RivlinCubeModelEnsightOutputHexa PROPERTIES TIMEOUT 10)
add_test(RivlinCubeModelEnsightOutputHexa-mpi
MoReFEM4RivlinCubeEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/RivlinCube/Hexahedra/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/RivlinCube/Hexahedra/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(RivlinCubeModelEnsightOutputHexa-mpi PROPERTIES TIMEOUT 10)
......@@ -96,7 +96,7 @@ set_tests_properties(RivlinCubeModelEnsightOutputHexa-mpi PROPERTIES TIMEOUT 10)
add_test(RivlinCubeModelEnsightOutputTetra
MoReFEM4RivlinCubeEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/RivlinCube/Tetrahedra/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/RivlinCube/Tetrahedra/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(RivlinCubeModelEnsightOutputTetra PROPERTIES TIMEOUT 10)
......@@ -104,7 +104,7 @@ set_tests_properties(RivlinCubeModelEnsightOutputTetra PROPERTIES TIMEOUT 10)
add_test(RivlinCubeModelEnsightOutputTetra-mpi
MoReFEM4RivlinCubeEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/RivlinCube/Tetrahedra/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/RivlinCube/Tetrahedra/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(RivlinCubeModelEnsightOutputTetra-mpi PROPERTIES TIMEOUT 10)
......
......@@ -81,20 +81,28 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/RivlinCube/ExpectedResults/" + geometry;
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/RivlinCube/") + geometry;
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/RivlinCube/ExpectedResults/" + geometry;
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/RivlinCube/") + geometry;
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata", __FILE__, __LINE__);
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
ref_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata", __FILE__, __LINE__);
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
ref_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "problem.case", __FILE__, __LINE__);
......
......@@ -53,7 +53,7 @@ set_tests_properties(Stokes-mpi PROPERTIES TIMEOUT 30)
add_test(StokesModelEnsightOutput
MoReFEM4StokesEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Stokes/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Seq/Stokes/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Seq)
set_tests_properties(StokesModelEnsightOutput PROPERTIES TIMEOUT 10)
......@@ -61,7 +61,7 @@ set_tests_properties(StokesModelEnsightOutput PROPERTIES TIMEOUT 10)
add_test(StokesModelEnsightOutput-mpi
MoReFEM4StokesEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Stokes/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/Mpi4/Stokes/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/Mpi4)
set_tests_properties(StokesModelEnsightOutput-mpi PROPERTIES TIMEOUT 10)
......
......@@ -59,7 +59,7 @@ set_tests_properties(Stokes_2_operators-mpi PROPERTIES TIMEOUT 40)
add_test(Stokes_2_operatorsModelEnsightOutput
MoReFEM4Stokes_2_operatorsEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Seq/Stokes/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Seq/Stokes/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Seq)
set_tests_properties(Stokes_2_operatorsModelEnsightOutput PROPERTIES TIMEOUT 40)
......@@ -67,7 +67,7 @@ set_tests_properties(Stokes_2_operatorsModelEnsightOutput PROPERTIES TIMEOUT 40)
add_test(Stokes_2_operatorsModelEnsightOutput-mpi
MoReFEM4Stokes_2_operatorsEnsightOutput
-e MOREFEM_ROOT=${MOREFEM_ROOT}
-i ${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Mpi4/Stokes/input_data.lua
-i ${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Mpi4/Stokes/Rank_0/input_data.lua
-e MOREFEM_RESULT_DIR=${MOREFEM_TEST_OUTPUT_DIR}/TwoOperators/Mpi4)
set_tests_properties(Stokes_2_operatorsModelEnsightOutput-mpi PROPERTIES TIMEOUT 40)
......
......@@ -70,21 +70,29 @@ namespace // anonymous
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(root_dir));
BOOST_REQUIRE(FilesystemNS::Folder::DoExist(output_dir));
std::string ref_dir = root_dir + "/Sources/ModelInstances/Stokes/ExpectedResults/";
std::string ref_dir_path = root_dir + "/Sources/ModelInstances/Stokes/ExpectedResults/";
std::string obtained_dir = output_dir + std::string("/") + seq_or_par + std::string("/Stokes/");
std::string obtained_dir_path = output_dir + std::string("/") + seq_or_par + std::string("/Stokes/");
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
FilesystemNS::Directory obtained_dir(obtained_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "input_data.lua", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "model_name.hhdata", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "unknowns.hhdata", __FILE__, __LINE__);
ref_dir += "/Mesh_1/";
obtained_dir += "/Mesh_1/";
ref_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Mesh_1", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "interfaces.hhdata", __FILE__, __LINE__);
ref_dir += "Ensight6/";
obtained_dir += "Ensight6/";
ref_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
obtained_dir.AddSubdirectory("Ensight6", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "mesh.geo", __FILE__, __LINE__);
TestNS::CheckIdenticalFiles(ref_dir, obtained_dir, "problem.case", __FILE__, __LINE__);
......
......@@ -116,13 +116,14 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
__FILE__, __LINE__);
// Its sole role is to provide RAII at the end of the constructor.
FilesystemNS::Directory::const_unique_ptr ensight_directory_smart_ptr = nullptr;
FilesystemNS::Directory::unique_ptr ensight_directory_smart_ptr = nullptr;
if (ensight_directory_ptr == nullptr)
{
ensight_directory_smart_ptr = std::make_unique<FilesystemNS::Directory>(mesh_directory,
"Ensight6",
__FILE__, __LINE__);
__FILE__, __LINE__,
std::make_unique<FilesystemNS::behaviour>(FilesystemNS::behaviour::overwrite));
ensight_directory_ptr = ensight_directory_smart_ptr.get();
}
......
......@@ -130,11 +130,9 @@ namespace // anonymous
environment.SubstituteValues("${MOREFEM_ROOT}/Sources/Test/PostProcessing/EnsightUnusedVertices/"
"ExpectedResult/Ensight6");
FilesystemNS::Directory ref_dir(mpi,
ref_dir_path,
FilesystemNS::Directory ref_dir(ref_dir_path,
FilesystemNS::behaviour::read,
__FILE__, __LINE__,
FilesystemNS::add_rank::no);
__FILE__, __LINE__);
std::ostringstream oconv;
for (auto time_iteration = 0ul; time_iteration < 2ul; ++time_iteration)
......
......@@ -10,6 +10,7 @@
#include "Utilities/Filesystem/Folder.hpp"
#include "Utilities/Filesystem/File.hpp"
#include "Utilities/Filesystem/Directory.hpp"
#include "Utilities/Exceptions/Exception.hpp"
#include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp"
......@@ -24,26 +25,26 @@ namespace MoReFEM
{
void CheckIdenticalFiles(const std::string& ref_dir,
const std::string& obtained_dir,
void CheckIdenticalFiles(const FilesystemNS::Directory& ref_dir,
const FilesystemNS::Directory& obtained_dir,
std::string&& filename,
const char* invoking_file, int invoking_line)
{
std::ostringstream oconv;
if (!FilesystemNS::Folder::DoExist(ref_dir))
if (!FilesystemNS::Folder::DoExist(ref_dir.GetPath()))
{
oconv << "Reference folder " + ref_dir + " does not exist.";
oconv << "Reference folder " << ref_dir << " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
if (!FilesystemNS::Folder::DoExist(obtained_dir))
if (!FilesystemNS::Folder::DoExist(obtained_dir.GetPath()))
{
oconv << "Result folder " + obtained_dir + " does not exist.";
oconv << "Result folder " << obtained_dir << " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
std::string ref_input_data = ref_dir + "/" + filename;
std::string ref_input_data = ref_dir.AddFile(filename);
if (!FilesystemNS::File::DoExist(ref_dir))
{
......@@ -51,11 +52,11 @@ namespace MoReFEM
throw Exception(oconv.str(), invoking_file, invoking_line);
}
std::string obtained_input_data = obtained_dir + "/" + filename;
std::string obtained_input_data = obtained_dir.AddFile(filename);
if (!FilesystemNS::File::DoExist(obtained_input_data))
{
oconv << "Result file " + obtained_input_data + " does not exist.";
oconv << "Result file " << obtained_input_data << " does not exist.";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
......
......@@ -37,8 +37,8 @@ namespace MoReFEM
* \a obtained_dir and to be located directly there (not in a subdirectory).
* \copydoc doxygen_hide_invoking_file_and_line
*/
void CheckIdenticalFiles(const std::string& ref_dir,
const std::string& obtained_dir,
void CheckIdenticalFiles(const FilesystemNS::Directory& ref_dir,
const FilesystemNS::Directory& obtained_dir,
std::string&& filename,
const char* invoking_file, int invoking_line);
......
......@@ -35,6 +35,7 @@ namespace MoReFEM::FilesystemNS
remove_no
};
ask_status AskCaseHelper(const std::string& message);
ask_status AskCaseRootProcessor(const std::string& wildcard_path,
const std::vector<int>& result);
......@@ -51,7 +52,7 @@ namespace MoReFEM::FilesystemNS
behaviour directory_behaviour,
const char* invoking_file, int invoking_line,
add_rank do_add_rank)
: mpi_(mpi),
: mpi_(&mpi),
directory_behaviour_(directory_behaviour),
with_rank_(do_add_rank == add_rank::yes)
{
......@@ -76,6 +77,21 @@ namespace MoReFEM::FilesystemNS
}
Directory::Directory(const std::string& path,
behaviour directory_behaviour,
const char* invoking_file, int invoking_line)
: mpi_(nullptr),
directory_behaviour_(directory_behaviour),
with_rank_(false)
{
std::ostringstream oconv;
oconv << path << '/';
path_ = oconv.str();
Construct(invoking_file, invoking_line);
}
void Directory::Construct(const char* invoking_file, int invoking_line) const
{
// First tackle - if relevant - the 'ask' case policy:
......@@ -86,7 +102,16 @@ namespace MoReFEM::FilesystemNS
// - Then root processor must tell the other processors to remove the directories.
// All the other policies may be handled without interprocessor communication.
if (directory_behaviour_ == behaviour::ask)
CollectAnswer(invoking_file, invoking_line);
{
if (IsMpi())
CollectAnswer(invoking_file, invoking_line);
else
{
std::ostringstream oconv;
oconv << "Directory '" << GetPath() << "' already exist. Do you want to remove it? [y/n]";
AskCaseHelper(oconv.str());
}
}
// At this point, each rank may do its own bidding.
if (Folder::DoExist(path_))
......@@ -140,7 +165,6 @@ namespace MoReFEM::FilesystemNS
assert(directory_behaviour_ == behaviour::ask);
decltype(auto) mpi = GetMpi();
const auto rank = mpi.GetRank<int>();
const bool do_path_exist = Folder::DoExist(path_);
......@@ -251,6 +275,29 @@ namespace MoReFEM::FilesystemNS
}
void Directory::AddSubdirectory(const std::string& subdirectory, const char* invoking_file, int invoking_line)
{
std::ostringstream oconv;
oconv << GetPath() << subdirectory << '/';
path_ = oconv.str();
Construct(invoking_file, invoking_line);
}
void Directory::CheckForSubdirectoryConstructor(const Directory& parent_directory,
const char* invoking_file, int invoking_line) const
{
if (!Folder::DoExist(parent_directory.GetPath()))
{
std::ostringstream oconv;
oconv << "Directory '" << parent_directory.GetPath() << "' couldn't be found whereas we were trying to build a "
"subdirectory from it (so the directory has been created at some point and then removed).";
throw Exception(oconv.str(), invoking_file, invoking_line);
}
}
namespace // anonymous
{
......@@ -277,8 +324,19 @@ namespace MoReFEM::FilesystemNS
ask_status AskCaseRootProcessor(const std::string& wildcard_path,
const std::vector<int>& result)
{
std::ostringstream oconv;
const std::string rank_list = RankList(result);
oconv << "Directories '" << wildcard_path << "' already exist for ranks " << rank_list
<< ". Do you want to remove them? [y/n]"<< std::endl;
return AskCaseHelper(oconv.str());
}
ask_status AskCaseHelper(const std::string& message)
{
std::string answer;
while (answer != "y" && answer != "n")
......@@ -291,8 +349,7 @@ namespace MoReFEM::FilesystemNS
std::cin.ignore(10000, '\n'); // clean-up what might remain in std::cin before using it again.
}
std::cout << "Directories '" << wildcard_path << "' already exist for ranks " << rank_list
<< ". Do you want to remove them? [y/n]"<< std::endl;
std::cout << message << std::endl;
std::cin >> answer;
......@@ -308,6 +365,7 @@ namespace MoReFEM::FilesystemNS
}
std::string ComputeWildcardPath(const Directory& directory)
{
decltype(auto) mpi = directory.GetMpi();
......
......@@ -18,6 +18,7 @@
# include "Utilities/Exceptions/Exception.hpp"
# include "Utilities/Filesystem/Folder.hpp"
# include "Utilities/Containers/Print.hpp"
# include "ThirdParty/Wrappers/Mpi/Mpi.hpp"
......@@ -50,6 +51,9 @@ namespace MoReFEM::FilesystemNS
quit,
ignore,
read
// TMP 'create' should be added!
// create_behaviour
// read_behaviour
};
//! \copydoc doxygen_hide_std_stream_out_overload
......@@ -87,6 +91,9 @@ namespace MoReFEM::FilesystemNS
//! Alias to self.