refactoring: rename GridCreator to GridManager

because "manager" sounds less religious than "creator" and the
GridCreators did all kinds of other stuff besides creating the grid.

this patch also gets rid of the static function inside these classes,
which should make them easier to understand...
This commit is contained in:
Andreas Lauser 2014-04-24 12:24:51 +02:00
parent 4c7a2d2ca0
commit 87f30dad6f
11 changed files with 123 additions and 148 deletions

View File

@ -114,10 +114,10 @@ relevant properties for the \eWoms property system:
used is defined in line \ref{tutorial1:set-grid} -- in this case
it is \texttt{Dune::YaspGrid}.
\item Since \Dune does not provide a uniform mechanism to create or
load grids, \eWoms features the concept of grid creators. In this
case, the generic \texttt{CubeGridCreator} is used. This grid
creator constructs a structured rectangular grid with a specified
size and resolution. For this grid creator, the physical domain of
load grids, \eWoms features the concept of grid managers. In this
case, the generic \texttt{CubeGridManager} is used. This grid
manager constructs a structured rectangular grid with a specified
size and resolution. For this grid manager, the physical domain of
the grid is specified via the run-time parameters
\texttt{DomainSizeX} and \texttt{DomainSizeY} and its resolution by
\texttt{CellsX} and \texttt{CellsY}. These parameters can be
@ -328,15 +328,15 @@ even not at all.
not want to go through the trouble of installing this grid manager,
please skip this exercise.
Change the grid creator used by the problem to
\texttt{SimplexGridCreator<TypeTag>} and the type of the grid to
\texttt{Dune::ALUSimplexGrid<2, 2>}. The grid creator is specified
on line \ref{tutorial1:set-gridcreator}, whil the type of the
Change the grid manager used by the problem to
\texttt{SimplexGridManager<TypeTag>} and the type of the grid to
\texttt{Dune::ALUSimplexGrid<2, 2>}. The grid manager is specified
on line \ref{tutorial1:set-grid-manager}, while the type of the
\Dune grid manager is set on line
\ref{tutorial1:set-grid}. You also need to change the include
statement of the grid creator from \texttt{cubegridcreator.hh} to
\texttt{simplexgridcreator.hh} on line
\ref{tutorial1:include-grid-creator} and the one for the grid
statement of the grid manager from \texttt{cubegridmanager.hh} to
\texttt{simplexgridmanager.hh} on line
\ref{tutorial1:include-grid-manager} and the one for the grid
manager from \texttt{dune/grid/yaspgrid.hh} to
\texttt{dune/grid/alugrid.hh} on line \ref{tutorial1:include-grid-manager}.

View File

@ -25,7 +25,7 @@
#define EWOMS_POWER_INJECTION_PROBLEM_HH
#include <ewoms/models/ncp/ncpproperties.hh>
#include <ewoms/io/cubegridcreator.hh>
#include <ewoms/io/cubegridmanager.hh>
#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
@ -53,8 +53,8 @@ NEW_TYPE_TAG(DiffusionBaseProblem);
// Set the grid implementation to be used
SET_TYPE_PROP(DiffusionBaseProblem, Grid, Dune::YaspGrid</*dim=*/1>);
// set the GridCreator property
SET_TYPE_PROP(DiffusionBaseProblem, GridCreator, Ewoms::CubeGridCreator<TypeTag>);
// set the GridManager property
SET_TYPE_PROP(DiffusionBaseProblem, GridManager, Ewoms::CubeGridManager<TypeTag>);
// Set the problem property
SET_TYPE_PROP(DiffusionBaseProblem, Problem, Ewoms::DiffusionProblem<TypeTag>);

View File

@ -18,13 +18,13 @@
*/
/*!
* \file
* \copydoc Ewoms::EclGridCreator
* \copydoc Ewoms::EclGridManager
*/
#ifndef EWOMS_ECL_GRID_CREATOR_HH
#define EWOMS_ECL_GRID_CREATOR_HH
#ifndef EWOMS_ECL_GRID_MANAGER_HH
#define EWOMS_ECL_GRID_MANAGER_HH
#include <ewoms/parallel/mpihelper.hh>
#include <ewoms/io/basegridcreator.hh>
#include <ewoms/io/basegridmanager.hh>
#include <opm/core/utility/PropertySystem.hpp>
#include <ewoms/common/parametersystem.hh>
@ -45,23 +45,23 @@ template <class TypeTag>
class EclProblem;
template <class TypeTag>
class EclGridCreator;
class EclGridManager;
} // namespace Ewoms
namespace Opm {
namespace Properties {
NEW_TYPE_TAG(EclGridCreator);
NEW_TYPE_TAG(EclGridManager);
// declare the properties required by the for the ecl grid creator
// declare the properties required by the for the ecl grid manager
NEW_PROP_TAG(Grid);
NEW_PROP_TAG(Scalar);
NEW_PROP_TAG(EclipseDeckFileName);
SET_STRING_PROP(EclGridCreator, EclipseDeckFileName, "grids/ecl.DATA");
SET_STRING_PROP(EclGridManager, EclipseDeckFileName, "grids/ecl.DATA");
// set the Grid and GridCreator properties
SET_TYPE_PROP(EclGridCreator, Grid, Dune::CpGrid);
SET_TYPE_PROP(EclGridCreator, GridCreator, Ewoms::EclGridCreator<TypeTag>);
// set the Grid and GridManager properties
SET_TYPE_PROP(EclGridManager, Grid, Dune::CpGrid);
SET_TYPE_PROP(EclGridManager, GridManager, Ewoms::EclGridManager<TypeTag>);
}} // namespace Opm, Properties
namespace Ewoms {
@ -71,20 +71,20 @@ namespace Ewoms {
* \brief Helper class for grid instantiation of the ecl problem.
*/
template <class TypeTag>
class EclGridCreator : public BaseGridCreator<TypeTag>
class EclGridManager : public BaseGridManager<TypeTag>
{
typedef BaseGridManager<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public:
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
typedef std::shared_ptr<Grid> GridPointer;
private:
typedef std::shared_ptr<Grid> GridPointer;
typedef std::shared_ptr<const Grid> GridConstPointer;
static const int dim = Grid::dimension;
public:
/*!
* \brief Register all run-time parameters for the grid creator.
* \brief Register all run-time parameters for the grid manager.
*/
static void registerParameters()
{
@ -95,7 +95,11 @@ public:
/*!
* \brief Create the grid for the ecl problem
*/
static void makeGrid()
/*!
* \brief Create the grid for the lens problem
*/
EclGridManager(Simulator &simulator)
: ParentType(simulator)
{
std::string fileName = EWOMS_GET_PARAM(TypeTag, std::string, EclipseDeckFileName);
@ -112,37 +116,26 @@ public:
/*isPeriodic=*/false,
/*flipNormals=*/false,
/*clipZ=*/false);
this->finalizeInit_();
}
/*!
* \brief Return a reference to the grid.
* \brief Return a pointer to the grid.
*/
static GridPointer gridPointer()
GridPointer gridPointer()
{ return grid_; }
/*!
* \brief Distribute the grid (and attached data) over all
* processes.
* \brief Return a pointer to the grid.
*/
static void loadBalance()
{ grid_->loadBalance(); }
/*!
* \brief Destroy the grid
*
* This is required to guarantee that the grid is deleted before
* MPI_Comm_free is called.
*/
static void deleteGrid()
{
grid_.reset();
deck_.reset();
}
GridConstPointer gridPointer() const
{ return grid_; }
/*!
* \brief Return a pointer to the parsed Eclipse deck
*/
static Opm::DeckConstPtr deck()
Opm::DeckConstPtr deck() const
{ return deck_; }
/*!
@ -153,24 +146,15 @@ public:
* EGRID files (which tends to be difficult with a plain
* Dune::CpGrid)
*/
static Opm::EclipseGridConstPtr eclipseGrid()
Opm::EclipseGridConstPtr eclipseGrid() const
{ return eclipseGrid_; }
private:
static GridPointer grid_;
static Opm::DeckConstPtr deck_;
static Opm::EclipseGridConstPtr eclipseGrid_;
GridPointer grid_;
Opm::DeckConstPtr deck_;
Opm::EclipseGridConstPtr eclipseGrid_;
};
template <class TypeTag>
typename EclGridCreator<TypeTag>::GridPointer EclGridCreator<TypeTag>::grid_;
template <class TypeTag>
Opm::DeckConstPtr EclGridCreator<TypeTag>::deck_;
template <class TypeTag>
Opm::EclipseGridConstPtr EclGridCreator<TypeTag>::eclipseGrid_;
} // namespace Ewoms
#endif

View File

@ -18,13 +18,13 @@
*/
/*!
* \file
* \copydoc Ewoms::FingerGridCreator
* \copydoc Ewoms::FingerGridManager
*/
#ifndef EWOMS_FINGER_GRID_CREATOR_HH
#define EWOMS_FINGER_GRID_CREATOR_HH
#ifndef EWOMS_FINGER_GRID_MANAGER_HH
#define EWOMS_FINGER_GRID_MANAGER_HH
#include <ewoms/parallel/mpihelper.hh>
#include <ewoms/io/basegridcreator.hh>
#include <ewoms/io/basegridmanager.hh>
#include <opm/core/utility/PropertySystem.hpp>
#include <ewoms/common/parametersystem.hh>
@ -34,13 +34,13 @@
#include <vector>
// some hacky defines for the grid creator
// some hacky defines for the grid manager
#define FINGER_DIM 2
#define FINGER_CUBES 1
namespace Ewoms {
template <class TypeTag>
class FingerGridCreator;
class FingerGridManager;
template <class TypeTag>
class FingerProblem;
@ -48,8 +48,8 @@ class FingerProblem;
namespace Opm {
namespace Properties {
// declare the properties required by the for the finger grid creator
NEW_TYPE_TAG(FingerGridCreator);
// declare the properties required by the for the finger grid manager
NEW_TYPE_TAG(FingerGridManager);
NEW_PROP_TAG(Grid);
NEW_PROP_TAG(Scalar);
@ -64,8 +64,8 @@ NEW_PROP_TAG(CellsZ);
NEW_PROP_TAG(GridGlobalRefinements);
SET_TYPE_PROP(FingerGridCreator, Grid, Dune::ALUGrid<FINGER_DIM, FINGER_DIM, Dune::cube, Dune::nonconforming>);
SET_TYPE_PROP(FingerGridCreator, GridCreator, Ewoms::FingerGridCreator<TypeTag>);
SET_TYPE_PROP(FingerGridManager, Grid, Dune::ALUGrid<FINGER_DIM, FINGER_DIM, Dune::cube, Dune::nonconforming>);
SET_TYPE_PROP(FingerGridManager, GridManager, Ewoms::FingerGridManager<TypeTag>);
}} // namespace Opm, Properties
@ -74,17 +74,18 @@ namespace Ewoms {
* \brief Helper class for grid instantiation of the finger problem.
*/
template <class TypeTag>
class FingerGridCreator : public BaseGridCreator<TypeTag>
class FingerGridManager : public BaseGridManager<TypeTag>
{
typedef BaseGridManager<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
enum { dim = FINGER_DIM };
public:
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
/*!
* \brief Register all run-time parameters for the grid creator.
* \brief Register all run-time parameters for the grid manager.
*/
static void registerParameters()
{
@ -112,7 +113,8 @@ public:
/*!
* \brief Create the grid for the finger problem
*/
static void makeGrid()
FingerGridManager(Simulator &simulator)
: ParentType(simulator)
{
grid_ = new Grid;
@ -268,33 +270,27 @@ public:
}
/*!
* \brief Return a reference to the grid.
* \brief Destroy the grid.
*/
static Grid* gridPointer()
~FingerGridManager()
{ delete grid_; }
/*!
* \brief Return a pointer to the grid.
*/
Grid* gridPointer()
{ return grid_; }
/*!
* \brief Distribute the grid (and attached data) over all
* processes.
* \brief Return a pointer to the grid.
*/
static void loadBalance()
{ grid_->loadBalance(); }
/*!
* \brief Destroy the grid.
*
* This is required to guarantee that the grid is deleted before
* MPI_Comm_free is called.
*/
static void deleteGrid()
{ delete grid_; }
const Grid* gridPointer() const
{ return grid_; }
private:
static Grid *grid_;
Grid *grid_;
};
template <class TypeTag>
typename FingerGridCreator<TypeTag>::Grid *FingerGridCreator<TypeTag>::grid_;
} // namespace Ewoms
#endif

View File

@ -24,7 +24,7 @@
#ifndef EWOMS_FINGER_PROBLEM_HH
#define EWOMS_FINGER_PROBLEM_HH
#include "fingergridcreator.hh"
#include "fingergridmanager.hh"
#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
@ -53,7 +53,7 @@ class FingerProblem;
namespace Opm {
namespace Properties {
NEW_TYPE_TAG(FingerBaseProblem, INHERITS_FROM(FingerGridCreator));
NEW_TYPE_TAG(FingerBaseProblem, INHERITS_FROM(FingerGridManager));
// declare the properties used by the finger problem
NEW_PROP_TAG(InitialWaterSaturation);

View File

@ -37,7 +37,7 @@
#include <opm/material/fluidsystems/2pImmiscibleFluidSystem.hpp>
#include <opm/material/components/SimpleH2O.hpp>
#include <opm/material/components/Dnapl.hpp>
#include <ewoms/io/artgridcreator.hh>
#include <ewoms/io/artgridmanager.hh>
#include <ewoms/models/discretefracture/discretefracturemodel.hh>
@ -59,8 +59,8 @@ namespace Properties {
// Create a type tag for the problem
NEW_TYPE_TAG(FractureProblem, INHERITS_FROM(DiscreteFractureModel));
// Set the GridCreator property
SET_TYPE_PROP(FractureProblem, GridCreator, Ewoms::ArtGridCreator<TypeTag>);
// Set the GridManager property
SET_TYPE_PROP(FractureProblem, GridManager, Ewoms::ArtGridManager<TypeTag>);
// Set the grid type
SET_TYPE_PROP(
@ -362,7 +362,7 @@ public:
* \brief Returns the object representating the fracture topology.
*/
const FractureMapper &fractureMapper() const
{ return GET_PROP_TYPE(TypeTag, GridCreator)::fractureMapper(); }
{ return this->simulator().gridManager().fractureMapper(); }
/*!
* \brief Returns the width of the fracture.

View File

@ -18,13 +18,13 @@
*/
/*!
* \file
* \copydoc Ewoms::LensGridCreator
* \copydoc Ewoms::LensGridManager
*/
#ifndef EWOMS_LENS_GRID_CREATOR_HH
#define EWOMS_LENS_GRID_CREATOR_HH
#ifndef EWOMS_LENS_GRID_MANAGER_HH
#define EWOMS_LENS_GRID_MANAGER_HH
#include <ewoms/parallel/mpihelper.hh>
#include <ewoms/io/basegridcreator.hh>
#include <ewoms/io/basegridmanager.hh>
#include <opm/core/utility/PropertySystem.hpp>
#include <ewoms/common/parametersystem.hh>
@ -39,14 +39,14 @@ template <class TypeTag>
class LensProblem;
template <class TypeTag>
class LensGridCreator;
class LensGridManager;
} // namespace Ewoms
namespace Opm {
namespace Properties {
NEW_TYPE_TAG(LensGridCreator);
NEW_TYPE_TAG(LensGridManager);
// declare the properties required by the for the lens grid creator
// declare the properties required by the for the lens grid manager
NEW_PROP_TAG(Grid);
NEW_PROP_TAG(Scalar);
@ -60,9 +60,9 @@ NEW_PROP_TAG(CellsZ);
NEW_PROP_TAG(GridGlobalRefinements);
// set the Grid and GridCreator properties
SET_TYPE_PROP(LensGridCreator, Grid, Dune::YaspGrid<2>);
SET_TYPE_PROP(LensGridCreator, GridCreator, Ewoms::LensGridCreator<TypeTag>);
// set the Grid and GridManager properties
SET_TYPE_PROP(LensGridManager, Grid, Dune::YaspGrid<2>);
SET_TYPE_PROP(LensGridManager, GridManager, Ewoms::LensGridManager<TypeTag>);
}} // namespace Opm, Properties
namespace Ewoms {
@ -72,19 +72,18 @@ namespace Ewoms {
* \brief Helper class for grid instantiation of the lens problem.
*/
template <class TypeTag>
class LensGridCreator : public BaseGridCreator<TypeTag>
class LensGridManager : public BaseGridManager<TypeTag>
{
typedef BaseGridManager<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public:
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
private:
static const int dim = Grid::dimension;
public:
/*!
* \brief Register all run-time parameters for the grid creator.
* \brief Register all run-time parameters for the grid manager.
*/
static void registerParameters()
{
@ -112,7 +111,8 @@ public:
/*!
* \brief Create the grid for the lens problem
*/
static void makeGrid()
LensGridManager(Simulator &simulator)
: ParentType(simulator)
{
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
std::bitset<dim> isPeriodic(false);
@ -149,37 +149,32 @@ public:
/*numCells=*/cellRes, isPeriodic,
/*overlap=*/1);
grid_->globalRefine(numRefinements);
this->finalizeInit_();
}
/*!
* \brief Return a reference to the grid.
* \brief Destroy the grid
*/
static Grid* gridPointer()
~LensGridManager()
{ delete grid_; }
/*!
* \brief Return a pointer to the grid object.
*/
Grid* gridPointer()
{ return grid_; }
/*!
* \brief Distribute the grid (and attached data) over all
* processes.
* \brief Return a constant pointer to the grid object.
*/
static void loadBalance()
{ grid_->loadBalance(); }
/*!
* \brief Destroy the grid
*
* This is required to guarantee that the grid is deleted before
* MPI_Comm_free is called.
*/
static void deleteGrid()
{ delete grid_; }
const Grid* gridPointer() const
{ return grid_; }
private:
static Grid *grid_;
Grid *grid_;
};
template <class TypeTag>
typename LensGridCreator<TypeTag>::Grid *LensGridCreator<TypeTag>::grid_;
} // namespace Ewoms
#endif

View File

@ -24,7 +24,7 @@
#ifndef EWOMS_LENS_PROBLEM_HH
#define EWOMS_LENS_PROBLEM_HH
#include "lensgridcreator.hh"
#include "lensgridmanager.hh"
#include <ewoms/models/immiscible/immiscibleproperties.hh>
#include <ewoms/linear/parallelamgbackend.hh>
@ -53,7 +53,7 @@ class LensProblem;
namespace Opm {
namespace Properties {
NEW_TYPE_TAG(LensBaseProblem, INHERITS_FROM(LensGridCreator));
NEW_TYPE_TAG(LensBaseProblem, INHERITS_FROM(LensGridManager));
// declare the properties specific for the lens problem
NEW_PROP_TAG(LensLowerLeftX);

View File

@ -34,7 +34,7 @@
#include <opm/material/components/SimpleH2O.hpp>
#include <opm/material/components/Air.hpp>
#include <ewoms/models/immiscible/immisciblemodel.hh>
#include <ewoms/io/cubegridcreator.hh>
#include <ewoms/io/cubegridmanager.hh>
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
@ -57,9 +57,9 @@ NEW_TYPE_TAG(PowerInjectionBaseProblem);
// Set the grid implementation to be used
SET_TYPE_PROP(PowerInjectionBaseProblem, Grid, Dune::YaspGrid</*dim=*/1>);
// set the GridCreator property
SET_TYPE_PROP(PowerInjectionBaseProblem, GridCreator,
Ewoms::CubeGridCreator<TypeTag>);
// set the GridManager property
SET_TYPE_PROP(PowerInjectionBaseProblem, GridManager,
Ewoms::CubeGridManager<TypeTag>);
// Set the problem property
SET_TYPE_PROP(PowerInjectionBaseProblem, Problem,

View File

@ -24,7 +24,7 @@
#define EWOMS_STOKES_NI_TEST_PROBLEM_HH
#include <ewoms/models/stokes/stokesmodel.hh>
#include <ewoms/io/simplexgridcreator.hh>
#include <ewoms/io/simplexgridmanager.hh>
#include <opm/material/fluidsystems/H2OAirFluidSystem.hpp>
#include <dune/grid/yaspgrid.hh>

View File

@ -43,7 +43,7 @@
// For the DUNE grid
#include <dune/grid/yaspgrid.hh> /*@\label{tutorial1:include-grid-manager}@*/
#include <ewoms/io/cubegridcreator.hh> /*@\label{tutorial1:include-grid-creator}@*/
#include <ewoms/io/cubegridmanager.hh> /*@\label{tutorial1:include-grid-manager}@*/
// For Dune::FieldMatrix
#include <dune/common/fmatrix.hh>
@ -68,9 +68,9 @@ SET_TAG_PROP(Tutorial1Problem, SpatialDiscretizationSplice,
SET_TYPE_PROP(Tutorial1Problem, Problem,
Ewoms::Tutorial1Problem<TypeTag>); /*@\label{tutorial1:set-problem}@*/
// Set grid and the grid creator to be used
// Set grid and the grid manager to be used
SET_TYPE_PROP(Tutorial1Problem, Grid, Dune::YaspGrid</*dim=*/2>); /*@\label{tutorial1:set-grid}@*/
SET_TYPE_PROP(Tutorial1Problem, GridCreator, Ewoms::CubeGridCreator<TypeTag>); /*@\label{tutorial1:set-gridcreator}@*/
SET_TYPE_PROP(Tutorial1Problem, GridManager, Ewoms::CubeGridManager<TypeTag>); /*@\label{tutorial1:set-grid-manager}@*/
// Set the wetting phase /*@\label{tutorial1:2p-system-start}@*/
SET_TYPE_PROP(Tutorial1Problem,