Add NNC class
This class provides the raw non-neighboring connections data as read from the deck and/or added using the addNNC method. The NNC data is currently not processed. I.e. multiple NNC connection between the same cell can exist side by side.
This commit is contained in:
@@ -108,6 +108,7 @@ EclipseState/Grid/EclipseGrid.cpp
|
||||
EclipseState/Grid/FaultFace.cpp
|
||||
EclipseState/Grid/Fault.cpp
|
||||
EclipseState/Grid/FaultCollection.cpp
|
||||
EclipseState/Grid/NNC.cpp
|
||||
#
|
||||
EclipseState/SimulationConfig/SimulationConfig.cpp
|
||||
EclipseState/SimulationConfig/ThresholdPressure.cpp
|
||||
@@ -195,6 +196,7 @@ EclipseState/Grid/TransMult.hpp
|
||||
EclipseState/Grid/FaultFace.hpp
|
||||
EclipseState/Grid/Fault.hpp
|
||||
EclipseState/Grid/FaultCollection.hpp
|
||||
EclipseState/Grid/NNC.hpp
|
||||
#
|
||||
EclipseState/SimulationConfig/SimulationConfig.hpp
|
||||
EclipseState/SimulationConfig/ThresholdPressure.hpp
|
||||
|
||||
74
opm/parser/eclipse/EclipseState/Grid/NNC.cpp
Normal file
74
opm/parser/eclipse/EclipseState/Grid/NNC.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright 2015 IRIS
|
||||
|
||||
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 "NNC.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
NNC::NNC(Opm::DeckConstPtr deck, EclipseGridConstPtr eclipseGrid)
|
||||
{
|
||||
if (deck->hasKeyword("NNC")) {
|
||||
const std::vector<DeckKeywordConstPtr>& nncs = deck->getKeywordList("NNC");
|
||||
for (size_t idx_nnc = 0; idx_nnc<nncs.size(); ++idx_nnc) {
|
||||
Opm::DeckKeywordConstPtr nnc = nncs[idx_nnc];
|
||||
size_t numNNC = nnc->size();
|
||||
nnc1_.reserve(numNNC);
|
||||
nnc2_.reserve(numNNC);
|
||||
trans_.reserve(numNNC);
|
||||
|
||||
for (size_t i = 0; i<numNNC; ++i) {
|
||||
std::array<int, 3> xyz1;
|
||||
xyz1[0] = nnc->getRecord(i)->getItem(0)->getInt(0)-1;
|
||||
xyz1[1] = nnc->getRecord(i)->getItem(1)->getInt(0)-1;
|
||||
xyz1[2] = nnc->getRecord(i)->getItem(2)->getInt(0)-1;
|
||||
size_t global_index1 = eclipseGrid->getGlobalIndex(xyz1[0],xyz1[1],xyz1[2]);
|
||||
nnc1_.push_back(global_index1);
|
||||
|
||||
std::array<int, 3> xyz2;
|
||||
xyz2[0] = nnc->getRecord(i)->getItem(3)->getInt(0)-1;
|
||||
xyz2[1] = nnc->getRecord(i)->getItem(4)->getInt(0)-1;
|
||||
xyz2[2] = nnc->getRecord(i)->getItem(5)->getInt(0)-1;
|
||||
size_t global_index2 = eclipseGrid->getGlobalIndex(xyz2[0],xyz2[1],xyz2[2]);
|
||||
nnc2_.push_back(global_index2);
|
||||
|
||||
const double trans = nnc->getRecord(i)->getItem(6)->getRawDouble(0);
|
||||
trans_.push_back(trans);
|
||||
}
|
||||
}
|
||||
hasNNC_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void NNC::addNNC(const int NNC1, const int NNC2, const double trans) {
|
||||
nnc1_.push_back(NNC1);
|
||||
nnc2_.push_back(NNC2);
|
||||
trans_.push_back(trans);
|
||||
}
|
||||
|
||||
int NNC::numNNC() {
|
||||
return(nnc1_.size());
|
||||
}
|
||||
|
||||
bool NNC::hasNNC() {
|
||||
return hasNNC_;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
52
opm/parser/eclipse/EclipseState/Grid/NNC.hpp
Normal file
52
opm/parser/eclipse/EclipseState/Grid/NNC.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2015 IRIS
|
||||
|
||||
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 NNC_HPP
|
||||
#define NNC_HPP
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
class NNC
|
||||
{
|
||||
public:
|
||||
/// Construct from input deck.
|
||||
NNC(Opm::DeckConstPtr deck, EclipseGridConstPtr eclipseGrid);
|
||||
void addNNC(const int NNC1, const int NNC2, const double trans);
|
||||
const std::vector<int>& nnc1() const { return nnc1_; }
|
||||
const std::vector<int>& nnc2() const { return nnc2_; }
|
||||
const std::vector<double>& trans() const { return trans_; }
|
||||
int numNNC();
|
||||
bool hasNNC();
|
||||
|
||||
private:
|
||||
std::vector<int> nnc1_;
|
||||
std::vector<int> nnc2_;
|
||||
std::vector<double> trans_;
|
||||
bool hasNNC_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
|
||||
#endif // NNC_HPP
|
||||
@@ -6,7 +6,7 @@ foreach(tapp CheckDeckValidity IntegrationTests ParseWellProbe
|
||||
ParseTVDP ParseDENSITY ParseVFPPROD ScheduleCreateFromDeck
|
||||
CompletionsFromDeck ParseEND IncludeTest ParseEQUIL
|
||||
ParseRSVD ParsePVTG ParsePVTO ParseSWOF BoxTest
|
||||
ParseMULTREGT ParseSGOF EclipseGridCreateFromDeck)
|
||||
ParseMULTREGT ParseSGOF EclipseGridCreateFromDeck NNCTests)
|
||||
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
|
||||
LIBRARIES opmparser ${Boost_LIBRARIES})
|
||||
endforeach()
|
||||
|
||||
90
opm/parser/eclipse/IntegrationTests/NNCTests.cpp
Normal file
90
opm/parser/eclipse/IntegrationTests/NNCTests.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright 2015 IRIS
|
||||
|
||||
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/parser/eclipse/EclipseState/Grid/NNC.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
#define NVERBOSE // to suppress our messages when throwing
|
||||
|
||||
#define BOOST_TEST_MODULE NNCTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(noNNC)
|
||||
{
|
||||
const std::string filename = "testdata/integration_tests/NNC/noNNC.DATA";
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr deck(parser->parseFile(filename));
|
||||
Opm::EclipseStateConstPtr eclipseState(new EclipseState(deck));
|
||||
auto eclGrid = eclipseState->getEclipseGrid();
|
||||
Opm::NNC nnc(deck, eclGrid);
|
||||
BOOST_CHECK(!nnc.hasNNC());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readDeck)
|
||||
{
|
||||
const std::string filename = "testdata/integration_tests/NNC/NNC.DATA";
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr deck(parser->parseFile(filename));
|
||||
Opm::EclipseStateConstPtr eclipseState(new EclipseState(deck));
|
||||
auto eclGrid = eclipseState->getEclipseGrid();
|
||||
Opm::NNC nnc(deck, eclGrid);
|
||||
BOOST_CHECK(nnc.hasNNC());
|
||||
const std::vector<int>& NNC1 = nnc.nnc1();
|
||||
const std::vector<int>& NNC2 = nnc.nnc2();
|
||||
const std::vector<double>& trans = nnc.trans();
|
||||
|
||||
// test the NNCs in nnc.DATA
|
||||
BOOST_CHECK_EQUAL(nnc.numNNC(), 4);
|
||||
BOOST_CHECK_EQUAL(NNC1[0], 0);
|
||||
BOOST_CHECK_EQUAL(NNC2[0], 1);
|
||||
BOOST_CHECK_EQUAL(trans[0], 0.5);
|
||||
BOOST_CHECK_EQUAL(NNC1[1], 0);
|
||||
BOOST_CHECK_EQUAL(NNC2[1], 10);
|
||||
BOOST_CHECK_EQUAL(trans[1], 1.0);
|
||||
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(addNNC)
|
||||
{
|
||||
const std::string filename = "testdata/integration_tests/NNC/NNC.DATA";
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr deck(parser->parseFile(filename));
|
||||
Opm::EclipseStateConstPtr eclipseState(new EclipseState(deck));
|
||||
auto eclGrid = eclipseState->getEclipseGrid();
|
||||
Opm::NNC nnc(deck, eclGrid);
|
||||
const std::vector<int>& NNC1 = nnc.nnc1();
|
||||
const std::vector<int>& NNC2 = nnc.nnc2();
|
||||
const std::vector<double>& trans = nnc.trans();
|
||||
|
||||
// test add NNC
|
||||
nnc.addNNC(2,2,2.0);
|
||||
BOOST_CHECK_EQUAL(nnc.numNNC(), 5);
|
||||
BOOST_CHECK_EQUAL(NNC1[4], 2);
|
||||
BOOST_CHECK_EQUAL(NNC2[4], 2);
|
||||
BOOST_CHECK_EQUAL(trans[4], 2.0);
|
||||
}
|
||||
|
||||
|
||||
37
testdata/integration_tests/NNC/NNC.DATA
vendored
Normal file
37
testdata/integration_tests/NNC/NNC.DATA
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
RUNSPEC
|
||||
|
||||
OIL
|
||||
GAS
|
||||
WATER
|
||||
|
||||
|
||||
DIMENS
|
||||
10 10 1 /
|
||||
|
||||
GRID
|
||||
|
||||
DXV
|
||||
10*1000.0
|
||||
/
|
||||
|
||||
DYV
|
||||
10*1000.0
|
||||
/
|
||||
|
||||
DZ
|
||||
100*20.0
|
||||
/
|
||||
|
||||
TOPS
|
||||
100*10
|
||||
/
|
||||
|
||||
NNC
|
||||
1 1 1 2 1 1 0.5 /
|
||||
1 1 1 1 2 1 1.0 /
|
||||
/
|
||||
|
||||
NNC
|
||||
1 1 1 2 1 1 0.5 /
|
||||
1 2 1 1 2 1 1.0 /
|
||||
/
|
||||
28
testdata/integration_tests/NNC/noNNC.DATA
vendored
Normal file
28
testdata/integration_tests/NNC/noNNC.DATA
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
RUNSPEC
|
||||
|
||||
OIL
|
||||
GAS
|
||||
WATER
|
||||
|
||||
|
||||
DIMENS
|
||||
10 10 1 /
|
||||
|
||||
GRID
|
||||
|
||||
DXV
|
||||
10*1000.0
|
||||
/
|
||||
|
||||
DYV
|
||||
10*1000.0
|
||||
/
|
||||
|
||||
DZ
|
||||
100*20.0
|
||||
/
|
||||
|
||||
TOPS
|
||||
100*10
|
||||
/
|
||||
|
||||
Reference in New Issue
Block a user