Loading...
Searching...
No Matches
RelPermUtils.hpp
/*
Copyright 2010 Statoil ASA.
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_UPSCALING_RELPERM_UTILS_HPP
#define OPM_UPSCALING_RELPERM_UTILS_HPP
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/common/utility/numeric/MonotCubicInterpolator.hpp>
#include <opm/upscaling/ParserAdditions.hpp>
#include <opm/upscaling/SinglePhaseUpscaler.hpp>
#include <array>
#include <map>
#include <memory>
#include <tuple>
#include <vector>
namespace Opm {
double getVoigtValue(const SinglePhaseUpscaler::permtensor_t& K, int voigt_idx);
void setVoigtValue(SinglePhaseUpscaler::permtensor_t& K, int voigt_idx, double val);
class RelPermUpscaleHelper {
public:
bool isMaster;
bool doEclipseCheck;
bool anisotropic_input;
int points;
int tensorElementCount;
bool upscaleBothPhases;
std::vector<double> WaterSaturation;
SinglePhaseUpscaler::permtensor_t permTensor;
std::vector<int> satnums;
std::vector<MonotCubicInterpolator> InvJfunctions;
std::array<std::array<std::vector<MonotCubicInterpolator>,2>,3> Krfunctions;
SinglePhaseUpscaler::BoundaryConditionType boundaryCondition;
std::vector<MonotCubicInterpolator> SwPcfunctions;
std::string saturationstring;
size_t tesselatedCells;
double volume;
double poreVolume;
std::vector<double> pressurePoints;
template <class String>
static Deck
parseEclipseFile(const String& eclipseFileName);
RelPermUpscaleHelper(int mpi_rank, std::map<std::string,std::string>& options_);
void collectResults();
std::vector<std::vector<double>> getRelPerm(int phase) const;
void upscaleSinglePhasePermeability();
void sanityCheckInput(const Opm::Deck& deck,
const double minPerm,
const double maxPerm,
const double minPoro);
void checkCriticalSaturations();
void setupBoundaryConditions();
double tesselateGrid(const Opm::Deck& deck);
void calculateCellPressureGradients();
void calculateMinMaxCapillaryPressure();
void upscaleCapillaryPressure();
std::tuple<double,double> upscalePermeability(int mpi_rank);
private:
bool checkCurve(MonotCubicInterpolator& func);
double Swir;
double Swor;
double Pcmin;
double Pcmax;
double critRelpThresh;
std::vector<int> node_vs_pressurepoint;
std::array<std::vector<std::vector<double>>,2> PhasePerm;
SinglePhaseUpscaler::permtensor_t permTensorInv;
SinglePhaseUpscaler upscaler;
std::array<std::vector<double>,3> perms;
std::vector<double> poros;
std::vector<double> zcorns;
double minSinglePhasePerm;
std::vector<double> cellPoreVolumes;
MonotCubicInterpolator WaterSaturationVsCapPressure;
#if defined(UNITTEST_TRESPASS_PRIVATE_PROPERTY_DP)
public: // Intrusive unit testing of calculcateCellPressureGradients()
#endif // UNITTEST_TRESPASS_PRIVATE_PROPERTY_DP
std::vector<double> dP;
#if defined(UNITTEST_TRESPASS_PRIVATE_PROPERTY_DP)
private:
#endif // UNITTEST_TRESPASS_PRIVATE_PROPERTY_DP
std::map<std::string,std::string>& options;
};
template <class String>
Deck
RelPermUpscaleHelper::parseEclipseFile(const String& eclipseFileName)
{
auto parser = Parser{};
addNonStandardUpscalingKeywords(parser);
return parser.parseFile(eclipseFileName);
}
}
#endif // OPM_UPSCALING_RELPERM_UTILS_HPP
Opm::RelPermUpscaleHelper::upscalePermeability
std::tuple< double, double > upscalePermeability(int mpi_rank)
Upscale permeabilities.
Definition RelPermUtils.cpp:997
Opm::RelPermUpscaleHelper::boundaryCondition
SinglePhaseUpscaler::BoundaryConditionType boundaryCondition
Boundary conditions to use.
Definition RelPermUtils.hpp:69
Opm::RelPermUpscaleHelper::satnums
std::vector< int > satnums
Cell satnums.
Definition RelPermUtils.hpp:65
Opm::RelPermUpscaleHelper::volume
double volume
Total volume.
Definition RelPermUtils.hpp:73
Opm::RelPermUpscaleHelper::upscaleSinglePhasePermeability
void upscaleSinglePhasePermeability()
Upscale single phase permeability.
Definition RelPermUtils.cpp:355
Opm::RelPermUpscaleHelper::RelPermUpscaleHelper
RelPermUpscaleHelper(int mpi_rank, std::map< std::string, std::string > &options_)
Default constructor.
Definition RelPermUtils.cpp:208
Opm::RelPermUpscaleHelper::upscaleCapillaryPressure
void upscaleCapillaryPressure()
Upscale capillary pressure.
Definition RelPermUtils.cpp:888
Opm::RelPermUpscaleHelper::permTensor
SinglePhaseUpscaler::permtensor_t permTensor
Tensor of upscaled results.
Definition RelPermUtils.hpp:64
Opm::RelPermUpscaleHelper::parseEclipseFile
static Deck parseEclipseFile(const String &eclipseFileName)
Form Deck object from input file (ECLIPSE format).
Definition RelPermUtils.hpp:191
Opm::RelPermUpscaleHelper::SwPcfunctions
std::vector< MonotCubicInterpolator > SwPcfunctions
Holds Sw(Pc) for each rocktype.
Definition RelPermUtils.hpp:70
Opm::RelPermUpscaleHelper::checkCriticalSaturations
void checkCriticalSaturations()
Check that input relperm curevs specify critical saturations.
Definition RelPermUtils.cpp:618
Opm::RelPermUpscaleHelper::isMaster
bool isMaster
Whether this is the master MPI node or not.
Definition RelPermUtils.hpp:57
Opm::RelPermUpscaleHelper::InvJfunctions
std::vector< MonotCubicInterpolator > InvJfunctions
Inverse of the loaded J-functions.
Definition RelPermUtils.hpp:66
Opm::RelPermUpscaleHelper::pressurePoints
std::vector< double > pressurePoints
Vector of capillary pressure points between Swor and Swir.
Definition RelPermUtils.hpp:75
Opm::RelPermUpscaleHelper::sanityCheckInput
void sanityCheckInput(const Opm::Deck &deck, const double minPerm, const double maxPerm, const double minPoro)
Do sanity checks for input file.
Definition RelPermUtils.cpp:392
Opm::RelPermUpscaleHelper::tesselatedCells
size_t tesselatedCells
Number of "active" cells (Sintef interpretation of "active").
Definition RelPermUtils.hpp:72
Opm::RelPermUpscaleHelper::calculateMinMaxCapillaryPressure
void calculateMinMaxCapillaryPressure()
Calculate minimum and maximum capillary pressures.
Definition RelPermUtils.cpp:733
Opm::RelPermUpscaleHelper::tensorElementCount
int tensorElementCount
Number of independent elements in resulting tensor.
Definition RelPermUtils.hpp:61
Opm::RelPermUpscaleHelper::Krfunctions
std::array< std::array< std::vector< MonotCubicInterpolator >, 2 >, 3 > Krfunctions
Relperm-curves for each (component->phase->stone type).
Definition RelPermUtils.hpp:68
Opm::RelPermUpscaleHelper::points
int points
Number of saturation points to upscale for.
Definition RelPermUtils.hpp:60
Opm::RelPermUpscaleHelper::doEclipseCheck
bool doEclipseCheck
Whether to check that input relperm curves include relperm at critical saturation points.
Definition RelPermUtils.hpp:58
Opm::RelPermUpscaleHelper::anisotropic_input
bool anisotropic_input
Whether input eclipse file has diagonal anisotrophy.
Definition RelPermUtils.hpp:59
Opm::RelPermUpscaleHelper::collectResults
void collectResults()
Collect results from all MPI nodes.
Definition RelPermUtils.cpp:239
Opm::RelPermUpscaleHelper::WaterSaturation
std::vector< double > WaterSaturation
Re-upscaled water saturation for the computed pressure points.
Definition RelPermUtils.hpp:63
Opm::RelPermUpscaleHelper::tesselateGrid
double tesselateGrid(const Opm::Deck &deck)
Tesselate grid.
Definition RelPermUtils.cpp:653
Opm::RelPermUpscaleHelper::upscaleBothPhases
bool upscaleBothPhases
Whether to upscale both phases.
Definition RelPermUtils.hpp:62
Opm::RelPermUpscaleHelper::saturationstring
std::string saturationstring
Fluid system type.
Definition RelPermUtils.hpp:71
Opm::RelPermUpscaleHelper::getRelPerm
std::vector< std::vector< double > > getRelPerm(int phase) const
Calculate relperm values from phase permeabilities.
Definition RelPermUtils.cpp:311
Opm::RelPermUpscaleHelper::poreVolume
double poreVolume
Total pore volume.
Definition RelPermUtils.hpp:74
Opm::RelPermUpscaleHelper::setupBoundaryConditions
void setupBoundaryConditions()
Setup requested boundary conditions.
Definition RelPermUtils.cpp:638
Opm::RelPermUpscaleHelper::calculateCellPressureGradients
void calculateCellPressureGradients()
Find cell center pressure gradient for every cell.
Definition RelPermUtils.cpp:690
Opm::SinglePhaseUpscaler
A class for doing single phase (permeability) upscaling.
Definition SinglePhaseUpscaler.hpp:51
Opm::UpscalerBase< UpscalingTraitsBasic >::permtensor_t
ResProp::MutablePermTensor permtensor_t
Definition UpscalerBase.hpp:66
Opm
Inverting small matrices.
Definition ImplicitAssembly.hpp:43
Opm::getVoigtValue
double getVoigtValue(const SinglePhaseUpscaler::permtensor_t &K, int voigt_idx)
Get value from tensor.
Definition RelPermUtils.cpp:175
Opm::addNonStandardUpscalingKeywords
void addNonStandardUpscalingKeywords(Parser &parser)
This function registers non-standard keywords used by opm-upscaling in a parser object.
Definition ParserAdditions.cpp:41
Opm::setVoigtValue
void setVoigtValue(SinglePhaseUpscaler::permtensor_t &K, int voigt_idx, double val)
Set value in tensor.
Definition RelPermUtils.cpp:192