Commit 4a87d7ea authored by Timo Koch's avatar Timo Koch
Browse files

[gridcreator] Port cake grid creator and test

parent 69ce83ce
This diff is collapsed.
......@@ -11,9 +11,11 @@ dune_add_test(NAME test_gridcreator_gmsh
${CMAKE_SOURCE_DIR}/test/references/bifurcation-reference-refined.vtu
${CMAKE_CURRENT_BINARY_DIR}/bifurcation-00001.vtu)
add_dumux_test(test_gridcreator_cake test_gridcreator_cake test_gridcreator_cake.cc
python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
--script fuzzy
--command "${CMAKE_CURRENT_BINARY_DIR}/test_gridcreator_cake"
--files ${CMAKE_SOURCE_DIR}/test/references/cake-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/cake-00000.vtu)
dune_add_test(NAME test_gridcreator_cake
SOURCES test_gridcreator_cake.cc
CMAKE_GUARD "( dune-uggrid_FOUND OR dune-alugrid_FOUND )"
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--command "${CMAKE_CURRENT_BINARY_DIR}/test_gridcreator_cake"
--files ${CMAKE_SOURCE_DIR}/test/references/cake-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/cake-00000.vtu)
......@@ -21,22 +21,27 @@
*/
#include "config.h"
#include <iostream>
#include <dune/common/parametertreeparser.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/timer.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/grid/io/file/vtk.hh>
#include <dumux/common/start.hh>
#include <dumux/common/basicproperties.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/io/cakegridcreator.hh>
#if HAVE_UG
#include <dune/grid/uggrid.hh>
#endif
#if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh>
#endif
namespace Dumux
{
namespace Properties
{
NEW_TYPE_TAG(GridCreatorCakeTest, INHERITS_FROM(NumericModel));
NEW_TYPE_TAG(GridCreatorCakeTest);
// Set the grid type
#if HAVE_DUNE_ALUGRID
SET_TYPE_PROP(GridCreatorCakeTest, Grid, Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>);
......@@ -46,52 +51,39 @@ SET_TYPE_PROP(GridCreatorCakeTest, Grid, Dune::UGGrid<3>);
}
}
int main(int argc, char** argv)
int main(int argc, char** argv) try
{
#if HAVE_DUNE_ALUGRID || HAVE_UG
try {
// initialize MPI, finalize is done automatically on exit
Dune::MPIHelper::instance(argc, argv);
// Some typedefs
using TypeTag = TTAG(GridCreatorCakeTest);
using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
using GridCreator = typename Dumux::CakeGridCreator<TypeTag>;
// initialize MPI, finalize is done automatically on exit
Dune::MPIHelper::instance(argc, argv);
// Read the parameters from the input file
using ParameterTree = typename GET_PROP(TypeTag, ParameterTree);
// Some typedefs
using TypeTag = TTAG(GridCreatorCakeTest);
using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
using GridCreator = typename Dumux::CakeGridCreator<Grid>;
// first read parameters from input file
Dune::ParameterTreeParser::readINITree("test_gridcreator_cake.input", ParameterTree::tree());
// first read parameters from input file
Dumux::Parameters::init(argc, argv, "test_gridcreator_cake.input");
// make the grid
Dune::Timer timer;
GridCreator::makeGrid();
std::cout << "Constructing cake grid with " << GridCreator::grid().leafGridView().size(0) << " elements took "
<< timer.elapsed() << " seconds.\n";
// construct a vtk output writer and attach the boundaryMakers
Dune::VTKWriter<Grid::LeafGridView> vtkWriter(GridCreator::grid().leafGridView());
vtkWriter.write("cake-00000");
// make the grid
Dune::Timer timer;
GridCreator::makeGrid();
std::cout << "Constructing cake grid with " << GridCreator::grid().leafGridView().size(0) << " elements took "
<< timer.elapsed() << " seconds.\n";
// construct a vtk output writer and attach the boundaryMakers
Dune::VTKWriter<Grid::LeafGridView> vtkWriter(GridCreator::grid().leafGridView());
vtkWriter.write("cake-00000");
return 0;
}
catch (Dumux::ParameterException &e) {
typedef typename TTAG(GridCreatorCakeTest) TypeTag;
Dumux::Parameters::print<TypeTag>();
std::cerr << e << ". Abort!\n";
return 1;
}
catch (Dune::Exception &e) {
std::cerr << "Dune reported error: " << e << std::endl;
return 3;
}
catch (...) {
std::cerr << "Unknown exception thrown!\n";
return 4;
}
#else
#warning "You need to have ALUGrid or UGGrid installed to run this test."
std::cerr << "You need to have ALUGrid or UGGrid installed to run this test\n";
return 77;
#endif
} // main
return 0;
}
catch (Dumux::ParameterException &e) {
std::cerr << e << ". Abort!\n";
return 1;
}
catch (Dune::Exception &e) {
std::cerr << "Dune reported error: " << e << std::endl;
return 3;
}
catch (...) {
std::cerr << "Unknown exception thrown!\n";
return 4;
}
Supports Markdown
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