Skip to content
Snippets Groups Projects
Commit 4f66cfb3 authored by Linus Seelinger's avatar Linus Seelinger Committed by Christian Engwer
Browse files

[Tests] Split yaspgrid tests into multiple ones in a separate directory,...

[Tests] Split yaspgrid tests into multiple ones in a separate directory, reduced run time for 3d case

(cherry picked from commit 1dda7ea599658c56d5750a863c4f3bb581bfe22e)

Conflicts:
	dune/grid/test/CMakeLists.txt
parent 6af06b0a
Branches
Tags
1 merge request!3Split YaspGrid tests into more tests and introduce parallel testing
add_subdirectory(yasp)
dune_add_test(SOURCES geometrygrid-coordfunction-copyconstructor.cc)
dune_add_test(NAME test-geogrid-yaspgrid
......@@ -28,9 +30,6 @@ dune_add_test(SOURCES test-oned.cc
dune_add_test(SOURCES test-mcmg-geogrid.cc)
dune_add_test(SOURCES test-yaspgrid.cc
COMPILE_DEFINITIONS GRIDDIM=2 WORLDDIM=2)
dune_add_test(SOURCES testiteratorranges.cc)
dune_add_test(SOURCES test-hierarchicsearch.cc)
......
set(TESTS
test-yaspgrid-backuprestore
test-yaspgrid-tensorgridfactory
test-yaspgrid-yaspfactory-1d
test-yaspgrid-yaspfactory-2d
test-yaspgrid-yaspfactory-3d
)
# Add all tests
foreach(_test ${TESTS})
add_executable(${_test} EXCLUDE_FROM_ALL ${_test}.cc)
add_dune_mpi_flags(${_test})
target_link_libraries(${_test} "dunegrid" ${DUNE_LIBS})
add_test(${_test} ${_test})
endforeach(_test ${TESTS})
# add test include property manually because the folder is not called "test"
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_BINARY_DIR}/BuildTests.cmake)
# Add tests to test target
add_directory_test_target(_test_target)
add_dependencies(${_test_target} ${TESTS})
set(SOURCES
test-yaspgrid-backuprestore.cc
test-yaspgrid-tensorgridfactory.cc
test-yaspgrid-yaspfactory-1d.cc
test-yaspgrid-yaspfactory-2d.cc
test-yaspgrid-yaspfactory-3d.cc
test-yaspgrid.hh
)
install(FILES ${SOURCES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/grid/test)
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/yaspgrid/backuprestore.hh>
#include "test-yaspgrid.hh"
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
// check the backup restore facility
check_backuprestore(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
check_backuprestore(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
check_backuprestore(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/utility/tensorgridfactory.hh>
#include "test-yaspgrid.hh"
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
// check the factory class for tensorproduct grids
Dune::TensorGridFactory<Dune::YaspGrid<2, Dune::TensorProductCoordinates<double,2> > > factory;
factory.setStart(0,-100.);
factory.fillIntervals(0,10,20.);
factory.fillRange(0, 5, 130.);
factory.geometricFillIntervals(0, 5, 2.0);
factory.geometricFillRange(1,10,100.,1.,false);
factory.fillRange(1,10,200);
factory.geometricFillRange(1,10,250.,1.,true);
factory.fillUntil(1,50,1000.);
factory.createGrid();
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/utility/tensorgridfactory.hh>
#include "test-yaspgrid.hh"
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
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());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/utility/tensorgridfactory.hh>
#include "test-yaspgrid.hh"
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
Dune::MPIHelper::instance(argc, argv);
check_yasp(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
check_yasp(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
check_yasp(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/utility/tensorgridfactory.hh>
#include "test-yaspgrid.hh"
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
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());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/yaspgrid/backuprestore.hh>
#include <dune/grid/utility/tensorgridfactory.hh>
#include "gridcheck.hh"
#include "checkcommunicate.hh"
#include "checkgeometryinfather.hh"
#include "checkintersectionit.hh"
#include "checkiterators.hh"
#include "checkadaptation.hh"
#include "checkpartition.hh"
#include <dune/grid/test/gridcheck.hh>
#include <dune/grid/test/checkcommunicate.hh>
#include <dune/grid/test/checkgeometryinfather.hh>
#include <dune/grid/test/checkintersectionit.hh>
#include <dune/grid/test/checkiterators.hh>
#include <dune/grid/test/checkadaptation.hh>
#include <dune/grid/test/checkpartition.hh>
template<int dim, class CC>
struct YaspFactory
......@@ -34,6 +23,11 @@ struct YaspFactory<dim, Dune::EquidistantCoordinates<double,dim> >
Dune::FieldVector<double,dim> Len(1.0);
std::array<int,dim> s;
std::fill(s.begin(), s.end(), 8);
std::array<int,dim> s;
if (dim < 3)
std::fill(s.begin(), s.end(), 8);
else
std::fill(s.begin(), s.end(), 4);
std::bitset<dim> p(0);
int overlap = 1;
......@@ -52,6 +46,11 @@ struct YaspFactory<dim, Dune::EquidistantOffsetCoordinates<double,dim> >
Dune::FieldVector<double,dim> upperright(1.0);
std::array<int,dim> s;
std::fill(s.begin(), s.end(), 8);
std::array<int,dim> s;
if (dim < 3)
std::fill(s.begin(), s.end(), 8);
else
std::fill(s.begin(), s.end(), 4);
std::bitset<dim> p(0);
int overlap = 1;
......@@ -70,18 +69,32 @@ struct YaspFactory<dim, Dune::TensorProductCoordinates<double,dim> >
int overlap = 1;
std::array<std::vector<double>,dim> coords;
for (int i=0; i<dim; i++)
{
coords[i].resize(9);
coords[i][0] = -1.0;
coords[i][1] = -0.5;
coords[i][2] = -0.25;
coords[i][3] = -0.125;
coords[i][4] = 0.0;
coords[i][5] = 0.125;
coords[i][6] = 0.25;
coords[i][7] = 0.5;
coords[i][8] = 1.0;
if (dim < 3) {
for (int i=0; i<dim; i++)
{
coords[i].resize(9);
coords[i][0] = -1.0;
coords[i][1] = -0.5;
coords[i][2] = -0.25;
coords[i][3] = -0.125;
coords[i][4] = 0.0;
coords[i][5] = 0.125;
coords[i][6] = 0.25;
coords[i][7] = 0.5;
coords[i][8] = 1.0;
}
} else {
for (int i=0; i<dim; i++)
{
coords[i].resize(7);
coords[i][0] = -1.0;
coords[i][1] = -0.5;
coords[i][2] = -0.25;
coords[i][3] = 0.0;
coords[i][4] = 0.25;
coords[i][5] = 0.5;
coords[i][6] = 1.0;
}
}
return new Dune::YaspGrid<dim, Dune::TensorProductCoordinates<double,dim> >(coords,p,overlap);
......@@ -173,50 +186,3 @@ void check_backuprestore(Dune::YaspGrid<dim,CC>* grid)
delete grid;
}
int main (int argc , char **argv) {
try {
// Initialize MPI, if present
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());
check_yasp(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
check_yasp(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
check_yasp(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
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());
// check the factory class for tensorproduct grids
Dune::TensorGridFactory<Dune::YaspGrid<2, Dune::TensorProductCoordinates<double,2> > > factory;
factory.setStart(0,-100.);
factory.fillIntervals(0,10,20.);
factory.fillRange(0, 5, 130.);
factory.geometricFillIntervals(0, 5, 2.0);
factory.geometricFillRange(1,10,100.,1.,false);
factory.fillRange(1,10,200);
factory.geometricFillRange(1,10,250.,1.,true);
factory.fillUntil(1,50,1000.);
auto grid = factory.createGrid();
// check the backup restore facility
check_backuprestore(YaspFactory<2,Dune::EquidistantCoordinates<double,2> >::buildGrid());
check_backuprestore(YaspFactory<2,Dune::EquidistantOffsetCoordinates<double,2> >::buildGrid());
check_backuprestore(YaspFactory<2,Dune::TensorProductCoordinates<double,2> >::buildGrid());
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 1;
} catch (...) {
std::cerr << "Generic exception!" << std::endl;
return 2;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment