diff --git a/dumux/common/properties.hh b/dumux/common/properties.hh index f97c06fd0d4589a601c78c94b3b1ebb469964e9b..1ccc0c730dad95b40ae9be0e528e889357136fa6 100644 --- a/dumux/common/properties.hh +++ b/dumux/common/properties.hh @@ -39,7 +39,6 @@ namespace Properties { /////////////////////////////////////// NEW_PROP_TAG(Scalar); //!< Property to specify the type of scalar values. NEW_PROP_TAG(ModelDefaultParameters); //!< Property which defines the group that is queried for parameters by default -NEW_PROP_TAG(GridCreator); //!< Property which provides a GridCreator (manages grids) NEW_PROP_TAG(Grid); //!< The DUNE grid type NEW_PROP_TAG(PrimaryVariables); //!< A vector of primary variables NEW_PROP_TAG(NumEqVector); //!< A vector of size number equations that can be used for Neumann fluxes, sources, residuals, ... diff --git a/dumux/common/properties/grid.hh b/dumux/common/properties/grid.hh index 2f4803a0b543ae8d825d217d36f88e90dda76eaf..2ab818bf02e53d8ee94a7b7aadb0faf454e65f21 100644 --- a/dumux/common/properties/grid.hh +++ b/dumux/common/properties/grid.hh @@ -28,21 +28,16 @@ #include <dumux/common/properties.hh> #include <dumux/common/pointsource.hh> -#include <dumux/io/gridcreator.hh> -namespace Dumux -{ -namespace Properties -{ +namespace Dumux { +namespace Properties { + //! Type tag for numeric models. NEW_TYPE_TAG(GridProperties); //! Use the leaf grid view if not defined otherwise SET_TYPE_PROP(GridProperties, GridView, typename GET_PROP_TYPE(TypeTag, Grid)::LeafGridView); -//! Use the DgfGridCreator by default -SET_TYPE_PROP(GridProperties, GridCreator, GridCreator<TypeTag>); - //! Use the minimal point source implementation as default SET_PROP(GridProperties, PointSource) { diff --git a/dumux/common/start.hh b/dumux/common/start.hh index 815a937a3e1d8882f0a9466a1197d213d126ed01..2da828911700d5620984dbac6b29e3e286566806 100644 --- a/dumux/common/start.hh +++ b/dumux/common/start.hh @@ -21,8 +21,8 @@ * \ingroup Common * \brief Provides a few default main functions for convenience. */ -#ifndef DUMUX_START_HH -#define DUMUX_START_HH +#ifndef DUMUX_COMMON_START_HH +#define DUMUX_COMMON_START_HH #include <ctime> #include <iostream> @@ -34,6 +34,7 @@ #include <dumux/common/parameters.hh> #include <dumux/common/dumuxmessage.hh> #include <dumux/common/defaultusagemessage.hh> +#include <dumux/io/grid/gridmanager.hh> #warning "start.hh is deprecated. Use new style main files see e.g. /test/porousmediumflow/1p." @@ -64,7 +65,6 @@ int start_(int argc, { // some aliases for better readability using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using TimeManager = typename GET_PROP_TYPE(TypeTag, TimeManager); @@ -86,8 +86,8 @@ int start_(int argc, // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); ////////////////////////////////////////////////////////////////////// // run the simulation @@ -108,7 +108,7 @@ int start_(int argc, // instantiate and run the problem TimeManager timeManager; - Problem problem(timeManager, GridCreator::grid()); + Problem problem(timeManager, gridManager.grid()); timeManager.init(problem, restartTime, dt, tEnd, restart); timeManager.run(); diff --git a/dumux/discretization/CMakeLists.txt b/dumux/discretization/CMakeLists.txt index a55ac8b0ff9b4c3e3cdd089835c164b9d08ce049..f3b5244a42a56a2c1c09d35bc42bb491ec0c7429 100644 --- a/dumux/discretization/CMakeLists.txt +++ b/dumux/discretization/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(staggered) install(FILES basefvgridgeometry.hh +checkoverlapsize.hh darcyslaw.hh effectivestresslaw.hh elementsolution.hh diff --git a/dumux/discretization/basefvgridgeometry.hh b/dumux/discretization/basefvgridgeometry.hh index 4a6a378a5f71950926e46803f9b245295f427427..45bad97574d87660dca0d4d95dbbea7fbc121fe0 100644 --- a/dumux/discretization/basefvgridgeometry.hh +++ b/dumux/discretization/basefvgridgeometry.hh @@ -55,6 +55,8 @@ class BaseFVGridGeometry using Element = typename GV::template Codim<0>::Entity; public: + //! export the grid type + using Grid = typename GV::Grid; //! export the grid view type using GridView = GV; //! export the global coordinate type diff --git a/dumux/discretization/box/fvgridgeometry.hh b/dumux/discretization/box/fvgridgeometry.hh index 1df7688e820701b2670a5cd5546782df42604edd..f5f142aee5b5691fd6f8f0e143f4b9152ef88f15 100644 --- a/dumux/discretization/box/fvgridgeometry.hh +++ b/dumux/discretization/box/fvgridgeometry.hh @@ -32,6 +32,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/common/defaultmappertraits.hh> #include <dumux/discretization/basefvgridgeometry.hh> +#include <dumux/discretization/checkoverlapsize.hh> #include <dumux/discretization/box/boxgeometryhelper.hh> #include <dumux/discretization/box/fvelementgeometry.hh> #include <dumux/discretization/box/subcontrolvolume.hh> @@ -112,7 +113,13 @@ public: //! Constructor BoxFVGridGeometry(const GridView gridView) - : ParentType(gridView) {} + : ParentType(gridView) + { + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::box>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The box discretization method only works with zero overlap for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); + } //! the vertex mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... @@ -316,7 +323,13 @@ public: //! Constructor BoxFVGridGeometry(const GridView gridView) - : ParentType(gridView) {} + : ParentType(gridView) + { + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::box>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The box discretization method only works with zero overlap for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); + } //! the vertex mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... diff --git a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh index 46e7f5df1ce7760a82df85468b98fb7289416c82..e2ebeeaa96059b34a5626efdd631acf05f45275e 100644 --- a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh +++ b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh @@ -31,6 +31,7 @@ #include <dumux/common/parameters.hh> #include <dumux/discretization/methods.hh> #include <dumux/discretization/basefvgridgeometry.hh> +#include <dumux/discretization/checkoverlapsize.hh> namespace Dumux { @@ -48,6 +49,16 @@ namespace Dumux { template<class GridView, class Traits, bool enableCache> class CCMpfaFVGridGeometry; +//! check the overlap size for parallel computations +template<class GridView> +void checkOverlapSizeCCMpfa(const GridView& gridView) +{ + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::ccmpfa>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The ccmpfa discretization method needs at least an overlap of 1 for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); +} + /*! * \ingroup CCMpfaDiscretization * \brief The finite volume geometry (scvs and scvfs) for cell-centered mpfa models on a grid view @@ -108,13 +119,17 @@ public: : ParentType(gridView) , secondaryIvIndicator_([] (const Element& e, const Intersection& is, bool isBranching) { return is.boundary() || isBranching; } ) - {} + { + checkOverlapSizeCCMpfa(gridView); + } //! Constructor with user-defined indicator function for secondary interaction volumes CCMpfaFVGridGeometry(const GridView& gridView, const SecondaryIvIndicatorType& indicator) : ParentType(gridView) , secondaryIvIndicator_(indicator) - {} + { + checkOverlapSizeCCMpfa(gridView); + } //! the element mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... @@ -467,13 +482,17 @@ public: : ParentType(gridView) , secondaryIvIndicator_([] (const Element& e, const Intersection& is, bool isBranching) { return is.boundary() || isBranching; } ) - {} + { + checkOverlapSizeCCMpfa(gridView); + } //! Constructor with user-defined indicator function for secondary interaction volumes CCMpfaFVGridGeometry(const GridView& gridView, const SecondaryIvIndicatorType& indicator) : ParentType(gridView) , secondaryIvIndicator_(indicator) - {} + { + checkOverlapSizeCCMpfa(gridView); + } //! the element mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... diff --git a/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh b/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh index 9cbf47d78debdff59d75885e42885efafe066730..71e48353a0654dbff43c6bd684b5ebd4d1eb215c 100644 --- a/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh +++ b/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh @@ -31,6 +31,7 @@ #include <dumux/common/defaultmappertraits.hh> #include <dumux/discretization/methods.hh> #include <dumux/discretization/basefvgridgeometry.hh> +#include <dumux/discretization/checkoverlapsize.hh> #include <dumux/discretization/cellcentered/subcontrolvolume.hh> #include <dumux/discretization/cellcentered/connectivitymap.hh> #include <dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh> @@ -116,7 +117,12 @@ public: //! Constructor CCTpfaFVGridGeometry(const GridView& gridView) : ParentType(gridView) - {} + { + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::cctpfa>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); + } //! the element mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... @@ -389,7 +395,12 @@ public: //! Constructor CCTpfaFVGridGeometry(const GridView& gridView) : ParentType(gridView) - {} + { + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::cctpfa>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The cctpfa discretization method needs at least an overlap of 1 for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); + } //! the element mapper is the dofMapper //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... diff --git a/dumux/discretization/checkoverlapsize.hh b/dumux/discretization/checkoverlapsize.hh new file mode 100644 index 0000000000000000000000000000000000000000..2637fc9d18bd20b61637ab40d207eefbb3b637b9 --- /dev/null +++ b/dumux/discretization/checkoverlapsize.hh @@ -0,0 +1,57 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * 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 2 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 + * \ingroup Discretization + * \brief Check the overlap size for different discretization methods + */ +#ifndef DUMUX_DISCRETIZATION_CHECK_OVERLAP_SIZE_HH +#define DUMUX_DISCRETIZATION_CHECK_OVERLAP_SIZE_HH + +#include <dumux/discretization/methods.hh> + +namespace Dumux { + +/*! + * \ingroup Discretization + * \brief Check if the overlap size is valid for a given discretization method + * \note the default checks if the grid has at least an overlap of one if there are no ghosts + * \note for sequential grids every overlap is fine + * \note specialize this for your discretization method if the default doesn't apply + */ +template<DiscretizationMethod discMethod> +struct CheckOverlapSize +{ + template<class GridView> + static bool isValid(const GridView& gridView) noexcept + { return gridView.comm().size() <= 1 || gridView.overlapSize(0) + gridView.ghostSize(0) > 0; } +}; + +//! specialization for the box method which requires an overlap size of 0 +template<> +struct CheckOverlapSize<DiscretizationMethod::box> +{ + template<class GridView> + static bool isValid(const GridView& gridView) noexcept + { return gridView.comm().size() <= 1 || gridView.overlapSize(0) == 0; } +}; + +} // end namespace Dumux + +#endif diff --git a/dumux/discretization/staggered/fvgridgeometry.hh b/dumux/discretization/staggered/fvgridgeometry.hh index c37ea7838ffc346e468bf9cb0bdfbc1c928593eb..1947615d90262761502924b261e19c5039e952d2 100644 --- a/dumux/discretization/staggered/fvgridgeometry.hh +++ b/dumux/discretization/staggered/fvgridgeometry.hh @@ -25,6 +25,7 @@ #define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY #include <dumux/discretization/basefvgridgeometry.hh> +#include <dumux/discretization/checkoverlapsize.hh> #include <dumux/discretization/methods.hh> namespace Dumux { @@ -85,7 +86,13 @@ public: //! Constructor StaggeredFVGridGeometry(const GridView& gridView) : ParentType(gridView) - , intersectionMapper_(gridView) {} + , intersectionMapper_(gridView) + { + // Check if the overlap size is what we expect + if (!CheckOverlapSize<DiscretizationMethod::staggered>::isValid(gridView)) + DUNE_THROW(Dune::InvalidStateException, "The satggered discretization method needs at least an overlap of 1 for parallel computations. " + << " Set the parameter \"Grid.Overlap\" in the input file."); + } //! The total number of sub control volumes std::size_t numScv() const diff --git a/dumux/freeflow/compositional/CMakeLists.txt b/dumux/freeflow/compositional/CMakeLists.txt index ddd32e167c4c7415e6ebe3af2afed6b63c02f05a..11209cfdcd29a954a40067a637e9d0ad3b2ad26d 100644 --- a/dumux/freeflow/compositional/CMakeLists.txt +++ b/dumux/freeflow/compositional/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory(staggered) install(FILES fluxvariables.hh indices.hh +kepsilonncmodel.hh +komegancmodel.hh localresidual.hh lowrekepsilonncmodel.hh navierstokesncmodel.hh diff --git a/dumux/freeflow/rans/twoeq/komega/CMakeLists.txt b/dumux/freeflow/rans/twoeq/komega/CMakeLists.txt index e6ef83c51b2fed49a92d4d1b15260958cf50561d..e6d5c4dc0305cac2463a5b66def96319831c234e 100644 --- a/dumux/freeflow/rans/twoeq/komega/CMakeLists.txt +++ b/dumux/freeflow/rans/twoeq/komega/CMakeLists.txt @@ -5,7 +5,6 @@ fluxvariables.hh indices.hh localresidual.hh model.hh -models.hh problem.hh volumevariables.hh vtkoutputfields.hh diff --git a/dumux/io/CMakeLists.txt b/dumux/io/CMakeLists.txt index d617dc5ef7541da43320b739ef7433186caceed1..6e76c281b1306dae934b3f136131b004be25aeea 100644 --- a/dumux/io/CMakeLists.txt +++ b/dumux/io/CMakeLists.txt @@ -1,11 +1,10 @@ +add_subdirectory(grid) + install(FILES adaptivegridrestart.hh -cakegridcreator.hh container.hh -cpgridcreator.hh defaultvtkoutputfields.hh gnuplotinterface.hh -gridcreator.hh ploteffectivediffusivitymodel.hh plotmateriallaw.hh plotmateriallaw3p.hh @@ -13,7 +12,6 @@ plotthermalconductivitymodel.hh pointcloudvtkwriter.hh restart.hh staggeredvtkoutputmodule.hh -subgridgridcreator.hh vtkfunction.hh vtkmultiwriter.hh vtknestedfunction.hh diff --git a/dumux/io/grid/CMakeLists.txt b/dumux/io/grid/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b60d65fddd73ae1110a3869b8689a9a353d7bd9 --- /dev/null +++ b/dumux/io/grid/CMakeLists.txt @@ -0,0 +1,8 @@ +install(FILES +cakegridcreator.hh +cpgridcreator.hh +gmshgriddatahandle.hh +griddata.hh +gridmanager.hh +subgridgridcreator.hh +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/io/grid) diff --git a/dumux/io/cakegridcreator.hh b/dumux/io/grid/cakegridcreator.hh similarity index 96% rename from dumux/io/cakegridcreator.hh rename to dumux/io/grid/cakegridcreator.hh index 08b92566f64ae5057af383326d83bcfac71d1c18..eb787e12afdd325dfd50b5852c13f4931e2ea2f4 100644 --- a/dumux/io/cakegridcreator.hh +++ b/dumux/io/grid/cakegridcreator.hh @@ -58,7 +58,7 @@ public: /*! * \brief Make the grid. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { static_assert(dim == 2 || dim == 3, "The CakeGridCreator is only implemented for 2D and 3D."); @@ -70,6 +70,7 @@ public: createVectors(polarCoordinates, indices, modelParamGroup, verbose); gridPtr() = createCakeGrid(polarCoordinates, indices, modelParamGroup, verbose); + loadBalance(); } /*! @@ -264,10 +265,10 @@ public: * \param polarCoordinates Vector containing radial, angular and axial coordinates (in this order) * \param indices Indices specifing the radial, angular and axial direction (in this order) */ - static std::shared_ptr<Grid> createCakeGrid(std::array<std::vector<Scalar>, dim> &polarCoordinates, - Dune::FieldVector<int, dim> &indices, - const std::string& modelParamGroup, - bool verbose = false) + std::unique_ptr<Grid> createCakeGrid(std::array<std::vector<Scalar>, dim> &polarCoordinates, + Dune::FieldVector<int, dim> &indices, + const std::string& modelParamGroup, + bool verbose = false) { std::vector<Scalar> dR = polarCoordinates[0]; std::vector<Scalar> dA = polarCoordinates[1]; @@ -446,14 +447,13 @@ public: } } // return the grid pointer - return std::shared_ptr<Grid>(gridFactory.createGrid()); - + return std::unique_ptr<Grid>(gridFactory.createGrid()); } /*! * \brief Returns a reference to the grid. */ - static Grid &grid() + Grid& grid() { return *gridPtr(); } @@ -462,19 +462,23 @@ public: * \brief Distributes the grid on all processes of a parallel * computation. */ - static void loadBalance() + void loadBalance() { gridPtr()->loadBalance(); } +protected: + /*! * \brief Returns a reference to the shared pointer to the grid. */ - static GridPointer &gridPtr() + GridPointer& gridPtr() { - static GridPointer cakeGrid; - return cakeGrid; + return cakeGrid_; } + +private: + GridPointer cakeGrid_; }; } // end namespace Dumux diff --git a/dumux/io/cpgridcreator.hh b/dumux/io/grid/cpgridcreator.hh similarity index 100% rename from dumux/io/cpgridcreator.hh rename to dumux/io/grid/cpgridcreator.hh diff --git a/dumux/io/grid/gmshgriddatahandle.hh b/dumux/io/grid/gmshgriddatahandle.hh new file mode 100644 index 0000000000000000000000000000000000000000..a5a932e884c8815f1a92151be3400c165ec9c0f6 --- /dev/null +++ b/dumux/io/grid/gmshgriddatahandle.hh @@ -0,0 +1,188 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * 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 2 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 + * \ingroup InputOutput + * \brief A data handle for commucating grid data for gmsh grids + */ +#ifndef DUMUX_GMSH_GRID_DATA_HANDLE_HH +#define DUMUX_GMSH_GRID_DATA_HANDLE_HH + +#include <memory> +#include <algorithm> + +#include <dune/common/parallel/collectivecommunication.hh> +#include <dune/grid/common/partitionset.hh> +#include <dune/grid/common/datahandleif.hh> + +// UGGrid specific includes +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif + +namespace Dumux { + +/*! + * \ingroup InputOutput + * \brief A data handle for commucating grid data for gmsh grids + */ +template<class Grid, class GridFactory, class Data> +struct GmshGridDataHandle : public Dune::CommDataHandleIF<GmshGridDataHandle<Grid, GridFactory, Data>, typename Data::value_type> +{ + using GridView = typename Grid::LevelGridView; + + GmshGridDataHandle(const Grid& grid, const GridFactory& gridFactory, Data& elementMarkers, Data& boundaryMarkers, Data& faceMarkers) + : gridView_(grid.levelGridView(0)) + , idSet_(grid.localIdSet()) + , elementMarkers_(elementMarkers) + , boundaryMarkers_(boundaryMarkers) + , faceMarkers_(faceMarkers) + { + const auto& indexSet = gridView_.indexSet(); + + for (const auto& element : elements(gridView_, Dune::Partitions::interior)) + std::swap(elementMarkers_[gridFactory.insertionIndex(element)], data_[idSet_.id(element)]); + + for (const auto& face : entities(gridView_, Dune::Codim<1>())) + std::swap(faceMarkers_[indexSet.index(face)], data_[idSet_.id(face)]); + } + + ~GmshGridDataHandle() + { + const auto& indexSet = gridView_.indexSet(); + + elementMarkers_.resize(indexSet.size(0)); + for (const auto& element : elements(gridView_)) + std::swap(elementMarkers_[indexSet.index(element)], data_[idSet_.id(element)]); + + faceMarkers_.resize(indexSet.size(1)); + for (const auto& face : entities(gridView_, Dune::Codim<1>())) + std::swap(faceMarkers_[indexSet.index(face)], data_[idSet_.id(face)]); + + boundaryMarkers_.resize(gridView_.grid().numBoundarySegments(), 0); + for (const auto& element : elements(gridView_.grid().leafGridView())) + { + for (const auto& intersection : intersections(gridView_.grid().leafGridView(), element)) + { + if (intersection.boundary()) + { + const auto marker = faceMarkers_[indexSet.index(element.template subEntity<1>(intersection.indexInInside()))]; + boundaryMarkers_[intersection.boundarySegmentIndex()] = marker; + } + } + } + } + + Dune::CommDataHandleIF<GmshGridDataHandle<Grid, GridFactory, Data>, typename Data::value_type>& interface() + { return *this; } + + bool contains (int dim, int codim) const + { return codim == 0 || codim == 1; } + + bool fixedSize (int dim, int codim) const + { return true; } + + template<class EntityType> + std::size_t size (const EntityType& e) const + { return 1; } + + template<class MessageBufferImp, class EntityType> + void gather (MessageBufferImp& buff, const EntityType& e) const + { buff.write(data_[idSet_.id(e)]); } + + template<class MessageBufferImp, class EntityType> + void scatter (MessageBufferImp& buff, const EntityType& e, std::size_t n) + { buff.read(data_[idSet_.id(e)]); } + +private: + using IdSet = typename Grid::LocalIdSet; + + const GridView gridView_; + const IdSet &idSet_; + Data& elementMarkers_; + Data& boundaryMarkers_; + Data& faceMarkers_; + mutable std::map< typename IdSet::IdType, typename Data::value_type> data_; +}; + +#if HAVE_UG + +/*! + * \ingroup InputOutput + * \brief A data handle for commucating grid data for gmsh grids (specialization for UGGrid) + */ +template<class GridFactory, class Data, int dimgrid> +struct GmshGridDataHandle<Dune::UGGrid<dimgrid>, GridFactory, Data> +: public Dune::CommDataHandleIF<GmshGridDataHandle<Dune::UGGrid<dimgrid>, GridFactory, Data>, typename Data::value_type> +{ + using Grid = Dune::UGGrid<dimgrid>; + using GridView = typename Grid::LevelGridView; + + GmshGridDataHandle(const Grid& grid, const GridFactory& gridFactory, Data& elementMarkers) + : gridView_(grid.levelGridView(0)) + , idSet_(grid.localIdSet()) + , elementMarkers_(elementMarkers) + { + for (const auto& element : elements(gridView_, Dune::Partitions::interior)) + std::swap(elementMarkers_[gridFactory.insertionIndex(element)], data_[idSet_.id(element)]); + } + + ~GmshGridDataHandle() + { + const auto& indexSet = gridView_.indexSet(); + elementMarkers_.resize(indexSet.size(0)); + for (const auto& element : elements(gridView_)) + std::swap(elementMarkers_[indexSet.index(element)], data_[idSet_.id(element)]); + } + + Dune::CommDataHandleIF<GmshGridDataHandle<Grid, GridFactory, Data>, typename Data::value_type>& interface() + { return *this; } + + bool contains (int dim, int codim) const + { return codim == 0 || codim == 1; } + + bool fixedSize (int dim, int codim) const + { return true; } + + template<class EntityType> + std::size_t size (const EntityType& e) const + { return 1; } + + template<class MessageBufferImp, class EntityType> + void gather (MessageBufferImp& buff, const EntityType& e) const + { buff.write(data_[idSet_.id(e)]); } + + template<class MessageBufferImp, class EntityType> + void scatter (MessageBufferImp& buff, const EntityType& e, std::size_t n) + { buff.read(data_[idSet_.id(e)]); } + +private: + using IdSet = typename Grid::LocalIdSet; + + const GridView gridView_; + const IdSet &idSet_; + Data& elementMarkers_; + mutable std::map< typename IdSet::IdType, typename Data::value_type> data_; +}; + +#endif // HAVE_UG + +} // namespace Dumux + +#endif diff --git a/dumux/io/grid/griddata.hh b/dumux/io/grid/griddata.hh new file mode 100644 index 0000000000000000000000000000000000000000..d7a7556f631e19941e81778ba25af3b189f14353 --- /dev/null +++ b/dumux/io/grid/griddata.hh @@ -0,0 +1,210 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * 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 2 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 + * \ingroup InputOutput + * \brief Class for grid data attached to dgf or gmsh grid files + */ +#ifndef DUMUX_IO_GRID_DATA_HH +#define DUMUX_IO_GRID_DATA_HH + +#include <vector> +#include <memory> +#include <type_traits> + +#include <dune/common/exceptions.hh> +#include <dune/common/parallel/collectivecommunication.hh> +#include <dune/common/parallel/mpihelper.hh> +#include <dune/grid/common/gridfactory.hh> + +// UGGrid specific includes +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif + +#include "gmshgriddatahandle.hh" + +namespace Dumux { + +namespace Detail { + +template<class Grid> +struct isUG : public std::false_type {}; + +#if HAVE_UG +template<int dim> +struct isUG<Dune::UGGrid<dim>> : public std::true_type {}; +#endif + +} // end namespace Details + +/*! + * \ingroup InputOutput + * \brief Class for grid data attached to dgf or gmsh grid files + */ +template <class Grid> +class GridData +{ + using Intersection = typename Grid::LeafIntersection; + using Element = typename Grid::template Codim<0>::Entity; + using DataHandle = GmshGridDataHandle<Grid, Dune::GridFactory<Grid>, std::vector<int>>; + +public: + //! constructor for gmsh grid data + GridData(std::shared_ptr<Grid> grid, std::shared_ptr<Dune::GridFactory<Grid>> factory, + std::vector<int>&& elementMarkers, std::vector<int>&& boundaryMarkers, std::vector<int>&& faceMarkers = std::vector<int>{}) + : gmshGrid_(grid) + , gridFactory_(factory) + , elementMarkers_(elementMarkers) + , boundaryMarkers_(boundaryMarkers) + , faceMarkers_(faceMarkers) + {} + + //! constructor for dgf grid data + GridData(Dune::GridPtr<Grid> grid) + : dgfGrid_(grid) + , isDgfData_(true) + {} + + + /*! + * \brief Call the parameters function of the DGF grid pointer if available + */ + template <class Entity> + const std::vector<double>& parameters(const Entity& entity) const + { + if (isDgfData_) + { + if (entity.hasFather()) + { + auto level0entity = entity; + while(level0entity.hasFather()) + level0entity = level0entity.father(); + + + return dgfGrid_.parameters(level0entity); + } + else + { + return dgfGrid_.parameters(entity); + } + } + else + DUNE_THROW(Dune::InvalidStateException, "The parameters method is only available if the grid was constructed with a DGF file."); + } + + /*! + * \brief Call the parameters function of the DGF grid pointer if available + */ + template <class GridImp, class IntersectionImp> + const Dune::DGFBoundaryParameter::type& parameters(const Dune::Intersection<GridImp, IntersectionImp>& intersection) const + { + if (isDgfData_) + return dgfGrid_.parameters(intersection); + else + DUNE_THROW(Dune::InvalidStateException, "The parameters method is only available if the grid was constructed with a DGF file."); + } + + /*! + * \brief Return the boundary domain marker (Gmsh physical entity number) of an intersection + Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. + * \param boundarySegmentIndex The boundary segment index of the intersection (intersection.boundarySegmentIndex() + */ + int getBoundaryDomainMarker(int boundarySegmentIndex) const + { + if (!gmshGrid_) + DUNE_THROW(Dune::InvalidStateException, "Domain markers are only available for gmsh grids."); + if (boundarySegmentIndex >= boundaryMarkers_.size()) + DUNE_THROW(Dune::RangeError, "Boundary segment index "<< boundarySegmentIndex << " bigger than number of boundary segments in grid."); + return boundaryMarkers_[boundarySegmentIndex]; + } + + /*! + * \brief Return the boundary domain marker (Gmsh physical entity number) of an intersection + Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. + * \param intersection The intersection to be evaluated + */ + int getBoundaryDomainMarker(const Intersection& intersection) const + { return getBoundaryDomainMarker(intersection.boundarySegmentIndex()); } + + + /*! + * \brief Return the element domain marker (Gmsh physical entity number) of an element. + Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. + * \param element The element to be evaluated + */ + int getElementDomainMarker(const Element& element) const + { + if (!gmshGrid_) + DUNE_THROW(Dune::InvalidStateException, "Domain markers are only available for gmsh grids."); + + // parameters are only given for level 0 elements + auto level0element = element; + while (level0element.hasFather()) + level0element = level0element.father(); + + // in the parallel case the data is load balanced and then accessed with indices of the index set + // for UGGrid element data is read on all processes since UGGrid can't communicate element data (yet) + if (gmshGrid_->comm().size() > 1 && !Detail::isUG<Grid>::value) + return elementMarkers_[gmshGrid_->levelGridView(0).indexSet().index(level0element)]; + else + return elementMarkers_[gridFactory_->insertionIndex(level0element)]; + } + + /*! + * \brief Create a data handle for communication of the data in parallel simulations + * \note this data hande is the default + */ + template<bool ug = Detail::isUG<Grid>::value, typename std::enable_if_t<!ug, int> = 0> + DataHandle createGmshDataHandle() + { + return DataHandle(*gmshGrid_, *gridFactory_, elementMarkers_, boundaryMarkers_, faceMarkers_); + } + + /*! + * \brief Create a data handle for communication of the data in parallel simulations + * \note this data hande is the specialized for UGGrid since UGGrid can't communicate element data (yet) + */ + template<bool ug = Detail::isUG<Grid>::value, typename std::enable_if_t<ug, int> = 0> + DataHandle createGmshDataHandle() + { + return DataHandle(*gmshGrid_, *gridFactory_, elementMarkers_); + } + +private: + // grid and grid factor for gmsh grid data + std::shared_ptr<Grid> gmshGrid_; + std::shared_ptr<Dune::GridFactory<Grid>> gridFactory_; + + /*! + * \brief Element and boundary domain markers obtained from Gmsh physical entities + * They map from element indices / boundary ids to the physical entity number + */ + std::vector<int> elementMarkers_; + std::vector<int> boundaryMarkers_; + std::vector<int> faceMarkers_; + + // dgf grid data + Dune::GridPtr<Grid> dgfGrid_; + bool isDgfData_ = false; +}; + +} // namespace Dumux + +#endif diff --git a/dumux/io/gridcreator.hh b/dumux/io/grid/gridmanager.hh similarity index 63% rename from dumux/io/gridcreator.hh rename to dumux/io/grid/gridmanager.hh index 36d866273a413cffc753a49a6ab9b19735540c65..c9118be37edb40cc637ab0162680d86913ec5800 100644 --- a/dumux/io/gridcreator.hh +++ b/dumux/io/grid/gridmanager.hh @@ -19,13 +19,13 @@ /*! * \file * \ingroup InputOutput - * \brief Provides a grid creator for all supported grid managers with - * input file interfaces. + * \brief Provides a grid manager for all supported grid managers with + * input file interfaces. Manages data via the grid data member. * * \todo add Petrel grids with dune-cornerpoint */ -#ifndef DUMUX_GRID_CREATOR_HH -#define DUMUX_GRID_CREATOR_HH +#ifndef DUMUX_IO_GRID_MANAGER_HH +#define DUMUX_IO_GRID_MANAGER_HH #include <array> #include <bitset> @@ -39,7 +39,6 @@ #include <dune/grid/io/file/dgfparser/dgfparser.hh> #include <dune/grid/io/file/gmshreader.hh> #include <dune/grid/common/gridfactory.hh> -#include <dune/grid/common/datahandleif.hh> #include <dune/grid/utility/structuredgridfactory.hh> // YaspGrid specific includes @@ -68,98 +67,38 @@ #include <dune/foamgrid/dgffoam.hh> #endif -#include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> #include <dumux/discretization/methods.hh> -namespace Dumux -{ - -template<class GridPtr, class GridCreator> -struct GridDataHandle : public Dune::CommDataHandleIF<GridDataHandle<GridPtr, GridCreator>, int> -{ - using GridType = typename GridPtr::element_type; - GridDataHandle( GridPtr& gridPtr) - : gridPtr_(gridPtr), idSet_(gridPtr->localIdSet()) - { - auto gridView = gridPtr_->levelGridView(0); - const auto& indexSet = gridView.indexSet(); - - for( const auto& element : elements(gridView, Dune::Partitions::interior)) - std::swap(GridCreator::elementMarkers_[GridCreator::gridFactory().insertionIndex(element)], data_[idSet_.id(element)]); - - for (const auto& face : entities(gridView, Dune::Codim<1>())) - std::swap(GridCreator::faceMarkers_[indexSet.index(face)], data_[idSet_.id(face)]); - } - - ~GridDataHandle() - { - auto gridView = gridPtr_->levelGridView(0); - const auto& indexSet = gridView.indexSet(); - - GridCreator::elementMarkers_.resize(indexSet.size(0)); - for(const auto& element : elements(gridView)) - std::swap(GridCreator::elementMarkers_[indexSet.index(element)], data_[idSet_.id(element)]); - - GridCreator::faceMarkers_.resize(indexSet.size(1)); - for (const auto& face : entities(gridView, Dune::Codim<1>())) - std::swap(GridCreator::faceMarkers_[indexSet.index(face)], data_[idSet_.id(face)]); - } - - Dune::CommDataHandleIF<GridDataHandle<GridPtr, GridCreator>, int>& interface() - { return *this; } - - bool contains (int dim, int codim) const - { return codim == 0 || codim == 1; } - - bool fixedSize (int dim, int codim) const - { return true; } - - template<class EntityType> - size_t size (const EntityType& e) const - { return 1; } - - template<class MessageBufferImp, class EntityType> - void gather (MessageBufferImp& buff, const EntityType& e) const - { buff.write(data_[idSet_.id(e)]); } - - template<class MessageBufferImp, class EntityType> - void scatter (MessageBufferImp& buff, const EntityType& e, size_t n) - { buff.read(data_[idSet_.id(e)]); } - -private: - GridPtr &gridPtr_; - using IdSet = typename GridType::LocalIdSet; - const IdSet &idSet_; - mutable std::map< typename IdSet::IdType, int> data_; -}; +#include "griddata.hh" +namespace Dumux { /*! * \ingroup InputOutput - * \brief Provides the grid creator base interface (public) and methods common - * to most grid creator specializations (protected). + * \brief The grid manager base interface (public) and methods common + * to most grid manager specializations (protected). */ -template <class Grid> -class GridCreatorBase +template <class GridType> +class GridManagerBase { - using Intersection = typename Grid::LeafIntersection; - using Element = typename Grid::template Codim<0>::Entity; - friend class GridDataHandle<std::shared_ptr<Grid>, GridCreatorBase>; public: + using Grid = GridType; + using GridData = Dumux::GridData<Grid>; + /*! * \brief Make the grid. Implement this method in the specialization of this class for a grid type. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { DUNE_THROW(Dune::NotImplemented, - "The GridCreator for grid type " << Dune::className<Grid>() << " is not implemented! Consider providing your own GridCreator."); + "The GridManager for grid type " << Dune::className<Grid>() << " is not implemented! Consider providing your own GridManager."); } /*! * \brief Returns a reference to the grid. */ - static Grid &grid() + Grid& grid() { if(enableDgfGridPointer_) return *dgfGridPtr(); @@ -167,141 +106,10 @@ public: return *gridPtr(); } - /*! - * \brief Call the parameters function of the DGF grid pointer if available - */ - template <class Entity> - static const std::vector<double>& parameters(const Entity& entity) - { - if(enableDgfGridPointer_) - { - if (entity.hasFather()) - { - auto level0entity = entity; - while(level0entity.hasFather()) - level0entity = level0entity.father(); - - - return dgfGridPtr().parameters(level0entity); - } - else - { - return dgfGridPtr().parameters(entity); - } - } - else - DUNE_THROW(Dune::InvalidStateException, "The parameters method is only available if the grid was constructed with a DGF file!"); - } - - /*! - * \brief Call the parameters function of the DGF grid pointer if available - */ - template <class GridImp, class IntersectionImp> - static const Dune::DGFBoundaryParameter::type& parameters(const Dune::Intersection<GridImp, IntersectionImp>& intersection) - { - if(enableDgfGridPointer_) - return dgfGridPtr().parameters(intersection); - else - DUNE_THROW(Dune::InvalidStateException, "The parameters method is only available if the grid was constructed with a DGF file!"); - } - - /*! - * \brief Return the boundary domain marker (Gmsh physical entity number) of an intersection - Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. - * \param boundarySegmentIndex The boundary segment index of the intersection (intersection.boundarySegmentIndex() - */ - static int getBoundaryDomainMarker(int boundarySegmentIndex) - { - if(enableGmshDomainMarkers_) - { - if (boundarySegmentIndex >= boundaryMarkers_.size()) - DUNE_THROW(Dune::RangeError, "Boundary segment index "<< boundarySegmentIndex << " bigger than number of boundary segments in grid!"); - return boundaryMarkers_[boundarySegmentIndex]; - } - else - DUNE_THROW(Dune::InvalidStateException, "The getBoundaryDomainMarker method is only available if DomainMarkers for Gmsh were enabled!" - << " If your Gmsh file contains domain markers / physical entities," - << " enable them by setting 'Grid.DomainMarkers = true' in the input file."); - } - - /*! - * \brief Return the boundary domain marker (Gmsh physical entity number) of an intersection - Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. - * \param intersection The intersection to be evaluated - */ - static int getBoundaryDomainMarker(const Intersection& intersection) - { - if(enableGmshDomainMarkers_) - { - return boundaryMarkers_[intersection.boundarySegmentIndex()]; - } - else - DUNE_THROW(Dune::InvalidStateException, "The getBoundaryDomainMarker method is only available if DomainMarkers for Gmsh were enabled!" - << " If your Gmsh file contains domain markers / physical entities," - << " enable them by setting 'Grid.DomainMarkers = true' in the input file."); - } - - /*! - * \brief Return the element domain marker (Gmsh physical entity number) of an element. - Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. - * \param elementIdx The element index - */ - DUNE_DEPRECATED_MSG("This may produce wrong results if the grid implementation reorders the elements after insertion. Use getElementDomainMarker(element) instead!") - static int getElementDomainMarker(int elementIdx) - { - if(enableGmshDomainMarkers_) - { - if(elementIdx >= grid().levelGridView(0).size(0)) - DUNE_THROW(Dune::RangeError, "Requested element index is bigger than the number of level 0 elements!"); - return elementMarkers_[elementIdx]; - } - else - DUNE_THROW(Dune::InvalidStateException, "The getElementDomainMarker method is only available if DomainMarkers for Gmsh were enabled!" - << " If your Gmsh file contains domain markers / physical entities," - << " enable them by setting 'Grid.DomainMarkers = true' in the input file."); - } - - /*! - * \brief Return the element domain marker (Gmsh physical entity number) of an element. - Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. - * \param element The element to be evaluated - */ - static int getElementDomainMarker(const Element& element) - { - if(enableGmshDomainMarkers_) - { - // parameters are only given for level 0 elements - if (element.hasFather()) - { - auto level0element = element; - while(level0element.hasFather()) - level0element = level0element.father(); - - // in the parallel case the data is load balanced and then accessed with indices of the index set - if (grid().comm().size() > 1) - return elementMarkers_[gridPtr()->levelGridView(0).indexSet().index(level0element)]; - else - return elementMarkers_[gridFactory().insertionIndex(level0element)]; - } - else - { - // in the parallel case the data is load balanced and then accessed with indices of the index set - if (grid().comm().size() > 1) - return elementMarkers_[gridPtr()->levelGridView(0).indexSet().index(element)]; - else - return elementMarkers_[gridFactory().insertionIndex(element)]; - } - } - else - DUNE_THROW(Dune::InvalidStateException, "The getElementDomainMarker method is only available if DomainMarkers for Gmsh were enabled!" - << " If your Gmsh file contains domain markers / physical entities," - << " enable them by setting 'Grid.DomainMarkers = true' in the input file."); - } - /*! * \brief Call loadBalance() function of the grid. */ - static void loadBalance() + void loadBalance() { if (Dune::MPIHelper::getCollectiveCommunication().size() > 1) { @@ -309,72 +117,52 @@ public: if(enableDgfGridPointer_) { dgfGridPtr().loadBalance(); + // update the grid data + gridData_ = std::make_shared<GridData>(dgfGridPtr()); } + // if we have gmsh parameters we have to manually load balance the data else if (enableGmshDomainMarkers_) { - { - // element and face markers are communicated during load balance - GridDataHandle<std::shared_ptr<Grid>, GridCreatorBase<Grid>> dh(gridPtr()); - gridPtr()->loadBalance(dh.interface()); - gridPtr()->communicate(dh.interface(), Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); - } - - // transform face markers to boundary markers - boundaryMarkers_.resize(gridPtr()->numBoundarySegments(), 0); - const auto& indexSet = gridPtr()->leafGridView().indexSet(); - for (const auto& element : elements(gridPtr()->leafGridView())) - { - for (const auto& intersection : intersections(gridPtr()->leafGridView(), element)) - { - if (intersection.boundary()) - { - auto marker = faceMarkers_[indexSet.index(element.template subEntity<1>(intersection.indexInInside()))]; - boundaryMarkers_[intersection.boundarySegmentIndex()] = marker; - } - } - } + // element and face markers are communicated during load balance + auto dh = gridData_->createGmshDataHandle(); + gridPtr()->loadBalance(dh.interface()); + gridPtr()->communicate(dh.interface(), Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); } else gridPtr()->loadBalance(); } } + std::shared_ptr<GridData> getGridData() const + { + if (!enableDgfGridPointer_ && !enableGmshDomainMarkers_) + DUNE_THROW(Dune::IOError, "No grid data available"); + + return gridData_; + } + + protected: /*! * \brief Returns a reference to the grid pointer (std::shared_ptr<Grid>) */ - static std::shared_ptr<Grid> &gridPtr() + std::shared_ptr<Grid>& gridPtr() { if(!enableDgfGridPointer_) - { - static std::shared_ptr<Grid> gridPtr_; return gridPtr_; - } else DUNE_THROW(Dune::InvalidStateException, "You are using DGF. To get the grid pointer use method dgfGridPtr()!"); } - /*! - * \brief Returns a reference to the grid factory - */ - static Dune::GridFactory<Grid> &gridFactory() - { - static Dune::GridFactory<Grid> gridFactory_; - return gridFactory_; - } - /*! * \brief Returns a reference to the DGF grid pointer (Dune::GridPtr<Grid>). */ - static Dune::GridPtr<Grid> &dgfGridPtr() + Dune::GridPtr<Grid>& dgfGridPtr() { if(enableDgfGridPointer_) - { - static Dune::GridPtr<Grid> dgfGridPtr_; return dgfGridPtr_; - } else DUNE_THROW(Dune::InvalidStateException, "The DGF grid pointer is only available if the grid was constructed with a DGF file!"); } @@ -382,7 +170,7 @@ protected: /*! * \brief Returns the filename extension of a given filename */ - static std::string getFileExtension(const std::string& fileName) + std::string getFileExtension(const std::string& fileName) const { std::size_t i = fileName.rfind('.', fileName.length()); if (i != std::string::npos) @@ -399,21 +187,22 @@ protected: /*! * \brief Makes a grid from a file. We currently support *.dgf (Dune Grid Format) and *.msh (Gmsh mesh format). */ - static void makeGridFromFile(const std::string& fileName, - const std::string& modelParamGroup) + void makeGridFromFile(const std::string& fileName, + const std::string& modelParamGroup) { // We found a file in the input file...does it have a supported extension? const std::string extension = getFileExtension(fileName); - if(extension != "dgf" && extension != "msh") + if (extension != "dgf" && extension != "msh") DUNE_THROW(Dune::IOError, "Grid type " << Dune::className<Grid>() << " only supports DGF (*.dgf) and Gmsh (*.msh) grid files but the specified filename has extension: *."<< extension); // make the grid - if(extension == "dgf") + if (extension == "dgf") { enableDgfGridPointer_ = true; dgfGridPtr() = Dune::GridPtr<Grid>(fileName.c_str(), Dune::MPIHelper::getCommunicator()); + gridData_ = std::make_shared<GridData>(dgfGridPtr_); } - if(extension == "msh") + if (extension == "msh") { // get some optional parameters const bool verbose = getParamFromGroup<bool>(modelParamGroup, "Grid.Verbosity", false); @@ -426,13 +215,17 @@ protected: // as default read it on all processes in parallel if(domainMarkers) { - Dune::GmshReader<Grid>::read(gridFactory(), fileName, boundaryMarkers_, elementMarkers_, verbose, boundarySegments); - gridPtr() = std::shared_ptr<Grid>(gridFactory().createGrid()); + std::vector<int> boundaryMarkers, elementMarkers; + auto gridFactory = std::make_unique<Dune::GridFactory<Grid>>(); + Dune::GmshReader<Grid>::read(*gridFactory, fileName, boundaryMarkers, elementMarkers, verbose, boundarySegments); + gridPtr() = std::shared_ptr<Grid>(gridFactory->createGrid()); + gridData_ = std::make_shared<GridData>(gridPtr_, std::move(gridFactory), std::move(elementMarkers), std::move(boundaryMarkers)); } else { - Dune::GmshReader<Grid>::read(gridFactory(), fileName, verbose, boundarySegments); - gridPtr() = std::shared_ptr<Grid>(gridFactory().createGrid()); + auto gridFactory = std::make_unique<Dune::GridFactory<Grid>>(); + Dune::GmshReader<Grid>::read(*gridFactory, fileName, verbose, boundarySegments); + gridPtr() = std::shared_ptr<Grid>(gridFactory->createGrid()); } } } @@ -440,7 +233,7 @@ protected: /*! * \brief Makes a grid from a DGF file. This is used by grid managers that only support DGF. */ - static void makeGridFromDgfFile(const std::string& fileName) + void makeGridFromDgfFile(const std::string& fileName) { // We found a file in the input file...does it have a supported extension? const std::string extension = getFileExtension(fileName); @@ -460,8 +253,8 @@ protected: * \brief Makes a structured cube grid using the structured grid factory */ template <int dim, int dimworld> - static void makeStructuredGrid(CellType cellType, - const std::string& modelParamGroup) + void makeStructuredGrid(CellType cellType, + const std::string& modelParamGroup) { using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>; const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup, "Grid.UpperRight"); @@ -489,7 +282,7 @@ protected: /*! * \brief Refines a grid after construction if GridParameterGroup.Refinement is set in the input file */ - static void maybeRefineGrid(const std::string& modelParamGroup) + void maybeRefineGrid(const std::string& modelParamGroup) { if (haveParamInGroup(modelParamGroup, "Grid.Refinement")) grid().globalRefine(getParamFromGroup<int>(modelParamGroup, "Grid.Refinement")); @@ -499,86 +292,35 @@ protected: * \brief A state variable if the DGF Dune::GridPtr has been enabled. * It is always enabled if a DGF grid file was used to create the grid. */ - static bool enableDgfGridPointer_; + bool enableDgfGridPointer_ = false; /*! * \brief A state variable if domain markers have been read from a Gmsh file. */ - static bool enableGmshDomainMarkers_; - - /*! - * \brief Element and boundary domain markers obtained from Gmsh physical entities - * They map from element indices / boundary ids to the physical entity number - */ - static std::vector<int> elementMarkers_; - static std::vector<int> boundaryMarkers_; - static std::vector<int> faceMarkers_; -}; - -template <class Grid> -bool GridCreatorBase<Grid>::enableDgfGridPointer_ = false; - -template <class Grid> -bool GridCreatorBase<Grid>::enableGmshDomainMarkers_ = false; + bool enableGmshDomainMarkers_ = false; -template <class Grid> -std::vector<int> GridCreatorBase<Grid>::elementMarkers_; + std::shared_ptr<Grid> gridPtr_; + Dune::GridPtr<Grid> dgfGridPtr_; -template <class Grid> -std::vector<int> GridCreatorBase<Grid>::boundaryMarkers_; - -template <class Grid> -std::vector<int> GridCreatorBase<Grid>::faceMarkers_; - -/*! - * \brief Provides the grid creator implementation for all supported grid managers that constructs a grid - * from information in the input file. This class is specialised below for all - * supported grid managers. It inherits the functionality of the base class. - */ -template <class Grid, DiscretizationMethod discMethod> -class GridCreatorImpl : public GridCreatorBase<Grid> {}; + std::shared_ptr<GridData> gridData_; +}; /*! - * \brief Provides the grid creator (this is the class called by the user) for all supported grid managers that constructs a grid - * from information in the input file. This class is specialised below for all - * supported grid managers. It inherits the functionality of the base class. - * \todo TODO The grid creator is independent of TypeTag now, - * it would only need two template parameters, none of the functions use a TypeTag directly - * \todo This shouldn't depend on FVGridGeometry, think about how to remove discMethod here, too + * \brief The grid manager (this is the class used by the user) for all supported grid managers that constructs a grid + * from information in the input file and handles the data. + * \note This class is specialised below for all supported grid managers. It inherits the functionality of the base class. */ -template <class TypeTag> -using GridCreator = GridCreatorImpl<typename GET_PROP_TYPE(TypeTag, Grid), GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod>; +template <class Grid> +class GridManager +: public GridManagerBase<Grid> +{}; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Specializations ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*! - * \brief Helper class for determining the default overlap in case of parallel yasp grids - * \note the default of 1 works for all overlapping implementation like the cell-centered discretization schemes - */ -template <DiscretizationMethod discMethod> -struct YaspOverlapHelper -{ - static int getOverlap(const std::string& modelParamGroup) - { - int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1); - if (overlap < 1) - DUNE_THROW(Dune::InvalidStateException, "Parallel non-overlapping grids for cc discretization is not allowed."); - return overlap; - } -}; - -//! specialization for the box method -template <> -struct YaspOverlapHelper<DiscretizationMethod::box> -{ - static int getOverlap(const std::string& modelParamGroup) - { return 0; } -}; - -/*! - * \brief Provides a grid creator for YaspGrids + * \brief Provides a grid manager for YaspGrids * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -594,18 +336,18 @@ struct YaspOverlapHelper<DiscretizationMethod::box> * - Refinement : the number of global refines to apply initially. * */ -template<DiscretizationMethod discMethod, class ct, int dim> -class GridCreatorImpl<Dune::YaspGrid<dim, Dune::EquidistantCoordinates<ct, dim> >, discMethod> - : public GridCreatorBase<Dune::YaspGrid<dim, Dune::EquidistantCoordinates<ct, dim> > > +template<class ct, int dim> +class GridManager<Dune::YaspGrid<dim, Dune::EquidistantCoordinates<ct, dim> >> +: public GridManagerBase<Dune::YaspGrid<dim, Dune::EquidistantCoordinates<ct, dim> > > { public: using Grid = typename Dune::YaspGrid<dim, Dune::EquidistantCoordinates<ct, dim> >; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // First try to create it from a DGF file in GridParameterGroup.File if (haveParamInGroup(modelParamGroup, "Grid.File")) @@ -629,8 +371,8 @@ public: // periodic boundaries const auto periodic = getParamFromGroup<std::bitset<dim>>(modelParamGroup, "Grid.Periodic", std::bitset<dim>()); - // get the overlap dependent on the discretization method - const int overlap = YaspOverlapHelper<discMethod>::getOverlap(modelParamGroup); + // get the overlap + const int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1); // make the grid if (!haveParamInGroup(modelParamGroup, "Grid.Partitioning")) @@ -663,17 +405,18 @@ private: /*! * \brief Postprocessing for YaspGrid */ - static void postProcessing_(const std::string& modelParamGroup) + void postProcessing_(const std::string& modelParamGroup) { // Check if should refine the grid bool keepPhysicalOverlap = getParamFromGroup<bool>(modelParamGroup, "Grid.KeepPhysicalOverlap", true); ParentType::grid().refineOptions(keepPhysicalOverlap); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } }; /*! - * \brief Provides a grid creator for YaspGrids with non-zero offset + * \brief Provides a grid manager for YaspGrids with non-zero offset * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -689,18 +432,18 @@ private: * - Refinement : the number of global refines to apply initially. * */ -template<DiscretizationMethod discMethod, class ct, int dim> -class GridCreatorImpl<Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim> >, discMethod> - : public GridCreatorBase<Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim> > > +template<class ct, int dim> +class GridManager<Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim>>> +: public GridManagerBase<Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim>>> { public: - using Grid = typename Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim> >; - using ParentType = GridCreatorBase<Grid>; + using Grid = typename Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<ct, dim>>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // First try to create it from a DGF file in GridParameterGroup.File if (haveParamInGroup(modelParamGroup, "Grid.File")) @@ -725,7 +468,7 @@ public: const auto periodic = getParamFromGroup<std::bitset<dim>>(modelParamGroup, "Grid.Periodic", std::bitset<dim>()); // get the overlap dependent on some template parameters - const int overlap = YaspOverlapHelper<discMethod>::getOverlap(modelParamGroup); + const int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1); // make the grid if (!haveParamInGroup(modelParamGroup, "Grid.Partitioning")) @@ -758,17 +501,18 @@ private: /*! * \brief Postprocessing for YaspGrid */ - static void postProcessing_(const std::string& modelParamGroup) + void postProcessing_(const std::string& modelParamGroup) { // Check if should refine the grid const bool keepPhysicalOverlap = getParamFromGroup<bool>(modelParamGroup, "Grid.KeepPhysicalOverlap", true); ParentType::grid().refineOptions(keepPhysicalOverlap); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } }; /*! - * \brief Provides a grid creator for YaspGrids with different zones and grading + * \brief Provides a grid manager for YaspGrids with different zones and grading * * All keys are expected to be in group GridParameterGroup. * The following keys are recognized: @@ -795,18 +539,18 @@ private: * \f$ g = -\frac{1}{g_\textrm{negative}} \f$ * to avoid issues with imprecise fraction numbers. */ -template<DiscretizationMethod discMethod, class ctype, int dim> -class GridCreatorImpl<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> >, discMethod> - : public GridCreatorBase<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> > > +template<class ctype, int dim> +class GridManager<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> >> +: public GridManagerBase<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> > > { public: using Grid = typename Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> >; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // Only construction from the input file is possible // Look for the necessary keys to construct from the input file @@ -832,22 +576,22 @@ public: } // call the generic function - makeGrid(positions, cells, grading, modelParamGroup); + init(positions, cells, grading, modelParamGroup); } /*! * \brief Make the grid using input data not read from the input file. */ - static void makeGrid(const std::array<std::vector<ctype>, dim>& positions, - const std::array<std::vector<int>, dim>& cells, - const std::array<std::vector<ctype>, dim>& grading, - const std::string& modelParamGroup = "") + void init(const std::array<std::vector<ctype>, dim>& positions, + const std::array<std::vector<int>, dim>& cells, + const std::array<std::vector<ctype>, dim>& grading, + const std::string& modelParamGroup = "") { // Additional arameters (they have a default) const auto periodic = getParamFromGroup<std::bitset<dim>>(modelParamGroup, "Grid.Periodic", std::bitset<dim>()); - const int overlap = YaspOverlapHelper<discMethod>::getOverlap(modelParamGroup); + const int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1); const bool verbose = getParamFromGroup<bool>(modelParamGroup, "Grid.Verbosity", false); // Some sanity checks @@ -895,16 +639,17 @@ private: /*! * \brief Postprocessing for YaspGrid */ - static void postProcessing_(const std::string& modelParamGroup) + void postProcessing_(const std::string& modelParamGroup) { // Check if should refine the grid const bool keepPhysicalOverlap = getParamFromGroup<bool>(modelParamGroup, "Grid.KeepPhysicalOverlap", true); ParentType::grid().refineOptions(keepPhysicalOverlap); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } //! Compute the global position tensor grid from the given positions, cells, and grading factors - static std::array<std::vector<ctype>, dim> + std::array<std::vector<ctype>, dim> computeGlobalPositions_(const std::array<std::vector<ctype>, dim>& positions, const std::array<std::vector<int>, dim>& cells, const std::array<std::vector<ctype>, dim>& grading, @@ -1011,7 +756,7 @@ private: }; /*! - * \brief Provides a grid creator for OneDGrids + * \brief Provides a grid manager for OneDGrids * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -1023,18 +768,18 @@ private: * - Refinement : the number of global refines to apply initially. * */ -template<DiscretizationMethod discMethod> -class GridCreatorImpl<Dune::OneDGrid, discMethod> - : public GridCreatorBase<Dune::OneDGrid> +template<> +class GridManager<Dune::OneDGrid> +: public GridManagerBase<Dune::OneDGrid> { public: using Grid = Dune::OneDGrid; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // try to create it from a DGF or msh file in GridParameterGroup.File @@ -1079,15 +824,15 @@ public: } /*! - * \brief Overload load balance. Does nothing since OneDGrid is not parallel + * \brief Call loadBalance() function of the grid. OneDGrid is not parallel an thus cannot communicate. */ - static void loadBalance() {} + void loadBalance() {} private: /*! * \brief Do some operatrion after making the grid, like global refinement */ - static void postProcessing_(const std::string& modelParamGroup) + void postProcessing_(const std::string& modelParamGroup) { // Set refinement type const auto refType = getParamFromGroup<std::string>(modelParamGroup, "Grid.RefinementType", "Local"); @@ -1100,123 +845,14 @@ private: // Check if should refine the grid ParentType::maybeRefineGrid(modelParamGroup); + loadBalance(); } }; #if HAVE_UG -template<typename Grid> -class UGLoadBalance -{ - const static int dimension = Grid::dimension; - using ctype = typename Grid::ctype; - using GridView = typename Grid::LeafGridView; - using IdSet = typename Grid::LocalIdSet; - using Data = std::map<typename IdSet::IdType, int>; - - class LBDataHandle - : public Dune::CommDataHandleIF<LBDataHandle, - typename Data::mapped_type> - { - public: - typedef typename Data::mapped_type DataType; - - public: - - bool contains (int dim, int codim) const - { - assert(dim == dimension); - return codim == 0; - } - - bool fixedSize (int dim, int codim) const - { - assert(dim == dimension); - return true; - } - - template<class Entity> - size_t size (Entity& entity) const - { - return 1; - } - - template<class MessageBuffer, class Entity> - void gather (MessageBuffer& buff, const Entity& entity) const - { - const auto& id = idSet_.id(entity); - buff.write(data_.at(id)); - } - - template<class MessageBuffer, class Entity> - void scatter (MessageBuffer& buff, const Entity& entity, size_t) - { - const auto& id = idSet_.id(entity); - buff.read(data_[id]); - } - - LBDataHandle (const IdSet& idSet, Data& data) - : idSet_(idSet) - , data_(data) - {} - - private: - const IdSet& idSet_; - Data& data_; - }; - - static void fillDataFromMarkers(const GridView& gv, - Data& data, - const std::vector<int>& elementMarkers) - { - const auto& idSet = gv.grid().localIdSet(); - - for (const auto& element : elements(gv, Dune::Partitions::interiorBorder)) - { - const auto& id = idSet.id(element); - - data[id] = elementMarkers[gv.indexSet().index(element)]; - } - } - - static void retrieveMarkersFromData(const GridView& gv, - Data& data, - std::vector<int>& elementMarkers) - { - const auto& idSet = gv.grid().localIdSet(); - - elementMarkers.resize(gv.size(0), 0); - for (const auto& element : elements(gv, Dune::Partitions::interiorBorder)) - { - const auto& id = idSet.id(element); - - elementMarkers[gv.indexSet().index(element)] = data[id]; - } - } - -public: - static void balance(Grid& grid, std::vector<int>& elementMarkers) - { - const auto& gv = grid.leafGridView(); - - // define the map containing the data to be balanced - Data data; - - LBDataHandle dataHandle(grid.localIdSet(), data); - - // fill the data map - fillDataFromMarkers(gv, data, elementMarkers); - - // balance the grid and the data - grid.loadBalance(dataHandle); - - // fill the markers vector - retrieveMarkersFromData(gv, data, elementMarkers); - } -}; - /*! - * \brief Provides a grid creator for UGGrids + * \brief Provides a grid manager for UGGrids * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -1233,19 +869,19 @@ public: * - BoundarySegments : whether to insert boundary segments into the grid * */ -template<DiscretizationMethod discMethod, int dim> -class GridCreatorImpl<Dune::UGGrid<dim>, discMethod> - : public GridCreatorBase<Dune::UGGrid<dim> > +template<int dim> +class GridManager<Dune::UGGrid<dim>> +: public GridManagerBase<Dune::UGGrid<dim>> { public: using Grid = typename Dune::UGGrid<dim>; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; using Element = typename Grid::template Codim<0>::Entity; /*! * \brief Make the UGGrid. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // try to create it from a DGF or msh file in GridParameterGroup.File @@ -1290,57 +926,37 @@ public: * For gmsh grids the parameters are read on every process so we use too much memory but * the parameters are available via the insertionIndex of the level 0 element. */ - static void loadBalance() - { - // if we may have dgf parameters use load balancing of the dgf pointer - if(ParentType::enableDgfGridPointer_) - { - ParentType::dgfGridPtr().loadBalance(); - } - else if (ParentType::enableGmshDomainMarkers_) - { - UGLoadBalance<Grid>::balance(ParentType::grid(), ParentType::elementMarkers_); - } - else - { - ParentType::gridPtr()->loadBalance(); - } - } - - /*! - * \brief Return the element domain marker (Gmsh physical entity number) of an element. - Only available when using Gmsh with GridParameterGroup.DomainMarkers = 1. - * \param elementIdx The element index - */ - static int getElementDomainMarker(const Element& element) + void loadBalance() { - if(ParentType::enableGmshDomainMarkers_) + if (Dune::MPIHelper::getCollectiveCommunication().size() > 1) { - // parameters are only given for level 0 elements - if (element.hasFather()) + // if we may have dgf parameters use load balancing of the dgf pointer + if(ParentType::enableDgfGridPointer_) { - auto level0element = element; - while(level0element.hasFather()) - level0element = level0element.father(); - - return ParentType::elementMarkers_[ParentType::gridFactory().insertionIndex(level0element)]; + ParentType::dgfGridPtr().loadBalance(); + // update the grid data + ParentType::gridData_ = std::make_shared<typename ParentType::GridData>(ParentType::dgfGridPtr()); } - else + + // if we have gmsh parameters we have to manually load balance the data + else if (ParentType::enableGmshDomainMarkers_) { - return ParentType::elementMarkers_[ParentType::gridFactory().insertionIndex(element)]; + // element and face markers are communicated during load balance + auto dh = ParentType::gridData_->createGmshDataHandle(); + ParentType::gridPtr()->loadBalance(dh.interface()); + // Right now, UGGrid cannot communicate element data. If this gets implemented, communicate the data here: + // ParentType::gridPtr()->communicate(dh.interface(), Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); } + else + ParentType::gridPtr()->loadBalance(); } - else - DUNE_THROW(Dune::InvalidStateException, "The getElementDomainMarker method is only available if DomainMarkers for Gmsh were enabled!" - << " If your Gmsh file contains domain markers / physical entities," - << " enable them by setting 'Grid.DomainMarkers = true' in the input file."); } private: /*! * \brief Do some operations before making the grid */ - static void preProcessing_(const std::string& modelParamGroup) + void preProcessing_(const std::string& modelParamGroup) { if(haveParamInGroup(modelParamGroup, "Grid.HeapSize")) Grid::setDefaultHeapSize(getParamFromGroup<unsigned>(modelParamGroup, "Grid.HeapSize")); @@ -1349,7 +965,7 @@ private: /*! * \brief Do some operatrion after making the grid, like global refinement */ - static void postProcessing_(const std::string& modelParamGroup) + void postProcessing_(const std::string& modelParamGroup) { // Set refinement type const auto refType = getParamFromGroup<std::string>(modelParamGroup, "Grid.RefinementType", "Local"); @@ -1371,15 +987,17 @@ private: // Check if should refine the grid ParentType::maybeRefineGrid(modelParamGroup); + // do load balancing + loadBalance(); } }; #endif // HAVE_UG - +// #if HAVE_DUNE_ALUGRID /*! - * \brief Provides a grid creator for Dune ALUGrids + * \brief Provides a grid manager for Dune ALUGrids * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -1394,18 +1012,18 @@ private: * - BoundarySegments : whether to insert boundary segments into the grid * */ -template<DiscretizationMethod discMethod, int dim, int dimworld, Dune::ALUGridElementType elType, Dune::ALUGridRefinementType refinementType> -class GridCreatorImpl<Dune::ALUGrid<dim, dimworld, elType, refinementType>, discMethod> - : public GridCreatorBase<Dune::ALUGrid<dim, dimworld, elType, refinementType> > +template<int dim, int dimworld, Dune::ALUGridElementType elType, Dune::ALUGridRefinementType refinementType> +class GridManager<Dune::ALUGrid<dim, dimworld, elType, refinementType>> +: public GridManagerBase<Dune::ALUGrid<dim, dimworld, elType, refinementType>> { public: using Grid = Dune::ALUGrid<dim, dimworld, elType, refinementType>; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "", bool adaptiveRestart = false) + void init(const std::string& modelParamGroup = "", bool adaptiveRestart = false) { // restarting an adaptive grid using Dune's BackupRestoreFacility // TODO: the part after first || is backward compatibilty with old sequential models remove once sequential adpative restart is replaced @@ -1425,6 +1043,7 @@ public: oss << name << "_time=" << restartTime << "_rank=" << rank << ".grs"; std::cout << "Restoring an ALUGrid from " << oss.str() << std::endl; ParentType::gridPtr() = std::shared_ptr<Grid>(Dune::BackupRestoreFacility<Grid>::restore(oss.str())); + ParentType::loadBalance(); return; } @@ -1433,6 +1052,7 @@ public: { makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup, "Grid.File"), modelParamGroup); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); return; } @@ -1447,6 +1067,7 @@ public: else DUNE_THROW(Dune::IOError, "ALUGrid only supports Dune::cube or Dune::simplex as cell type!"); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } // Didn't find a way to construct the grid @@ -1463,8 +1084,8 @@ public: /*! * \brief Makes a grid from a file. We currently support *.dgf (Dune Grid Format) and *.msh (Gmsh mesh format). */ - static void makeGridFromFile(const std::string& fileName, - const std::string& modelParamGroup) + void makeGridFromFile(const std::string& fileName, + const std::string& modelParamGroup) { // We found a file in the input file...does it have a supported extension? const std::string extension = ParentType::getFileExtension(fileName); @@ -1472,12 +1093,13 @@ public: DUNE_THROW(Dune::IOError, "Grid type " << Dune::className<Grid>() << " only supports DGF (*.dgf) and Gmsh (*.msh) grid files but the specified filename has extension: *."<< extension); // make the grid - if(extension == "dgf") + if (extension == "dgf") { ParentType::enableDgfGridPointer_ = true; ParentType::dgfGridPtr() = Dune::GridPtr<Grid>(fileName.c_str(), Dune::MPIHelper::getCommunicator()); + ParentType::gridData_ = std::make_shared<typename ParentType::GridData>(ParentType::dgfGridPtr()); } - if(extension == "msh") + if (extension == "msh") { // get some optional parameters const bool verbose = getParamFromGroup<bool>(modelParamGroup, "Grid.Verbosity", false); @@ -1488,37 +1110,42 @@ public: ParentType::enableGmshDomainMarkers_ = true; // only filll the factory for rank 0 - if(domainMarkers) + if (domainMarkers) { - std::vector<int> boundaryMarkersInsertionIndex; + std::vector<int> boundaryMarkersInsertionIndex, boundaryMarkers, faceMarkers, elementMarkers; + auto gridFactory = std::make_unique<Dune::GridFactory<Grid>>(); if (Dune::MPIHelper::getCollectiveCommunication().rank() == 0) - Dune::GmshReader<Grid>::read(ParentType::gridFactory(), fileName, boundaryMarkersInsertionIndex, ParentType::elementMarkers_, verbose, boundarySegments); + Dune::GmshReader<Grid>::read(*gridFactory, fileName, boundaryMarkersInsertionIndex, elementMarkers, verbose, boundarySegments); - ParentType::gridPtr() = std::shared_ptr<Grid>(ParentType::gridFactory().createGrid()); + ParentType::gridPtr() = std::shared_ptr<Grid>(gridFactory->createGrid()); // reorder boundary markers according to boundarySegmentIndex - ParentType::boundaryMarkers_.resize(ParentType::gridPtr()->numBoundarySegments(), 0); - ParentType::faceMarkers_.resize(ParentType::gridPtr()->leafGridView().size(1), 0); + boundaryMarkers.resize(ParentType::gridPtr()->numBoundarySegments(), 0); + faceMarkers.resize(ParentType::gridPtr()->leafGridView().size(1), 0); const auto& indexSet = ParentType::gridPtr()->leafGridView().indexSet(); for (const auto& element : elements(ParentType::gridPtr()->leafGridView())) { for (const auto& intersection : intersections(ParentType::gridPtr()->leafGridView(), element)) { - if (intersection.boundary() && ParentType::gridFactory().wasInserted(intersection)) + if (intersection.boundary() && gridFactory->wasInserted(intersection)) { - auto marker = boundaryMarkersInsertionIndex[ParentType::gridFactory().insertionIndex(intersection)]; - ParentType::boundaryMarkers_[intersection.boundarySegmentIndex()] = marker; - ParentType::faceMarkers_[indexSet.index(element.template subEntity<1>(intersection.indexInInside()))] = marker; + auto marker = boundaryMarkersInsertionIndex[gridFactory->insertionIndex(intersection)]; + boundaryMarkers[intersection.boundarySegmentIndex()] = marker; + faceMarkers[indexSet.index(element.template subEntity<1>(intersection.indexInInside()))] = marker; } } } + + ParentType::gridData_ = std::make_shared<typename ParentType::GridData>(ParentType::gridPtr(), std::move(gridFactory), + std::move(elementMarkers), std::move(boundaryMarkers), std::move(faceMarkers)); } else { + auto gridFactory = std::make_unique<Dune::GridFactory<Grid>>(); if (Dune::MPIHelper::getCollectiveCommunication().rank() == 0) - Dune::GmshReader<Grid>::read(ParentType::gridFactory(), fileName, verbose, boundarySegments); + Dune::GmshReader<Grid>::read(*gridFactory, fileName, verbose, boundarySegments); - ParentType::gridPtr() = std::shared_ptr<Grid>(ParentType::gridFactory().createGrid()); + ParentType::gridPtr() = std::shared_ptr<Grid>(gridFactory->createGrid()); } } } @@ -1529,7 +1156,7 @@ public: #if HAVE_DUNE_FOAMGRID /*! - * \brief Provides a grid creator for FoamGrids + * \brief Provides a grid manager for FoamGrids * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -1542,24 +1169,25 @@ public: * - Cells : number of elements in a structured grid * */ -template<DiscretizationMethod discMethod, int dim, int dimworld> -class GridCreatorImpl<Dune::FoamGrid<dim, dimworld>, discMethod> - : public GridCreatorBase<Dune::FoamGrid<dim, dimworld> > +template<int dim, int dimworld> +class GridManager<Dune::FoamGrid<dim, dimworld>> +: public GridManagerBase<Dune::FoamGrid<dim, dimworld>> { public: using Grid = Dune::FoamGrid<dim, dimworld>; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // try to create it from file if (haveParamInGroup(modelParamGroup, "Grid.File")) { ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup, "Grid.File"), modelParamGroup); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); return; } @@ -1568,6 +1196,7 @@ public: { ParentType::template makeStructuredGrid<dim, dimworld>(ParentType::CellType::Simplex, modelParamGroup); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } // Didn't find a way to construct the grid @@ -1583,7 +1212,7 @@ public: }; /*! - * \brief Provides a grid creator for FoamGrids of dim 1 + * \brief Provides a grid manager for FoamGrids of dim 1 * from information in the input file * * All keys are expected to be in group GridParameterGroup. @@ -1596,24 +1225,25 @@ public: * - Cells : number of elements in a structured grid * */ -template<DiscretizationMethod discMethod, int dimworld> -class GridCreatorImpl<Dune::FoamGrid<1, dimworld>, discMethod> - : public GridCreatorBase<Dune::FoamGrid<1, dimworld> > +template<int dimworld> +class GridManager<Dune::FoamGrid<1, dimworld>> +: public GridManagerBase<Dune::FoamGrid<1, dimworld>> { public: using Grid = Dune::FoamGrid<1, dimworld>; - using ParentType = GridCreatorBase<Grid>; + using ParentType = GridManagerBase<Grid>; /*! * \brief Make the grid. This is implemented by specializations of this method. */ - static void makeGrid(const std::string& modelParamGroup = "") + void init(const std::string& modelParamGroup = "") { // try to create it from file if (haveParamInGroup(modelParamGroup, "Grid.File")) { ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup, "Grid.File"), modelParamGroup); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); return; } @@ -1644,11 +1274,12 @@ public: ParentType::gridPtr() = std::shared_ptr<Grid>(factory.createGrid()); ParentType::maybeRefineGrid(modelParamGroup); + ParentType::loadBalance(); } }; #endif // HAVE_DUNE_FOAMGRID -} // namespace Dumux +} // end namespace Dumux #endif diff --git a/dumux/io/subgridgridcreator.hh b/dumux/io/grid/subgridgridcreator.hh similarity index 100% rename from dumux/io/subgridgridcreator.hh rename to dumux/io/grid/subgridgridcreator.hh diff --git a/dumux/porousmediumflow/sequential/impetproblem.hh b/dumux/porousmediumflow/sequential/impetproblem.hh index 62a2fea7c4064ccbe386cae44c324bfb517c7ce1..9b2cf6dea9243e15866cdc42623e792edbfee497 100644 --- a/dumux/porousmediumflow/sequential/impetproblem.hh +++ b/dumux/porousmediumflow/sequential/impetproblem.hh @@ -85,7 +85,6 @@ private: using PrimaryVariables = typename SolutionTypes::PrimaryVariables; using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); //private!! copy constructor IMPETProblem(const IMPETProblem&) diff --git a/test/freeflow/navierstokes/angelitestproblem.hh b/test/freeflow/navierstokes/angelitestproblem.hh index 2febcd530f90c7488cd384bab764e6bbacac1293..fe3ef822123a369dd769c90a61545e3d507ecb87 100644 --- a/test/freeflow/navierstokes/angelitestproblem.hh +++ b/test/freeflow/navierstokes/angelitestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_ANGELI_TEST_PROBLEM_HH #define DUMUX_ANGELI_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/channeltestproblem.hh b/test/freeflow/navierstokes/channeltestproblem.hh index 2c45fdd6da28d27d932038532a564bf7d099bea5..cf323d7905dcdda0bb6185ad3b8dcfe39750f255 100644 --- a/test/freeflow/navierstokes/channeltestproblem.hh +++ b/test/freeflow/navierstokes/channeltestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_CHANNEL_TEST_PROBLEM_HH #define DUMUX_CHANNEL_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/simpleh2o.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/closedsystemtestproblem.hh b/test/freeflow/navierstokes/closedsystemtestproblem.hh index 0fa6beb09a481e5122ab5016eb935ba8d4b5b576..1030ac73c7cf222ba4861ff2619c6548671c21de 100644 --- a/test/freeflow/navierstokes/closedsystemtestproblem.hh +++ b/test/freeflow/navierstokes/closedsystemtestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_CLOSEDSYSTEM_TEST_PROBLEM_HH #define DUMUX_CLOSEDSYSTEM_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/doneatestproblem.hh b/test/freeflow/navierstokes/doneatestproblem.hh index 451a2ac32b98f53b008c2a622b34607a7d2f6fbd..74b67e2a6cb98b215f939a53b567c51b527543be 100644 --- a/test/freeflow/navierstokes/doneatestproblem.hh +++ b/test/freeflow/navierstokes/doneatestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_DONEA_TEST_PROBLEM_HH #define DUMUX_DONEA_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/kovasznaytestproblem.hh b/test/freeflow/navierstokes/kovasznaytestproblem.hh index 6bc2bfce6196faf81191c88d242011591fba0023..e56c8a48bcf08af80ba6114618a2a2a84f9279a4 100644 --- a/test/freeflow/navierstokes/kovasznaytestproblem.hh +++ b/test/freeflow/navierstokes/kovasznaytestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_KOVASZNAY_TEST_PROBLEM_HH #define DUMUX_KOVASZNAY_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/navierstokesanalyticproblem.hh b/test/freeflow/navierstokes/navierstokesanalyticproblem.hh index 23305e94665cda2bf0f01f38211771de5baf4519..38833db5d1f5872c0d83d4a28c09609a158e6a9c 100644 --- a/test/freeflow/navierstokes/navierstokesanalyticproblem.hh +++ b/test/freeflow/navierstokes/navierstokesanalyticproblem.hh @@ -26,6 +26,8 @@ #ifndef DUMUX_DONEA_TEST_PROBLEM_HH #define DUMUX_DONEA_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/constant.hh> #include <dumux/material/fluidsystems/1pliquid.hh> diff --git a/test/freeflow/navierstokes/stokeschannel3dproblem.hh b/test/freeflow/navierstokes/stokeschannel3dproblem.hh index b757d830a90254237b6f211ae8614a18b293bcbf..e82f8f0c31b156337dedf8cd88d36d311aa7aed6 100644 --- a/test/freeflow/navierstokes/stokeschannel3dproblem.hh +++ b/test/freeflow/navierstokes/stokeschannel3dproblem.hh @@ -28,6 +28,8 @@ #ifndef DUMUX_3D_CHANNEL_PROBLEM_HH #define DUMUX_3D_CHANNEL_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/freeflow/navierstokes/test_angeli.cc b/test/freeflow/navierstokes/test_angeli.cc index 8ced7b487033e8b2d1f36cfeedcfa8b1eb522a48..707536c3c401477a704222984ce6c156e1e490a5 100644 --- a/test/freeflow/navierstokes/test_angeli.cc +++ b/test/freeflow/navierstokes/test_angeli.cc @@ -50,6 +50,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -101,16 +102,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_channel.cc b/test/freeflow/navierstokes/test_channel.cc index 39f706fb94e597c27a4af5183fa9ac4651430342..6717818d7783e1c6ae5fd37fd7ecb6e5baed5056 100644 --- a/test/freeflow/navierstokes/test_channel.cc +++ b/test/freeflow/navierstokes/test_channel.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/freeflow/navierstokes/staggered/fluxoversurface.hh> @@ -102,16 +103,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_closedsystem.cc b/test/freeflow/navierstokes/test_closedsystem.cc index 0fdd3bd631a8a7648fe9a84599b46f2621a31d40..a29b3bb4765535292028f5966d4872ed2fa35ae8 100644 --- a/test/freeflow/navierstokes/test_closedsystem.cc +++ b/test/freeflow/navierstokes/test_closedsystem.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_donea.cc b/test/freeflow/navierstokes/test_donea.cc index 03f60731c4929c6492766f43737d59f6725b6f7f..7b168e83eeab8ee802aac745cde844231ad5be86 100644 --- a/test/freeflow/navierstokes/test_donea.cc +++ b/test/freeflow/navierstokes/test_donea.cc @@ -51,6 +51,9 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> + +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -102,16 +105,16 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + using GridManager = Dumux::GridManager<typename GET_PROP_TYPE(TypeTag, Grid)>; + GridManager gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_kovasznay.cc b/test/freeflow/navierstokes/test_kovasznay.cc index 019bd257e2b1b7b16f5572d80e0cfc827073d55a..95de8b519b92579692bd5255a7bc6137462f6730 100644 --- a/test/freeflow/navierstokes/test_kovasznay.cc +++ b/test/freeflow/navierstokes/test_kovasznay.cc @@ -50,6 +50,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -101,16 +102,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_navierstokes_1d.cc b/test/freeflow/navierstokes/test_navierstokes_1d.cc index 4d8c4598ea6f7bec49abb8153b098e27f709c9eb..91edf0498ffbccad51d6a875876aff0f5c70f2b2 100644 --- a/test/freeflow/navierstokes/test_navierstokes_1d.cc +++ b/test/freeflow/navierstokes/test_navierstokes_1d.cc @@ -43,6 +43,7 @@ #include <dumux/assembly/diffmethod.hh> #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/linear/seqsolverbackend.hh> #include <dumux/nonlinear/newtonsolver.hh> @@ -89,16 +90,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokes/test_stokes_channel_3d.cc b/test/freeflow/navierstokes/test_stokes_channel_3d.cc index bffaab16dac9f7384178ae88e1c7e042fc37540b..3d69225f2179f896fa7aa13c1c371adadb8489a7 100644 --- a/test/freeflow/navierstokes/test_stokes_channel_3d.cc +++ b/test/freeflow/navierstokes/test_stokes_channel_3d.cc @@ -43,6 +43,7 @@ #include <dumux/assembly/diffmethod.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/freeflow/navierstokes/staggered/fluxoversurface.hh> /*! @@ -95,16 +96,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokesnc/channeltestproblem.hh b/test/freeflow/navierstokesnc/channeltestproblem.hh index bd48143b6766ccc95d8417987414cc5ab97b25a8..dfce1847115370e8b346a30405ca746da29df86b 100644 --- a/test/freeflow/navierstokesnc/channeltestproblem.hh +++ b/test/freeflow/navierstokesnc/channeltestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_CHANNEL_NC_TEST_PROBLEM_HH #define DUMUX_CHANNEL_NC_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/simpleh2o.hh> #include <dumux/material/fluidsystems/h2oair.hh> diff --git a/test/freeflow/navierstokesnc/densityflowproblem.hh b/test/freeflow/navierstokesnc/densityflowproblem.hh index 38959ede9d2cbeee18a8885506bdc484c6f49f46..4e6141443681e87487d475aa5a56b8b743e84371 100644 --- a/test/freeflow/navierstokesnc/densityflowproblem.hh +++ b/test/freeflow/navierstokesnc/densityflowproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_DENSITY_FLOW_NC_TEST_PROBLEM_HH #define DUMUX_DENSITY_FLOW_NC_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/simpleh2o.hh> #include <dumux/material/fluidsystems/h2oair.hh> diff --git a/test/freeflow/navierstokesnc/msfreeflowtestproblem.hh b/test/freeflow/navierstokesnc/msfreeflowtestproblem.hh index 93978c823046c1c418659ce24736012cff6148a1..4920d19494a1b0f3834aa946b5102f1e489b8a30 100644 --- a/test/freeflow/navierstokesnc/msfreeflowtestproblem.hh +++ b/test/freeflow/navierstokesnc/msfreeflowtestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_CHANNEL_MAXWELL_STEFAN_TEST_PROBLEM_HH #define DUMUX_CHANNEL_MAXWELL_STEFAN_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/freeflow/compositional/navierstokesncmodel.hh> #include <dumux/freeflow/navierstokes/problem.hh> diff --git a/test/freeflow/navierstokesnc/test_channel.cc b/test/freeflow/navierstokesnc/test_channel.cc index 9198f5df82b599af9b7837ac1db0b8f30518ae17..066444114b30b2f2c522f9fb6a3349d62446ff9d 100644 --- a/test/freeflow/navierstokesnc/test_channel.cc +++ b/test/freeflow/navierstokesnc/test_channel.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokesnc/test_densitydrivenflow.cc b/test/freeflow/navierstokesnc/test_densitydrivenflow.cc index 614df58447027d2ccc0522e1f458c7d88acd1792..25fd54d6f6173c2feb0e229b8b0a37154c8d6883 100644 --- a/test/freeflow/navierstokesnc/test_densitydrivenflow.cc +++ b/test/freeflow/navierstokesnc/test_densitydrivenflow.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/navierstokesnc/test_msfreeflow.cc b/test/freeflow/navierstokesnc/test_msfreeflow.cc index 88c23a75a6304f3901075b590db2183b2cb2b2cc..d19b6e6960d66c0b30572e9104256c068decd14a 100644 --- a/test/freeflow/navierstokesnc/test_msfreeflow.cc +++ b/test/freeflow/navierstokesnc/test_msfreeflow.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/rans/pipelauferproblem.hh b/test/freeflow/rans/pipelauferproblem.hh index d69ba41ddc91e8ba33077e13d7cd228d9b991b73..379b9139c3b2b4c5deccd7a1345ee36395ba983a 100644 --- a/test/freeflow/rans/pipelauferproblem.hh +++ b/test/freeflow/rans/pipelauferproblem.hh @@ -27,6 +27,8 @@ #ifndef DUMUX_PIPE_LAUFER_PROBLEM_HH #define DUMUX_PIPE_LAUFER_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/staggered/freeflow/properties.hh> #include <dumux/freeflow/turbulenceproperties.hh> #include <dumux/material/fluidsystems/1pgas.hh> diff --git a/test/freeflow/rans/test_pipe_laufer.cc b/test/freeflow/rans/test_pipe_laufer.cc index 62e9d82f500fd18891a1cc1c09b37455734d157c..56825467c7e8514814d19b9ea85bee7539586b4d 100644 --- a/test/freeflow/rans/test_pipe_laufer.cc +++ b/test/freeflow/rans/test_pipe_laufer.cc @@ -53,6 +53,7 @@ #include <dumux/io/gnuplotinterface.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/freeflow/ransnc/flatplatetestproblem.hh b/test/freeflow/ransnc/flatplatetestproblem.hh index e51fec4c7bb618ac8e50cbc71e025ee7eeabba1b..c0111ec6b4cb4584cc4aa54aff130bb6bbd0b439 100644 --- a/test/freeflow/ransnc/flatplatetestproblem.hh +++ b/test/freeflow/ransnc/flatplatetestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_RANS_NC_TEST_PROBLEM_HH #define DUMUX_RANS_NC_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/staggered/freeflow/properties.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/freeflow/turbulenceproperties.hh> diff --git a/test/freeflow/ransnc/test_flatplate.cc b/test/freeflow/ransnc/test_flatplate.cc index 2c8475437366dfe733a87add53f573df536bd60e..2767ea5126481b716f900684206053fca418bcbe 100644 --- a/test/freeflow/ransnc/test_flatplate.cc +++ b/test/freeflow/ransnc/test_flatplate.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/staggeredvtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -89,16 +90,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/geomechanics/elastic/problem.hh b/test/geomechanics/elastic/problem.hh index b7fab27f9bbb99b286e07d182b903665e581bf92..9762336500325cafcaa8139463a4420475def5b0 100644 --- a/test/geomechanics/elastic/problem.hh +++ b/test/geomechanics/elastic/problem.hh @@ -24,6 +24,7 @@ #define DUMUX_ELASTICPROBLEM_HH #include <dune/common/fmatrix.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/geomechanics/elastic/model.hh> diff --git a/test/geomechanics/elastic/test_elastic.cc b/test/geomechanics/elastic/test_elastic.cc index 005a0682eca9b145d91e60ce274f1a6787f03cac..74ae58761f9f7d6673e9d59a31ce28da934f7d14 100644 --- a/test/geomechanics/elastic/test_elastic.cc +++ b/test/geomechanics/elastic/test_elastic.cc @@ -47,6 +47,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // main function int main(int argc, char** argv) try @@ -70,16 +71,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/geomechanics/poroelastic/problem.hh b/test/geomechanics/poroelastic/problem.hh index 887e4313ef703c42220ffd0ec2ff9b0041f64860..fc675b5db9f961f62b18d63c4cbc3fda0ec258c3 100644 --- a/test/geomechanics/poroelastic/problem.hh +++ b/test/geomechanics/poroelastic/problem.hh @@ -24,6 +24,7 @@ #define DUMUX_POROELASTIC_PROBLEM_HH #include <dune/common/fmatrix.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/geomechanics/poroelastic/model.hh> diff --git a/test/geomechanics/poroelastic/test_poroelastic.cc b/test/geomechanics/poroelastic/test_poroelastic.cc index dba038fe79d08e4335790a5630071d8c2405989c..2f82bd8f59f9b90ded277a989fdc78ec2b2234f0 100644 --- a/test/geomechanics/poroelastic/test_poroelastic.cc +++ b/test/geomechanics/poroelastic/test_poroelastic.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // function to evaluate the element stresses template< class StressType, @@ -113,16 +114,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/io/gridcreator/gridcreatortests.hh b/test/io/gridcreator/gridmanagertests.hh similarity index 74% rename from test/io/gridcreator/gridcreatortests.hh rename to test/io/gridcreator/gridmanagertests.hh index 8db38bfbc999f15eb892b9b6c67a03c0780c3231..2cf7aad31522b4c9d7b1aec4c608c4f327f325fb 100644 --- a/test/io/gridcreator/gridcreatortests.hh +++ b/test/io/gridcreator/gridmanagertests.hh @@ -21,8 +21,8 @@ * \note This can/should be extended */ -#ifndef DUMUX_GRIDCREATOR_TESTS_HH -#define DUMUX_GRIDCREATOR_TESTS_HH +#ifndef DUMUX_TEST_IO_GRIDMANAGER_TESTS_HH +#define DUMUX_TEST_IO_GRIDMANAGER_TESTS_HH #include <dune/common/version.hh> #include <dune/geometry/referenceelements.hh> @@ -30,7 +30,7 @@ #include <dune/grid/common/mcmgmapper.hh> #include <dune/grid/io/file/vtk.hh> -#include <dumux/io/gridcreator.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/discretization/methods.hh> namespace Dumux { @@ -100,12 +100,12 @@ private: }; template<class Grid> -class GridCreatorTests +class GridManagerTests { using GridView = typename Grid::LeafGridView; using Scalar = double; static const int dim = Grid::dimension; - using GridCreator = typename Dumux::GridCreatorImpl<Grid, DiscretizationMethod::none>; + using GridManager = typename Dumux::GridManager<Grid>; using ReferenceElements = typename Dune::ReferenceElements<Scalar, dim>; public: @@ -114,17 +114,20 @@ public: const std::string& vtkFileName = "test", bool refine = true) { - // initialize the grid - initialize_(); + // make the grid manager and initialize the grid + GridManager gridManager; + gridManager.init(); + auto gridData = gridManager.getGridData(); + const auto& leafGridView = gridManager.grid().leafGridView(); // read the boundary and element markers as well as the rank std::vector<int> boundaryMarker, elementMarker, rank; - getBoundaryMarkers_(boundaryMarker); - getElementMarkers_(elementMarker, type); - getRank_(rank); + getBoundaryMarkers_(leafGridView, gridData, boundaryMarker); + getElementMarkers_(leafGridView, gridData, elementMarker, type); + getRank_(leafGridView, rank); // construct a vtk output writer and attach the boundary markers - Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(GridCreator::grid().leafGridView(), vtkFileName, ".", ""); + Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(leafGridView, vtkFileName, ".", ""); vtkWriter.addVertexData(boundaryMarker, "boundaryMarker"); vtkWriter.addCellData(elementMarker, "elementMarker"); vtkWriter.addCellData(rank, "rank"); @@ -133,10 +136,10 @@ public: if (refine) { // refine grid once and write out the markers again - GridCreator::grid().globalRefine(1); - getBoundaryMarkers_(boundaryMarker); - getElementMarkers_(elementMarker, type); - getRank_(rank); + gridManager.grid().globalRefine(1); + getBoundaryMarkers_(leafGridView, gridData, boundaryMarker); + getElementMarkers_(leafGridView, gridData, elementMarker, type); + getRank_(leafGridView, rank); vtkWriter.write(1); } } @@ -145,16 +148,18 @@ public: const std::string& vtkFileName = "test", bool refine = true) { - // initialize the grid - initialize_(); + // make the grid manager and initialize the grid + GridManager gridManager; + gridManager.init(); + auto gridData = gridManager.getGridData(); // read the element markers and the rank std::vector<int> elementMarker, rank; - getElementMarkers_(elementMarker, type); - getRank_(rank); + getElementMarkers_(gridManager.grid().leafGridView(), gridData, elementMarker, type); + getRank_(gridManager.grid().leafGridView(), rank); // construct a vtk output writer and attach the element markers - Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(GridCreator::grid().leafGridView(), vtkFileName, ".", ""); + Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(gridManager.grid().leafGridView(), vtkFileName, ".", ""); vtkWriter.addCellData(elementMarker, "elementMarker"); vtkWriter.addCellData(rank, "rank"); vtkWriter.write(0); @@ -162,19 +167,17 @@ public: if (refine) { // refine grid once and write out the markers again - GridCreator::grid().globalRefine(1); - getElementMarkers_(elementMarker, type); - getRank_(rank); + gridManager.grid().globalRefine(1); + getElementMarkers_(gridManager.grid().leafGridView(), gridData, elementMarker, type); + getRank_(gridManager.grid().leafGridView(), rank); vtkWriter.write(1); } } private: - static void getRank_(std::vector<int>& rank) + static void getRank_(const GridView& gridView, std::vector<int>& rank) { - const auto& gridView = GridCreator::grid().leafGridView(); - rank.clear(); rank.resize(gridView.size(0)); @@ -185,31 +188,32 @@ private: } } - static void getElementMarkers_(std::vector<int>& elementMarker, + template<class GridData> + static void getElementMarkers_(const GridView& gridView, + const GridData& gridData, + std::vector<int>& elementMarker, const std::string& type) { - const auto& gridView = GridCreator::grid().leafGridView(); - elementMarker.clear(); elementMarker.resize(gridView.size(0)); for(const auto& element : elements(gridView)) { - auto eIdx = gridView.indexSet().index(element); - + const auto eIdx = gridView.indexSet().index(element); if (type == "gmsh") - elementMarker[eIdx] = GridCreator::getElementDomainMarker(element); + elementMarker[eIdx] = gridData->getElementDomainMarker(element); else if (type == "dgf") - elementMarker[eIdx] = GridCreator::parameters(element)[0]; + elementMarker[eIdx] = gridData->parameters(element)[0]; else DUNE_THROW(Dune::InvalidStateException, "No parameters for type " << type); } } - static void getBoundaryMarkers_(std::vector<int>& boundaryMarker) + template<class GridData> + static void getBoundaryMarkers_(const GridView& gridView, + const GridData& gridData, + std::vector<int>& boundaryMarker) { - const auto& gridView = GridCreator::grid().leafGridView(); - boundaryMarker.clear(); boundaryMarker.resize(gridView.size(dim), 0); @@ -217,7 +221,7 @@ private: { for(const auto& intersection : intersections(gridView, element)) { - if(!intersection.boundary()) + if (!intersection.boundary()) continue; const auto refElement = ReferenceElements::general(element.geometry().type()); @@ -231,11 +235,11 @@ private: // make sure we always take the lowest non-zero marker (problem dependent!) if (boundaryMarker[vIdxGlobal] == 0) - boundaryMarker[vIdxGlobal] = GridCreator::getBoundaryDomainMarker(intersection); + boundaryMarker[vIdxGlobal] = gridData->getBoundaryDomainMarker(intersection); else { - if (boundaryMarker[vIdxGlobal] > GridCreator::getBoundaryDomainMarker(intersection)) - boundaryMarker[vIdxGlobal] = GridCreator::getBoundaryDomainMarker(intersection); + if (boundaryMarker[vIdxGlobal] > gridData->getBoundaryDomainMarker(intersection)) + boundaryMarker[vIdxGlobal] = gridData->getBoundaryDomainMarker(intersection); } } } @@ -253,15 +257,6 @@ private: Dune::ForwardCommunication); } } - - static void initialize_() - { - // Make the grid - GridCreator::makeGrid(); - - // Load balancing if parallel - GridCreator::loadBalance(); - } }; } // end namespace Dumux diff --git a/test/io/gridcreator/test_gridcreator_cake.cc b/test/io/gridcreator/test_gridcreator_cake.cc index 41ef55e5e6c6eca4fcca815639b554a24ba2e4bf..7ecfee27bfb42f599de17a91b0f0179a4108d34d 100644 --- a/test/io/gridcreator/test_gridcreator_cake.cc +++ b/test/io/gridcreator/test_gridcreator_cake.cc @@ -26,7 +26,8 @@ #include <dune/grid/io/file/vtk.hh> #include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> -#include <dumux/io/cakegridcreator.hh> +#include <dumux/io/grid/gridmanager.hh> +#include <dumux/io/grid/cakegridcreator.hh> #if HAVE_UG #include <dune/grid/uggrid.hh> @@ -59,18 +60,19 @@ int main(int argc, char** argv) try // using declarations using TypeTag = TTAG(GridCreatorCakeTest); using Grid = typename GET_PROP_TYPE(TypeTag, Grid); - using GridCreator = typename Dumux::CakeGridCreator<Grid>; + using GridManager = typename Dumux::CakeGridCreator<Grid>; + GridManager gridManager; // 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 " + gridManager.init(); + std::cout << "Constructing cake grid with " << gridManager.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()); + Dune::VTKWriter<Grid::LeafGridView> vtkWriter(gridManager.grid().leafGridView()); vtkWriter.write("cake-00000"); return 0; diff --git a/test/io/gridcreator/test_gridcreator_dgf_e_markers.cc b/test/io/gridcreator/test_gridcreator_dgf_e_markers.cc index e1e9ada10e8af29f085dc216bc858ea0989b070a..3f5b245a15a62e4d96904384c41bf8a255a8c0ed 100644 --- a/test/io/gridcreator/test_gridcreator_dgf_e_markers.cc +++ b/test/io/gridcreator/test_gridcreator_dgf_e_markers.cc @@ -25,7 +25,7 @@ #include <dune/common/parallel/mpihelper.hh> #include <dumux/common/parameters.hh> -#include "gridcreatortests.hh" +#include "gridmanagertests.hh" int main(int argc, char** argv) try { @@ -34,7 +34,7 @@ int main(int argc, char** argv) try Dumux::Parameters::init(argc, argv, "test_gridcreator_dgf_e_markers.input"); auto name = Dumux::getParam<std::string>("Problem.Name"); - Dumux::GridCreatorTests<GRIDTYPE>::testElementMarkers("dgf", name); + Dumux::GridManagerTests<GRIDTYPE>::testElementMarkers("dgf", name); return 0; } diff --git a/test/io/gridcreator/test_gridcreator_gmsh_3d.cc b/test/io/gridcreator/test_gridcreator_gmsh_3d.cc index 9d2eb30e257c4bdc8f9b28ae714a535c3c456638..2ae6aadf1f166003b2bae9b3bf3227c5ce7ed50a 100644 --- a/test/io/gridcreator/test_gridcreator_gmsh_3d.cc +++ b/test/io/gridcreator/test_gridcreator_gmsh_3d.cc @@ -25,7 +25,7 @@ #include <dune/common/parallel/mpihelper.hh> #include <dumux/common/parameters.hh> -#include "gridcreatortests.hh" +#include "gridmanagertests.hh" int main(int argc, char** argv) try { @@ -35,7 +35,7 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, "test_gridcreator_gmsh_3d.input"); const auto name = getParam<std::string>("Problem.Name"); const auto refine = Dumux::getParam<bool>("Grid.Refine", true); - GridCreatorTests<GRIDTYPE>::testBoundaryAndElementMarkers("gmsh", name, refine); + GridManagerTests<GRIDTYPE>::testBoundaryAndElementMarkers("gmsh", name, refine); return 0; } diff --git a/test/io/gridcreator/test_gridcreator_gmsh_e_markers.cc b/test/io/gridcreator/test_gridcreator_gmsh_e_markers.cc index f39dd3d6e95d5ca7bb70b1b875ad1a5c28e60993..47dfb3ebcf3fc88d63be4d6e055d34d5f6a2339a 100644 --- a/test/io/gridcreator/test_gridcreator_gmsh_e_markers.cc +++ b/test/io/gridcreator/test_gridcreator_gmsh_e_markers.cc @@ -25,7 +25,7 @@ #include <dune/common/parallel/mpihelper.hh> #include <dumux/common/parameters.hh> -#include "gridcreatortests.hh" +#include "gridmanagertests.hh" int main(int argc, char** argv) try { @@ -34,7 +34,7 @@ int main(int argc, char** argv) try Dumux::Parameters::init(argc, argv, "test_gridcreator_gmsh_e_markers.input"); auto name = Dumux::getParam<std::string>("Problem.Name"); - Dumux::GridCreatorTests<GRIDTYPE>::testElementMarkers("gmsh", name); + Dumux::GridManagerTests<GRIDTYPE>::testElementMarkers("gmsh", name); return 0; } diff --git a/test/io/gridcreator/test_gridcreator_subgrid.cc b/test/io/gridcreator/test_gridcreator_subgrid.cc index 61dfc31f5b9c6516281fd816ab095ebff76560f3..370c2f82cddcc07e83bb0c172ec18b83fbf174ef 100644 --- a/test/io/gridcreator/test_gridcreator_subgrid.cc +++ b/test/io/gridcreator/test_gridcreator_subgrid.cc @@ -25,10 +25,11 @@ #include <dune/common/fvector.hh> #include <dune/common/timer.hh> #include <dune/grid/io/file/vtk.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/common/parameters.hh> -#include <dumux/io/gridcreator.hh> -#include <dumux/io/subgridgridcreator.hh> +#include <dumux/io/grid/gridmanager.hh> +#include <dumux/io/grid/subgridgridcreator.hh> #include <dumux/discretization/methods.hh> /*! @@ -67,13 +68,16 @@ int main(int argc, char** argv) try Dune::Timer timer; using HostGrid = Dune::YaspGrid<dim, Dune::TensorProductCoordinates<double, dim> >; - using HostGridCreator = GridCreatorImpl<HostGrid, DiscretizationMethod::none>; - HostGridCreator::makeGrid(); + + using HostGridManager = Dumux::GridManager<HostGrid>; + HostGridManager hostGridManager; + hostGridManager.init(); + auto& hostGrid = hostGridManager.grid(); // Calculate the bounding box of the host grid view. GlobalPosition bBoxMin(std::numeric_limits<double>::max()); GlobalPosition bBoxMax(std::numeric_limits<double>::min()); - for (const auto& vertex : vertices(HostGridCreator::grid().leafGridView())) + for (const auto& vertex : vertices(hostGrid.leafGridView())) { for (int i=0; i<dim; i++) { @@ -105,14 +109,14 @@ int main(int argc, char** argv) try CircleSelector<GlobalPosition> elementSelectorThree(center); // Create three different subgrids from the same hostgrid. - auto subgridPtrOne = SubgridGridCreator<HostGrid>::makeGrid(HostGridCreator::grid(), elementSelectorOne, "SubGridOne"); - auto subgridPtrTwo = SubgridGridCreator<HostGrid>::makeGrid(HostGridCreator::grid(), elementSelectorTwo, "SubGridTwo"); - auto subgridPtrThree = SubgridGridCreator<HostGrid>::makeGrid(HostGridCreator::grid(), elementSelectorThree, "SubGridThree"); + auto subgridPtrOne = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorOne, "SubGridOne"); + auto subgridPtrTwo = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorTwo, "SubGridTwo"); + auto subgridPtrThree = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorThree, "SubGridThree"); std::cout << "Constructing a host grid and three subgrids took " << timer.elapsed() << " seconds.\n"; // Write out the host grid and the subgrids. - Dune::VTKWriter<HostGrid::LeafGridView> vtkWriter(HostGridCreator::grid().leafGridView()); + Dune::VTKWriter<HostGrid::LeafGridView> vtkWriter(hostGrid.leafGridView()); vtkWriter.write("hostgrid"); return 0; diff --git a/test/porousmediumflow/1p/implicit/1pniconductionproblem.hh b/test/porousmediumflow/1p/implicit/1pniconductionproblem.hh index 193d3c7c89ca4307e494d64cd2e95e68a3bac73f..3ba1bdd20804e3683859b522075c060fa888abbe 100644 --- a/test/porousmediumflow/1p/implicit/1pniconductionproblem.hh +++ b/test/porousmediumflow/1p/implicit/1pniconductionproblem.hh @@ -25,7 +25,8 @@ #ifndef DUMUX_1PNI_CONDUCTION_PROBLEM_HH #define DUMUX_1PNI_CONDUCTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/1p/implicit/1pniconvectionproblem.hh b/test/porousmediumflow/1p/implicit/1pniconvectionproblem.hh index 9d0aca9b4aae11bc8e0ed2fae8b08aed953fb6f4..af9064770c4c1d0a2f14e81ac35fc7ec1d1c700b 100644 --- a/test/porousmediumflow/1p/implicit/1pniconvectionproblem.hh +++ b/test/porousmediumflow/1p/implicit/1pniconvectionproblem.hh @@ -26,7 +26,8 @@ #ifndef DUMUX_1PNI_CONVECTION_PROBLEM_HH #define DUMUX_1PNI_CONVECTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/1p/implicit/1ptestproblem.hh b/test/porousmediumflow/1p/implicit/1ptestproblem.hh index 7165e9d4a398e74224bbdc39785fb99ce1e837cc..d33123e9de38042d82b262080071de40d6c78725 100644 --- a/test/porousmediumflow/1p/implicit/1ptestproblem.hh +++ b/test/porousmediumflow/1p/implicit/1ptestproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_1PTEST_PROBLEM_HH #define DUMUX_1PTEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/1p/implicit/compressible/problem.hh b/test/porousmediumflow/1p/implicit/compressible/problem.hh index 57cb404c286fb803643a1962c231ea25f2c1a8e6..f0d4bc70bc6f68ab9c5757d886b659536f97b5f6 100644 --- a/test/porousmediumflow/1p/implicit/compressible/problem.hh +++ b/test/porousmediumflow/1p/implicit/compressible/problem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/h2o.hh> #include <dumux/material/components/tabulatedcomponent.hh> #include <dumux/material/fluidsystems/1pliquid.hh> diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p.cc b/test/porousmediumflow/1p/implicit/compressible/test_1p.cc index 0681e6b11993174f06fbe0de52d61b06ecc6a40c..1408949eadbefca13c79e8923ce7f02f46415b4f 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p.cc +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p.cc @@ -47,6 +47,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> int main(int argc, char** argv) try { @@ -72,16 +73,15 @@ int main(int argc, char** argv) try // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc index 61a955a939b6bbd8df9013b8e1ada7eb6837ac69..723cf74e240e32ac6a4fd7f77d7a3eb0545b3f54 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc @@ -45,6 +45,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> int main(int argc, char** argv) try { @@ -70,16 +71,15 @@ int main(int argc, char** argv) try // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/incompressible/problem.hh b/test/porousmediumflow/1p/implicit/incompressible/problem.hh index f7d379dc559ff4cd2e00900ba744275fdefa8349..0d7ae66f7706c91bb2b504a46302f512a68768c0 100644 --- a/test/porousmediumflow/1p/implicit/incompressible/problem.hh +++ b/test/porousmediumflow/1p/implicit/incompressible/problem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc b/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc index 35eaadff20c7091c66f78d5df38238d1ee9610e1..2754ab3a4d0a16cf4866b67ba4f4c804b4168a75 100644 --- a/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc +++ b/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc @@ -42,6 +42,9 @@ #include <dumux/common/dumuxmessage.hh> #include <dumux/common/defaultusagemessage.hh> +#include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> + #include <dumux/assembly/fvassembler.hh> #include "problem.hh" @@ -70,12 +73,11 @@ int main(int argc, char** argv) try // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/pointsources/1psingularityproblem.hh b/test/porousmediumflow/1p/implicit/pointsources/1psingularityproblem.hh index a52d270b454808251497bb0261d1695900349636..e77b07c1fc20afd1757d854b08f18d405f768428 100644 --- a/test/porousmediumflow/1p/implicit/pointsources/1psingularityproblem.hh +++ b/test/porousmediumflow/1p/implicit/pointsources/1psingularityproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_1P_SINGULARITY_PROBLEM_HH #define DUMUX_1P_SINGULARITY_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/1p/model.hh> diff --git a/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources.cc b/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources.cc index 92abc5b34e108093d2e5e708dc9aefe59d1791fb..75f38d634207ae54059ceec9a5fc83b9960200ab 100644 --- a/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources.cc +++ b/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> int main(int argc, char** argv) try { @@ -68,16 +69,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources_timedependent.cc b/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources_timedependent.cc index f0fbf2fe90b19ae767f1c45f5d39728762de4da7..7603390e6b6da23fb847a789a9cbfca25a52e8f5 100644 --- a/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources_timedependent.cc +++ b/test/porousmediumflow/1p/implicit/pointsources/test_1pfv_pointsources_timedependent.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> int main(int argc, char** argv) try { @@ -68,16 +69,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/test_1pfv.cc b/test/porousmediumflow/1p/implicit/test_1pfv.cc index 20b487087d3487e380ae631a3caf3c199d9119b4..f021f8408ddfa8798e6a34dc9d4d63103f937c3e 100644 --- a/test/porousmediumflow/1p/implicit/test_1pfv.cc +++ b/test/porousmediumflow/1p/implicit/test_1pfv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -99,16 +100,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/test_1pfv_fracture2d3d.cc b/test/porousmediumflow/1p/implicit/test_1pfv_fracture2d3d.cc index 661a2eacd5451bde016255477413c9f10318e14b..65a1a9c23b560f61b5db0c87501891f44b1a0493 100644 --- a/test/porousmediumflow/1p/implicit/test_1pfv_fracture2d3d.cc +++ b/test/porousmediumflow/1p/implicit/test_1pfv_fracture2d3d.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/test_1pfv_network1d3d.cc b/test/porousmediumflow/1p/implicit/test_1pfv_network1d3d.cc index 8002c628157d72f13e7f9e306b962a84ddbc5497..edd24f310b7c7de23f3f420901527095796509bd 100644 --- a/test/porousmediumflow/1p/implicit/test_1pfv_network1d3d.cc +++ b/test/porousmediumflow/1p/implicit/test_1pfv_network1d3d.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/implicit/test_1pnifv.cc b/test/porousmediumflow/1p/implicit/test_1pnifv.cc index 936c8e7dd64e46fbfeb17e72484e7fb5c73be1a7..cceb83f2ad4a5632713bb381d108e42cb6ee606e 100644 --- a/test/porousmediumflow/1p/implicit/test_1pnifv.cc +++ b/test/porousmediumflow/1p/implicit/test_1pnifv.cc @@ -50,6 +50,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -95,16 +96,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1p/sequential/test_1pproblem.hh b/test/porousmediumflow/1p/sequential/test_1pproblem.hh index cdc0c03c2d6dcbf8e56cc852bfbd6f9cbaa9256f..03709cca98970d9ed7d98478a88bb2bba7d4ee56 100644 --- a/test/porousmediumflow/1p/sequential/test_1pproblem.hh +++ b/test/porousmediumflow/1p/sequential/test_1pproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_TEST_1P_PROBLEM_HH #define DUMUX_TEST_1P_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/constant.hh> diff --git a/test/porousmediumflow/1p/sequential/test_diffusion.cc b/test/porousmediumflow/1p/sequential/test_diffusion.cc index e8e5c19d98528a35eb7c2d09174436750d64e6df..89a23a4dd9a73a314a524a8658f2e96d38dcb2b2 100644 --- a/test/porousmediumflow/1p/sequential/test_diffusion.cc +++ b/test/porousmediumflow/1p/sequential/test_diffusion.cc @@ -28,6 +28,8 @@ #include <dune/common/exceptions.hh> #include <dune/common/parallel/mpihelper.hh> +#include <dumux/io/grid/gridmanager.hh> + #include "test_diffusionproblem.hh" #include "resultevaluation.hh" @@ -62,9 +64,9 @@ int main(int argc, char** argv) //////////////////////////////////////////////////////////// // create the grid //////////////////////////////////////////////////////////// - using GridCreator = GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - auto& grid = GridCreator::grid(); + Dumux::GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); + auto& grid = gridManager.grid(); //////////////////////////////////////////////////////////// // instantiate and run the concrete problem diff --git a/test/porousmediumflow/1p/sequential/test_diffusion3d.cc b/test/porousmediumflow/1p/sequential/test_diffusion3d.cc index def411851314dff7b96a726f208ee874605e392e..f9a15a2f437210b32f097a95ab30d070a129d8ff 100644 --- a/test/porousmediumflow/1p/sequential/test_diffusion3d.cc +++ b/test/porousmediumflow/1p/sequential/test_diffusion3d.cc @@ -37,6 +37,8 @@ #include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> +#include <dumux/io/grid/gridmanager.hh> + #include "test_diffusionproblem3d.hh" #include "resultevaluation3d.hh" @@ -86,18 +88,17 @@ int start(int argc, // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - try { GridCreator::makeGrid(); } + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + try { gridManager.init(); } catch (...) { std::string usageMessage = "\n\t -> Creation of the grid failed! <- \n\n"; usageMessage += defaultUsageMessage(argv[0]); usage(argv[0], usageMessage); throw; } - GridCreator::loadBalance(); // print grid info - auto& grid = GridCreator::grid(); + auto& grid = gridManager.grid(); Dune::gridinfo(grid); ////////////////////////////////////////////////////////////////////// diff --git a/test/porousmediumflow/1p/sequential/test_diffusionproblem3d.hh b/test/porousmediumflow/1p/sequential/test_diffusionproblem3d.hh index 509d3c6915b26594cc180ac040ff4c9abe619084..28412467280b84f21d755b6213a00720a401d50d 100644 --- a/test/porousmediumflow/1p/sequential/test_diffusionproblem3d.hh +++ b/test/porousmediumflow/1p/sequential/test_diffusionproblem3d.hh @@ -22,6 +22,14 @@ #ifndef DUMUX_TEST_DIFFUSION_3D_PROBLEM_HH #define DUMUX_TEST_DIFFUSION_3D_PROBLEM_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/constant.hh> #include <dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/pressureproperties.hh> diff --git a/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh index 53237741f0ae6d725b4695bc692ee978bb296607..d86da0cb0e6362f6cd3f46fa28250d97706cb773 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2cniconductionproblem.hh @@ -25,6 +25,11 @@ #ifndef DUMUX_1P2CNI_CONDUCTION_TEST_PROBLEM_HH #define DUMUX_1P2CNI_CONDUCTION_TEST_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> diff --git a/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh index 635b657e10bb940ebbc7af69324bbfe513b661b4..70d397f051ee4c08e0e8cf57b7062da46793dec8 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2cniconvectionproblem.hh @@ -25,6 +25,11 @@ #ifndef DUMUX_1P2CNI_CONVECTION_TEST_PROBLEM_HH #define DUMUX_1P2CNI_CONVECTION_TEST_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> diff --git a/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh b/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh index ae77a6c9dbaf240af749381ff84844d0fe0d6a41..c044501577e71defa0a20af36a6d4f98f62aaf2b 100644 --- a/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh +++ b/test/porousmediumflow/1pnc/implicit/1p2ctestproblem.hh @@ -25,6 +25,11 @@ #ifndef DUMUX_1P2C_TEST_PROBLEM_HH #define DUMUX_1P2C_TEST_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc index d9bb15ae6442ab0714a135338485aa40319776de..86133ee13d6ea3cf46a160c0f156baf15f4039e5 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2c_fv.cc @@ -21,176 +21,176 @@ * * \brief test for the 1pnc model */ - #include <config.h> +#include <config.h> - #include "1p2ctestproblem.hh" +#include "1p2ctestproblem.hh" - #include <ctime> - #include <iostream> +#include <ctime> +#include <iostream> - #include <dune/common/parallel/mpihelper.hh> - #include <dune/common/timer.hh> - #include <dune/grid/io/file/dgfparser/dgfexception.hh> - #include <dune/grid/io/file/vtk.hh> - #include <dune/istl/io.hh> +#include <dune/common/parallel/mpihelper.hh> +#include <dune/common/timer.hh> +#include <dune/grid/io/file/dgfparser/dgfexception.hh> +#include <dune/grid/io/file/vtk.hh> +#include <dune/istl/io.hh> - #include <dumux/discretization/methods.hh> +#include <dumux/discretization/methods.hh> - #include <dumux/common/properties.hh> - #include <dumux/common/parameters.hh> - #include <dumux/common/dumuxmessage.hh> - #include <dumux/common/defaultusagemessage.hh> +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> +#include <dumux/common/dumuxmessage.hh> +#include <dumux/common/defaultusagemessage.hh> - #include <dumux/linear/seqsolverbackend.hh> - #include <dumux/nonlinear/newtonsolver.hh> +#include <dumux/linear/seqsolverbackend.hh> +#include <dumux/nonlinear/newtonsolver.hh> - #include <dumux/assembly/fvassembler.hh> +#include <dumux/assembly/fvassembler.hh> - #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> - int main(int argc, char** argv) try - { - using namespace Dumux; +int main(int argc, char** argv) try +{ + using namespace Dumux; - // define the type tag for this problem - using TypeTag = TTAG(TYPETAG); + // define the type tag for this problem + using TypeTag = TTAG(TYPETAG); - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); + // initialize MPI, finalize is done automatically on exit + const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); + // print dumux start message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/true); - // initialize parameter tree - Parameters::init(argc, argv); + // initialize parameter tree + Parameters::init(argc, argv); - ////////////////////////////////////////////////////////////////////// - // try to create a grid (from the given grid file or the input file) - ///////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + // try to create a grid (from the given grid file or the input file) + ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + // run instationary non-linear problem on this grid + //////////////////////////////////////////////////////////// - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + // we compute on the leaf grid view + const auto& leafGridView = gridManager.grid().leafGridView(); - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); + // create the finite volume grid geometry + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); + fvGridGeometry->update(); - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - auto dt = getParam<Scalar>("TimeLoop.DtInitial"); - auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - - // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputFields::init(vtkWriter); //!< Add model specific output fields - vtkWriter.write(0.0); - - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = ILU0BiCGSTABBackend; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - NewtonSolver<Assembler, LinearSolver> nonLinearSolver(assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // solve the non-linear system with time step control - nonLinearSolver.solve(x, *timeLoop); - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // write vtk output - vtkWriter.write(timeLoop->time()); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by the newton solver - timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/false); - - return 0; - - } - catch (Dumux::ParameterException &e) - { - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; - } - catch (Dune::DGFException & e) - { - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; - } - catch (Dune::Exception &e) - { - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; - } - catch (...) - { - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; - } + // the problem (initial and boundary conditions) + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + auto problem = std::make_shared<Problem>(fvGridGeometry); + + // the solution vector + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + SolutionVector x(fvGridGeometry->numDofs()); + problem->applyInitialSolution(x); + auto xOld = x; + + // the grid variables + using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); + auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); + gridVariables->init(x, xOld); + + // get some time loop parameters + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); + auto dt = getParam<Scalar>("TimeLoop.DtInitial"); + auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); + + // intialize the vtk output module + VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); + VtkOutputFields::init(vtkWriter); //!< Add model specific output fields + vtkWriter.write(0.0); + + // instantiate time loop + auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); + timeLoop->setMaxTimeStepSize(maxDt); + + // the assembler with time loop for instationary problem + using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; + auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); + + // the linear solver + using LinearSolver = ILU0BiCGSTABBackend; + auto linearSolver = std::make_shared<LinearSolver>(); + + // the non-linear solver + NewtonSolver<Assembler, LinearSolver> nonLinearSolver(assembler, linearSolver); + + // time loop + timeLoop->start(); do + { + // set previous solution for storage evaluations + assembler->setPreviousSolution(xOld); + + // solve the non-linear system with time step control + nonLinearSolver.solve(x, *timeLoop); + + // make the new solution the old solution + xOld = x; + gridVariables->advanceTimeStep(); + + // advance to the time loop to the next step + timeLoop->advanceTimeStep(); + + // write vtk output + vtkWriter.write(timeLoop->time()); + + // report statistics of this time step + timeLoop->reportTimeStep(); + + // set new dt as suggested by the newton solver + timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); + + } while (!timeLoop->finished()); + + timeLoop->finalize(leafGridView.comm()); + + //////////////////////////////////////////////////////////// + // finalize, print dumux message to say goodbye + //////////////////////////////////////////////////////////// + + // print dumux end message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/false); + + return 0; +} + +catch (Dumux::ParameterException &e) +{ + std::cerr << std::endl << e << " ---> Abort!" << std::endl; + return 1; +} +catch (Dune::DGFException & e) +{ + std::cerr << "DGF exception thrown (" << e << + "). Most likely, the DGF file name is wrong " + "or the DGF file is corrupted, " + "e.g. missing hash at end of file or wrong number (dimensions) of entries." + << " ---> Abort!" << std::endl; + return 2; +} +catch (Dune::Exception &e) +{ + std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; + return 3; +} +catch (...) +{ + std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; + return 4; +} diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc index d259b5725782e5ec79c47929b0a35b41e183e947..f61f996cc770a3f09b52bfc78af7b6da0ffd5cd0 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2cni_conduction_fv.cc @@ -21,185 +21,185 @@ * * \brief test for the 1pnc model */ - #include <config.h> +#include <config.h> - #include "1p2cniconductionproblem.hh" +#include "1p2cniconductionproblem.hh" - #include <ctime> - #include <iostream> +#include <ctime> +#include <iostream> - #include <dune/common/parallel/mpihelper.hh> - #include <dune/common/timer.hh> - #include <dune/grid/io/file/dgfparser/dgfexception.hh> - #include <dune/grid/io/file/vtk.hh> - #include <dune/istl/io.hh> +#include <dune/common/parallel/mpihelper.hh> +#include <dune/common/timer.hh> +#include <dune/grid/io/file/dgfparser/dgfexception.hh> +#include <dune/grid/io/file/vtk.hh> +#include <dune/istl/io.hh> - #include <dumux/discretization/methods.hh> +#include <dumux/discretization/methods.hh> - #include <dumux/common/properties.hh> - #include <dumux/common/parameters.hh> - #include <dumux/common/dumuxmessage.hh> - #include <dumux/common/defaultusagemessage.hh> +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> +#include <dumux/common/dumuxmessage.hh> +#include <dumux/common/defaultusagemessage.hh> - #include <dumux/nonlinear/newtonsolver.hh> - #include <dumux/linear/seqsolverbackend.hh> +#include <dumux/nonlinear/newtonsolver.hh> +#include <dumux/linear/seqsolverbackend.hh> - #include <dumux/assembly/fvassembler.hh> +#include <dumux/assembly/fvassembler.hh> - #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> - int main(int argc, char** argv) try - { - using namespace Dumux; +int main(int argc, char** argv) try +{ + using namespace Dumux; - // define the type tag for this problem - using TypeTag = TTAG(TYPETAG); + // define the type tag for this problem + using TypeTag = TTAG(TYPETAG); - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); + // initialize MPI, finalize is done automatically on exit + const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); + // print dumux start message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/true); - // initialize parameter tree - Parameters::init(argc, argv); + // initialize parameter tree + Parameters::init(argc, argv); - ////////////////////////////////////////////////////////////////////// - // try to create a grid (from the given grid file or the input file) - ///////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + // try to create a grid (from the given grid file or the input file) + ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + // run instationary non-linear problem on this grid + //////////////////////////////////////////////////////////// - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + // we compute on the leaf grid view + const auto& leafGridView = gridManager.grid().leafGridView(); - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); + // create the finite volume grid geometry + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); + fvGridGeometry->update(); - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); + // the problem (initial and boundary conditions) + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + auto problem = std::make_shared<Problem>(fvGridGeometry); - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; + // the solution vector + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + SolutionVector x(fvGridGeometry->numDofs()); + problem->applyInitialSolution(x); + auto xOld = x; - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); + // the grid variables + using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); + auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); + gridVariables->init(x, xOld); - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - auto dt = getParam<Scalar>("TimeLoop.DtInitial"); - auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); + // get some time loop parameters + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); + auto dt = getParam<Scalar>("TimeLoop.DtInitial"); + auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputFields::init(vtkWriter); //!< Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - // output every vtkOutputInterval time step - const auto vtkOutputInterval = getParam<int>("Problem.OutputInterval"); + // intialize the vtk output module + VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); + VtkOutputFields::init(vtkWriter); //!< Add model specific output fields + vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); + vtkWriter.write(0.0); + // output every vtkOutputInterval time step + const auto vtkOutputInterval = getParam<int>("Problem.OutputInterval"); - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); + // instantiate time loop + auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); + timeLoop->setMaxTimeStepSize(maxDt); - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); + // the assembler with time loop for instationary problem + using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; + auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - // the linear solver + // the linear solver // using LinearSolver = UMFPackBackend; - using LinearSolver = ILU0BiCGSTABBackend; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>; - NewtonSolver nonLinearSolver(assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // linearize & solve - nonLinearSolver.solve(x, *timeLoop); - - // update the exact time temperature - problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // write vtk output - if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) - vtkWriter.write(timeLoop->time()); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by the newton solver - timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/false); - - return 0; - - } - catch (Dumux::ParameterException &e) - { - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; - } - catch (Dune::DGFException & e) - { - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; - } - catch (Dune::Exception &e) - { - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; - } - catch (...) - { - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; - } + using LinearSolver = ILU0BiCGSTABBackend; + auto linearSolver = std::make_shared<LinearSolver>(); + + // the non-linear solver + using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>; + NewtonSolver nonLinearSolver(assembler, linearSolver); + + // time loop + timeLoop->start(); do + { + // set previous solution for storage evaluations + assembler->setPreviousSolution(xOld); + + // linearize & solve + nonLinearSolver.solve(x, *timeLoop); + + // update the exact time temperature + problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); + + // make the new solution the old solution + xOld = x; + gridVariables->advanceTimeStep(); + + // advance to the time loop to the next step + timeLoop->advanceTimeStep(); + + // write vtk output + if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) + vtkWriter.write(timeLoop->time()); + + // report statistics of this time step + timeLoop->reportTimeStep(); + + // set new dt as suggested by the newton solver + timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); + + } while (!timeLoop->finished()); + + timeLoop->finalize(leafGridView.comm()); + + //////////////////////////////////////////////////////////// + // finalize, print dumux message to say goodbye + //////////////////////////////////////////////////////////// + + // print dumux end message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/false); + + return 0; + +} +catch (Dumux::ParameterException &e) +{ + std::cerr << std::endl << e << " ---> Abort!" << std::endl; + return 1; +} +catch (Dune::DGFException & e) +{ + std::cerr << "DGF exception thrown (" << e << + "). Most likely, the DGF file name is wrong " + "or the DGF file is corrupted, " + "e.g. missing hash at end of file or wrong number (dimensions) of entries." + << " ---> Abort!" << std::endl; + return 2; +} +catch (Dune::Exception &e) +{ + std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; + return 3; +} +catch (...) +{ + std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; + return 4; +} diff --git a/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc b/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc index 8bfdfd015db407ae1e8ac9c08cbff03e79ceb90f..1a555df69cff3ad1f2b8d70860e3ecf3ca3ef261 100644 --- a/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc +++ b/test/porousmediumflow/1pnc/implicit/test_1p2cni_convection_fv.cc @@ -21,185 +21,185 @@ * * \brief test for the 1pnc model */ - #include <config.h> +#include <config.h> - #include "1p2cniconvectionproblem.hh" +#include "1p2cniconvectionproblem.hh" - #include <ctime> - #include <iostream> +#include <ctime> +#include <iostream> - #include <dune/common/parallel/mpihelper.hh> - #include <dune/common/timer.hh> - #include <dune/grid/io/file/dgfparser/dgfexception.hh> - #include <dune/grid/io/file/vtk.hh> - #include <dune/istl/io.hh> +#include <dune/common/parallel/mpihelper.hh> +#include <dune/common/timer.hh> +#include <dune/grid/io/file/dgfparser/dgfexception.hh> +#include <dune/grid/io/file/vtk.hh> +#include <dune/istl/io.hh> - #include <dumux/discretization/methods.hh> +#include <dumux/discretization/methods.hh> - #include <dumux/common/properties.hh> - #include <dumux/common/parameters.hh> - #include <dumux/common/dumuxmessage.hh> - #include <dumux/common/defaultusagemessage.hh> +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> +#include <dumux/common/dumuxmessage.hh> +#include <dumux/common/defaultusagemessage.hh> - #include <dumux/nonlinear/newtonsolver.hh> - #include <dumux/linear/seqsolverbackend.hh> +#include <dumux/nonlinear/newtonsolver.hh> +#include <dumux/linear/seqsolverbackend.hh> - #include <dumux/assembly/fvassembler.hh> +#include <dumux/assembly/fvassembler.hh> - #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> - int main(int argc, char** argv) try - { - using namespace Dumux; +int main(int argc, char** argv) try +{ + using namespace Dumux; - // define the type tag for this problem - using TypeTag = TTAG(TYPETAG); + // define the type tag for this problem + using TypeTag = TTAG(TYPETAG); - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); + // initialize MPI, finalize is done automatically on exit + const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); + // print dumux start message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/true); - // initialize parameter tree - Parameters::init(argc, argv); + // initialize parameter tree + Parameters::init(argc, argv); - ////////////////////////////////////////////////////////////////////// - // try to create a grid (from the given grid file or the input file) - ///////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + // try to create a grid (from the given grid file or the input file) + ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + // run instationary non-linear problem on this grid + //////////////////////////////////////////////////////////// - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + // we compute on the leaf grid view + const auto& leafGridView = gridManager.grid().leafGridView(); - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); + // create the finite volume grid geometry + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); + fvGridGeometry->update(); - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); + // the problem (initial and boundary conditions) + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + auto problem = std::make_shared<Problem>(fvGridGeometry); - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; + // the solution vector + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + SolutionVector x(fvGridGeometry->numDofs()); + problem->applyInitialSolution(x); + auto xOld = x; - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); + // the grid variables + using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); + auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); + gridVariables->init(x, xOld); - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - auto dt = getParam<Scalar>("TimeLoop.DtInitial"); - auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); + // get some time loop parameters + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); + auto dt = getParam<Scalar>("TimeLoop.DtInitial"); + auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - // intialize the vtk output module - VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputFields::init(vtkWriter); //!< Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - // output every vtkOutputInterval time step - const auto vtkOutputInterval = getParam<int>("Problem.OutputInterval"); + // intialize the vtk output module + VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); + VtkOutputFields::init(vtkWriter); //!< Add model specific output fields + vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); + vtkWriter.write(0.0); + // output every vtkOutputInterval time step + const auto vtkOutputInterval = getParam<int>("Problem.OutputInterval"); - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); + // instantiate time loop + auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); + timeLoop->setMaxTimeStepSize(maxDt); - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); + // the assembler with time loop for instationary problem + using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; + auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - // the linear solver + // the linear solver // using LinearSolver = UMFPackBackend; - using LinearSolver = ILU0BiCGSTABBackend; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>; - NewtonSolver nonLinearSolver(assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // linearize & solve - nonLinearSolver.solve(x, *timeLoop); - - // update the exact time temperature - problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // write vtk output - if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) - vtkWriter.write(timeLoop->time()); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by the newton solver - timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/false); - - return 0; - - } - catch (Dumux::ParameterException &e) - { - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; - } - catch (Dune::DGFException & e) - { - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; - } - catch (Dune::Exception &e) - { - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; - } - catch (...) - { - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; - } + using LinearSolver = ILU0BiCGSTABBackend; + auto linearSolver = std::make_shared<LinearSolver>(); + + // the non-linear solver + using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>; + NewtonSolver nonLinearSolver(assembler, linearSolver); + + // time loop + timeLoop->start(); do + { + // set previous solution for storage evaluations + assembler->setPreviousSolution(xOld); + + // linearize & solve + nonLinearSolver.solve(x, *timeLoop); + + // update the exact time temperature + problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); + + // make the new solution the old solution + xOld = x; + gridVariables->advanceTimeStep(); + + // advance to the time loop to the next step + timeLoop->advanceTimeStep(); + + // write vtk output + if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) + vtkWriter.write(timeLoop->time()); + + // report statistics of this time step + timeLoop->reportTimeStep(); + + // set new dt as suggested by the newton solver + timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); + + } while (!timeLoop->finished()); + + timeLoop->finalize(leafGridView.comm()); + + //////////////////////////////////////////////////////////// + // finalize, print dumux message to say goodbye + //////////////////////////////////////////////////////////// + + // print dumux end message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/false); + + return 0; + +} +catch (Dumux::ParameterException &e) +{ + std::cerr << std::endl << e << " ---> Abort!" << std::endl; + return 1; +} +catch (Dune::DGFException & e) +{ + std::cerr << "DGF exception thrown (" << e << + "). Most likely, the DGF file name is wrong " + "or the DGF file is corrupted, " + "e.g. missing hash at end of file or wrong number (dimensions) of entries." + << " ---> Abort!" << std::endl; + return 2; +} +catch (Dune::Exception &e) +{ + std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; + return 3; +} +catch (...) +{ + std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; + return 4; +} diff --git a/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc b/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc index 1c2903a3fe5f399126a9e4b70a918ee2c523165e..12a429b089c7188832b8067b3d2c1322927e7aba 100644 --- a/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc +++ b/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc @@ -36,6 +36,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "thermochemproblem.hh" @@ -98,16 +99,15 @@ int main(int argc, char** argv) try // try to create a grid (from the given grid file or the input file) ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh b/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh index 47eca4d035ca4c6d52d9a360fcf328618e8fbefe..6f49329b1c81bdb7beaf6d9c14b4cdae2c43f8ed 100644 --- a/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh +++ b/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_THERMOCHEM_PROBLEM_HH #define DUMUX_THERMOCHEM_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/porousmediumflow/1pncmin/model.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/2p/implicit/adaptive/test_2p_adaptive_fv.cc b/test/porousmediumflow/2p/implicit/adaptive/test_2p_adaptive_fv.cc index a2704d6b02dfad7cefceac1d537a2b3383c65626..e17049b166566a46a810d8b6befd15612e4929ee 100644 --- a/test/porousmediumflow/2p/implicit/adaptive/test_2p_adaptive_fv.cc +++ b/test/porousmediumflow/2p/implicit/adaptive/test_2p_adaptive_fv.cc @@ -46,6 +46,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/adaptive/adapt.hh> #include <dumux/adaptive/markelements.hh> @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); @@ -149,8 +149,8 @@ int main(int argc, char** argv) try initIndicator.calculate(x); bool wasAdapted = false; - if (markElements(GridCreator::grid(), initIndicator)) - wasAdapted = adapt(GridCreator::grid(), dataTransfer); + if (markElements(gridManager.grid(), initIndicator)) + wasAdapted = adapt(gridManager.grid(), dataTransfer); // update grid data after adaption if (wasAdapted) @@ -165,8 +165,8 @@ int main(int argc, char** argv) try indicator.calculate(x, refineTol, coarsenTol); bool wasAdapted = false; - if (markElements(GridCreator::grid(), indicator)) - wasAdapted = adapt(GridCreator::grid(), dataTransfer); + if (markElements(gridManager.grid(), indicator)) + wasAdapted = adapt(gridManager.grid(), dataTransfer); // update grid data after adaption if (wasAdapted) @@ -220,8 +220,8 @@ int main(int argc, char** argv) try // mark elements and maybe adapt grid bool wasAdapted = false; - if (markElements(GridCreator::grid(), indicator)) - wasAdapted = adapt(GridCreator::grid(), dataTransfer); + if (markElements(gridManager.grid(), indicator)) + wasAdapted = adapt(gridManager.grid(), dataTransfer); if (wasAdapted) { diff --git a/test/porousmediumflow/2p/implicit/boxdfm/problem.hh b/test/porousmediumflow/2p/implicit/boxdfm/problem.hh index 258385a9d707ae236995e982d43b10f871fd58cc..f09456fef0a9ff93acddfcb5a11b8ef744621f26 100644 --- a/test/porousmediumflow/2p/implicit/boxdfm/problem.hh +++ b/test/porousmediumflow/2p/implicit/boxdfm/problem.hh @@ -23,6 +23,14 @@ #ifndef DUMUX_INCOMPRESSIBLE_TWOPBOXDFM_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_TWOPBOXDFM_TEST_PROBLEM_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/components/trichloroethene.hh> #include <dumux/material/components/simpleh2o.hh> #include <dumux/material/fluidsystems/1pliquid.hh> diff --git a/test/porousmediumflow/2p/implicit/boxdfm/test_2pboxdfm.cc b/test/porousmediumflow/2p/implicit/boxdfm/test_2pboxdfm.cc index dac6d77ed3842b4a0f8d533649035775ea691d43..cc85df984411b095ee4353eb463edd72a47fafa1 100644 --- a/test/porousmediumflow/2p/implicit/boxdfm/test_2pboxdfm.cc +++ b/test/porousmediumflow/2p/implicit/boxdfm/test_2pboxdfm.cc @@ -47,6 +47,7 @@ #include <dumux/assembly/diffmethod.hh> #include <dumux/discretization/methods.hh> +#include <dumux/io/grid/gridmanager.hh> #include <dumux/porousmediumflow/boxdfm/vtkoutputmodule.hh> @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p/implicit/cornerpoint/problem.hh b/test/porousmediumflow/2p/implicit/cornerpoint/problem.hh index dd80e513066eeed9819cf73b4be454581355eab1..5850c3b1f660ce0de375f35f098daac655221230 100644 --- a/test/porousmediumflow/2p/implicit/cornerpoint/problem.hh +++ b/test/porousmediumflow/2p/implicit/cornerpoint/problem.hh @@ -25,7 +25,6 @@ #include <opm/grid/CpGrid.hpp> -#include <dumux/io/cpgridcreator.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/material/components/trichloroethene.hh> @@ -74,9 +73,6 @@ public: using type = TwoPCornerPointTestSpatialParams<FVGridGeometry, Scalar>; }; -// Set the grid creator -SET_TYPE_PROP(TwoPCornerPoint, GridCreator, CpGridCreator); - // Enable caching SET_BOOL_PROP(TwoPCornerPoint, EnableGridVolumeVariablesCache, false); SET_BOOL_PROP(TwoPCornerPoint, EnableGridFluxVariablesCache, false); @@ -105,7 +101,6 @@ class TwoPCornerPointTestProblem : public PorousMediumFlowProblem<TypeTag> using GlobalPosition = typename Element::Geometry::GlobalCoordinate; using NumEqVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices; - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); enum { dimWorld = GridView::dimensionworld }; public: @@ -178,7 +173,7 @@ public: { NumEqVector values(0.0); - int eIdx = GridCreator::grid().leafGridView().indexSet().index(element); + int eIdx = this->fvGridGeometry().gridView().indexSet().index(element); if (eIdx == injectionElement_) values[FluidSystem::phase1Idx] = injectionRate_/element.geometry().volume(); diff --git a/test/porousmediumflow/2p/implicit/cornerpoint/spatialparams.hh b/test/porousmediumflow/2p/implicit/cornerpoint/spatialparams.hh index 66daf1148bbe29aa4f6113a3699ab4696221fd6a..1e8ee307f76f4eddb6c8a18b4f7265467d4b42cb 100644 --- a/test/porousmediumflow/2p/implicit/cornerpoint/spatialparams.hh +++ b/test/porousmediumflow/2p/implicit/cornerpoint/spatialparams.hh @@ -23,7 +23,7 @@ #ifndef DUMUX_TWOP_CORNERPOINT_TEST_SPATIAL_PARAMS_HH #define DUMUX_TWOP_CORNERPOINT_TEST_SPATIAL_PARAMS_HH -#include <dumux/io/cpgridcreator.hh> +#include <dumux/io/grid/cpgridcreator.hh> #include <dumux/material/spatialparams/fv.hh> #include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchten.hh> #include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh> @@ -44,7 +44,6 @@ class TwoPCornerPointTestSpatialParams using SubControlVolume = typename FVElementGeometry::SubControlVolume; using ThisType = TwoPCornerPointTestSpatialParams<FVGridGeometry, Scalar>; using ParentType = FVSpatialParams<FVGridGeometry, Scalar, ThisType>; - using GridCreator = CpGridCreator; static constexpr int dimWorld = GridView::dimensionworld; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; @@ -63,11 +62,11 @@ public: { homogeneous_ = getParam<bool>("Problem.Homogeneous"); - const std::vector<int>& globalCell = GridCreator::grid().globalCell(); + const std::vector<int>& globalCell = this->fvGridGeometry().grid().globalCell(); - if (GridCreator::deck().hasKeyword("PORO")) { + if (CpGridCreator::deck().hasKeyword("PORO")) { std::cout << "Found PORO..." << std::endl; - std::vector<double> eclVector = GridCreator::deck().getKeyword("PORO").getRawDoubleData(); + std::vector<double> eclVector = CpGridCreator::deck().getKeyword("PORO").getRawDoubleData(); porosity_.resize(globalCell.size()); for (size_t i = 0; i < globalCell.size(); ++i) { @@ -78,9 +77,9 @@ public: } } - if (GridCreator::deck().hasKeyword("PERMX")) { + if (CpGridCreator::deck().hasKeyword("PERMX")) { std::cout << "Found PERMX..." << std::endl; - std::vector<double> eclVector = GridCreator::deck().getKeyword("PERMX").getRawDoubleData(); + std::vector<double> eclVector = CpGridCreator::deck().getKeyword("PERMX").getRawDoubleData(); permX_.resize(globalCell.size()); for (size_t i = 0; i < globalCell.size(); ++i) { @@ -92,9 +91,9 @@ public: } } - if (GridCreator::deck().hasKeyword("PERMZ")) { + if (CpGridCreator::deck().hasKeyword("PERMZ")) { std::cout << "Found PERMZ..." << std::endl; - std::vector<double> eclVector = GridCreator::deck().getKeyword("PERMZ").getRawDoubleData(); + std::vector<double> eclVector = CpGridCreator::deck().getKeyword("PERMZ").getRawDoubleData(); permZ_.resize(globalCell.size()); for (size_t i = 0; i < globalCell.size(); ++i) { @@ -129,7 +128,7 @@ public: const SubControlVolume& scv, const ElementSolution& elemSol) const { - int eIdx = GridCreator::grid().leafGridView().indexSet().index(element); + int eIdx = this->fvGridGeometry().gridView().indexSet().index(element); PermeabilityType K(0); K[0][0] = K[1][1] = permX_[eIdx]; @@ -151,7 +150,7 @@ public: const SubControlVolume& scv, const ElementSolution& elemSol) const { - int eIdx = GridCreator::grid().leafGridView().indexSet().index(element); + int eIdx = this->fvGridGeometry().gridView().indexSet().index(element); return porosity_[eIdx]; } diff --git a/test/porousmediumflow/2p/implicit/cornerpoint/test_2p_cornerpoint.cc b/test/porousmediumflow/2p/implicit/cornerpoint/test_2p_cornerpoint.cc index b291a8eef661ea81e9c9da28389ff61cd4556b5f..eb7436cc7aab1645ef295a51136ea7d484202f87 100644 --- a/test/porousmediumflow/2p/implicit/cornerpoint/test_2p_cornerpoint.cc +++ b/test/porousmediumflow/2p/implicit/cornerpoint/test_2p_cornerpoint.cc @@ -56,6 +56,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/cpgridcreator.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -107,16 +108,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + CpGridCreator::makeGrid(); + CpGridCreator::loadBalance(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = CpGridCreator::grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p/implicit/fracture/test_2p_fracture_fv.cc b/test/porousmediumflow/2p/implicit/fracture/test_2p_fracture_fv.cc index 6090dc310d7054ba982bd8740ca3e91eb2aa1186..ca4bbbc07f2a6a0779e64fb16979021ff720d424 100644 --- a/test/porousmediumflow/2p/implicit/fracture/test_2p_fracture_fv.cc +++ b/test/porousmediumflow/2p/implicit/fracture/test_2p_fracture_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -82,16 +83,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p/implicit/incompressible/problem.hh b/test/porousmediumflow/2p/implicit/incompressible/problem.hh index bf8cb8a6b767d09cfff1d3234e22e2c0ba054c69..5d630ec5953c05dc6cb4c51916c101732d4f64db 100644 --- a/test/porousmediumflow/2p/implicit/incompressible/problem.hh +++ b/test/porousmediumflow/2p/implicit/incompressible/problem.hh @@ -23,6 +23,8 @@ #ifndef DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> diff --git a/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc b/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc index daac6cf940a40adec59f2530569db2aa503375e8..4df2e90942f7a9e15789156babb72b1700acea48 100644 --- a/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc +++ b/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p/implicit/nonisothermal/problem.hh b/test/porousmediumflow/2p/implicit/nonisothermal/problem.hh index c75513a24919307b26da354e738c6d1bcb2032a6..b94828c3efd62c3f24e171a5932fdfd8166a0991 100644 --- a/test/porousmediumflow/2p/implicit/nonisothermal/problem.hh +++ b/test/porousmediumflow/2p/implicit/nonisothermal/problem.hh @@ -27,6 +27,14 @@ #ifndef DUMUX_INJECTION_PROBLEM_2PNI_HH #define DUMUX_INJECTION_PROBLEM_2PNI_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/common/properties.hh> #include <dumux/porousmediumflow/2p/model.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/2p/implicit/nonisothermal/test_2pni_fv.cc b/test/porousmediumflow/2p/implicit/nonisothermal/test_2pni_fv.cc index 22b8215f5ec39379dcaa08e241f8b835cd691a55..81228335c8177c1177126ae840fad3a22eadf215 100644 --- a/test/porousmediumflow/2p/implicit/nonisothermal/test_2pni_fv.cc +++ b/test/porousmediumflow/2p/implicit/nonisothermal/test_2pni_fv.cc @@ -43,6 +43,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "problem.hh" @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p/sequential/test_3d2pproblem.hh b/test/porousmediumflow/2p/sequential/test_3d2pproblem.hh index ec8494cf5bd31f2ac54fe19c8239d40c3782a4d7..f79049eec1204eac6455d649e720e616157d750c 100644 --- a/test/porousmediumflow/2p/sequential/test_3d2pproblem.hh +++ b/test/porousmediumflow/2p/sequential/test_3d2pproblem.hh @@ -24,6 +24,9 @@ #ifndef DUMUX_TEST_3D2P_PROBLEM_HH #define DUMUX_TEST_3D2P_PROBLEM_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/fluidsystems/1pgas.hh> diff --git a/test/porousmediumflow/2p/sequential/test_impesadaptiveproblem.hh b/test/porousmediumflow/2p/sequential/test_impesadaptiveproblem.hh index da694f34e8c682227216d0bce010633623e1660f..a71ae2f09d390ce0c4c6df68cb346396423fe8f2 100644 --- a/test/porousmediumflow/2p/sequential/test_impesadaptiveproblem.hh +++ b/test/porousmediumflow/2p/sequential/test_impesadaptiveproblem.hh @@ -24,6 +24,9 @@ #ifndef DUMUX_TEST_IMPES_ADAPTIVE_PROBLEM_HH #define DUMUX_TEST_IMPES_ADAPTIVE_PROBLEM_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/simpleh2o.hh> @@ -115,7 +118,6 @@ class TestIMPESAdaptiveProblem: public IMPESProblem2P<TypeTag> using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); using SolutionTypes = typename GET_PROP(TypeTag, SolutionTypes); using PrimaryVariables = typename SolutionTypes::PrimaryVariables; - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); public: TestIMPESAdaptiveProblem(TimeManager &timeManager, Grid& grid) : diff --git a/test/porousmediumflow/2p/sequential/test_impesproblem.hh b/test/porousmediumflow/2p/sequential/test_impesproblem.hh index 24b57e8a43d689dc61832a688648351e4d7bfd56..7dafa1e5ca979aff8efe1639ee91b334ede66796 100644 --- a/test/porousmediumflow/2p/sequential/test_impesproblem.hh +++ b/test/porousmediumflow/2p/sequential/test_impesproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_TEST_IMPES_PROBLEM_HH #define DUMUX_TEST_IMPES_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/simpleh2o.hh> @@ -98,9 +100,8 @@ NEW_TYPE_TAG(IMPESTestWithAMGTypeTag, INHERITS_FROM(IMPESTestTypeTag)); SET_TYPE_PROP(IMPESTestWithAMGTypeTag, LinearSolver, AMGBackend<TypeTag>); // Set the grid type SET_TYPE_PROP(IMPESTestWithAMGTypeTag, Grid, Dune::YaspGrid<2>); -// Set the grid creator -SET_TYPE_PROP(IMPESTestWithAMGTypeTag, GridCreator, GridCreator<TypeTag>); -} + +} // end namespace Properties /*! * \ingroup SequentialTwoPTests diff --git a/test/porousmediumflow/2p/sequential/test_mpfa2pproblem.hh b/test/porousmediumflow/2p/sequential/test_mpfa2pproblem.hh index 302c32854fbf533689185ad009be1cceb53c983a..dc8fe92c859f88be6a89b3128335655f704bb9c1 100644 --- a/test/porousmediumflow/2p/sequential/test_mpfa2pproblem.hh +++ b/test/porousmediumflow/2p/sequential/test_mpfa2pproblem.hh @@ -24,6 +24,11 @@ #ifndef DUMUX_TEST_MPFA2P_PROBLEM_HH #define DUMUX_TEST_MPFA2P_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/2pimmiscible.hh> #include <dumux/material/fluidsystems/1pliquid.hh> #include <dumux/material/components/simpleh2o.hh> diff --git a/test/porousmediumflow/2p/sequential/test_transportproblem.hh b/test/porousmediumflow/2p/sequential/test_transportproblem.hh index c8c80c786369dc0627a97558f2a8e8cfe9d59131..bd08a4799ae875a96f031db535149d6e1ba964e1 100644 --- a/test/porousmediumflow/2p/sequential/test_transportproblem.hh +++ b/test/porousmediumflow/2p/sequential/test_transportproblem.hh @@ -24,6 +24,7 @@ #ifndef DUMUX_TEST_TRANSPORT_PROBLEM_HH #define DUMUX_TEST_TRANSPORT_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> #include <dune/grid/io/file/dgfparser/dgfyasp.hh> #include <dumux/material/fluidsystems/1pliquid.hh> diff --git a/test/porousmediumflow/2p1c/implicit/steaminjectionproblem.hh b/test/porousmediumflow/2p1c/implicit/steaminjectionproblem.hh index 6baa7d3514bda26023255a56af6e0e8efff7871b..1ca802b5a2b78b32f4ae3be005440567848d979c 100644 --- a/test/porousmediumflow/2p1c/implicit/steaminjectionproblem.hh +++ b/test/porousmediumflow/2p1c/implicit/steaminjectionproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_STEAM_INJECTIONPROBLEM_HH #define DUMUX_STEAM_INJECTIONPROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/2p1c/model.hh> diff --git a/test/porousmediumflow/2p1c/implicit/test_2p1c_fv.cc b/test/porousmediumflow/2p1c/implicit/test_2p1c_fv.cc index f6ec0b61d786ab39e0aef9b6e4e7a04899e6badd..9f869544a52fdea9ae96715dfdcaeca717a7b72c 100644 --- a/test/porousmediumflow/2p1c/implicit/test_2p1c_fv.cc +++ b/test/porousmediumflow/2p1c/implicit/test_2p1c_fv.cc @@ -20,135 +20,135 @@ * \file * * \brief test for the 1pnc model - */ - #include <config.h> +*/ +#include <config.h> - #include "steaminjectionproblem.hh" +#include "steaminjectionproblem.hh" - #include <ctime> - #include <iostream> +#include <ctime> +#include <iostream> - #include <dune/common/parallel/mpihelper.hh> - #include <dune/common/timer.hh> - #include <dune/grid/io/file/dgfparser/dgfexception.hh> - #include <dune/grid/io/file/vtk.hh> - #include <dune/istl/io.hh> +#include <dune/common/parallel/mpihelper.hh> +#include <dune/common/timer.hh> +#include <dune/grid/io/file/dgfparser/dgfexception.hh> +#include <dune/grid/io/file/vtk.hh> +#include <dune/istl/io.hh> - #include <dumux/discretization/methods.hh> +#include <dumux/discretization/methods.hh> - #include <dumux/common/properties.hh> - #include <dumux/common/parameters.hh> - #include <dumux/common/dumuxmessage.hh> - #include <dumux/common/defaultusagemessage.hh> +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> +#include <dumux/common/dumuxmessage.hh> +#include <dumux/common/defaultusagemessage.hh> - #include <dumux/linear/seqsolverbackend.hh> - #include <dumux/nonlinear/privarswitchnewtonsolver.hh> +#include <dumux/linear/seqsolverbackend.hh> +#include <dumux/nonlinear/privarswitchnewtonsolver.hh> - #include <dumux/assembly/fvassembler.hh> +#include <dumux/assembly/fvassembler.hh> - #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> - int main(int argc, char** argv) try - { - using namespace Dumux; +int main(int argc, char** argv) try +{ + using namespace Dumux; - // define the type tag for this problem - using TypeTag = TTAG(TYPETAG); + // define the type tag for this problem + using TypeTag = TTAG(TYPETAG); - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); + // initialize MPI, finalize is done automatically on exit + const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); + // print dumux start message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/true); - // initialize parameter tree - Parameters::init(argc, argv); + // initialize parameter tree + Parameters::init(argc, argv); - ////////////////////////////////////////////////////////////////////// - // try to create a grid (from the given grid file or the input file) - ///////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + // try to create a grid (from the given grid file or the input file) + ///////////////////////////////////////////////////////////////////// - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + // run instationary non-linear problem on this grid + //////////////////////////////////////////////////////////// - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + // we compute on the leaf grid view + const auto& leafGridView = gridManager.grid().leafGridView(); - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); + // create the finite volume grid geometry + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); + fvGridGeometry->update(); - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); + // the problem (initial and boundary conditions) + using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + auto problem = std::make_shared<Problem>(fvGridGeometry); - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; + // the solution vector + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + SolutionVector x(fvGridGeometry->numDofs()); + problem->applyInitialSolution(x); + auto xOld = x; - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); + // the grid variables + using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); + auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); + gridVariables->init(x, xOld); - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - auto dt = getParam<Scalar>("TimeLoop.DtInitial"); - auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); + // get some time loop parameters + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); + auto dt = getParam<Scalar>("TimeLoop.DtInitial"); + auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - // intialize the vtk output module - VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputFields::init(vtkWriter); //!< Add model specific output fields - vtkWriter.write(0.0); + // intialize the vtk output module + VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); + VtkOutputFields::init(vtkWriter); //!< Add model specific output fields + vtkWriter.write(0.0); - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); + // instantiate time loop + auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd); + timeLoop->setMaxTimeStepSize(maxDt); - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); + // the assembler with time loop for instationary problem + using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; + auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - // the linear solver - using LinearSolver = ILU0BiCGSTABBackend; - auto linearSolver = std::make_shared<LinearSolver>(); + // the linear solver + using LinearSolver = ILU0BiCGSTABBackend; + auto linearSolver = std::make_shared<LinearSolver>(); - // the non-linear solver - using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch); - using NewtonSolver = Dumux::PriVarSwitchNewtonSolver<Assembler, LinearSolver, PrimaryVariableSwitch>; - NewtonSolver nonLinearSolver(assembler, linearSolver); + // the non-linear solver + using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch); + using NewtonSolver = Dumux::PriVarSwitchNewtonSolver<Assembler, LinearSolver, PrimaryVariableSwitch>; + NewtonSolver nonLinearSolver(assembler, linearSolver); - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); + // time loop + timeLoop->start(); do + { + // set previous solution for storage evaluations + assembler->setPreviousSolution(xOld); - // solve the non-linear system with time step control - nonLinearSolver.solve(x, *timeLoop); + // solve the non-linear system with time step control + nonLinearSolver.solve(x, *timeLoop); - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); + // make the new solution the old solution + xOld = x; + gridVariables->advanceTimeStep(); - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); + // advance to the time loop to the next step + timeLoop->advanceTimeStep(); - // write vtk output + // write vtk output vtkWriter.write(timeLoop->time()); // report statistics of this time step @@ -157,42 +157,42 @@ // set new dt as suggested by the newton solver timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/false); - - return 0; - - } - catch (Dumux::ParameterException &e) - { - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; - } - catch (Dune::DGFException & e) - { - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; - } - catch (Dune::Exception &e) - { - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; - } - catch (...) - { - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; - } + } while (!timeLoop->finished()); + + timeLoop->finalize(leafGridView.comm()); + + //////////////////////////////////////////////////////////// + // finalize, print dumux message to say goodbye + //////////////////////////////////////////////////////////// + + // print dumux end message + if (mpiHelper.rank() == 0) + DumuxMessage::print(/*firstCall=*/false); + + return 0; + +} +catch (Dumux::ParameterException &e) +{ + std::cerr << std::endl << e << " ---> Abort!" << std::endl; + return 1; +} +catch (Dune::DGFException & e) +{ + std::cerr << "DGF exception thrown (" << e << + "). Most likely, the DGF file name is wrong " + "or the DGF file is corrupted, " + "e.g. missing hash at end of file or wrong number (dimensions) of entries." + << " ---> Abort!" << std::endl; + return 2; +} +catch (Dune::Exception &e) +{ + std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; + return 3; +} +catch (...) +{ + std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; + return 4; +} diff --git a/test/porousmediumflow/2p2c/implicit/injectionproblem.hh b/test/porousmediumflow/2p2c/implicit/injectionproblem.hh index a68d033caf3db25e64b12cbb732e9ea7730c0e11..b1664984861e68700e295a4a4f14eede046dd451 100644 --- a/test/porousmediumflow/2p2c/implicit/injectionproblem.hh +++ b/test/porousmediumflow/2p2c/implicit/injectionproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_INJECTION_PROBLEM_HH #define DUMUX_INJECTION_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/mpfa/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/2p2c/implicit/mpnccomparison/test_2p2c_comparison_fv.cc b/test/porousmediumflow/2p2c/implicit/mpnccomparison/test_2p2c_comparison_fv.cc index 6d481bae8a91015375be13b0530b793d6c3441c8..1aeb4f518ddd850ebf299cf8e6c8995a0072c024 100644 --- a/test/porousmediumflow/2p2c/implicit/mpnccomparison/test_2p2c_comparison_fv.cc +++ b/test/porousmediumflow/2p2c/implicit/mpnccomparison/test_2p2c_comparison_fv.cc @@ -44,6 +44,7 @@ #include <dumux/assembly/diffmethod.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "2p2c_comparison_problem.hh" @@ -94,16 +95,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc index 1b86e04ba7cc00ff355e3f9513ed3c0ede80ef9b..2e6f3fe159a3691cecc4ab6d09bfc446bc02f7dc 100644 --- a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc +++ b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc @@ -46,6 +46,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // the problem definitions #include "injectionproblem.hh" @@ -69,16 +70,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2p2c/implicit/waterairproblem.hh b/test/porousmediumflow/2p2c/implicit/waterairproblem.hh index cfbc5518d399f6712b97e3cc7cdafd43aabae9bd..4842f3329a3703be0673d08290c28f70efc6b6ab 100644 --- a/test/porousmediumflow/2p2c/implicit/waterairproblem.hh +++ b/test/porousmediumflow/2p2c/implicit/waterairproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_WATER_AIR_PROBLEM_HH #define DUMUX_WATER_AIR_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/methods.hh> diff --git a/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c2dproblem.hh b/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c2dproblem.hh index 9d7965b0fda8426ba4a4c3b9c4754387beacb204..8e93d1e7214d6af5c677cc07bdf5ec40ff5c885b 100644 --- a/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c2dproblem.hh +++ b/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c2dproblem.hh @@ -24,6 +24,11 @@ #ifndef DUMUX_TEST_ADAPTIVE2D_2P2C_PROBLEM_HH #define DUMUX_TEST_ADAPTIVE2D_2P2C_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/common/math.hh> #include <dumux/porousmediumflow/2p2c/sequential/adaptiveproperties.hh> #include <dumux/porousmediumflow/2p2c/sequential/problem.hh> diff --git a/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c3dproblem.hh b/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c3dproblem.hh index 4657fded674b90fd7eba71a448fbbf241cdc3e0e..cff99b2e3d933308893191cdf8c4f6d2e9ebdbb0 100644 --- a/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c3dproblem.hh +++ b/test/porousmediumflow/2p2c/sequential/test_adaptive2p2c3dproblem.hh @@ -24,6 +24,11 @@ #ifndef DUMUX_TEST_ADAPTIVE3D_2P2C_PROBLEM_HH #define DUMUX_TEST_ADAPTIVE3D_2P2C_PROBLEM_HH +#if HAVE_UG +#include <dune/grid/uggrid.hh> +#endif +#include <dune/grid/yaspgrid.hh> + #include <dumux/common/math.hh> #include <dumux/porousmediumflow/2p2c/sequential/adaptiveproperties.hh> #include <dumux/porousmediumflow/2p2c/sequential/problem.hh> diff --git a/test/porousmediumflow/2p2c/sequential/test_dec2p2cproblem.hh b/test/porousmediumflow/2p2c/sequential/test_dec2p2cproblem.hh index 7f208d5bea02817295954ec88ce9a8e50fe3b2d7..6148999c241e90f6a224485e9cf5da8189f1b23e 100644 --- a/test/porousmediumflow/2p2c/sequential/test_dec2p2cproblem.hh +++ b/test/porousmediumflow/2p2c/sequential/test_dec2p2cproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_TEST_2P2C_PROBLEM_HH #define DUMUX_TEST_2P2C_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/porousmediumflow/2p2c/sequential/problem.hh> #include <dumux/porousmediumflow/2p2c/sequential/fvpressure.hh> #include <dumux/porousmediumflow/2p2c/sequential/fvtransport.hh> diff --git a/test/porousmediumflow/2p2c/sequential/test_multiphysics2p2cproblem.hh b/test/porousmediumflow/2p2c/sequential/test_multiphysics2p2cproblem.hh index f1527b6086d1ec214e96aaeb1e5e42143704ba5c..619ede2893e313191d8b17db09487c90b352bba2 100644 --- a/test/porousmediumflow/2p2c/sequential/test_multiphysics2p2cproblem.hh +++ b/test/porousmediumflow/2p2c/sequential/test_multiphysics2p2cproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_TEST_2P2C_PROBLEM_HH #define DUMUX_TEST_2P2C_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/porousmediumflow/2p2c/sequential/problem.hh> #include <dumux/porousmediumflow/2p2c/sequential/fvpressuremultiphysics.hh> #include <dumux/porousmediumflow/2p2c/sequential/fvtransportmultiphysics.hh> diff --git a/test/porousmediumflow/2pnc/implicit/2pncdiffusionproblem.hh b/test/porousmediumflow/2pnc/implicit/2pncdiffusionproblem.hh index cd1f3a0ac42a4968268e9c01e1158c57a7f30294..5296da54883ec581f996c64fbb27da7cf69720cf 100644 --- a/test/porousmediumflow/2pnc/implicit/2pncdiffusionproblem.hh +++ b/test/porousmediumflow/2pnc/implicit/2pncdiffusionproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_TWOPNC_DIFFUSION_PROBLEM_HH #define DUMUX_TWOPNC_DIFFUSION_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> #include <dumux/porousmediumflow/2pnc/model.hh> diff --git a/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh b/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh index c4f2e2037d3501a2a6400b5746fecae5d1e59d9d..f6fec3a4f98d8ee394d4f83569a0594998d8206c 100644 --- a/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh +++ b/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_FUELCELL_PROBLEM_HH #define DUMUX_FUELCELL_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/2pnc/implicit/test_2pnc_fv.cc b/test/porousmediumflow/2pnc/implicit/test_2pnc_fv.cc index 21750d4981c2680cb3fca3793e36fdd17fa8a795..8b4349cbb69d44f3251fcfadef8ca870a9dcb5a4 100644 --- a/test/porousmediumflow/2pnc/implicit/test_2pnc_fv.cc +++ b/test/porousmediumflow/2pnc/implicit/test_2pnc_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "fuelcellproblem.hh" @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2pnc/implicit/test_cc2pnc_diffusion.cc b/test/porousmediumflow/2pnc/implicit/test_cc2pnc_diffusion.cc index 31870b972c8c13143b81ff9cbfb81d2d8e9296ea..eaa00f5ba116f21c5a72a74596f0da8a70ea7e40 100644 --- a/test/porousmediumflow/2pnc/implicit/test_cc2pnc_diffusion.cc +++ b/test/porousmediumflow/2pnc/implicit/test_cc2pnc_diffusion.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -91,16 +92,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh b/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh index de3a9490692bedacc9a80ef7ce34b28d7644c8a3..d64422a5485815e65fe8cdcf372adbcc63521305 100644 --- a/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh +++ b/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_DISSOLUTION_PROBLEM_HH #define DUMUX_DISSOLUTION_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/methods.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/2pncmin/implicit/test_2pncmin_fv.cc b/test/porousmediumflow/2pncmin/implicit/test_2pncmin_fv.cc index 1ccc7b74a2a18bc6bca8b7b1e58e3fa2f759b190..47c64c82c140f314f2b6516188fb74473a0e664a 100644 --- a/test/porousmediumflow/2pncmin/implicit/test_2pncmin_fv.cc +++ b/test/porousmediumflow/2pncmin/implicit/test_2pncmin_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -91,16 +92,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh b/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh index 87f1f03db67b7fcdf59b0713d1b17cc036029a14..49fc43ed7979d763d28f89a966301fece2b81596 100644 --- a/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh +++ b/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh @@ -25,7 +25,8 @@ #ifndef DUMUX_3PNI_CONDUCTION_PROBLEM_HH #define DUMUX_3PNI_CONDUCTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh b/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh index a08cfca359d363015cba9899e5eda1ee65f23048..8e3f52422bea2d0b1a1dcd687dee1fa42667a146 100644 --- a/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh +++ b/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh @@ -25,7 +25,8 @@ #ifndef DUMUX_3PNI_CONVECTION_PROBLEM_HH #define DUMUX_3PNI_CONVECTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/3p/implicit/test_3p_fv.cc b/test/porousmediumflow/3p/implicit/test_3p_fv.cc index 6a17a142b3806e16db6dd03e1ccc42b79202c405..de385c23203bd4b5a70cd5300359607400585dd5 100644 --- a/test/porousmediumflow/3p/implicit/test_3p_fv.cc +++ b/test/porousmediumflow/3p/implicit/test_3p_fv.cc @@ -47,6 +47,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -98,16 +99,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc index 7ea429bfedf02c61fa632761c3d5943c2e562df7..d04de7bf5e34b6155cec61d1148fabc3131f8dc7 100644 --- a/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc @@ -47,6 +47,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -98,16 +99,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc index dcaf2bcac876a466e0ed91a20cad72ae5a7accde..b36e7ffd66d623c92b126ce1a7fbf35324f1017d 100644 --- a/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc @@ -47,6 +47,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -98,16 +99,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/3p3c/implicit/columnxylolproblem.hh b/test/porousmediumflow/3p3c/implicit/columnxylolproblem.hh index 1afb0749bafb3b350c7a9274880806294f2fd5f5..10c08741bc5982fec5119b8bb9d60f425dc0c14b 100644 --- a/test/porousmediumflow/3p3c/implicit/columnxylolproblem.hh +++ b/test/porousmediumflow/3p3c/implicit/columnxylolproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_COLUMNXYLOLPROBLEM_HH #define DUMUX_COLUMNXYLOLPROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/material/fluidsystems/h2oairxylene.hh> #include <dumux/material/solidstates/compositionalsolidstate.hh> #include <dumux/material/solidsystems/compositionalsolidphase.hh> diff --git a/test/porousmediumflow/3p3c/implicit/infiltration3p3cproblem.hh b/test/porousmediumflow/3p3c/implicit/infiltration3p3cproblem.hh index 711383004d287b0019a0a6366e1c9fd7f484fbde..55bd88117da47e1df17a111d7d9d87d1b34720f5 100644 --- a/test/porousmediumflow/3p3c/implicit/infiltration3p3cproblem.hh +++ b/test/porousmediumflow/3p3c/implicit/infiltration3p3cproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_INFILTRATION_THREEPTHREEC_PROBLEM_HH #define DUMUX_INFILTRATION_THREEPTHREEC_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/3p3c/implicit/kuevetteproblem.hh b/test/porousmediumflow/3p3c/implicit/kuevetteproblem.hh index 0fbc105e51bf2fdadc4d62cac184e5b32966f826..88c7601ee4aff42e25be3ec8017be57a2d561df9 100644 --- a/test/porousmediumflow/3p3c/implicit/kuevetteproblem.hh +++ b/test/porousmediumflow/3p3c/implicit/kuevetteproblem.hh @@ -27,6 +27,7 @@ #define DUMUX_KUEVETTE3P3CNIPROBLEM_HH #include <dune/common/float_cmp.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/material/fluidsystems/h2oairmesitylene.hh> #include <dumux/material/components/constant.hh> diff --git a/test/porousmediumflow/3p3c/implicit/test_3p3c_fv.cc b/test/porousmediumflow/3p3c/implicit/test_3p3c_fv.cc index d656cad00b0712e86d79e25f0fc4f1232f8669f8..86c7031199f2bdcb6ca3877f7071646a93a5dcc0 100644 --- a/test/porousmediumflow/3p3c/implicit/test_3p3c_fv.cc +++ b/test/porousmediumflow/3p3c/implicit/test_3p3c_fv.cc @@ -45,6 +45,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "infiltration3p3cproblem.hh" #include "kuevetteproblem.hh" @@ -98,16 +99,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh b/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh index 6e6e7c5f2b7fd1efce118c7775db9d4e505319ce..a5733fecd71ebd4e422a4234770fe6d216f4f013 100644 --- a/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh +++ b/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_SAGDPROBLEM_HH #define DUMUX_SAGDPROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/porousmediumflow/problem.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc b/test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc index bbf72d26335a1ffa26e950b4122b69ca3bbd6e13..e809fc4149804e8de78b5283883a94edbde4adff 100644 --- a/test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc +++ b/test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc @@ -45,6 +45,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "3pwateroilsagdproblem.hh" @@ -95,16 +96,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/co2/implicit/heterogeneousproblem.hh b/test/porousmediumflow/co2/implicit/heterogeneousproblem.hh index 6a0765938acaf8e0e469accc84f7601b95a4b1c1..9447df13b1f2519808f8d2cf79c35c3ef3caf5fd 100644 --- a/test/porousmediumflow/co2/implicit/heterogeneousproblem.hh +++ b/test/porousmediumflow/co2/implicit/heterogeneousproblem.hh @@ -24,6 +24,10 @@ #ifndef DUMUX_HETEROGENEOUS_PROBLEM_HH #define DUMUX_HETEROGENEOUS_PROBLEM_HH +#if HAVE_DUNE_ALUGRID +#include <dune/alugrid/grid.hh> +#endif + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> @@ -55,15 +59,14 @@ NEW_TYPE_TAG(HeterogeneousBoxTypeTag, INHERITS_FROM(BoxModel, HeterogeneousTypeT NEW_TYPE_TAG(HeterogeneousCCTpfaTypeTag, INHERITS_FROM(CCTpfaModel, HeterogeneousTypeTag)); //Set the grid type -#if HAVE_DUNE_ALUGRID SET_TYPE_PROP(HeterogeneousTypeTag, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>); -#endif // Set the problem property SET_TYPE_PROP(HeterogeneousTypeTag, Problem, HeterogeneousProblem<TypeTag>); // Set the spatial parameters -SET_TYPE_PROP(HeterogeneousTypeTag, SpatialParams, HeterogeneousSpatialParams<TypeTag>); +SET_TYPE_PROP(HeterogeneousTypeTag, SpatialParams, HeterogeneousSpatialParams<typename GET_PROP_TYPE(TypeTag, FVGridGeometry), + typename GET_PROP_TYPE(TypeTag, Scalar)>); // Set fluid configuration SET_TYPE_PROP(HeterogeneousTypeTag, FluidSystem, FluidSystems::BrineCO2<typename GET_PROP_TYPE(TypeTag, Scalar), @@ -84,7 +87,8 @@ SET_TYPE_PROP(HeterogeneousNITypeTag, Grid, Dune::ALUGrid<2, 2, Dune::cube, Dune SET_TYPE_PROP(HeterogeneousNITypeTag, Problem, HeterogeneousProblem<TypeTag>); // Set the spatial parameters -SET_TYPE_PROP(HeterogeneousNITypeTag, SpatialParams, HeterogeneousSpatialParams<TypeTag>); +SET_TYPE_PROP(HeterogeneousNITypeTag, SpatialParams,HeterogeneousSpatialParams<typename GET_PROP_TYPE(TypeTag, FVGridGeometry), + typename GET_PROP_TYPE(TypeTag, Scalar)>); // Set fluid configuration SET_TYPE_PROP(HeterogeneousNITypeTag, FluidSystem, FluidSystems::BrineCO2<typename GET_PROP_TYPE(TypeTag, Scalar), @@ -185,8 +189,9 @@ public: * \param timeManager The time manager * \param gridView The grid view */ - HeterogeneousProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) - : ParentType(fvGridGeometry) + template<class SpatialParams> + HeterogeneousProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<SpatialParams> spatialParams) + : ParentType(fvGridGeometry, spatialParams) , injectionTop_(1) , injectionBottom_(2) , dirichletBoundary_(3) diff --git a/test/porousmediumflow/co2/implicit/heterogeneousspatialparameters.hh b/test/porousmediumflow/co2/implicit/heterogeneousspatialparameters.hh index dd7ce0edea38d9c9ebfa01f5e350cb4f8ad21c53..1f685f89398447c65899c731bf2c9bad76907284 100644 --- a/test/porousmediumflow/co2/implicit/heterogeneousspatialparameters.hh +++ b/test/porousmediumflow/co2/implicit/heterogeneousspatialparameters.hh @@ -27,6 +27,7 @@ #ifndef DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH #define DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH +#include <dumux/io/grid/griddata.hh> #include <dumux/material/spatialparams/fv.hh> #include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscorey.hh> #include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh> @@ -42,21 +43,19 @@ namespace Dumux { * problem which uses the non-isothermal or isothermal CO2 * fully implicit model. */ -template<class TypeTag> +template<class FVGridGeometry, class Scalar> class HeterogeneousSpatialParams -: public FVSpatialParams<typename GET_PROP_TYPE(TypeTag, FVGridGeometry), - typename GET_PROP_TYPE(TypeTag, Scalar), - HeterogeneousSpatialParams<TypeTag>> +: public FVSpatialParams<FVGridGeometry, + Scalar, + HeterogeneousSpatialParams<FVGridGeometry, Scalar>> { - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + using Grid = typename FVGridGeometry::Grid; using GridView = typename FVGridGeometry::GridView; using FVElementGeometry = typename FVGridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; using Element = typename GridView::template Codim<0>::Entity; - using ParentType = FVSpatialParams<FVGridGeometry, Scalar, HeterogeneousSpatialParams<TypeTag>>; + using ParentType = FVSpatialParams<FVGridGeometry, Scalar, HeterogeneousSpatialParams<FVGridGeometry, Scalar>>; - enum { dimWorld = GridView::dimensionworld }; using GlobalPosition = typename SubControlVolume::GlobalPosition; using EffectiveLaw = RegularizedBrooksCorey<Scalar>; @@ -71,8 +70,9 @@ public: * * \param gridView The grid view */ - HeterogeneousSpatialParams(std::shared_ptr<const FVGridGeometry> fvGridGeometry) - : ParentType(fvGridGeometry) + HeterogeneousSpatialParams(std::shared_ptr<const FVGridGeometry> fvGridGeometry, + std::shared_ptr<const GridData<Grid>> gridData) + : ParentType(fvGridGeometry), gridData_(gridData) { //Set the permeability for the layers @@ -101,11 +101,10 @@ public: const auto& gridView = this->fvGridGeometry().gridView(); paramIdx_.resize(gridView.size(0)); - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); for (const auto& element : elements(gridView)) { const auto eIdx = this->fvGridGeometry().elementMapper().index(element); - paramIdx_[eIdx] = GridCreator::parameters(element)[0]; + paramIdx_[eIdx] = gridData_->parameters(element)[0]; } } @@ -203,6 +202,9 @@ public: { return FluidSystem::BrineIdx; } private: + + std::shared_ptr<const GridData<Grid>> gridData_; + int barrierTop_ = 1; int barrierMiddle_ = 2; int reservoir_ = 3; diff --git a/test/porousmediumflow/co2/implicit/test_co2_fv.cc b/test/porousmediumflow/co2/implicit/test_co2_fv.cc index c9e2297ebec09eee239847eaaf193c411d45a88c..85ddce197d22be6f8963e3807ef08ebfbdf68c44 100644 --- a/test/porousmediumflow/co2/implicit/test_co2_fv.cc +++ b/test/porousmediumflow/co2/implicit/test_co2_fv.cc @@ -46,6 +46,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // the problem definitions #include "heterogeneousproblem.hh" @@ -68,25 +69,28 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); fvGridGeometry->update(); + // the spatial parameters + using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams); + auto spatialParams = std::make_shared<SpatialParams>(fvGridGeometry, gridManager.getGridData()); + // the problem (initial and boundary conditions) using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); + auto problem = std::make_shared<Problem>(fvGridGeometry, spatialParams); // the solution vector using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); diff --git a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh index 46f94f47ca9ef3e8fc69b76fdc94ffbcb5385b43..5ddb383b6dd4c44e4881e989353f03a1ea3526ce 100644 --- a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh +++ b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh @@ -25,6 +25,7 @@ #define DUMUX_MPNC_TWOPTWOC_COMPARISON_OBSTACLEPROBLEM_HH #include <dune/common/parametertreeparser.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/test_mpnc_comparison_fv.cc b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/test_mpnc_comparison_fv.cc index 4b01fdd4f908a32686c378aec52b5d744945c4a8..26324226ba8426b497b6502ce1900d73bd053b5d 100644 --- a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/test_mpnc_comparison_fv.cc +++ b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/test_mpnc_comparison_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh b/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh index 3f78d47867097a9c9347622d93ab74f27a852269..ca4b2ec94c191560db0e7c876e6bf6c3e8eca799 100644 --- a/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh +++ b/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh @@ -27,6 +27,8 @@ #ifndef DUMUX_COMBUSTION_PROBLEM_ONE_COMPONENT_HH #define DUMUX_COMBUSTION_PROBLEM_ONE_COMPONENT_HH +#include <dune/grid/onedgrid.hh> + #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh index 8727ae7733fc687fba4fb2ad2e85936c3a64f8a9..43f7dcec1e98cd61c290739db157d40c0286b1d2 100644 --- a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh +++ b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh @@ -39,6 +39,8 @@ // setting it here, because it impacts volume variables and spatialparameters #define USE_PCMAX 1 +#include <dune/grid/yaspgrid.hh> + #include <dumux/common/properties.hh> #include <dumux/discretization/box/properties.hh> diff --git a/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh b/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh index 87136c78ee5248ee41d87a1826c2d82164df6641..1c37becb4626ea56640cdb0f8cb74ed1df3c9058 100644 --- a/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh +++ b/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh @@ -27,6 +27,7 @@ #define DUMUX_OBSTACLEPROBLEM_HH #include <dune/common/parametertreeparser.hh> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/mpnc/implicit/test_boxmpnckinetic.cc b/test/porousmediumflow/mpnc/implicit/test_boxmpnckinetic.cc index 2f6e9f2ef03e7a99a21e99b61d24fab545df1e9f..4d0fdb57172ac18b72d2628d81854df3df7a3c90 100644 --- a/test/porousmediumflow/mpnc/implicit/test_boxmpnckinetic.cc +++ b/test/porousmediumflow/mpnc/implicit/test_boxmpnckinetic.cc @@ -48,6 +48,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -97,16 +98,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/mpnc/implicit/test_boxmpncthermalnonequil.cc b/test/porousmediumflow/mpnc/implicit/test_boxmpncthermalnonequil.cc index 7501c698c7c12e55683a6e5e56d95ca81c033a5f..c0a6070ae6d9031719b59ce8e732012a9ffe8294 100644 --- a/test/porousmediumflow/mpnc/implicit/test_boxmpncthermalnonequil.cc +++ b/test/porousmediumflow/mpnc/implicit/test_boxmpncthermalnonequil.cc @@ -48,6 +48,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -97,16 +98,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/mpnc/implicit/test_mpnc_obstacle_fv.cc b/test/porousmediumflow/mpnc/implicit/test_mpnc_obstacle_fv.cc index 86bdae2d55617673846ec7e4dc7ff17c93c18dcc..6176146751f548feba0b571b553f81d84ae2a111 100644 --- a/test/porousmediumflow/mpnc/implicit/test_mpnc_obstacle_fv.cc +++ b/test/porousmediumflow/mpnc/implicit/test_mpnc_obstacle_fv.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richards/implicit/richardsanalyticalproblem.hh b/test/porousmediumflow/richards/implicit/richardsanalyticalproblem.hh index f0db44035b39111c2020aa55604af4e24f701da4..993db884bd318298afa9d32f9659aa5257f5d427 100644 --- a/test/porousmediumflow/richards/implicit/richardsanalyticalproblem.hh +++ b/test/porousmediumflow/richards/implicit/richardsanalyticalproblem.hh @@ -30,6 +30,8 @@ #include <cmath> #include <dune/geometry/quadraturerules.hh> +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/richards/implicit/richardslensproblem.hh b/test/porousmediumflow/richards/implicit/richardslensproblem.hh index 43b022246425c086267e260407f37e00b2dc8c6c..034d0634c6c4c97f5003586e8d66796fc3281d34 100644 --- a/test/porousmediumflow/richards/implicit/richardslensproblem.hh +++ b/test/porousmediumflow/richards/implicit/richardslensproblem.hh @@ -26,6 +26,8 @@ #ifndef DUMUX_RICHARDS_LENSPROBLEM_HH #define DUMUX_RICHARDS_LENSPROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/problem.hh> @@ -60,7 +62,8 @@ SET_TYPE_PROP(RichardsLensTypeTag, Grid, Dune::YaspGrid<2>); SET_TYPE_PROP(RichardsLensTypeTag, Problem, RichardsLensProblem<TypeTag>); // Set the spatial parameters -SET_TYPE_PROP(RichardsLensTypeTag, SpatialParams, RichardsLensSpatialParams<TypeTag>); +SET_TYPE_PROP(RichardsLensTypeTag, SpatialParams, RichardsLensSpatialParams<typename GET_PROP_TYPE(TypeTag, FVGridGeometry), + typename GET_PROP_TYPE(TypeTag, Scalar)>); } // end namespace Dumux /*! diff --git a/test/porousmediumflow/richards/implicit/richardslensspatialparams.hh b/test/porousmediumflow/richards/implicit/richardslensspatialparams.hh index ac19cf890b8dec2d2e05e9d35291b0699adb5150..87cc492cd838b7c3f9291d783e962d49bbada89d 100644 --- a/test/porousmediumflow/richards/implicit/richardslensspatialparams.hh +++ b/test/porousmediumflow/richards/implicit/richardslensspatialparams.hh @@ -37,31 +37,26 @@ namespace Dumux { * \ingroup ImplicitTestProblems * \brief The spatial parameters for the RichardsLensProblem */ -template<class TypeTag> +template<class FVGridGeometry, class Scalar> class RichardsLensSpatialParams -: public FVSpatialParams<typename GET_PROP_TYPE(TypeTag, FVGridGeometry), - typename GET_PROP_TYPE(TypeTag, Scalar), - RichardsLensSpatialParams<TypeTag>> +: public FVSpatialParams<FVGridGeometry, Scalar, RichardsLensSpatialParams<FVGridGeometry, Scalar>> { - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + using ThisType = RichardsLensSpatialParams<FVGridGeometry, Scalar>; + using ParentType = FVSpatialParams<FVGridGeometry, Scalar, ThisType>; using GridView = typename FVGridGeometry::GridView; - using ParentType = FVSpatialParams<FVGridGeometry, Scalar, RichardsLensSpatialParams<TypeTag>>; - - enum { dimWorld=GridView::dimensionworld }; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - using EffectiveLaw = RegularizedVanGenuchten<Scalar>; + enum { dimWorld = GridView::dimensionworld }; public: - using MaterialLaw = EffToAbsLaw<EffectiveLaw>; + using MaterialLaw = EffToAbsLaw<RegularizedVanGenuchten<Scalar>>; using MaterialLawParams = typename MaterialLaw::Params; // export permeability type using PermeabilityType = Scalar; RichardsLensSpatialParams(std::shared_ptr<const FVGridGeometry> fvGridGeometry) - : ParentType(fvGridGeometry) + : ParentType(fvGridGeometry) { lensLowerLeft_ = {1.0, 2.0}; diff --git a/test/porousmediumflow/richards/implicit/richardsniconductionproblem.hh b/test/porousmediumflow/richards/implicit/richardsniconductionproblem.hh index 4679e2a76c847e5c6665abf68098cbd6cb90a00a..8a7fe6dc066bae1ee9cfec1ecf80b6f95c457b78 100644 --- a/test/porousmediumflow/richards/implicit/richardsniconductionproblem.hh +++ b/test/porousmediumflow/richards/implicit/richardsniconductionproblem.hh @@ -25,7 +25,8 @@ #ifndef DUMUX_RICHARDS_CONDUCTION_PROBLEM_HH #define DUMUX_RICHARDS_CONDUCTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/richards/implicit/richardsniconvectionproblem.hh b/test/porousmediumflow/richards/implicit/richardsniconvectionproblem.hh index c077dc8e02819961fb82ce3041ce5d18e65e5f2c..98491eb70d5ae9fc09c22d6e6aa3f7e2fc9de1ea 100644 --- a/test/porousmediumflow/richards/implicit/richardsniconvectionproblem.hh +++ b/test/porousmediumflow/richards/implicit/richardsniconvectionproblem.hh @@ -26,7 +26,8 @@ #ifndef DUMUX_RICHARDS_CONVECTION_PROBLEM_HH #define DUMUX_RICHARDS_CONVECTION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/richards/implicit/richardsnievaporationproblem.hh b/test/porousmediumflow/richards/implicit/richardsnievaporationproblem.hh index 51ba223a93a2b32d78f71e63b16c1607018c89c4..c4d572cbfda8c8967cc5d630fdd405cb9fe4280c 100644 --- a/test/porousmediumflow/richards/implicit/richardsnievaporationproblem.hh +++ b/test/porousmediumflow/richards/implicit/richardsnievaporationproblem.hh @@ -25,7 +25,8 @@ #ifndef DUMUX_RICHARDS_EVAPORATION_PROBLEM_HH #define DUMUX_RICHARDS_EVAPORATION_PROBLEM_HH -#include <math.h> +#include <cmath> +#include <dune/grid/yaspgrid.hh> #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/richards/implicit/test_ccrichardsanalytical.cc b/test/porousmediumflow/richards/implicit/test_ccrichardsanalytical.cc index 8b9be9df435726b7c1f96153589fcdcd9d7eb885..a39faff519ce811a807d1188b6b5272bdf2e29f9 100644 --- a/test/porousmediumflow/richards/implicit/test_ccrichardsanalytical.cc +++ b/test/porousmediumflow/richards/implicit/test_ccrichardsanalytical.cc @@ -46,6 +46,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc b/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc index 1550ec49da78fe7301c5ce8b9cdbbb6deb171409..d6190f237dea57abc423c42f9c7f817a3c2f016b 100644 --- a/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc +++ b/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc @@ -23,8 +23,6 @@ */ #include <config.h> -#include "richardslensproblem.hh" - #include <ctime> #include <iostream> @@ -46,31 +44,9 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> -/*! - * \brief Provides an interface for customizing error messages associated with - * reading in parameters. - * - * \param progName The name of the program, that was tried to be started. - * \param errorMsg The error message that was issued by the start function. - * Comprises the thing that went wrong and a general help message. - */ -void usage(const char *progName, const std::string &errorMsg) -{ - if (errorMsg.size() > 0) { - std::string errorMessageOut = "\nUsage: "; - errorMessageOut += progName; - errorMessageOut += " [options]\n"; - errorMessageOut += errorMsg; - errorMessageOut += "\n\nThe list of mandatory options for this program is:\n" - "\t-TimeManager.TEnd End of the simulation [s] \n" - "\t-TimeManager.DtInitial Initial timestep size [s] \n" - "\t-Grid.File Name of the file containing the grid \n" - "\t definition in DGF format\n"; - - std::cout << errorMessageOut - << "\n"; - } -} +#include <dumux/io/grid/gridmanager.hh> + +#include "richardslensproblem.hh" //////////////////////// // the main function @@ -90,19 +66,18 @@ int main(int argc, char** argv) try DumuxMessage::print(/*firstCall=*/true); // parse command line arguments and input file - Parameters::init(argc, argv, usage); + Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc b/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc index 82f3c629c1ff7fe3cec09ff145c205a5b7294605..d0fd30addaf62db84650e0d11c38bd12a20cb2c6 100644 --- a/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc +++ b/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc @@ -46,6 +46,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc b/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc index ba18b9ce986dedf404ac039b60b0934e6807aea4..99015535579c703189dc8394b46e25ec4b727571 100644 --- a/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc +++ b/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc @@ -46,6 +46,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richards/implicit/test_richardsnievaporation_fv.cc b/test/porousmediumflow/richards/implicit/test_richardsnievaporation_fv.cc index 3464a371f31613bbdf685ae0bc61f7e8b2c419cb..b2ba91688d93074f014a8cf7e3ad4ca2a016680a 100644 --- a/test/porousmediumflow/richards/implicit/test_richardsnievaporation_fv.cc +++ b/test/porousmediumflow/richards/implicit/test_richardsnievaporation_fv.cc @@ -44,6 +44,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> //////////////////////// // the main function @@ -66,16 +67,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/richardsnc/implicit/richardswelltracerproblem.hh b/test/porousmediumflow/richardsnc/implicit/richardswelltracerproblem.hh index d86975d0d1430f72390ba43bcd6f118856440c26..bff137ae0a9d3bd8700720fdc153054a644f189b 100644 --- a/test/porousmediumflow/richardsnc/implicit/richardswelltracerproblem.hh +++ b/test/porousmediumflow/richardsnc/implicit/richardswelltracerproblem.hh @@ -26,6 +26,8 @@ #ifndef DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH #define DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc index 22decb0f0484c57307e9089684e7a29ae2732523..76d815c63e82b05e2bee644b67e3ac57911b460e 100644 --- a/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc +++ b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc @@ -46,6 +46,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with * reading in parameters. @@ -93,16 +94,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/tracer/1ptracer/1ptestproblem.hh b/test/porousmediumflow/tracer/1ptracer/1ptestproblem.hh index dc40f8b3d76cfc7628df38839919fd5834e45bde..c29f31dc47cc7a98f10719d803964766f179dbc6 100644 --- a/test/porousmediumflow/tracer/1ptracer/1ptestproblem.hh +++ b/test/porousmediumflow/tracer/1ptracer/1ptestproblem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/porousmediumflow/1p/model.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc b/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc index 010fa973806c4bfdd533c387f3d10841f41993ab..605be207521441abfa29c6101ffeb0869d12c5b7 100644 --- a/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc +++ b/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc @@ -44,6 +44,7 @@ #include <dumux/assembly/diffmethod.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> int main(int argc, char** argv) try { @@ -72,16 +73,11 @@ int main(int argc, char** argv) try ///////////////////////////////////////////////////////////////////// // only create the grid once using the 1p type tag - using GridCreator = typename GET_PROP_TYPE(OnePTypeTag, GridCreator); - try { GridCreator::makeGrid(); } - catch (...) { - std::cout << "\n\t -> Creation of the grid failed! <- \n\n"; - throw; - } - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(OnePTypeTag, Grid)> gridManager; + gridManager.init(); //! we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); //////////////////////////////////////////////////////////// // setup & solve 1p problem on this grid diff --git a/test/porousmediumflow/tracer/1ptracer/tracertestproblem.hh b/test/porousmediumflow/tracer/1ptracer/tracertestproblem.hh index 1b8aee0b7a6c5b218750ce46646d7dd0c0c008c6..d60e7ebac3bfa3e3f4257e1ac50a24e6a90deed7 100644 --- a/test/porousmediumflow/tracer/1ptracer/tracertestproblem.hh +++ b/test/porousmediumflow/tracer/1ptracer/tracertestproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_TRACER_TEST_PROBLEM_HH #define DUMUX_TRACER_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/porousmediumflow/tracer/model.hh> #include <dumux/porousmediumflow/problem.hh> diff --git a/test/porousmediumflow/tracer/constvel/test_tracer.cc b/test/porousmediumflow/tracer/constvel/test_tracer.cc index b710725758a67fa11365ef8b161f5635e390f695..fafc94e10eb28c9dd89edc4059f762f59807ad90 100644 --- a/test/porousmediumflow/tracer/constvel/test_tracer.cc +++ b/test/porousmediumflow/tracer/constvel/test_tracer.cc @@ -40,6 +40,7 @@ #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "tracertestproblem.hh" @@ -61,20 +62,19 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - try { GridCreator::makeGrid(); } + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + try { gridManager.init(); } catch (...) { std::cout << "\n\t -> Creation of the grid failed! <- \n\n"; throw; } - GridCreator::loadBalance(); //////////////////////////////////////////////////////////// // setup instationary non-linear problem on this grid //////////////////////////////////////////////////////////// //! we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); //! create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/test/porousmediumflow/tracer/constvel/tracertestproblem.hh b/test/porousmediumflow/tracer/constvel/tracertestproblem.hh index 0d47a990986d7e7a5d57207fa0b49ad949b5db4b..74646019a02bb34ed0842a067fda419e649ed08a 100644 --- a/test/porousmediumflow/tracer/constvel/tracertestproblem.hh +++ b/test/porousmediumflow/tracer/constvel/tracertestproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_TRACER_TEST_PROBLEM_HH #define DUMUX_TRACER_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/discretization/cellcentered/mpfa/properties.hh> diff --git a/test/porousmediumflow/tracer/multicomp/maxwellstefantestproblem.hh b/test/porousmediumflow/tracer/multicomp/maxwellstefantestproblem.hh index a44270018b3002979e551a058102d907088eb753..7fba519f3593ba1311f53bb497adfc6052c54564 100644 --- a/test/porousmediumflow/tracer/multicomp/maxwellstefantestproblem.hh +++ b/test/porousmediumflow/tracer/multicomp/maxwellstefantestproblem.hh @@ -25,6 +25,8 @@ #ifndef DUMUX_MAXWELL_STEFAN_TEST_PROBLEM_HH #define DUMUX_MAXWELL_STEFAN_TEST_PROBLEM_HH +#include <dune/grid/yaspgrid.hh> + #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/box/properties.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> diff --git a/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc b/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc index a03b1a28a8ea0f57010f1c869fe4199256d67a6a..da2bd4a0c1ad4bbec7f05ac7b21ca4f533bc7ca9 100644 --- a/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc +++ b/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc @@ -49,6 +49,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -100,16 +101,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/ex1/exercise1.cc b/tutorial/ex1/exercise1.cc index d6bb2599a084c7f1bad7d919d712ae5984dd3015..3bf3e8d87c4cc32d2f4db34d9ecef6ade0aee790 100644 --- a/tutorial/ex1/exercise1.cc +++ b/tutorial/ex1/exercise1.cc @@ -44,6 +44,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "injection2pproblem.hh" @@ -68,16 +69,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/ex1/exercise1_2p.cc b/tutorial/ex1/exercise1_2p.cc index 7ae3bca427fb0c6c88341a0cd7ef04937b148ea2..558f2d0f3373ed23df1fefbb0af5c296a698484a 100644 --- a/tutorial/ex1/exercise1_2p.cc +++ b/tutorial/ex1/exercise1_2p.cc @@ -44,6 +44,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // The problem file, where setup-specific boundary and initial conditions are defined. #include "injection2pproblem.hh" @@ -69,16 +70,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/ex1/exercise1_2p2c.cc b/tutorial/ex1/exercise1_2p2c.cc index 6f7e515c043a634b3673b4fe554f22a46a8cc3e1..c2b46ea15fcab30a078f85acf0f8d07b122b8209 100644 --- a/tutorial/ex1/exercise1_2p2c.cc +++ b/tutorial/ex1/exercise1_2p2c.cc @@ -44,6 +44,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // The problem file, where setup-specific boundary and initial conditions are defined. #include "injection2p2cproblem.hh" @@ -69,16 +70,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/ex2/exercise2.cc b/tutorial/ex2/exercise2.cc index d031e8753b39eba25ae4979d5cdb563ba534608e..2a7493e6771bb5620efc20f21eb95683485ab42e 100644 --- a/tutorial/ex2/exercise2.cc +++ b/tutorial/ex2/exercise2.cc @@ -45,6 +45,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "injection2p2cproblem.hh" @@ -66,16 +67,15 @@ int main(int argc, char** argv)try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/ex3/exercise3.cc b/tutorial/ex3/exercise3.cc index 4669ea7f18988da5a659b439437820b1aff4f84c..acfc230b5ff53cb4de42a955a3bdba04799d5a1e 100644 --- a/tutorial/ex3/exercise3.cc +++ b/tutorial/ex3/exercise3.cc @@ -50,6 +50,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> /*! * \brief Provides an interface for customizing error messages associated with @@ -105,16 +106,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv, usage); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/solution/ex1/exercise1_2p2c.cc b/tutorial/solution/ex1/exercise1_2p2c.cc index 779a668a6196d5518f716d04dfd7fb43d6daa0df..55496aad06bae940e473fa8ad013a27d23be5444 100644 --- a/tutorial/solution/ex1/exercise1_2p2c.cc +++ b/tutorial/solution/ex1/exercise1_2p2c.cc @@ -44,6 +44,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "injection2p2cproblem.hh" @@ -68,16 +69,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/solution/ex1/exercise1_2pni_solution.cc b/tutorial/solution/ex1/exercise1_2pni_solution.cc index d8e6af7ba5a46a78a29393954872acc65cd5d10e..68f9d3b50ffa07c4aedf2e9843174da557e1544d 100644 --- a/tutorial/solution/ex1/exercise1_2pni_solution.cc +++ b/tutorial/solution/ex1/exercise1_2pni_solution.cc @@ -44,6 +44,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> // The problem file, where setup-specific boundary and initial conditions are defined. #include "injection2pniproblem.hh" @@ -69,16 +70,15 @@ int main(int argc, char** argv) try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); diff --git a/tutorial/solution/ex2/exercise2_solution.cc b/tutorial/solution/ex2/exercise2_solution.cc index d031e8753b39eba25ae4979d5cdb563ba534608e..2a7493e6771bb5620efc20f21eb95683485ab42e 100644 --- a/tutorial/solution/ex2/exercise2_solution.cc +++ b/tutorial/solution/ex2/exercise2_solution.cc @@ -45,6 +45,7 @@ #include <dumux/discretization/methods.hh> #include <dumux/io/vtkoutputmodule.hh> +#include <dumux/io/grid/gridmanager.hh> #include "injection2p2cproblem.hh" @@ -66,16 +67,15 @@ int main(int argc, char** argv)try Parameters::init(argc, argv); // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); + GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager; + gridManager.init(); //////////////////////////////////////////////////////////// // run instationary non-linear problem on this grid //////////////////////////////////////////////////////////// // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); + const auto& leafGridView = gridManager.grid().leafGridView(); // create the finite volume grid geometry using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);