diff --git a/ebos/eclgenerictracermodel.cc b/ebos/eclgenerictracermodel.cc index bcf4f1d22..bdd8403ea 100644 --- a/ebos/eclgenerictracermodel.cc +++ b/ebos/eclgenerictracermodel.cc @@ -106,15 +106,6 @@ EclGenericTracerModel(const GridView& gridView, { } -template -const std::string& EclGenericTracerModel:: -tracerName(int tracerIdx) const -{ - if (tracerNames_.empty()) - throw std::logic_error("This method should never be called when there are no tracers in the model"); - - return tracerNames_[tracerIdx]; -} template Scalar EclGenericTracerModel:: @@ -141,6 +132,20 @@ numTracers() const return this->eclState_.tracer().size(); } +template +std::string EclGenericTracerModel:: +fname(int tracerIdx) const +{ + return this->eclState_.tracer()[tracerIdx].fname(); +} + +template +const std::string& EclGenericTracerModel:: +name(int tracerIdx) const +{ + return this->eclState_.tracer()[tracerIdx].name; +} + template void EclGenericTracerModel:: @@ -164,15 +169,14 @@ doInit(bool enabled, size_t numGridDof, // retrieve the number of tracers from the deck const size_t numTracers = tracers.size(); - tracerNames_.resize(numTracers); tracerConcentration_.resize(numTracers); storageOfTimeIndex1_.resize(numTracers); // the phase where the tracer is tracerPhaseIdx_.resize(numTracers); - size_t tracerIdx = 0; - for (const auto& tracer : tracers) { - tracerNames_[tracerIdx] = tracer.name; + for (size_t tracerIdx = 0; tracerIdx < numTracers; tracerIdx++) { + const auto& tracer = tracers[tracerIdx]; + if (tracer.phase == Phase::WATER) tracerPhaseIdx_[tracerIdx] = waterPhaseIdx; else if (tracer.phase == Phase::OIL) @@ -206,8 +210,6 @@ doInit(bool enabled, size_t numGridDof, } } else throw std::logic_error(fmt::format("Can not initialize tracer: {}", tracer.name)); - - ++tracerIdx; } // initial tracer concentration diff --git a/ebos/eclgenerictracermodel.hh b/ebos/eclgenerictracermodel.hh index 95a7183b0..80cb2f02d 100644 --- a/ebos/eclgenerictracermodel.hh +++ b/ebos/eclgenerictracermodel.hh @@ -60,7 +60,9 @@ public: /*! * \brief Return the tracer name */ - const std::string& tracerName(int tracerIdx) const; + const std::string& name(int tracerIdx) const; + std::string fname(int tracerIdx) const; + /*! * \brief Return the tracer concentration for tracer index and global DofIdx @@ -99,7 +101,6 @@ protected: const CartesianIndexMapper& cartMapper_; const DofMapper& dofMapper_; - std::vector tracerNames_; std::vector tracerPhaseIdx_; std::vector>> tracerConcentration_; std::vector>> tracerConcentrationInitial_; diff --git a/ebos/ecltracermodel.hh b/ebos/ecltracermodel.hh index 597c4705f..4fce8eb1e 100644 --- a/ebos/ecltracermodel.hh +++ b/ebos/ecltracermodel.hh @@ -306,12 +306,12 @@ protected: const auto& well = wellPtr->wellEcl(); for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) { - this->wellTracerRate_[std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])] = 0.0; + this->wellTracerRate_[std::make_pair(well.name(), this->name(tr.idx_[tIdx]))] = 0.0; } std::vector wtracer(tr.numTracer()); for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) { - wtracer[tIdx] = well.getTracerProperties().getConcentration(this->tracerNames_[tr.idx_[tIdx]]); + wtracer[tIdx] = well.getTracerProperties().getConcentration(this->name(tr.idx_[tIdx])); } for (auto& perfData : wellPtr->perforationData()) { @@ -321,7 +321,7 @@ protected: for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) { tr.residual_[tIdx][I][0] -= rate*wtracer[tIdx]; // Store _injector_ tracer rate for reporting - this->wellTracerRate_.at(std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])) += rate*wtracer[tIdx]; + this->wellTracerRate_.at(std::make_pair(well.name(),this->name(tr.idx_[tIdx]))) += rate*wtracer[tIdx]; } } else if (rate < 0) { @@ -402,7 +402,7 @@ protected: if (rate < 0) { rateWellNeg += rate; for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) { - this->wellTracerRate_.at(std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])) += rate*tr.concentration_[tIdx][I]; + this->wellTracerRate_.at(std::make_pair(well.name(),this->name(tr.idx_[tIdx]))) += rate*tr.concentration_[tIdx][I]; } } else { @@ -424,7 +424,7 @@ protected: const Scalar bucketPrDay = 10.0/(1000.*3600.*24.); // ... keeps (some) trouble away const Scalar factor = (rateWellTotal < -bucketPrDay) ? rateWellTotal/rateWellNeg : 0.0; for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) { - this->wellTracerRate_.at(std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])) *= factor; + this->wellTracerRate_.at(std::make_pair(well.name(),this->name(tr.idx_[tIdx]))) *= factor; } } } @@ -435,27 +435,27 @@ protected: for (size_t tracerIdx=0; tracerIdxtracerPhaseIdx_.size(); ++tracerIdx) { if (this->tracerPhaseIdx_[tracerIdx] == FluidSystem::waterPhaseIdx) { if (! FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)){ - throw std::runtime_error("Water tracer specified for non-water fluid system:" + this->tracerNames_[tracerIdx]); + throw std::runtime_error("Water tracer specified for non-water fluid system:" + this->name(tracerIdx)); } wat_.addTracer(tracerIdx, this->tracerConcentration_[tracerIdx]); } else if (this->tracerPhaseIdx_[tracerIdx] == FluidSystem::oilPhaseIdx) { if (! FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)){ - throw std::runtime_error("Oil tracer specified for non-oil fluid system:" + this->tracerNames_[tracerIdx]); + throw std::runtime_error("Oil tracer specified for non-oil fluid system:" + this->name(tracerIdx)); } if (FluidSystem::enableVaporizedOil()) { - throw std::runtime_error("Oil tracer in combination with kw VAPOIL is not supported: " + this->tracerNames_[tracerIdx]); + throw std::runtime_error("Oil tracer in combination with kw VAPOIL is not supported: " + this->name(tracerIdx)); } oil_.addTracer(tracerIdx, this->tracerConcentration_[tracerIdx]); } else if (this->tracerPhaseIdx_[tracerIdx] == FluidSystem::gasPhaseIdx) { if (! FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)){ - throw std::runtime_error("Gas tracer specified for non-gas fluid system:" + this->tracerNames_[tracerIdx]); + throw std::runtime_error("Gas tracer specified for non-gas fluid system:" + this->name(tracerIdx)); } if (FluidSystem::enableDissolvedGas()) { - throw std::runtime_error("Gas tracer in combination with kw DISGAS is not supported: " + this->tracerNames_[tracerIdx]); + throw std::runtime_error("Gas tracer in combination with kw DISGAS is not supported: " + this->name(tracerIdx)); } gas_.addTracer(tracerIdx, this->tracerConcentration_[tracerIdx]); diff --git a/ebos/vtkecltracermodule.hh b/ebos/vtkecltracermodule.hh index 78263b147..b1b2ec608 100644 --- a/ebos/vtkecltracermodule.hh +++ b/ebos/vtkecltracermodule.hh @@ -153,7 +153,7 @@ namespace Opm { if (eclTracerConcentrationOutput_()){ const auto& tracerModel = this->simulator_.problem().tracerModel(); for(size_t tracerIdx=0; tracerIdxcommitScalarBuffer_(baseWriter,tmp.c_str(), eclTracerConcentration_[tracerIdx]); } }