Commit 8518c7ab authored by Steffen Müthing's avatar Steffen Müthing

Merge branch 'cherry-pick-7af23ae9' into 'releases/2.6'

Merge branch 'yaspgrid-unique-test-file-names' into 'master'

See merge request !297
parents 1f45a713 7916f3ce
Pipeline #10390 passed with stage
in 7 minutes and 26 seconds
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,13 +17,18 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto & mpiHelper = Dune::MPIHelper::instance(argc, argv);
std::string testID =
"backuprestore-equidistant-np" + std::to_string(mpiHelper.size());
// check the backup restore facility
check_backuprestore(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
check_backuprestore(testID,
YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
// Test again with refinement
check_backuprestore(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(true, 1));
check_backuprestore(testID + "-ref",
YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(true, 1));
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
......
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,13 +17,18 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto & mpiHelper = Dune::MPIHelper::instance(argc, argv);
std::string testID =
"backuprestore-equidistantoffset-np" + std::to_string(mpiHelper.size());
// check the backup restore facility
check_backuprestore(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
check_backuprestore(testID,
YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
// Test again with refinement
check_backuprestore(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(true, 1));
check_backuprestore(testID + "-ref",
YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(true, 1));
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
......
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,13 +17,18 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto & mpiHelper = Dune::MPIHelper::instance(argc, argv);
std::string testID =
"backuprestore-tensor-np" + std::to_string(mpiHelper.size());
// check the backup restore facility
check_backuprestore(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
check_backuprestore(testID,
YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
// Test again with refinement
check_backuprestore(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(true, 1));
check_backuprestore(testID + "-ref",
YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(true, 1));
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
......
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,11 +17,17 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto & mpiHelper = Dune::MPIHelper::instance(argc, argv);
check_yasp(YaspFactory<1,Dune::EquidistantCoordinates<double,1> >::buildGrid());
check_yasp(YaspFactory<1,Dune::EquidistantOffsetCoordinates<double,1> >::buildGrid());
check_yasp(YaspFactory<1,Dune::TensorProductCoordinates<double,1> >::buildGrid());
std::string testID =
"yaspfactory-1d-np" + std::to_string(mpiHelper.size());
check_yasp(testID + "equidistant",
YaspFactory<1,Dune::EquidistantCoordinates<double,1> >::buildGrid());
check_yasp(testID + "equidistantoffset",
YaspFactory<1,Dune::EquidistantOffsetCoordinates<double,1> >::buildGrid());
check_yasp(testID + "tensor",
YaspFactory<1,Dune::TensorProductCoordinates<double,1> >::buildGrid());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
......
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,17 +17,28 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto &mpiHelper = Dune::MPIHelper::instance(argc, argv);
check_yasp(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(true, 0));
check_yasp(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(true, 0));
check_yasp(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(true, 0));
std::string testID =
"yaspfactory-2d-np" + std::to_string(mpiHelper.size());
check_yasp(testID + "equidistant",
YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(true, 0));
check_yasp(testID + "equidistantoffset",
YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(true, 0));
check_yasp(testID + "tensor",
YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(true, 0));
// In 2D, also test refinement
for (int refineOpt = 0; refineOpt <= 1; ++refineOpt) {
check_yasp(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
check_yasp(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
check_yasp(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
std::string refTestID = testID + "-ref" + std::to_string(refineOpt);
check_yasp(refTestID + "equidistant",
YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
check_yasp(refTestID + "equidistantoffset",
YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
check_yasp(refTestID + "tensor",
YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid(refineOpt == 1, 1));
}
// And periodicity
......
......@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
......@@ -16,11 +17,17 @@
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
const auto & mpiHelper = Dune::MPIHelper::instance(argc, argv);
check_yasp(YaspFactory<3,Dune::EquidistantCoordinates<double,3> >::buildGrid());
check_yasp(YaspFactory<3,Dune::EquidistantOffsetCoordinates<double,3> >::buildGrid());
check_yasp(YaspFactory<3,Dune::TensorProductCoordinates<double,3> >::buildGrid());
std::string testID =
"yaspfactory-3d-np" + std::to_string(mpiHelper.size());
check_yasp(testID + "equidistant",
YaspFactory<3,Dune::EquidistantCoordinates<double,3> >::buildGrid());
check_yasp(testID + "equidistantoffset",
YaspFactory<3,Dune::EquidistantOffsetCoordinates<double,3> >::buildGrid());
check_yasp(testID + "tensor",
YaspFactory<3,Dune::TensorProductCoordinates<double,3> >::buildGrid());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
......
......@@ -3,6 +3,8 @@
#ifndef DUNE_GRID_TEST_TEST_YASPGRID_HH
#define DUNE_GRID_TEST_TEST_YASPGRID_HH
#include <string>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/test/gridcheck.hh>
......@@ -110,7 +112,7 @@ struct YaspFactory<dim, Dune::TensorProductCoordinates<double,dim> >
};
template <int dim, class CC>
void check_yasp(Dune::YaspGrid<dim,CC>* grid) {
void check_yasp(std::string testID, Dune::YaspGrid<dim,CC>* grid) {
std::cout << std::endl << "YaspGrid<" << dim << ">";
gridcheck(*grid);
......@@ -138,7 +140,7 @@ void check_yasp(Dune::YaspGrid<dim,CC>* grid) {
std::ofstream file;
std::ostringstream filename;
filename << "output" <<grid->comm().rank();
filename << testID << "-output" <<grid->comm().rank();
file.open(filename.str());
file << *grid << std::endl;
file.close();
......@@ -147,27 +149,27 @@ void check_yasp(Dune::YaspGrid<dim,CC>* grid) {
}
template <int dim, class CC = Dune::EquidistantCoordinates<double,dim> >
void check_backuprestore(Dune::YaspGrid<dim,CC>* grid)
void check_backuprestore(std::string testID, Dune::YaspGrid<dim,CC>* grid)
{
typedef Dune::YaspGrid<dim,CC> Grid;
grid->globalRefine(2);
Dune::BackupRestoreFacility<Grid>::backup(*grid, "backup");
Dune::BackupRestoreFacility<Grid>::backup(*grid, testID+"-backup");
// avoid that processes that having nothing to backup try to restore
// a grid that has not been backuped yet.
grid->comm().barrier();
Grid* restored = Dune::BackupRestoreFacility<Grid>::restore("backup");
Grid* restored = Dune::BackupRestoreFacility<Grid>::restore(testID+"-backup");
// write a backup of the restored file. this has to be identical to backup
Dune::BackupRestoreFacility<Grid>::backup(*restored, "copy");
Dune::BackupRestoreFacility<Grid>::backup(*restored, testID+"-copy");
if ((std::is_same<CC,Dune::TensorProductCoordinates<double,dim> >::value) || (grid->comm().rank() == 0))
{
// check whether copy and backup are equal
std::ostringstream s1,s2;
s1 << "backup";
s2 << "copy";
s1 << testID << "-backup";
s2 << testID << "-copy";
if (std::is_same<CC,Dune::TensorProductCoordinates<double,dim> >::value)
{
s1 << grid->comm().rank();
......@@ -187,7 +189,7 @@ void check_backuprestore(Dune::YaspGrid<dim,CC>* grid)
}
}
check_yasp(restored);
check_yasp(testID, restored);
delete grid;
}
......
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