Merge pull request #2496 from akva2/tracers_from_state

Use tracers from EclipseState
This commit is contained in:
Joakim Hove 2020-03-25 10:17:56 +01:00 committed by GitHub
commit 54cd4f96f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 108 deletions

View File

@ -28,7 +28,7 @@
#ifndef EWOMS_ECL_TRACER_MODEL_HH #ifndef EWOMS_ECL_TRACER_MODEL_HH
#define EWOMS_ECL_TRACER_MODEL_HH #define EWOMS_ECL_TRACER_MODEL_HH
#include "tracervdtable.hh" #include <opm/parser/eclipse/EclipseState/Tables/TracerVdTable.hpp>
#include <opm/models/blackoil/blackoilmodel.hh> #include <opm/models/blackoil/blackoilmodel.hh>
@ -95,15 +95,10 @@ public:
*/ */
void init() void init()
{ {
const Opm::Deck& deck = simulator_.vanguard().deck(); const auto& tracers = simulator_.vanguard().eclState().tracer();
const auto& comm = simulator_.gridView().comm(); const auto& comm = simulator_.gridView().comm();
bool has; if (tracers.size() == 0)
if (comm.rank() == 0)
has = deck.hasKeyword("TRACERS");
comm.broadcast(&has, 1, 0);
if (!has)
return; // tracer treatment is supposed to be disabled return; // tracer treatment is supposed to be disabled
if (!EWOMS_GET_PARAM(TypeTag, bool, EnableTracerModel)) { if (!EWOMS_GET_PARAM(TypeTag, bool, EnableTracerModel)) {
@ -115,19 +110,16 @@ public:
return; // Tracer transport must be enabled by the user return; // Tracer transport must be enabled by the user
} }
if (!deck.hasKeyword("TRACER")) if (comm.size() > 1) {
throw std::runtime_error("The deck does not contain the TRACER keyword");
if (simulator_.gridView().comm().size() > 1) {
tracerNames_.resize(0); tracerNames_.resize(0);
if (simulator_.gridView().comm().rank() == 0) if (comm.rank() == 0)
std::cout << "Warning: The tracer model currently does not work for parallel runs\n" std::cout << "Warning: The tracer model currently does not work for parallel runs\n"
<< std::flush; << std::flush;
return; return;
} }
// retrieve the number of tracers from the deck // retrieve the number of tracers from the deck
const int numTracers = deck.getKeyword("TRACER").size(); const size_t numTracers = tracers.size();
tracerNames_.resize(numTracers); tracerNames_.resize(numTracers);
tracerConcentration_.resize(numTracers); tracerConcentration_.resize(numTracers);
storageOfTimeIndex1_.resize(numTracers); storageOfTimeIndex1_.resize(numTracers);
@ -135,60 +127,44 @@ public:
// the phase where the tracer is // the phase where the tracer is
tracerPhaseIdx_.resize(numTracers); tracerPhaseIdx_.resize(numTracers);
size_t numGridDof = simulator_.model().numGridDof(); size_t numGridDof = simulator_.model().numGridDof();
for (int tracerIdx = 0; tracerIdx < numTracers; ++tracerIdx) { size_t tracerIdx = 0;
const auto& tracerRecord = deck.getKeyword("TRACER").getRecord(tracerIdx); for (const auto& tracer : tracers) {
tracerNames_[tracerIdx] = tracerRecord.getItem("NAME").template get<std::string>(0); tracerNames_[tracerIdx] = tracer.name;
const std::string& fluidName = tracerRecord.getItem("FLUID").template get<std::string>(0); if (tracer.phase == Phase::WATER)
if (fluidName == "WAT")
tracerPhaseIdx_[tracerIdx] = waterPhaseIdx; tracerPhaseIdx_[tracerIdx] = waterPhaseIdx;
else if (fluidName == "OIL") else if (tracer.phase == Phase::OIL)
tracerPhaseIdx_[tracerIdx] = oilPhaseIdx; tracerPhaseIdx_[tracerIdx] = oilPhaseIdx;
else if (fluidName == "GAS") else if (tracer.phase == Phase::GAS)
tracerPhaseIdx_[tracerIdx] = gasPhaseIdx; tracerPhaseIdx_[tracerIdx] = gasPhaseIdx;
else
throw std::invalid_argument("Tracer: invalid fluid name "
+fluidName+" for "+tracerNames_[tracerIdx]);
tracerConcentration_[tracerIdx].resize(numGridDof); tracerConcentration_[tracerIdx].resize(numGridDof);
storageOfTimeIndex1_[tracerIdx].resize(numGridDof); storageOfTimeIndex1_[tracerIdx].resize(numGridDof);
std::string tmp = "TVDPF" +tracerNames_[tracerIdx];
//TBLK keyword //TBLK keyword
if (deck.hasKeyword("TBLKF" +tracerNames_[tracerIdx])){ if (!tracer.concentration.empty()){
const auto& cartMapper = simulator_.vanguard().cartesianIndexMapper(); const auto& cartMapper = simulator_.vanguard().cartesianIndexMapper();
const auto& tblkData = int tblkDatasize = tracer.concentration.size();
deck.getKeyword("TBLKF"
+tracerNames_
[tracerIdx]).getRecord(0).getItem(0).getSIDoubleData();
int tblkDatasize = tblkData.size();
if (tblkDatasize < simulator_.vanguard().cartesianSize()){ if (tblkDatasize < simulator_.vanguard().cartesianSize()){
throw std::runtime_error("Uninitialized tracer concentration (TBLKF) for tracer " throw std::runtime_error("Wrong size of TBLK for" + tracer.name);
+ tracerName(tracerIdx));
} }
for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){ for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){
int cartDofIdx = cartMapper.cartesianIndex(globalDofIdx); int cartDofIdx = cartMapper.cartesianIndex(globalDofIdx);
tracerConcentration_[tracerIdx][globalDofIdx] = tblkData[cartDofIdx]; tracerConcentration_[tracerIdx][globalDofIdx] = tracer.concentration[cartDofIdx];
} }
} }
//TVDPF keyword //TVDPF keyword
else if (deck.hasKeyword(tmp)){ else {
TracerVdTable dtable(deck.getKeyword(tmp).getRecord(0).getItem(0));
const auto& eclGrid = simulator_.vanguard().eclState().getInputGrid(); const auto& eclGrid = simulator_.vanguard().eclState().getInputGrid();
const auto& cartMapper = simulator_.vanguard().cartesianIndexMapper(); const auto& cartMapper = simulator_.vanguard().cartesianIndexMapper();
for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){ for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){
int cartDofIdx = cartMapper.cartesianIndex(globalDofIdx); int cartDofIdx = cartMapper.cartesianIndex(globalDofIdx);
const auto& center = eclGrid.getCellCenter(cartDofIdx); const auto& center = eclGrid.getCellCenter(cartDofIdx);
tracerConcentration_[tracerIdx][globalDofIdx] tracerConcentration_[tracerIdx][globalDofIdx] = tracer.tvdpf.evaluate("TRACER_CONCENTRATION", center[2]);
= dtable.evaluate("TRACER_CONCENTRATION", center[2]);
} }
} }
else { ++tracerIdx;
throw std::runtime_error("Uninitialized tracer concentration for tracer "
+ tracerName(tracerIdx));
}
} }
// initial tracer concentration // initial tracer concentration

View File

@ -1,65 +0,0 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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 2 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/>.
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
*
* \copydoc Opm::TracerVdTable
*/
#ifndef EWOMS_TRACER_VD_TABLE_HH
#define EWOMS_TRACER_VD_TABLE_HH
#include <opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp>
namespace Opm {
/*!
* \brief A class that contains tracer concentration vs depth table
*/
class TracerVdTable : public Opm::SimpleTable
{
public:
TracerVdTable(const Opm::DeckItem& item)
{
this->m_schema.addColumn(Opm::ColumnSchema("DEPTH", Opm::Table::STRICTLY_INCREASING, Opm::Table::DEFAULT_NONE));
this->m_schema.addColumn(Opm::ColumnSchema("TRACER_CONCENTRATION", Opm::Table::RANDOM, Opm::Table::DEFAULT_NONE));
Opm::SimpleTable::init(item);
}
/*!
* \brief Return the depth column
*/
const Opm::TableColumn& getDepthColumn() const
{ return Opm::SimpleTable::getColumn(0); }
/*!
* \brief Return the tracer concentration column
*/
const Opm::TableColumn& getTracerConcentration() const
{ return Opm::SimpleTable::getColumn(1); }
};
}
#endif // TRACERVDTABLE_HH

View File

@ -33,6 +33,7 @@
#include <opm/parser/eclipse/EclipseState/Aquifetp.hpp> #include <opm/parser/eclipse/EclipseState/Aquifetp.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseConfig.hpp> #include <opm/parser/eclipse/EclipseState/EclipseConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp> #include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/TracerConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp> #include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp> #include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp> #include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
@ -426,6 +427,7 @@ TEST_FOR_TYPE(TableManager)
TEST_FOR_TYPE(TableSchema) TEST_FOR_TYPE(TableSchema)
TEST_FOR_TYPE(ThresholdPressure) TEST_FOR_TYPE(ThresholdPressure)
TEST_FOR_TYPE(TimeMap) TEST_FOR_TYPE(TimeMap)
TEST_FOR_TYPE(TracerConfig)
TEST_FOR_TYPE(TransMult) TEST_FOR_TYPE(TransMult)
TEST_FOR_TYPE(Tuning) TEST_FOR_TYPE(Tuning)
TEST_FOR_TYPE(UDAValue) TEST_FOR_TYPE(UDAValue)