2014-06-23 07:52:55 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2014 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/>.
|
|
|
|
|
*/
|
2016-06-20 12:27:56 +02:00
|
|
|
|
2014-06-23 07:52:55 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
|
|
2019-10-17 14:53:49 +02:00
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
2016-10-12 10:46:40 +02:00
|
|
|
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
2020-01-13 15:46:06 +01:00
|
|
|
#include <opm/parser/eclipse/Deck/DeckSection.hpp>
|
2019-11-20 14:28:28 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
2014-06-23 07:52:55 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
|
2017-09-24 15:17:10 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/GridDims.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
|
2014-06-23 07:52:55 +02:00
|
|
|
|
2016-06-20 12:27:56 +02:00
|
|
|
|
2014-06-23 07:52:55 +02:00
|
|
|
namespace Opm {
|
|
|
|
|
|
2020-01-13 15:46:06 +01:00
|
|
|
TransMult::TransMult(const GridDims& dims, const Deck& deck, const FieldPropsManager& fp) :
|
2017-10-03 12:41:07 +02:00
|
|
|
m_nx( dims.getNX()),
|
|
|
|
|
m_ny( dims.getNY()),
|
|
|
|
|
m_nz( dims.getNZ()),
|
2016-10-12 10:46:40 +02:00
|
|
|
m_names( { { FaceDir::XPlus, "MULTX" },
|
|
|
|
|
{ FaceDir::YPlus, "MULTY" },
|
|
|
|
|
{ FaceDir::ZPlus, "MULTZ" },
|
|
|
|
|
{ FaceDir::XMinus, "MULTX-" },
|
|
|
|
|
{ FaceDir::YMinus, "MULTY-" },
|
2017-09-24 15:17:10 +02:00
|
|
|
{ FaceDir::ZMinus, "MULTZ-" }}),
|
2020-01-14 14:16:58 +01:00
|
|
|
m_multregtScanner( dims, &fp, deck.getKeywordList( "MULTREGT" ))
|
2017-09-24 15:17:10 +02:00
|
|
|
{
|
2019-10-17 14:53:49 +02:00
|
|
|
EDITSection edit_section(deck);
|
|
|
|
|
if (edit_section.hasKeyword("MULTREGT")) {
|
|
|
|
|
std::string msg =
|
|
|
|
|
R"(This deck has the MULTREGT keyword located in the EDIT section. Note that:
|
|
|
|
|
1) The MULTREGT keyword from EDIT section will be applied.
|
|
|
|
|
2) It is recommended to place MULTREGT in the GRID section.)";
|
|
|
|
|
|
|
|
|
|
OpmLog::warning(msg);
|
|
|
|
|
}
|
2017-09-24 15:17:10 +02:00
|
|
|
}
|
2014-06-23 07:52:55 +02:00
|
|
|
|
2019-12-16 14:27:16 +01:00
|
|
|
|
|
|
|
|
TransMult::TransMult(const std::array<size_t,3>& size,
|
|
|
|
|
const std::map<FaceDir::DirEnum, std::vector<double>>& trans,
|
|
|
|
|
const std::map<FaceDir::DirEnum, std::string>& names,
|
|
|
|
|
const MULTREGTScanner& scanner) :
|
|
|
|
|
m_nx(size[0]),
|
|
|
|
|
m_ny(size[1]),
|
|
|
|
|
m_nz(size[2]),
|
|
|
|
|
m_trans(trans),
|
|
|
|
|
m_names(names),
|
|
|
|
|
m_multregtScanner(scanner)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 07:52:55 +02:00
|
|
|
void TransMult::assertIJK(size_t i , size_t j , size_t k) const {
|
|
|
|
|
if ((i >= m_nx) || (j >= m_ny) || (k >= m_nz))
|
|
|
|
|
throw std::invalid_argument("Invalid ijk");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t TransMult::getGlobalIndex(size_t i , size_t j , size_t k) const {
|
|
|
|
|
assertIJK(i,j,k);
|
|
|
|
|
return i + j*m_nx + k*m_nx*m_ny;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-07-05 13:46:53 +02:00
|
|
|
double TransMult::getMultiplier(size_t globalIndex, FaceDir::DirEnum faceDir) const {
|
2014-06-23 07:52:55 +02:00
|
|
|
if (globalIndex < m_nx * m_ny * m_nz)
|
2019-12-03 20:24:11 +01:00
|
|
|
return this->getMultiplier__(globalIndex , faceDir);
|
2014-06-23 07:52:55 +02:00
|
|
|
else
|
|
|
|
|
throw std::invalid_argument("Invalid global index");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 13:46:53 +02:00
|
|
|
double TransMult::getMultiplier__(size_t globalIndex, FaceDir::DirEnum faceDir) const {
|
|
|
|
|
if (hasDirectionProperty( faceDir )) {
|
2019-12-03 20:24:11 +01:00
|
|
|
const auto& data = m_trans.at(faceDir);
|
2019-09-28 09:03:35 +02:00
|
|
|
return data[globalIndex];
|
2014-07-05 13:46:53 +02:00
|
|
|
} else
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
2014-12-08 16:34:28 +01:00
|
|
|
|
|
|
|
|
|
2014-07-05 13:46:53 +02:00
|
|
|
|
2014-06-23 07:52:55 +02:00
|
|
|
|
|
|
|
|
double TransMult::getMultiplier(size_t i , size_t j , size_t k, FaceDir::DirEnum faceDir) const {
|
2019-12-03 20:24:11 +01:00
|
|
|
size_t globalIndex = this->getGlobalIndex(i,j,k);
|
2014-07-05 13:46:53 +02:00
|
|
|
return getMultiplier__( globalIndex , faceDir );
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-05 11:14:53 +01:00
|
|
|
double TransMult::getRegionMultiplier(size_t globalCellIndex1, size_t globalCellIndex2, FaceDir::DirEnum faceDir) const {
|
2016-10-12 10:46:40 +02:00
|
|
|
return m_multregtScanner.getRegionMultiplier(globalCellIndex1, globalCellIndex2, faceDir);
|
2014-12-05 11:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-05 13:46:53 +02:00
|
|
|
bool TransMult::hasDirectionProperty(FaceDir::DirEnum faceDir) const {
|
2016-03-08 17:07:42 +01:00
|
|
|
return m_trans.count(faceDir) == 1;
|
2014-07-05 13:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2019-12-03 20:24:11 +01:00
|
|
|
std::vector<double>& TransMult::getDirectionProperty(FaceDir::DirEnum faceDir) {
|
|
|
|
|
if (m_trans.count(faceDir) == 0) {
|
|
|
|
|
std::size_t global_size = this->m_nx * this->m_ny * this->m_nz;
|
|
|
|
|
m_trans[faceDir] = std::vector<double>(global_size, 1);
|
|
|
|
|
}
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2014-07-05 13:46:53 +02:00
|
|
|
return m_trans.at( faceDir );
|
|
|
|
|
}
|
2014-07-15 14:09:56 +02:00
|
|
|
|
2019-12-03 20:24:11 +01:00
|
|
|
void TransMult::applyMULT(const std::vector<double>& srcData, FaceDir::DirEnum faceDir)
|
2014-07-15 14:09:56 +02:00
|
|
|
{
|
2019-12-03 20:24:11 +01:00
|
|
|
auto& dstProp = this->getDirectionProperty(faceDir);
|
2014-07-15 14:09:56 +02:00
|
|
|
for (size_t i = 0; i < srcData.size(); ++i)
|
2019-12-03 20:24:11 +01:00
|
|
|
dstProp[i] *= srcData[i];
|
2014-07-15 14:09:56 +02:00
|
|
|
}
|
2014-07-05 13:46:53 +02:00
|
|
|
|
|
|
|
|
|
2016-05-02 17:50:45 +02:00
|
|
|
void TransMult::applyMULTFLT(const Fault& fault) {
|
|
|
|
|
double transMult = fault.getTransMult();
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2016-10-07 15:19:22 +02:00
|
|
|
for( const auto& face : fault ) {
|
|
|
|
|
FaceDir::DirEnum faceDir = face.getDir();
|
2019-12-03 20:24:11 +01:00
|
|
|
auto& multProperty = this->getDirectionProperty(faceDir);
|
2016-10-07 15:19:22 +02:00
|
|
|
|
2019-12-03 20:24:11 +01:00
|
|
|
for( auto globalIndex : face )
|
|
|
|
|
multProperty[globalIndex] *= transMult;
|
2015-11-02 12:17:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2016-05-02 17:50:45 +02:00
|
|
|
void TransMult::applyMULTFLT(const FaultCollection& faults) {
|
|
|
|
|
for (size_t faultIndex = 0; faultIndex < faults.size(); faultIndex++) {
|
|
|
|
|
auto& fault = faults.getFault(faultIndex);
|
2019-12-03 20:24:11 +01:00
|
|
|
this->applyMULTFLT(fault);
|
2014-07-05 13:46:53 +02:00
|
|
|
}
|
2014-06-23 07:52:55 +02:00
|
|
|
}
|
2019-12-16 14:27:16 +01:00
|
|
|
|
|
|
|
|
std::array<size_t,3> TransMult::getSize() const {
|
|
|
|
|
return {m_nx, m_ny, m_nz};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::map<FaceDir::DirEnum, std::vector<double>>& TransMult::getTrans() const {
|
|
|
|
|
return m_trans;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::map<FaceDir::DirEnum, std::string>& TransMult::getNames() const {
|
|
|
|
|
return m_names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MULTREGTScanner& TransMult::getScanner() const {
|
|
|
|
|
return m_multregtScanner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TransMult::operator==(const TransMult& data) const {
|
|
|
|
|
return this->getSize() == data.getSize() &&
|
|
|
|
|
this->getTrans() == data.getTrans() &&
|
|
|
|
|
this->getNames() == data.getNames() &&
|
|
|
|
|
this->getScanner() == data.getScanner();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-03 20:24:11 +01:00
|
|
|
}
|