rebase
This commit is contained in:
@@ -96,6 +96,8 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/input/eclipse/EclipseState/EndpointScaling.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/Box.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/BoxManager.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/Carfin.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/CarfinManager.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp
|
||||
@@ -110,6 +112,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/input/eclipse/EclipseState/Grid/NNC.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/Operate.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/PinchMode.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/readKeywordCarfin.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/setKeywordBox.cpp
|
||||
src/opm/input/eclipse/EclipseState/Grid/TranCalculator.cpp
|
||||
@@ -445,6 +448,7 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/parser/ADDREGTests.cpp
|
||||
tests/parser/AquiferTests.cpp
|
||||
tests/parser/BoxTests.cpp
|
||||
tests/parser/CarfinTests.cpp
|
||||
tests/parser/ColumnSchemaTests.cpp
|
||||
tests/parser/ConnectionTests.cpp
|
||||
tests/parser/COMPSEGUnits.cpp
|
||||
@@ -973,12 +977,14 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/Fault.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/Box.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/Carfin.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/FieldProps.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/FaultFace.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/NNC.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/BoxManager.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/FaceDir.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/MapAxes.hpp
|
||||
opm/input/eclipse/EclipseState/Grid/MinpvMode.hpp
|
||||
|
||||
117
opm/input/eclipse/EclipseState/Grid/Carfin.hpp
Normal file
117
opm/input/eclipse/EclipseState/Grid/Carfin.hpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
Copyright 2022 Equinor
|
||||
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 CARFIN_HPP_
|
||||
#define CARFIN_HPP_
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace Opm {
|
||||
class DeckRecord;
|
||||
}
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
class Carfin
|
||||
{
|
||||
public:
|
||||
using IsActive = std::function<bool(const std::size_t globalIdx)>;
|
||||
using ActiveIdx = std::function<std::size_t(const std::size_t globalIdx)>;
|
||||
|
||||
struct cell_index
|
||||
{
|
||||
std::size_t global_index;
|
||||
std::size_t active_index;
|
||||
std::size_t data_index;
|
||||
|
||||
cell_index(std::size_t g,std::size_t a, std::size_t d)
|
||||
: global_index(g)
|
||||
, active_index(a)
|
||||
, data_index(d)
|
||||
{}
|
||||
|
||||
cell_index(std::size_t g, std::size_t d)
|
||||
: global_index(g)
|
||||
, active_index(g)
|
||||
, data_index(d)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
explicit Carfin(const GridDims& gridDims,
|
||||
IsActive isActive,
|
||||
ActiveIdx activeIdx);
|
||||
|
||||
Carfin(const GridDims& gridDims,
|
||||
IsActive isActive,
|
||||
ActiveIdx activeIdx,
|
||||
std::string name, int i1, int i2,
|
||||
int j1, int j2,
|
||||
int k1, int k2,
|
||||
int nx, int ny,
|
||||
int nz);
|
||||
|
||||
void update(const DeckRecord& deckRecord);
|
||||
void reset();
|
||||
|
||||
bool isGlobal() const;
|
||||
std::size_t size() const;
|
||||
std::size_t getDim(std::size_t idim) const;
|
||||
|
||||
const std::vector<cell_index>& index_list() const;
|
||||
const std::vector<cell_index>& global_index_list() const;
|
||||
|
||||
bool operator==(const Carfin& other) const;
|
||||
bool equal(const Carfin& other) const;
|
||||
|
||||
std::string NAME() const;
|
||||
int I1() const;
|
||||
int I2() const;
|
||||
int J1() const;
|
||||
int J2() const;
|
||||
int K1() const;
|
||||
int K2() const;
|
||||
int NX() const;
|
||||
int NY() const;
|
||||
int NZ() const;
|
||||
|
||||
private:
|
||||
GridDims m_globalGridDims_{};
|
||||
IsActive m_globalIsActive_{};
|
||||
ActiveIdx m_globalActiveIdx_{};
|
||||
|
||||
std::array<std::size_t, 3> m_dims{};
|
||||
std::array<std::size_t, 3> m_offset{};
|
||||
std::array<std::size_t, 3> m_end_offset{};
|
||||
|
||||
std::vector<cell_index> m_active_index_list;
|
||||
std::vector<cell_index> m_global_index_list;
|
||||
|
||||
void init(std::string name, int i1, int i2, int j1, int j2, int k1, int k2, int nx , int ny , int nz);
|
||||
void initIndexList();
|
||||
int lower(int dim) const;
|
||||
int upper(int dim) const;
|
||||
int dimension(int dim) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
62
opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp
Normal file
62
opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2022 Equinor
|
||||
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 CARFINMANAGER_HPP_
|
||||
#define CARFINMANAGER_HPP_
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class CarfinManager
|
||||
{
|
||||
public:
|
||||
explicit CarfinManager(const GridDims& gridDims,
|
||||
Carfin::IsActive isActive,
|
||||
Carfin::ActiveIdx activeIdx);
|
||||
|
||||
void setInputCarfin(std::string name, int i1, int i2, int j1, int j2, int k1, int k2, int nx , int ny , int nz);
|
||||
void readKeywordCarfin(std::string name, int i1, int i2, int j1, int j2, int k1, int k2, int nx , int ny , int nz);
|
||||
|
||||
void endSection();
|
||||
void endInputCarfin();
|
||||
void endKeyword();
|
||||
|
||||
const Carfin& getActiveCarfin() const;
|
||||
const std::vector<Carfin::cell_index>& index_list() const;
|
||||
|
||||
private:
|
||||
GridDims gridDims_{};
|
||||
Carfin::IsActive isActive_{};
|
||||
Carfin::ActiveIdx activeIdx_{};
|
||||
|
||||
std::unique_ptr<Carfin> m_globalCarfin;
|
||||
std::unique_ptr<Carfin> m_inputCarfin;
|
||||
std::unique_ptr<Carfin> m_keywordCarfin;
|
||||
|
||||
std::unique_ptr<Carfin>
|
||||
makeLgr(std::string name, int i1, int i2,
|
||||
int j1, int j2,
|
||||
int k1, int k2,
|
||||
int nx , int ny , int nz) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
292
src/opm/input/eclipse/EclipseState/Grid/Carfin.cpp
Normal file
292
src/opm/input/eclipse/EclipseState/Grid/Carfin.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
Copyright 2022 Equinor
|
||||
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/input/eclipse/EclipseState/Grid/Carfin.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Parser/ParserKeywords/C.hpp> //CARFIN
|
||||
|
||||
#include <opm/input/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace {
|
||||
|
||||
void assert_dims(std::string name, int l1 , int l2, int nlgr, int nglobal) {
|
||||
|
||||
if ((l1 < 0) || (l2 < 0) || (l1 > l2))
|
||||
throw std::invalid_argument(name + ": Invalid index values for lgr");
|
||||
|
||||
if (l2 > nglobal)
|
||||
throw std::invalid_argument(name + ": Index values for lgr greater than global grid size");
|
||||
|
||||
if (nlgr % (l2-l1+1) != 0)
|
||||
throw std::invalid_argument(name + ": Number of divisions in CARFIN is not a multiple of the number of gridblocks to be refined (I2-I1+1).");
|
||||
}
|
||||
|
||||
bool update_default_index(const Opm::DeckItem& item,
|
||||
int& value)
|
||||
{
|
||||
if (item.defaultApplied(0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = item.get<int>(0) - 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool update_default(const Opm::DeckItem& item,
|
||||
int& value)
|
||||
{
|
||||
if (item.defaultApplied(0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = item.get<int>(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool update_default_name(const Opm::DeckItem& item,
|
||||
std::string& value)
|
||||
{
|
||||
if (item.defaultApplied(0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = item.get<std::string>(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
Carfin::Carfin(const GridDims& gridDims,
|
||||
IsActive isActive,
|
||||
ActiveIdx activeIdx)
|
||||
: m_globalGridDims_ (gridDims)
|
||||
, m_globalIsActive_ (std::move(isActive))
|
||||
, m_globalActiveIdx_(std::move(activeIdx))
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
|
||||
Carfin::Carfin(const GridDims& gridDims,
|
||||
IsActive isActive,
|
||||
ActiveIdx activeIdx,
|
||||
const std::string name, const int i1, const int i2,
|
||||
const int j1, const int j2,
|
||||
const int k1, const int k2,
|
||||
const int nx, const int ny,
|
||||
const int nz)
|
||||
: m_globalGridDims_ (gridDims)
|
||||
, m_globalIsActive_ (std::move(isActive))
|
||||
, m_globalActiveIdx_(std::move(activeIdx))
|
||||
{
|
||||
this->init(name,i1,i2,j1,j2,k1,k2,nx,ny,nz);
|
||||
}
|
||||
|
||||
void Carfin::update(const DeckRecord& deckRecord)
|
||||
{
|
||||
|
||||
auto default_count = 0;
|
||||
|
||||
std::string name = "LGR";
|
||||
default_count += update_default_name(deckRecord.getItem<ParserKeywords::CARFIN::NAME>(), name);
|
||||
|
||||
|
||||
int i1 = 0;
|
||||
int i2 = this->m_globalGridDims_.getNX() - 1;
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::I1>(), i1);
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::I2>(), i2);
|
||||
|
||||
int j1 = 0;
|
||||
int j2 = this->m_globalGridDims_.getNY() - 1;
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::J1>(), j1);
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::J2>(), j2);
|
||||
|
||||
int k1 = 0;
|
||||
int k2 = this->m_globalGridDims_.getNZ() - 1;
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::K1>(), k1);
|
||||
default_count += update_default_index(deckRecord.getItem<ParserKeywords::CARFIN::K2>(), k2);
|
||||
|
||||
int nx = this->m_globalGridDims_.getNX();
|
||||
int ny = this->m_globalGridDims_.getNY();
|
||||
int nz = this->m_globalGridDims_.getNZ();
|
||||
default_count += update_default(deckRecord.getItem<ParserKeywords::CARFIN::NX>(), nx);
|
||||
default_count += update_default(deckRecord.getItem<ParserKeywords::CARFIN::NY>(), ny);
|
||||
default_count += update_default(deckRecord.getItem<ParserKeywords::CARFIN::NZ>(), nz);
|
||||
|
||||
if (default_count != 10) {
|
||||
this->init(name, i1, i2, j1, j2, k1, k2, nx, ny, nz);
|
||||
}
|
||||
}
|
||||
|
||||
void Carfin::reset()
|
||||
{
|
||||
this->init("LGR", 0, this->m_globalGridDims_.getNX() - 1,
|
||||
0, this->m_globalGridDims_.getNY() - 1,
|
||||
0, this->m_globalGridDims_.getNZ() - 1,
|
||||
this->m_globalGridDims_.getNX(), this->m_globalGridDims_.getNY(), this->m_globalGridDims_.getNZ());
|
||||
}
|
||||
|
||||
void Carfin::init(const std::string name, const int i1, const int i2,
|
||||
const int j1, const int j2,
|
||||
const int k1, const int k2,
|
||||
const int nx, const int ny,
|
||||
const int nz)
|
||||
{
|
||||
assert_dims(name, i1 , i2, nx, this->m_globalGridDims_.getNX());
|
||||
assert_dims(name, j1 , j2, ny, this->m_globalGridDims_.getNY());
|
||||
assert_dims(name, k1 , k2, nz, this->m_globalGridDims_.getNZ());
|
||||
|
||||
this->m_dims[0] = nx;
|
||||
this->m_dims[1] = ny;
|
||||
this->m_dims[2] = nz;
|
||||
|
||||
this->m_offset[0] = static_cast<std::size_t>(i1);
|
||||
this->m_offset[1] = static_cast<std::size_t>(j1);
|
||||
this->m_offset[2] = static_cast<std::size_t>(k1);
|
||||
|
||||
this->m_end_offset[0] = static_cast<std::size_t>(i2);
|
||||
this->m_end_offset[1] = static_cast<std::size_t>(j2);
|
||||
this->m_end_offset[2] = static_cast<std::size_t>(k2);
|
||||
|
||||
this->initIndexList();
|
||||
}
|
||||
|
||||
std::size_t Carfin::size() const
|
||||
{
|
||||
return m_dims[0] * m_dims[1] * m_dims[2];
|
||||
}
|
||||
|
||||
bool Carfin::isGlobal() const
|
||||
{
|
||||
return this->size() == this->m_globalGridDims_.getCartesianSize();
|
||||
}
|
||||
|
||||
std::size_t Carfin::getDim(std::size_t idim) const
|
||||
{
|
||||
if (idim >= 3) {
|
||||
throw std::invalid_argument("The input dimension value is invalid");
|
||||
}
|
||||
|
||||
return m_dims[idim];
|
||||
}
|
||||
|
||||
const std::vector<Carfin::cell_index>& Carfin::index_list() const {
|
||||
return this->m_active_index_list;
|
||||
}
|
||||
|
||||
const std::vector<Carfin::cell_index>& Carfin::global_index_list() const {
|
||||
return this->m_global_index_list;
|
||||
}
|
||||
|
||||
void Carfin::initIndexList()
|
||||
{
|
||||
this->m_active_index_list.clear();
|
||||
this->m_global_index_list.clear();
|
||||
|
||||
const auto lgrdims = GridDims(this->m_dims[0], this->m_dims[1], this->m_dims[2]);
|
||||
const auto ncells = lgrdims.getCartesianSize();
|
||||
|
||||
auto binSize = std::array<std::size_t, 3>{};
|
||||
for (auto i = 0*binSize.size(); i < binSize.size(); ++i) {
|
||||
binSize[i] = this->m_dims[i] / (this->m_end_offset[i] - this->m_offset[i] + 1);
|
||||
}
|
||||
|
||||
for (auto data_index = 0*ncells; data_index != ncells; ++data_index) {
|
||||
const auto lgrIJK = lgrdims.getIJK(data_index);
|
||||
const auto global_index = this->m_globalGridDims_
|
||||
.getGlobalIndex(this->m_offset[0] + (lgrIJK[0] / binSize[0]),
|
||||
this->m_offset[1] + (lgrIJK[1] / binSize[1]),
|
||||
this->m_offset[2] + (lgrIJK[2] / binSize[2]));
|
||||
|
||||
if (this->m_globalIsActive_(global_index)) {
|
||||
const auto active_index = this->m_globalActiveIdx_(global_index);
|
||||
this->m_active_index_list.emplace_back(global_index, active_index, data_index);
|
||||
}
|
||||
|
||||
this->m_global_index_list.emplace_back(global_index, data_index);
|
||||
}
|
||||
}
|
||||
|
||||
bool Carfin::operator==(const Carfin& other) const
|
||||
{
|
||||
return (this->m_dims == other.m_dims)
|
||||
&& (this->m_offset == other.m_offset)
|
||||
&& (this->m_end_offset == other.m_end_offset);
|
||||
}
|
||||
|
||||
bool Carfin::equal(const Carfin& other) const
|
||||
{
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
int Carfin::lower(int dim) const {
|
||||
return m_offset[dim];
|
||||
}
|
||||
|
||||
int Carfin::upper(int dim) const {
|
||||
return m_end_offset[dim];
|
||||
}
|
||||
|
||||
int Carfin::dimension(int dim) const {
|
||||
return m_dims[dim];
|
||||
}
|
||||
|
||||
// std::string Carfin::NAME() const {
|
||||
// return ?;
|
||||
// }
|
||||
|
||||
int Carfin::I1() const {
|
||||
return lower(0);
|
||||
}
|
||||
|
||||
int Carfin::I2() const {
|
||||
return upper(0);
|
||||
}
|
||||
|
||||
int Carfin::J1() const {
|
||||
return lower(1);
|
||||
}
|
||||
|
||||
int Carfin::J2() const {
|
||||
return upper(1);
|
||||
}
|
||||
|
||||
int Carfin::K1() const {
|
||||
return lower(2);
|
||||
}
|
||||
|
||||
int Carfin::K2() const {
|
||||
return upper(2);
|
||||
}
|
||||
|
||||
int Carfin::NX() const {
|
||||
return dimension(0);
|
||||
}
|
||||
|
||||
int Carfin::NY() const {
|
||||
return dimension(1);
|
||||
}
|
||||
|
||||
int Carfin::NZ() const {
|
||||
return dimension(2);
|
||||
}
|
||||
|
||||
}
|
||||
97
src/opm/input/eclipse/EclipseState/Grid/CarfinManager.cpp
Normal file
97
src/opm/input/eclipse/EclipseState/Grid/CarfinManager.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
Copyright 2022 Equinor
|
||||
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 <stdexcept>
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
CarfinManager::CarfinManager(const GridDims& gridDims,
|
||||
Carfin::IsActive isActive,
|
||||
Carfin::ActiveIdx activeIdx)
|
||||
: gridDims_ (gridDims)
|
||||
, isActive_ (isActive)
|
||||
, activeIdx_ (activeIdx)
|
||||
, m_globalCarfin(std::make_unique<Carfin>(gridDims_, isActive_, activeIdx_))
|
||||
{}
|
||||
|
||||
const Carfin& CarfinManager::getActiveCarfin() const {
|
||||
if (m_keywordCarfin)
|
||||
return *m_keywordCarfin;
|
||||
|
||||
if (m_inputCarfin)
|
||||
return *m_inputCarfin;
|
||||
|
||||
return *m_globalCarfin;
|
||||
}
|
||||
|
||||
void CarfinManager::setInputCarfin(std::string name, int i1, int i2,
|
||||
int j1, int j2,
|
||||
int k1, int k2,
|
||||
int nx , int ny , int nz)
|
||||
{
|
||||
this->m_inputCarfin = this->makeLgr(name, i1, i2, j1, j2, k1, k2, nx, ny, nz);
|
||||
}
|
||||
|
||||
void CarfinManager::endInputCarfin()
|
||||
{
|
||||
if (this->m_keywordCarfin != nullptr) {
|
||||
throw std::invalid_argument {
|
||||
"the SECTION is terminated with an active keyword Carfin"
|
||||
};
|
||||
}
|
||||
|
||||
this->m_inputCarfin.reset();
|
||||
}
|
||||
|
||||
void CarfinManager::endSection()
|
||||
{
|
||||
this->endInputCarfin();
|
||||
}
|
||||
|
||||
void CarfinManager::readKeywordCarfin(std::string name, int i1, int i2,
|
||||
int j1, int j2,
|
||||
int k1, int k2,
|
||||
int nx , int ny , int nz)
|
||||
{
|
||||
this->m_keywordCarfin = this->makeLgr(name, i1, i2, j1, j2, k1, k2, nx, ny, nz);
|
||||
}
|
||||
|
||||
void CarfinManager::endKeyword()
|
||||
{
|
||||
this->m_keywordCarfin.reset();
|
||||
}
|
||||
|
||||
const std::vector<Carfin::cell_index>& CarfinManager::index_list() const
|
||||
{
|
||||
return this->getActiveCarfin().index_list();
|
||||
}
|
||||
|
||||
std::unique_ptr<Carfin>
|
||||
CarfinManager::makeLgr(std::string name, int i1, int i2,
|
||||
int j1, int j2,
|
||||
int k1, int k2,
|
||||
int nx , int ny , int nz) const
|
||||
{
|
||||
return std::make_unique<Carfin>(this->gridDims_,
|
||||
this->isActive_,
|
||||
this->activeIdx_,
|
||||
name, i1, i2,
|
||||
j1, j2,
|
||||
k1, k2,
|
||||
nx, ny, nz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (C) 2022 Equinor
|
||||
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 "readKeywordCarfin.hpp"
|
||||
namespace Opm {
|
||||
|
||||
void readKeywordCarfin( const DeckRecord& deckRecord, CarfinManager& carfinManager) {
|
||||
const auto& NAMEItem = deckRecord.getItem("NAME");
|
||||
const auto& I1Item = deckRecord.getItem("I1");
|
||||
const auto& I2Item = deckRecord.getItem("I2");
|
||||
const auto& J1Item = deckRecord.getItem("J1");
|
||||
const auto& J2Item = deckRecord.getItem("J2");
|
||||
const auto& K1Item = deckRecord.getItem("K1");
|
||||
const auto& K2Item = deckRecord.getItem("K2");
|
||||
const auto& NXItem = deckRecord.getItem("NX");
|
||||
const auto& NYItem = deckRecord.getItem("NY");
|
||||
const auto& NZItem = deckRecord.getItem("NZ");
|
||||
// const auto& NWMAXItem = deckRecord.getItem("NWMAX");
|
||||
// const auto& PARENTItem = deckRecord.getItem("PARENT");
|
||||
|
||||
const auto& active_carfin = carfinManager.getActiveCarfin();
|
||||
|
||||
const std::string name = NAMEItem.defaultApplied(0) ? active_carfin.NAME() : NAMEItem.get<std::string>(0);
|
||||
const int i1 = I1Item.defaultApplied(0) ? active_carfin.I1() : I1Item.get<int>(0) - 1;
|
||||
const int i2 = I2Item.defaultApplied(0) ? active_carfin.I2() : I2Item.get<int>(0) - 1;
|
||||
const int j1 = J1Item.defaultApplied(0) ? active_carfin.J1() : J1Item.get<int>(0) - 1;
|
||||
const int j2 = J2Item.defaultApplied(0) ? active_carfin.J2() : J2Item.get<int>(0) - 1;
|
||||
const int k1 = K1Item.defaultApplied(0) ? active_carfin.K1() : K1Item.get<int>(0) - 1;
|
||||
const int k2 = K2Item.defaultApplied(0) ? active_carfin.K2() : K2Item.get<int>(0) - 1;
|
||||
const int nx = NXItem.defaultApplied(0) ? active_carfin.NX() : NXItem.get<int>(0);
|
||||
const int ny = NYItem.defaultApplied(0) ? active_carfin.NY() : NYItem.get<int>(0);
|
||||
const int nz = NZItem.defaultApplied(0) ? active_carfin.NZ() : NZItem.get<int>(0);
|
||||
|
||||
carfinManager.readKeywordCarfin(name,i1,i2,j1,j2,k1,k2,nx,ny,nz);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright (C) 2022 Equinor
|
||||
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 READ_KEYWORDCARFIN_HPP
|
||||
#define READ_KEYWORDCARFIN_HPP
|
||||
|
||||
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
void readKeywordCarfin( const DeckRecord& deckRecord, CarfinManager& carfinManager);
|
||||
|
||||
}
|
||||
#endif
|
||||
83
tests/parser/CarfinTests.cpp
Normal file
83
tests/parser/CarfinTests.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright (C) 2022 Equinor
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE CarfinManagerTests
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
Opm::Carfin::IsActive allActive()
|
||||
{
|
||||
return [](const std::size_t) { return true; };
|
||||
}
|
||||
|
||||
Opm::Carfin::ActiveIdx identityMapping()
|
||||
{
|
||||
return [](const std::size_t i) { return i; };
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestKeywordCarfin) {
|
||||
|
||||
Opm::GridDims gridDims(10,7,6);
|
||||
|
||||
// J2 < J1
|
||||
BOOST_CHECK_THROW( Opm::Carfin(gridDims, allActive(), identityMapping(), "LGR",1,1,4,3,2,2,2,2,2), std::invalid_argument);
|
||||
|
||||
// J2 > nyglobal
|
||||
BOOST_CHECK_THROW( Opm::Carfin(gridDims, allActive(), identityMapping(), "LGR",1,1,3,8,2,2,2,12,2), std::invalid_argument);
|
||||
|
||||
//nlgr % (l2-l1+1) != 0
|
||||
BOOST_CHECK_THROW( Opm::Carfin(gridDims, allActive(), identityMapping(), "LGR",1,1,3,4,2,2,2,5,2), std::invalid_argument);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateLgr) {
|
||||
Opm::Carfin lgr(Opm::GridDims{ 4, 3, 2 }, allActive(), identityMapping());
|
||||
BOOST_CHECK_EQUAL( 24U , lgr.size() );
|
||||
BOOST_CHECK( lgr.isGlobal() );
|
||||
BOOST_CHECK_EQUAL( 4U , lgr.getDim(0) );
|
||||
BOOST_CHECK_EQUAL( 3U , lgr.getDim(1) );
|
||||
BOOST_CHECK_EQUAL( 2U , lgr.getDim(2) );
|
||||
|
||||
BOOST_CHECK_THROW( lgr.getDim(5) , std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateCarfinManager) {
|
||||
Opm::GridDims gridDims(10,10,10);
|
||||
Opm::CarfinManager carfinManager(gridDims, allActive(), identityMapping());
|
||||
Opm::Carfin lgr(gridDims, allActive(), identityMapping());
|
||||
|
||||
BOOST_CHECK( lgr.equal( carfinManager.getActiveCarfin()) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestInputCarfin) {
|
||||
Opm::GridDims gridDims(10,10,10);
|
||||
Opm::CarfinManager carfinManager(gridDims, allActive(), identityMapping());
|
||||
Opm::Carfin inputLgr( gridDims, allActive(), identityMapping(), "LGR", 1,4,1,4,1,4,4,4,4);
|
||||
Opm::Carfin globalLgr( gridDims, allActive(), identityMapping() );
|
||||
|
||||
carfinManager.setInputCarfin("LGR", 1,4,1,4,1,4,4,4,4);
|
||||
BOOST_CHECK( inputLgr.equal( carfinManager.getActiveCarfin()) );
|
||||
carfinManager.endSection();
|
||||
BOOST_CHECK( carfinManager.getActiveCarfin().equal(globalLgr));
|
||||
}
|
||||
Reference in New Issue
Block a user