diff --git a/test/io/gridmanager/CMakeLists.txt b/test/io/gridmanager/CMakeLists.txt index 38bf4d1e983d6f6697fb9181d2f3202cbf46eb4c..933072ad3e998ca71a8f6ad4c90f8878e3a99999 100644 --- a/test/io/gridmanager/CMakeLists.txt +++ b/test/io/gridmanager/CMakeLists.txt @@ -249,3 +249,9 @@ dune_add_test(NAME test_gmshboundaryflag_caching LABELS unit io CMAKE_GUARD "( dune-alugrid_FOUND )" ) + +dune_add_test(NAME test_gridmanager_mmesh + SOURCES test_gridmanager_mmesh.cc + LABELS unit io + CMAKE_GUARD "( dune-mmesh_FOUND )" + ) diff --git a/test/io/gridmanager/test_gridmanager_mmesh.cc b/test/io/gridmanager/test_gridmanager_mmesh.cc new file mode 100644 index 0000000000000000000000000000000000000000..976f666684bd3881573aba3c77ed12d4c6b86362 --- /dev/null +++ b/test/io/gridmanager/test_gridmanager_mmesh.cc @@ -0,0 +1,74 @@ +/***************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \brief Test for the mmesh grid manager + */ +#include <config.h> + +#include <dune/common/parallel/mpihelper.hh> +#include <dune/grid/io/file/vtk.hh> +#include <dumux/io/grid/gridmanager_mmesh.hh> + +int main(int argc, char** argv) try +{ + using namespace Dumux; + + // Initialize MPI, finalize is done automatically on exit. + Dune::MPIHelper::instance(argc, argv); + + // First set parameters + Dumux::Parameters::init([](auto& params){ + params["Grid.LowerLeft"] = "-1 -1 -1"; + params["Grid.UpperRight"] = "1 1 1"; + }); + + { + using Grid = Dune::MovingMesh<3>; + GridManager<Grid> gridManager; gridManager.init(); + Dune::VTKWriter<Grid::LeafGridView> vtkWriter(gridManager.grid().leafGridView()); + vtkWriter.write("mmesh-3d"); + } + + Dumux::Parameters::init([](auto& params){ + params["Grid.File"] = "grids/complex_equi_coarse_tri.msh"; + }); + + { + using Grid = Dune::MovingMesh<2>; + GridManager<Grid> gridManager; gridManager.init(); + Dune::VTKWriter<Grid::LeafGridView> vtkWriter(gridManager.grid().leafGridView()); + vtkWriter.write("mmesh-2d"); + } + + return 0; +} +/////////////////////////////////////// +//////// Error handler //////////////// +/////////////////////////////////////// +catch (const Dumux::ParameterException& e) { + std::cerr << e << ". Abort!\n"; + return 1; +} +catch (const Dune::Exception& e) { + std::cerr << "Dune reported error: " << e << std::endl; + return 3; +} +catch (...) { + std::cerr << "Unknown exception thrown!\n"; + return 4; +}