Added GridManager class.
This commit is contained in:
parent
d7d2c3cb2f
commit
13e4e0fb15
@ -52,6 +52,7 @@ opm/core/utility/cpgpreprocess/uniquepoints.c \
|
||||
opm/core/utility/StopWatch.cpp \
|
||||
opm/core/utility/newwells.c \
|
||||
opm/core/utility/writeVtkData.cpp \
|
||||
opm/core/GridManager.cpp \
|
||||
opm/core/linalg/sparse_sys.c \
|
||||
opm/core/pressure/cfsh.c \
|
||||
opm/core/pressure/flow_bc.c \
|
||||
@ -137,7 +138,6 @@ opm/core/utility/Units.hpp \
|
||||
opm/core/utility/buildUniformMonotoneTable.hpp \
|
||||
opm/core/utility/linInt.hpp \
|
||||
opm/core/utility/linearInterpolation.hpp \
|
||||
opm/core/newwells.h \
|
||||
opm/core/utility/cpgpreprocess/readvector.hpp \
|
||||
opm/core/utility/cpgpreprocess/uniquepoints.h \
|
||||
opm/core/utility/cpgpreprocess/preprocess.h \
|
||||
@ -148,11 +148,13 @@ opm/core/utility/cpgpreprocess/facetopology.h \
|
||||
opm/core/utility/cpgpreprocess/grdecl.h \
|
||||
opm/core/utility/cart_grid.h \
|
||||
opm/core/utility/writeVtkData.hpp \
|
||||
opm/core/well.h \
|
||||
opm/core/linalg/sparse_sys.h \
|
||||
opm/core/linalg/blas_lapack.h \
|
||||
opm/core/grid.h \
|
||||
opm/core/well.h \
|
||||
opm/core/newwells.h \
|
||||
opm/core/GridAdapter.hpp \
|
||||
opm/core/GridManager.hpp \
|
||||
opm/core/pressure/fsh.h \
|
||||
opm/core/pressure/HybridPressureSolver.hpp \
|
||||
opm/core/pressure/TPFAPressureSolver.hpp \
|
||||
|
114
opm/core/GridManager.cpp
Normal file
114
opm/core/GridManager.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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 3 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/>.
|
||||
*/
|
||||
|
||||
#include <opm/core/GridManager.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/utility/cart_grid.h>
|
||||
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
|
||||
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// Construct a 3d corner-point grid from a deck.
|
||||
GridManager::GridManager(const Opm::EclipseGridParser& deck)
|
||||
{
|
||||
// Extract data from deck.
|
||||
const std::vector<double>& zcorn = deck.getFloatingPointValue("ZCORN");
|
||||
const std::vector<double>& coord = deck.getFloatingPointValue("COORD");
|
||||
const std::vector<int>& actnum = deck.getIntegerValue("ACTNUM");
|
||||
std::vector<int> dims;
|
||||
if (deck.hasField("DIMENS")) {
|
||||
dims = deck.getIntegerValue("DIMENS");
|
||||
} else if (deck.hasField("SPECGRID")) {
|
||||
dims = deck.getSPECGRID().dimensions;
|
||||
} else {
|
||||
THROW("Deck must have either DIMENS or SPECGRID.");
|
||||
}
|
||||
|
||||
// Collect in input struct for preprocessing.
|
||||
struct grdecl grdecl;
|
||||
grdecl.zcorn = &zcorn[0];
|
||||
grdecl.coord = &coord[0];
|
||||
grdecl.actnum = &actnum[0];
|
||||
grdecl.dims[0] = dims[0];
|
||||
grdecl.dims[1] = dims[1];
|
||||
grdecl.dims[2] = dims[2];
|
||||
|
||||
// Process and compute.
|
||||
ug_ = preprocess(&grdecl, 0.0);
|
||||
compute_geometry(ug_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Construct a 2d cartesian grid with cells of unit size.
|
||||
GridManager::GridManager(int nx, int ny)
|
||||
{
|
||||
ug_ = create_cart_grid_2d(nx, ny);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Construct a 3d cartesian grid with cells of unit size.
|
||||
GridManager::GridManager(int nx, int ny, int nz)
|
||||
{
|
||||
ug_ = create_cart_grid_3d(nx, ny, nz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Construct a 3d cartesian grid with cells of size [dx, dy, dz].
|
||||
GridManager::GridManager(int nx, int ny, int nz,
|
||||
double dx, double dy, double dz)
|
||||
{
|
||||
ug_ = create_hexa_grid_3d(nx, ny, nz, dx, dy, dz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Destructor.
|
||||
GridManager::~GridManager()
|
||||
{
|
||||
free_grid(ug_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// Access the managed UnstructuredGrid.
|
||||
/// The method is named similarly to c_str() in std::string,
|
||||
/// to make it clear that we are returning a C-compatible struct.
|
||||
const UnstructuredGrid* GridManager::c_grid() const
|
||||
{
|
||||
return ug_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Opm
|
73
opm/core/GridManager.hpp
Normal file
73
opm/core/GridManager.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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 3 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/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_GRIDMANAGER_HEADER_INCLUDED
|
||||
#define OPM_GRIDMANAGER_HEADER_INCLUDED
|
||||
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class EclipseGridParser;
|
||||
|
||||
/// This class manages an Opm::UnstructuredGrid in the sense that it
|
||||
/// encapsulates creation and destruction of the grid.
|
||||
/// The following grid types can be constructed:
|
||||
/// - 3d corner-point grids (from deck input)
|
||||
/// - 2d cartesian grids
|
||||
/// - 3d cartesian grids
|
||||
/// The resulting UnstructuredGrid is available through the c_grid() method.
|
||||
class GridManager
|
||||
{
|
||||
public:
|
||||
/// Construct a 3d corner-point grid from a deck.
|
||||
GridManager(const Opm::EclipseGridParser& deck);
|
||||
|
||||
/// Construct a 2d cartesian grid with cells of unit size.
|
||||
GridManager(int nx, int ny);
|
||||
|
||||
/// Construct a 3d cartesian grid with cells of unit size.
|
||||
GridManager(int nx, int ny, int nz);
|
||||
|
||||
/// Construct a 3d cartesian grid with cells of size [dx, dy, dz].
|
||||
GridManager(int nx, int ny, int nz,
|
||||
double dx, double dy, double dz);
|
||||
|
||||
/// Destructor.
|
||||
~GridManager();
|
||||
|
||||
/// Access the managed UnstructuredGrid.
|
||||
/// The method is named similarly to c_str() in std::string,
|
||||
/// to make it clear that we are returning a C-compatible struct.
|
||||
const UnstructuredGrid* c_grid() const;
|
||||
|
||||
private:
|
||||
// Disable copying and assignment.
|
||||
GridManager(const GridManager& other);
|
||||
GridManager& operator=(const GridManager& other);
|
||||
// The managed UnstructuredGrid.
|
||||
UnstructuredGrid* ug_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_GRIDMANAGER_HEADER_INCLUDED
|
Loading…
Reference in New Issue
Block a user