LensProblem and FingerProblem: use StructuredGridManager.

This commit is contained in:
Robert Kloefkorn 2016-01-07 15:59:31 -07:00
parent 9dd0ebff6b
commit c10d4905f7
4 changed files with 37 additions and 220 deletions

View File

@ -1,190 +0,0 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright (C) 2012-2013 by Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM 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.
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
* \copydoc Ewoms::FingerGridManager
*/
#ifndef EWOMS_FINGER_GRID_MANAGER_HH
#define EWOMS_FINGER_GRID_MANAGER_HH
#include <ewoms/io/basegridmanager.hh>
#include <ewoms/common/propertysystem.hh>
#include <ewoms/common/parametersystem.hh>
#if HAVE_DUNE_ALUGRID
// we cannot use SFC reordering since it messes up the test case logic
#define DISABLE_ALUGRID_SFC_ORDERING
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/dgf.hh>
#else
#include <dune/grid/alugrid.hh>
#endif
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
#include <dune/common/fvector.hh>
#include <dune/common/version.hh>
#include <vector>
#include <memory>
// some hacky defines for the grid manager
#define FINGER_DIM 2
#define FINGER_CUBES 1
namespace Ewoms {
template <class TypeTag>
class FingerGridManager;
template <class TypeTag>
class FingerProblem;
namespace Properties {
// declare the properties required by the for the finger grid manager
NEW_TYPE_TAG(FingerGridManager);
NEW_PROP_TAG(Grid);
NEW_PROP_TAG(Scalar);
NEW_PROP_TAG(DomainSizeX);
NEW_PROP_TAG(DomainSizeY);
NEW_PROP_TAG(DomainSizeZ);
NEW_PROP_TAG(CellsX);
NEW_PROP_TAG(CellsY);
NEW_PROP_TAG(CellsZ);
NEW_PROP_TAG(GridGlobalRefinements);
#if HAVE_DUNE_ALUGRID
SET_TYPE_PROP(FingerGridManager, Grid, Dune::ALUGrid<FINGER_DIM, FINGER_DIM, Dune::cube, Dune::nonconforming>);
#else
SET_TYPE_PROP(FingerGridManager, Grid, Dune::YaspGrid<FINGER_DIM> );
#endif
SET_TYPE_PROP(FingerGridManager, GridManager, Ewoms::FingerGridManager<TypeTag>);
} // namespace Properties
/*!
* \brief Helper class for grid instantiation of the finger problem.
*/
template <class 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;
typedef std::unique_ptr<Grid> GridPointer;
enum { dim = FINGER_DIM };
public:
/*!
* \brief Register all run-time parameters for the grid manager.
*/
static void registerParameters()
{
EWOMS_REGISTER_PARAM(TypeTag, unsigned, GridGlobalRefinements,
"The number of global refinements of the grid "
"executed after it was loaded");
EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeX,
"The size of the domain in x direction");
EWOMS_REGISTER_PARAM(TypeTag, int, CellsX,
"The number of intervalls in x direction");
if (dim > 1) {
EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeY,
"The size of the domain in y direction");
EWOMS_REGISTER_PARAM(TypeTag, int, CellsY,
"The number of intervalls in y direction");
}
if (dim > 2) {
EWOMS_REGISTER_PARAM(TypeTag, Scalar, DomainSizeZ,
"The size of the domain in z direction");
EWOMS_REGISTER_PARAM(TypeTag, int, CellsZ,
"The number of intervalls in z direction");
}
}
/*!
* \brief Create the grid for the finger problem
*/
FingerGridManager(Simulator &simulator)
: ParentType(simulator)
{
Dune::FieldVector<int, dim> cellRes;
Dune::FieldVector<Scalar, dim> upperRight;
Dune::FieldVector<Scalar, dim> lowerLeft;
lowerLeft = 0.0;
upperRight[0] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeX);
upperRight[1] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeY);
cellRes[0] = EWOMS_GET_PARAM(TypeTag, int, CellsX);
cellRes[1] = EWOMS_GET_PARAM(TypeTag, int, CellsY);
if (dim == 3) {
upperRight[2] = EWOMS_GET_PARAM(TypeTag, Scalar, DomainSizeZ);
cellRes[2] = EWOMS_GET_PARAM(TypeTag, int, CellsZ);
}
// create a DGF input stream containing an interval block
std::stringstream dgfFile;
dgfFile << "DGF" << std::endl;
dgfFile << "Interval" << std::endl;
dgfFile << lowerLeft << std::endl;
dgfFile << upperRight << std::endl;
dgfFile << cellRes << std::endl;
dgfFile << "#" << std::endl;
dgfFile << "GridParameter" << std::endl;
dgfFile << "overlap 1" << std::endl;
dgfFile << "#" << std::endl;
dgfFile << "Simplex" << std::endl;
dgfFile << "#" << std::endl;
gridPtr_.reset( Dune::GridPtr< Grid >(dgfFile).release() );
unsigned numRefinments = EWOMS_GET_PARAM(TypeTag, unsigned, GridGlobalRefinements);
gridPtr_->globalRefine(numRefinments);
this->finalizeInit_();
}
/*!
* \brief Return a reference to the grid.
*/
Grid& grid()
{ return *gridPtr_; }
/*!
* \brief Return a reference to the grid.
*/
const Grid& grid() const
{ return *gridPtr_; }
private:
GridPointer gridPtr_;
};
} // namespace Ewoms
#endif

View File

@ -26,7 +26,10 @@
#ifndef EWOMS_FINGER_PROBLEM_HH
#define EWOMS_FINGER_PROBLEM_HH
#include "fingergridmanager.hh"
// uncomment to run problem in 3d
// #define GRIDDIM 3
#include "structuredgridmanager.hh"
#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
@ -55,7 +58,7 @@ template <class TypeTag>
class FingerProblem;
namespace Properties {
NEW_TYPE_TAG(FingerBaseProblem, INHERITS_FROM(FingerGridManager));
NEW_TYPE_TAG(FingerBaseProblem, INHERITS_FROM(StructuredGridManager));
// declare the properties used by the finger problem
NEW_PROP_TAG(InitialWaterSaturation);

View File

@ -26,7 +26,7 @@
#ifndef EWOMS_LENS_PROBLEM_HH
#define EWOMS_LENS_PROBLEM_HH
#include "lensgridmanager.hh"
#include "structuredgridmanager.hh"
#include <ewoms/models/immiscible/immiscibleproperties.hh>
@ -39,12 +39,6 @@
#include <opm/material/components/SimpleH2O.hpp>
#include <opm/material/components/Dnapl.hpp>
//#define LENS_USE_ALUGRID 1
#if LENS_USE_ALUGRID
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/dgf.hh>
#endif
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
@ -58,11 +52,7 @@ template <class TypeTag>
class LensProblem;
namespace Properties {
#if LENS_USE_ALUGRID
NEW_TYPE_TAG(LensBaseProblem);
#else
NEW_TYPE_TAG(LensBaseProblem, INHERITS_FROM(LensGridManager));
#endif
NEW_TYPE_TAG(LensBaseProblem, INHERITS_FROM(StructuredGridManager));
// declare the properties specific for the lens problem
NEW_PROP_TAG(LensLowerLeftX);
@ -95,10 +85,6 @@ public:
typedef Opm::LiquidPhase<Scalar, Opm::DNAPL<Scalar> > type;
};
#if LENS_USE_ALUGRID
SET_TYPE_PROP(LensBaseProblem, Grid, Dune::ALUGrid< 2, 2, Dune::cube, Dune::nonconforming > );
#endif
// Set the material Law
SET_PROP(LensBaseProblem, MaterialLaw)
{

View File

@ -2,6 +2,7 @@
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright (C) 2012-2013 by Andreas Lauser
Copyright (C) 2016 IRIS AS
This file is part of the Open Porous Media project (OPM).
@ -20,10 +21,10 @@
*/
/*!
* \file
* \copydoc Ewoms::LensGridManager
* \copydoc Ewoms::StructuredGridManager
*/
#ifndef EWOMS_LENS_GRID_MANAGER_HH
#define EWOMS_LENS_GRID_MANAGER_HH
#ifndef EWOMS_STRUCTURED_GRID_MANAGER_HH
#define EWOMS_STRUCTURED_GRID_MANAGER_HH
#include <ewoms/io/basegridmanager.hh>
#include <ewoms/common/propertysystem.hh>
@ -32,6 +33,12 @@
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
//#define TESTS_USE_ALUGRID 1
#if TESTS_USE_ALUGRID
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/dgf.hh>
#endif
#include <dune/common/fvector.hh>
#include <dune/common/version.hh>
@ -39,14 +46,12 @@
#include <memory>
namespace Ewoms {
template <class TypeTag>
class LensProblem;
template <class TypeTag>
class LensGridManager;
class StructuredGridManager;
namespace Properties {
NEW_TYPE_TAG(LensGridManager);
NEW_TYPE_TAG(StructuredGridManager);
// declare the properties required by the for the lens grid manager
NEW_PROP_TAG(Grid);
@ -62,10 +67,21 @@ NEW_PROP_TAG(CellsZ);
NEW_PROP_TAG(GridGlobalRefinements);
// set the Grid and GridManager properties
SET_TYPE_PROP(LensGridManager, Grid, Dune::YaspGrid<2>);
// GRIDDIM is only set by the finger problem
#ifndef GRIDDIM
static const int dim = 2;
#else
static const int dim = GRIDDIM;
#endif
SET_TYPE_PROP(LensGridManager, GridManager, Ewoms::LensGridManager<TypeTag>);
// set the Grid and GridManager properties
#if TESTS_USE_ALUGRID
SET_TYPE_PROP(StructuredGridManager, Grid, Dune::ALUGrid< dim, dim, Dune::cube, Dune::nonconforming >);
#else
SET_TYPE_PROP(StructuredGridManager, Grid, Dune::YaspGrid< dim >);
#endif
SET_TYPE_PROP(StructuredGridManager, GridManager, Ewoms::StructuredGridManager<TypeTag>);
} // namespace Properties
/*!
@ -74,7 +90,7 @@ SET_TYPE_PROP(LensGridManager, GridManager, Ewoms::LensGridManager<TypeTag>);
* \brief Helper class for grid instantiation of the lens problem.
*/
template <class TypeTag>
class LensGridManager : public BaseGridManager<TypeTag>
class StructuredGridManager : public BaseGridManager<TypeTag>
{
typedef BaseGridManager<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
@ -115,7 +131,7 @@ public:
/*!
* \brief Create the grid for the lens problem
*/
LensGridManager(Simulator &simulator)
StructuredGridManager(Simulator &simulator)
: ParentType(simulator)
{
Dune::FieldVector<int, dim> cellRes;
@ -144,6 +160,8 @@ public:
dgffile << "GridParameter" << std::endl;
dgffile << "overlap 1" << std::endl;
dgffile << "#" << std::endl;
dgffile << "Simplex" << std::endl;
dgffile << "#" << std::endl;
// use DGF parser to create a grid from interval block
gridPtr_.reset( Dune::GridPtr< Grid >( dgffile ).release() );