move the hydrostatic equilibrium code to its proper location and make it compile

this just moves the hydrostatic equilibrium code from its historc
location at opm/core to ebos/equil and adds minimal changes to make it
compile. this allows to clean up that code without disturbing the
legacy simulators.
This commit is contained in:
Andreas Lauser 2018-01-02 12:43:56 +01:00
parent f6f2a78a6c
commit 6871e1cf88
6 changed files with 105 additions and 96 deletions

View File

@ -28,17 +28,13 @@
#ifndef EWOMS_ECL_EQUIL_INITIALIZER_HH
#define EWOMS_ECL_EQUIL_INITIALIZER_HH
#include "equil/initStateEquil.hpp"
#include <ewoms/common/propertysystem.hh>
#include <opm/material/fluidstates/BlackOilFluidState.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
// the ordering of these includes matters. do not touch it if you're not prepared to deal
// with some trouble!
#include <dune/grid/cpgrid/GridHelpers.hpp>
#include <opm/core/simulator/initStateEquil.hpp>
#include <vector>
namespace Ewoms {
@ -97,7 +93,7 @@ public:
unsigned numCartesianElems = gridManager.cartesianSize();
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
Opm::EQUIL::DeckDependent::InitialStateComputer<FluidSystem> initialState(materialLawManager,
EQUIL::DeckDependent::InitialStateComputer<FluidSystem> initialState(materialLawManager,
gridManager.eclState(),
gridManager.grid(),
simulator.problem().gravity()[dimWorld - 1]);

View File

@ -48,7 +48,7 @@
#if EBOS_USE_ALUGRID
#include "eclalugridmanager.hh"
#else
#include "eclpolyhedralgridmanager.hh"
//#include "eclpolyhedralgridmanager.hh"
#include "eclcpgridmanager.hh"
#endif
#include "eclwellmanager.hh"

View File

@ -1,7 +1,6 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2014 SINTEF ICT, Applied Mathematics.
Copyright 2017 IRIS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
@ -16,10 +15,19 @@
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_EQUILIBRATIONHELPERS_HEADER_INCLUDED
#define OPM_EQUILIBRATIONHELPERS_HEADER_INCLUDED
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/**
* \file
*
* \brief Auxiliary routines that to solve the ODEs that emerge from the hydrostatic
* equilibrium problem
*/
#ifndef EWOMS_EQUILIBRATIONHELPERS_HEADER_INCLUDED
#define EWOMS_EQUILIBRATIONHELPERS_HEADER_INCLUDED
#include <opm/core/utility/linearInterpolation.hpp>
#include <opm/core/utility/RegionMapping.hpp>
@ -73,9 +81,7 @@ namespace Opm
---- end of synopsis of EquilibrationHelpers.hpp ----
*/
namespace Opm
namespace Ewoms
{
/**
* Types and routines that collectively implement a basic
@ -217,7 +223,7 @@ namespace Opm
if (sat_gas > 0.0) {
return satRs(press, temp);
} else {
return std::min(satRs(press, temp), linearInterpolationNoExtrapolation(depth_, rs_, depth));
return std::min(satRs(press, temp), Opm::linearInterpolationNoExtrapolation(depth_, rs_, depth));
}
}
@ -281,7 +287,7 @@ namespace Opm
if (std::abs(sat_oil) > 1e-16) {
return satRv(press, temp);
} else {
return std::min(satRv(press, temp), linearInterpolationNoExtrapolation(depth_, rv_, depth));
return std::min(satRv(press, temp), Opm::linearInterpolationNoExtrapolation(depth_, rv_, depth));
}
}
@ -465,7 +471,7 @@ namespace Opm
* \param[in] rv Calculator of vapourised oil-gas ratio.
* \param[in] pvtRegionIdx The pvt region index
*/
EquilReg(const EquilRecord& rec,
EquilReg(const Opm::EquilRecord& rec,
std::shared_ptr<Miscibility::RsFunction> rs,
std::shared_ptr<Miscibility::RsFunction> rv,
const int pvtIdx)
@ -542,7 +548,7 @@ namespace Opm
private:
EquilRecord rec_; /**< Equilibration data */
Opm::EquilRecord rec_; /**< Equilibration data */
std::shared_ptr<Miscibility::RsFunction> rs_; /**< RS calculator */
std::shared_ptr<Miscibility::RsFunction> rv_; /**< RV calculator */
const int pvtIdx_;
@ -671,7 +677,7 @@ namespace Opm
const int max_iter = 60;
const double tol = 1e-6;
int iter_used = -1;
typedef RegulaFalsi<ThrowOnError> ScalarSolver;
typedef Opm::RegulaFalsi<Opm::ThrowOnError> ScalarSolver;
const double sol = ScalarSolver::solve(f, std::min(s0, s1), std::max(s0, s1), max_iter, tol, iter_used);
return sol;
}
@ -753,7 +759,7 @@ namespace Opm
const int max_iter = 30;
const double tol = 1e-6;
int iter_used = -1;
typedef RegulaFalsi<ThrowOnError> ScalarSolver;
typedef Opm::RegulaFalsi<Opm::ThrowOnError> ScalarSolver;
const double sol = ScalarSolver::solve(f, smin, smax, max_iter, tol, iter_used);
return sol;
}
@ -793,7 +799,6 @@ namespace Opm
}
} // namespace Equil
} // namespace Opm
} // namespace Ewoms
#endif // OPM_EQUILIBRATIONHELPERS_HEADER_INCLUDED
#endif // EWOMS_EQUILIBRATIONHELPERS_HEADER_INCLUDED

View File

@ -1,6 +1,6 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2014 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
@ -15,17 +15,20 @@
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_REGIONMAPPING_HEADER_INCLUDED
#define OPM_REGIONMAPPING_HEADER_INCLUDED
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_REGIONMAPPING_HH
#define OPM_REGIONMAPPING_HH
#include <boost/range.hpp>
#include <unordered_map>
#include <vector>
namespace Opm
namespace Ewoms
{
/**

View File

@ -1,9 +1,6 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2014 SINTEF ICT, Applied Mathematics.
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 NTNU
Copyright 2017 IRIS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
@ -18,15 +15,25 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/**
* \file
*
* \brief Routines that actually solve the ODEs that emerge from the hydrostatic
* equilibrium problem
*/
#ifndef EWOMS_INITSTATEEQUIL_HEADER_INCLUDED
#define EWOMS_INITSTATEEQUIL_HEADER_INCLUDED
#ifndef OPM_INITSTATEEQUIL_HEADER_INCLUDED
#define OPM_INITSTATEEQUIL_HEADER_INCLUDED
#include "EquilibrationHelpers.hpp"
#include "RegionMapping.hpp"
#include <opm/core/grid/GridHelpers.hpp>
#include <opm/core/simulator/EquilibrationHelpers.hpp>
#include <opm/core/utility/RegionMapping.hpp>
#include <opm/core/utility/extractPvtTableIndex.hpp>
#include <dune/grid/cpgrid/GridHelpers.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -49,14 +56,7 @@
#include <utility>
#include <vector>
/**
* \file
* Facilities for an ECLIPSE-style equilibration-based
* initialisation scheme (keyword 'EQUIL').
*/
struct UnstructuredGrid;
namespace Opm
namespace Ewoms
{
@ -112,7 +112,7 @@ namespace Opm
phasePressures(const Grid& G,
const Region& reg,
const CellRange& cells,
const double grav = unit::gravity);
const double grav = Opm::unit::gravity);
@ -189,7 +189,7 @@ namespace Opm
namespace DeckDependent {
inline
std::vector<EquilRecord>
std::vector<Opm::EquilRecord>
getEquil(const Opm::EclipseState& state)
{
const auto& init = state.getInitConfig();
@ -210,11 +210,11 @@ namespace Opm
{
std::vector<int> eqlnum;
if (eclipseState.get3DProperties().hasDeckIntGridProperty("EQLNUM")) {
const int nc = UgGridHelpers::numCells(G);
const int nc = Opm::UgGridHelpers::numCells(G);
eqlnum.resize(nc);
const std::vector<int>& e =
eclipseState.get3DProperties().getIntGridProperty("EQLNUM").getData();
const int* gc = UgGridHelpers::globalCell(G);
const int* gc = Opm::UgGridHelpers::globalCell(G);
for (int cell = 0; cell < nc; ++cell) {
const int deck_pos = (gc == NULL) ? cell : gc[cell];
eqlnum[cell] = e[deck_pos] - 1;
@ -223,7 +223,7 @@ namespace Opm
else {
// No explicit equilibration region.
// All cells in region zero.
eqlnum.assign(UgGridHelpers::numCells(G), 0);
eqlnum.assign(Opm::UgGridHelpers::numCells(G), 0);
}
return eqlnum;
@ -236,33 +236,33 @@ namespace Opm
InitialStateComputer(MaterialLawManager& materialLawManager,
const Opm::EclipseState& eclipseState,
const Grid& G ,
const double grav = unit::gravity,
const double grav = Opm::unit::gravity,
const bool applySwatInit = true
)
: pp_(FluidSystem::numPhases,
std::vector<double>(UgGridHelpers::numCells(G))),
std::vector<double>(Opm::UgGridHelpers::numCells(G))),
sat_(FluidSystem::numPhases,
std::vector<double>(UgGridHelpers::numCells(G))),
rs_(UgGridHelpers::numCells(G)),
rv_(UgGridHelpers::numCells(G))
std::vector<double>(Opm::UgGridHelpers::numCells(G))),
rs_(Opm::UgGridHelpers::numCells(G)),
rv_(Opm::UgGridHelpers::numCells(G))
{
//Check for presence of kw SWATINIT
if (eclipseState.get3DProperties().hasDeckDoubleGridProperty("SWATINIT") && applySwatInit) {
const std::vector<double>& swat_init_ecl = eclipseState.
get3DProperties().getDoubleGridProperty("SWATINIT").getData();
const int nc = UgGridHelpers::numCells(G);
const int nc = Opm::UgGridHelpers::numCells(G);
swat_init_.resize(nc);
const int* gc = UgGridHelpers::globalCell(G);
const int* gc = Opm::UgGridHelpers::globalCell(G);
for (int c = 0; c < nc; ++c) {
const int deck_pos = (gc == NULL) ? c : gc[c];
swat_init_[c] = swat_init_ecl[deck_pos];
}
}
// Get the equilibration records.
const std::vector<EquilRecord> rec = getEquil(eclipseState);
const std::vector<Opm::EquilRecord> rec = getEquil(eclipseState);
const auto& tables = eclipseState.getTableManager();
// Create (inverse) region mapping.
const RegionMapping<> eqlmap(equilnum(eclipseState, G));
const Ewoms::RegionMapping<> eqlmap(equilnum(eclipseState, grid));
const int invalidRegion = -1;
regionPvtIdx_.resize(rec.size(), invalidRegion);
setRegionPvtIdx(G, eclipseState, eqlmap);
@ -270,7 +270,7 @@ namespace Opm
// Create Rs functions.
rs_func_.reserve(rec.size());
if (FluidSystem::enableDissolvedGas()) {
const TableContainer& rsvdTables = tables.getRsvdTables();
const Opm::TableContainer& rsvdTables = tables.getRsvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
if (eqlmap.cells(i).empty())
{
@ -282,7 +282,7 @@ namespace Opm
if (rsvdTables.size() <= 0 ) {
OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table not available.");
}
const RsvdTable& rsvdTable = rsvdTables.getTable<RsvdTable>(i);
const Opm::RsvdTable& rsvdTable = rsvdTables.getTable<Opm::RsvdTable>(i);
std::vector<double> depthColumn = rsvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rsColumn = rsvdTable.getColumn("RS").vectorCopy();
rs_func_.push_back(std::make_shared<Miscibility::RsVD<FluidSystem>>(pvtIdx,
@ -307,7 +307,7 @@ namespace Opm
rv_func_.reserve(rec.size());
if (FluidSystem::enableVaporizedOil()) {
const TableContainer& rvvdTables = tables.getRvvdTables();
const Opm::TableContainer& rvvdTables = tables.getRvvdTables();
for (size_t i = 0; i < rec.size(); ++i) {
if (eqlmap.cells(i).empty())
{
@ -320,7 +320,7 @@ namespace Opm
OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table not available.");
}
const RvvdTable& rvvdTable = rvvdTables.getTable<RvvdTable>(i);
const Opm::RvvdTable& rvvdTable = rvvdTables.getTable<Opm::RvvdTable>(i);
std::vector<double> depthColumn = rvvdTable.getColumn("DEPTH").vectorCopy();
std::vector<double> rvColumn = rvvdTable.getColumn("RV").vectorCopy();
rv_func_.push_back(std::make_shared<Miscibility::RvVD<FluidSystem>>(pvtIdx,
@ -374,7 +374,7 @@ namespace Opm
void setRegionPvtIdx(const Grid& G, const Opm::EclipseState& eclipseState, const RMap& reg) {
std::vector<int> cellPvtRegionIdx;
extractPvtTableIndex(cellPvtRegionIdx, eclipseState, UgGridHelpers::numCells(G), UgGridHelpers::globalCell(G));
extractPvtTableIndex(cellPvtRegionIdx, eclipseState, Opm::UgGridHelpers::numCells(G), Opm::UgGridHelpers::globalCell(G));
for (const auto& r : reg.activeRegions()) {
const auto& cells = reg.cells(r);
const int cell = *(cells.begin());
@ -385,7 +385,7 @@ namespace Opm
template <class RMap, class MaterialLawManager, class Grid>
void
calcPressSatRsRv(const RMap& reg ,
const std::vector< EquilRecord >& rec ,
const std::vector< Opm::EquilRecord >& rec ,
MaterialLawManager& materialLawManager,
const Grid& G ,
const double grav)
@ -394,7 +394,7 @@ namespace Opm
const auto& cells = reg.cells(r);
if (cells.empty())
{
OpmLog::warning("Equilibration region " + std::to_string(r + 1)
Opm::OpmLog::warning("Equilibration region " + std::to_string(r + 1)
+ " has no active cells");
continue;
}
@ -441,6 +441,6 @@ namespace Opm
} // namespace EQUIL
} // namespace Opm
#include <opm/core/simulator/initStateEquil_impl.hpp>
#include "initStateEquil_impl.hpp"
#endif // OPM_INITSTATEEQUIL_HEADER_INCLUDED

View File

@ -1,9 +1,6 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2014 SINTEF ICT, Applied Mathematics.
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 NTNU
Copyright 2017 IRIS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
@ -18,13 +15,21 @@
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_INITSTATEEQUIL_IMPL_HEADER_INCLUDED
#define OPM_INITSTATEEQUIL_IMPL_HEADER_INCLUDED
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/**
* \file
*
* \brief Routines that actually solve the ODEs that emerge from the hydrostatic
* equilibrium problem
*/
#ifndef EWOMS_INITSTATEEQUIL_IMPL_HEADER_INCLUDED
#define EWOMS_INITSTATEEQUIL_IMPL_HEADER_INCLUDED
#include <opm/core/grid.h>
#include <opm/core/grid/GridHelpers.hpp>
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
@ -33,7 +38,7 @@
#include <functional>
#include <vector>
namespace Opm
namespace Ewoms
{
namespace Details {
template <class RHS>
@ -257,7 +262,7 @@ namespace Opm
{
assert (c < p.size());
const double z = UgGridHelpers::cellCenterDepth(G, *ci);
const double z = Opm::UgGridHelpers::cellCenterDepth(G, *ci);
p[c] = (z < split) ? f[up](z) : f[down](z);
}
}
@ -519,9 +524,9 @@ namespace Opm
int ncell = 0;
{
// This code is only supported in three space dimensions
assert (UgGridHelpers::dimensions(G) == 3);
assert (Opm::UgGridHelpers::dimensions(G) == 3);
const int nd = UgGridHelpers::dimensions(G);
const int nd = Opm::UgGridHelpers::dimensions(G);
// Define vertical span as
//
@ -536,8 +541,8 @@ namespace Opm
// imposes the requirement that cell centroids are all
// within this vertical span. That requirement is not
// checked.
auto cell2Faces = UgGridHelpers::cell2Faces(G);
auto faceVertices = UgGridHelpers::face2Vertices(G);
auto cell2Faces = Opm::UgGridHelpers::cell2Faces(G);
auto faceVertices = Opm::UgGridHelpers::face2Vertices(G);
for (typename CellRange::const_iterator
ci = cells.begin(), ce = cells.end();
@ -551,7 +556,7 @@ namespace Opm
for (auto i = faceVertices[*fi].begin(), e = faceVertices[*fi].end();
i != e; ++i)
{
const double z = UgGridHelpers::vertexCoordinates(G, *i)[nd-1];
const double z = Opm::UgGridHelpers::vertexCoordinates(G, *i)[nd-1];
if (z < span[0]) { span[0] = z; }
if (z > span[1]) { span[1] = z; }
@ -637,7 +642,7 @@ namespace Opm
double sw = 0.0;
if (water) {
if (isConstPc<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager,FluidSystem::waterPhaseIdx, cell)){
const double cellDepth = UgGridHelpers::cellCenterDepth(G,
const double cellDepth = Opm::UgGridHelpers::cellCenterDepth(G,
cell);
sw = satFromDepth<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager,cellDepth,reg.zwoc(),waterpos,cell,false);
phase_saturations[waterpos][local_index] = sw;
@ -657,7 +662,7 @@ namespace Opm
double sg = 0.0;
if (gas) {
if (isConstPc<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager,FluidSystem::gasPhaseIdx,cell)){
const double cellDepth = UgGridHelpers::cellCenterDepth(G,
const double cellDepth = Opm::UgGridHelpers::cellCenterDepth(G,
cell);
sg = satFromDepth<FluidSystem, MaterialLaw, MaterialLawManager>(materialLawManager,cellDepth,reg.zgoc(),gaspos,cell,true);
phase_saturations[gaspos][local_index] = sg;
@ -773,11 +778,11 @@ namespace Opm
const Miscibility::RsFunction& rs_func,
const std::vector<double> gas_saturation)
{
assert(UgGridHelpers::dimensions(grid) == 3);
assert(Opm::UgGridHelpers::dimensions(grid) == 3);
std::vector<double> rs(cells.size());
int count = 0;
for (auto it = cells.begin(); it != cells.end(); ++it, ++count) {
const double depth = UgGridHelpers::cellCenterDepth(grid, *it);
const double depth = Opm::UgGridHelpers::cellCenterDepth(grid, *it);
rs[count] = rs_func(depth, oil_pressure[count], temperature[count], gas_saturation[count]);
}
return rs;