28#ifndef OPM_TRACER_MODEL_HPP
29#define OPM_TRACER_MODEL_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
32#include <opm/common/TimingMacros.hpp>
34#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
36#include <opm/grid/utility/ElementChunks.hpp>
54template<
class TypeTag,
class MyTypeTag>
68template <
class TypeTag>
70 GetPropType<TypeTag, Properties::GridView>,
71 GetPropType<TypeTag, Properties::DofMapper>,
72 GetPropType<TypeTag, Properties::Stencil>,
73 GetPropType<TypeTag, Properties::FluidSystem>,
74 GetPropType<TypeTag, Properties::Scalar>>
92 using TracerEvaluation = DenseAd::Evaluation<Scalar,1>;
98 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
99 enum { numPhases = FluidSystem::numPhases };
100 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
101 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
102 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
106 :
BaseType(simulator.vanguard().gridView(),
107 simulator.vanguard().eclState(),
108 simulator.vanguard().cartesianIndexMapper(),
109 simulator.model().dofMapper(),
110 simulator.vanguard().cellCentroids())
112 ,
tbatch({waterPhaseIdx, oilPhaseIdx, gasPhaseIdx})
141 gasPhaseIdx, oilPhaseIdx, waterPhaseIdx);
146 for (std::size_t tracerIdx = 0; tracerIdx < this->
tracerPhaseIdx_.size(); ++tracerIdx) {
148 if (! FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)){
149 throw std::runtime_error(
"Water tracer specified for non-water fluid system: " +
150 this->
name(tracerIdx));
155 else if (this->
tracerPhaseIdx_[tracerIdx] == FluidSystem::oilPhaseIdx) {
156 if (! FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)){
157 throw std::runtime_error(
"Oil tracer specified for non-oil fluid system: " +
158 this->
name(tracerIdx));
163 else if (this->
tracerPhaseIdx_[tracerIdx] == FluidSystem::gasPhaseIdx) {
164 if (! FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)){
165 throw std::runtime_error(
"Gas tracer specified for non-gas fluid system: " +
166 this->
name(tracerIdx));
185 for (
auto& tr : this->
tbatch) {
186 if (tr.numTracer() != 0) {
191 tr.mat = std::make_unique<TracerMatrix>(*base);
203 OPM_TIMEBLOCK(tracerUpdateCache);
216 OPM_TIMEBLOCK(tracerAdvance);
224 template <
class Restarter>
234 template <
class Restarter>
238 template<
class Serializer>
241 serializer(
static_cast<BaseType&
>(*
this));
251 template<TracerTypeIdx Index>
253 const unsigned globalDofIdx,
254 const unsigned timeIdx)
const
256 const auto& intQuants =
simulator_.model().intensiveQuantities(globalDofIdx, timeIdx);
257 const auto& fs = intQuants.fluidState();
258 constexpr Scalar min_volume = 1e-10;
261 return std::max(decay<Scalar>(fs.saturation(tracerPhaseIdx)) *
262 decay<Scalar>(fs.invB(tracerPhaseIdx)) *
263 decay<Scalar>(intQuants.porosity()),
267 if (tracerPhaseIdx == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
268 return std::max(decay<Scalar>(fs.saturation(FluidSystem::gasPhaseIdx)) *
269 decay<Scalar>(fs.invB(FluidSystem::gasPhaseIdx)) *
270 decay<Scalar>(fs.Rv()) *
271 decay<Scalar>(intQuants.porosity()),
276 else if (tracerPhaseIdx == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
277 return std::max(decay<Scalar>(fs.saturation(FluidSystem::oilPhaseIdx)) *
278 decay<Scalar>(fs.invB(FluidSystem::oilPhaseIdx)) *
279 decay<Scalar>(fs.Rs()) *
280 decay<Scalar>(intQuants.porosity()),
288 template<TracerTypeIdx Index>
289 std::pair<TracerEvaluation, bool>
291 const ElementContext& elemCtx,
292 const unsigned scvfIdx,
293 const unsigned timeIdx)
const
295 const auto& stencil = elemCtx.stencil(timeIdx);
296 const auto& scvf = stencil.interiorFace(scvfIdx);
298 const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
299 const unsigned inIdx = extQuants.interiorIndex();
305 upIdx = extQuants.upstreamIndex(tracerPhaseIdx);
306 const auto& intQuants = elemCtx.intensiveQuantities(upIdx, timeIdx);
307 const auto& fs = intQuants.fluidState();
308 v = decay<Scalar>(extQuants.volumeFlux(tracerPhaseIdx)) *
309 decay<Scalar>(fs.invB(tracerPhaseIdx));
311 if (tracerPhaseIdx == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
312 upIdx = extQuants.upstreamIndex(FluidSystem::gasPhaseIdx);
314 const auto& intQuants = elemCtx.intensiveQuantities(upIdx, timeIdx);
315 const auto& fs = intQuants.fluidState();
316 v = decay<Scalar>(fs.invB(FluidSystem::gasPhaseIdx)) *
317 decay<Scalar>(extQuants.volumeFlux(FluidSystem::gasPhaseIdx)) *
318 decay<Scalar>(fs.Rv());
321 else if (tracerPhaseIdx == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
322 upIdx = extQuants.upstreamIndex(FluidSystem::oilPhaseIdx);
324 const auto& intQuants = elemCtx.intensiveQuantities(upIdx, timeIdx);
325 const auto& fs = intQuants.fluidState();
326 v = decay<Scalar>(fs.invB(FluidSystem::oilPhaseIdx)) *
327 decay<Scalar>(extQuants.volumeFlux(FluidSystem::oilPhaseIdx)) *
328 decay<Scalar>(fs.Rs());
336 const Scalar A = scvf.area();
337 return inIdx == upIdx
338 ? std::pair{A * v * variable<TracerEvaluation>(1.0, 0),
true}
339 : std::pair{A * v,
false};
342 template<TracerTypeIdx Index,
class TrRe>
350 return tr.storageOfTimeIndex1_[tIdx][I][
Index];
352 return computeVolume_<Index>(tr.phaseIdx_, I1, 1) *
353 tr.concentration_[tIdx][I1][
Index];
359 const ElementContext& elemCtx,
360 const Scalar scvVolume,
366 if (tr.numTracer() == 0) {
370 const TracerEvaluation fVol = computeVolume_<Free>(tr.phaseIdx_, I, 0) * variable<TracerEvaluation>(1.0, 0);
371 const TracerEvaluation sVol = computeVolume_<Solution>(tr.phaseIdx_, I, 0) * variable<TracerEvaluation>(1.0, 0);
372 dVol_[
Solution][tr.phaseIdx_][I] += sVol.value() * scvVolume -
vol1_[1][tr.phaseIdx_][I];
373 dVol_[
Free][tr.phaseIdx_][I] += fVol.value() * scvVolume -
vol1_[0][tr.phaseIdx_][I];
374 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
376 const Scalar fStorageOfTimeIndex0 = fVol.value() * tr.concentration_[tIdx][I][
Free];
377 const Scalar fLocalStorage = (fStorageOfTimeIndex0 - storage1_<Free>(tr, tIdx, I, I1,
378 elemCtx.enableStorageCache())) * scvVolume / dt;
379 tr.residual_[tIdx][I][
Free] += fLocalStorage;
382 const Scalar sStorageOfTimeIndex0 = sVol.value() * tr.concentration_[tIdx][I][
Solution];
383 const Scalar sLocalStorage = (sStorageOfTimeIndex0 - storage1_<Solution>(tr, tIdx, I, I1,
384 elemCtx.enableStorageCache())) * scvVolume / dt;
385 tr.residual_[tIdx][I][
Solution] += sLocalStorage;
389 (*tr.mat)[I][I][
Free][
Free] += fVol.derivative(0) * scvVolume/dt;
395 const ElementContext& elemCtx,
401 if (tr.numTracer() == 0) {
405 const auto& [fFlux, isUpF] = computeFlux_<Free>(tr.phaseIdx_, elemCtx, scvfIdx, 0);
406 const auto& [sFlux, isUpS] = computeFlux_<Solution>(tr.phaseIdx_, elemCtx, scvfIdx, 0);
408 dVol_[
Free][tr.phaseIdx_][I] += fFlux.value() * dt;
409 const int fGlobalUpIdx = isUpF ? I : J;
410 const int sGlobalUpIdx = isUpS ? I : J;
411 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
413 tr.residual_[tIdx][I][
Free] += fFlux.value()*tr.concentration_[tIdx][fGlobalUpIdx][
Free];
414 tr.residual_[tIdx][I][
Solution] += sFlux.value()*tr.concentration_[tIdx][sGlobalUpIdx][
Solution];
419 (*tr.mat)[J][I][
Free][
Free] = -fFlux.derivative(0);
420 (*tr.mat)[I][I][
Free][
Free] += fFlux.derivative(0);
428 template<
class TrRe,
class Well>
432 if (tr.numTracer() == 0) {
436 const auto& eclWell = well.wellEcl();
442 auto* mswTracerRate = eclWell.isMultiSegment()
445 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
446 tracerRate[tr.idx_[tIdx]] = {this->
name(tr.idx_[tIdx]), 0.0};
447 freeTracerRate[tr.idx_[tIdx]] = {this->
wellfname(tr.idx_[tIdx]), 0.0};
448 solTracerRate[tr.idx_[tIdx]] = {this->
wellsname(tr.idx_[tIdx]), 0.0};
449 if (eclWell.isMultiSegment()) {
450 auto& wtr = mswTracerRate->at(tr.idx_[tIdx]) = {this->
name(tr.idx_[tIdx])};;
451 wtr.rate.reserve(eclWell.getConnections().size());
452 for (std::size_t i = 0; i < eclWell.getConnections().size(); ++i) {
453 wtr.rate.emplace(eclWell.getConnections().get(i).segment(), 0.0);
458 std::vector<Scalar> wtracer(tr.numTracer());
459 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
461 simulator_.problem().wellModel().summaryState());
465 const auto& ws =
simulator_.problem().wellModel().wellState().well(well.name());
466 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
467 const auto I = ws.perf_data.cell_index[i];
468 const Scalar rate = well.volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
470 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
471 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
473 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
474 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
480 const Scalar rate_f = rate - rate_s;
482 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
483 const Scalar delta = rate_f * wtracer[tIdx];
485 tr.residual_[tIdx][I][
Free] -= delta;
489 tracerRate[tr.idx_[tIdx]].rate += delta;
490 freeTracerRate[tr.idx_[tIdx]].rate += delta;
491 if (eclWell.isMultiSegment()) {
492 (*mswTracerRate)[tr.idx_[tIdx]].rate[eclWell.getConnections().get(i).segment()] += delta;
495 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
497 else if (rate_f < 0) {
498 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
499 const Scalar delta = rate_f * wtracer[tIdx];
502 tracerRate[tr.idx_[tIdx]].rate += delta;
503 freeTracerRate[tr.idx_[tIdx]].rate += delta;
506 tr.residual_[tIdx][I][
Free] -= rate_f * tr.concentration_[tIdx][I][
Free];
508 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
511 (*tr.mat)[I][I][
Free][
Free] -= rate_f * variable<TracerEvaluation>(1.0, 0).derivative(0);
514 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
516 tr.residual_[tIdx][I][
Solution] -= rate_s * tr.concentration_[tIdx][I][
Solution];
521 (*tr.mat)[I][I][
Solution][
Solution] -= rate_s * variable<TracerEvaluation>(1.0, 0).derivative(0);
531 if (tr.numTracer() == 0) {
536 if (tr.phaseIdx_ == FluidSystem::waterPhaseIdx ||
537 (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && !FluidSystem::enableDissolvedGas()) ||
538 (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && !FluidSystem::enableVaporizedOil()))
544 const Scalar& dfVol =
dVol_[
Free][tr.phaseIdx_][I];
547 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
549 const auto delta = (dfVol / dt) * tr.concentration_[tIdx][I][
Free];
550 tr.residual_[tIdx][I][
Free] -= delta;
551 tr.residual_[tIdx][I][
Solution] += delta;
554 const auto delta = (dsVol / dt) * tr.concentration_[tIdx][I][
Solution];
555 tr.residual_[tIdx][I][
Free] += delta;
556 tr.residual_[tIdx][I][
Solution] -= delta;
562 const auto delta = (dfVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
563 (*tr.mat)[I][I][
Free][
Free] -= delta;
567 const auto delta = (dsVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
584 OPM_TIMEBLOCK(tracerAssemble);
586 if (tr.numTracer() != 0) {
588 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
589 tr.residual_[tIdx] = 0.0;
603 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
608 for (
const auto& wellPtr : wellPtrs) {
610 const auto& eclWell = wellPtr->wellEcl();
614 auto* mswTracerRate = eclWell.isMultiSegment()
627 #pragma omp parallel for
631 const Scalar dt = elemCtx.simulator().timeStepSize();
633 for (
const auto& elem : chunk) {
634 elemCtx.updateStencil(elem);
635 const std::size_t I = elemCtx.globalSpaceIndex( 0, 0);
637 if (elem.partitionType() != Dune::InteriorEntity) {
641 for (
const auto& tr :
tbatch) {
642 if (tr.numTracer() != 0) {
643 (*tr.mat)[I][I][0][0] = 1.;
644 (*tr.mat)[I][I][1][1] = 1.;
649 elemCtx.updateAllIntensiveQuantities();
650 elemCtx.updateAllExtensiveQuantities();
652 const Scalar extrusionFactor =
653 elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
654 Valgrind::CheckDefined(extrusionFactor);
655 assert(isfinite(extrusionFactor));
656 assert(extrusionFactor > 0.0);
657 const Scalar scvVolume =
658 elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
659 const std::size_t I1 = elemCtx.globalSpaceIndex( 0, 1);
664 if (tr.numTracer() == 0) {
670 const std::size_t numInteriorFaces = elemCtx.numInteriorFaces(0);
671 for (
unsigned scvfIdx = 0; scvfIdx < numInteriorFaces; scvfIdx++) {
672 const auto& face = elemCtx.stencil(0).interiorFace(scvfIdx);
673 const unsigned j = face.exteriorIndex();
674 const unsigned J = elemCtx.globalSpaceIndex( j, 0);
676 if (tr.numTracer() == 0) {
685 if (tr.numTracer() == 0) {
694 "assembleTracerEquations() failed: ",
699 if (tr.numTracer() == 0) {
704 simulator_.gridView().communicate(handle, Dune::InteriorBorder_All_Interface,
705 Dune::ForwardCommunication);
709 template<TracerTypeIdx Index,
class TrRe>
711 const Scalar scvVolume,
712 const unsigned globalDofIdx)
714 const Scalar vol1 = computeVolume_<Index>(tr.phaseIdx_, globalDofIdx, 0);
715 vol1_[
Index][tr.phaseIdx_][globalDofIdx] = vol1 * scvVolume;
716 dVol_[
Index][tr.phaseIdx_][globalDofIdx] = 0.0;
717 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
718 tr.storageOfTimeIndex1_[tIdx][globalDofIdx][
Index] =
719 vol1 * tr.concentrationInitial_[tIdx][globalDofIdx][
Index];
726 if (tr.numTracer() != 0) {
727 tr.concentrationInitial_ = tr.concentration_;
733 #pragma omp parallel for
738 for (
const auto& elem : chunk) {
739 elemCtx.updatePrimaryStencil(elem);
740 elemCtx.updatePrimaryIntensiveQuantities(0);
741 const Scalar extrusionFactor = elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
742 const Scalar scvVolume = elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
743 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(0, 0);
746 if (tr.numTracer() == 0) {
751 updateElem<Free>(tr, scvVolume, globalDofIdx);
752 updateElem<Solution>(tr, scvVolume, globalDofIdx);
758 template<TracerTypeIdx Index,
class TrRe>
760 const std::vector<TracerVector>& dx,
763 const unsigned globalDofIdx,
764 std::vector<TracerVectorSingle>& sc)
766 constexpr Scalar tol_gas_sat = 1e-6;
767 tr.concentration_[tIdx][globalDofIdx][
Index] -= dx[tIdx][globalDofIdx][
Index];
768 if (tr.concentration_[tIdx][globalDofIdx][
Index] < 0.0 || S < tol_gas_sat) {
769 tr.concentration_[tIdx][globalDofIdx][
Index] = 0.0;
771 sc[tr.idx_[tIdx]][globalDofIdx] = tr.concentration_[tIdx][globalDofIdx][
Index];
774 template<TracerTypeIdx Index,
class TrRe>
785 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
787 const Scalar delta = rate * tr.concentration_[tIdx][I][
Index];
788 tracerRate[tr.idx_[tIdx]].rate += delta;
789 splitRate[tr.idx_[tIdx]].rate += delta;
790 if (eclWell.isMultiSegment()) {
791 (*mswTracerRate)[tr.idx_[tIdx]].rate[eclWell.getConnections().get(i).segment()] += delta;
802 if (tr.numTracer() == 0) {
808 std::vector<TracerVector> dx(tr.concentration_);
809 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
815 OpmLog::warning(
"### Tracer model: Linear solver did not converge. ###");
818 OPM_TIMEBLOCK(tracerPost);
820 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
821 for (std::size_t globalDofIdx = 0; globalDofIdx < tr.concentration_[tIdx].size(); ++globalDofIdx) {
824 const auto& intQuants =
simulator_.model().intensiveQuantities(globalDofIdx, 0);
825 const auto& fs = intQuants.fluidState();
826 const Scalar Sf = decay<Scalar>(fs.saturation(tr.phaseIdx_));
829 if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
830 Ss = decay<Scalar>(fs.saturation(FluidSystem::oilPhaseIdx));
832 else if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
833 Ss = decay<Scalar>(fs.saturation(FluidSystem::gasPhaseIdx));
842 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
843 for (
const auto& wellPtr : wellPtrs) {
844 const auto& eclWell = wellPtr->wellEcl();
847 if (!eclWell.isProducer()) {
851 Scalar rateWellPos = 0.0;
852 Scalar rateWellNeg = 0.0;
853 const std::size_t well_index =
simulator_.problem().wellModel().wellState().index(eclWell.name()).value();
854 const auto& ws =
simulator_.problem().wellModel().wellState().well(well_index);
858 auto* mswTracerRate = eclWell.isMultiSegment() ? &this->
mSwTracerRate_[eclWell.seqIndex()] :
nullptr;
860 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
861 const auto I = ws.perf_data.cell_index[i];
862 const Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
865 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
866 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
868 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
869 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
875 const Scalar rate_f = rate - rate_s;
876 assignRates<Free>(tr, eclWell, i, I, rate_f,
877 tracerRate, mswTracerRate, freeTracerRate);
878 assignRates<Solution>(tr, eclWell, i, I, rate_s,
879 tracerRate, mswTracerRate, solTracerRate);
894 const Scalar official_well_rate_total =
895 simulator_.problem().wellModel().wellState().well(well_index).surface_rates[tr.phaseIdx_];
897 const Scalar rateWellTotal = official_well_rate_total;
899 if (rateWellTotal > rateWellNeg) {
900 constexpr Scalar bucketPrDay = 10.0 / (1000. * 3600. * 24.);
901 const Scalar factor = (rateWellTotal < -bucketPrDay) ? rateWellTotal / rateWellNeg : 0.0;
902 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
903 tracerRate[tIdx].rate *= factor;
920 template <
typename TV>
929 std::unique_ptr<TracerMatrix>
mat;
940 result.
idx_ = {1,2,3};
949 template<
class Serializer>
959 {
return idx_.size(); }
963 const int numGridDof = concentration.size();
964 idx_.emplace_back(idx);
972 std::array<TracerBatch<TracerVector>,numPhases>
tbatch;
976 std::array<std::array<std::vector<Scalar>,numPhases>,2>
vol1_;
977 std::array<std::array<std::vector<Scalar>,numPhases>,2>
dVol_;
#define OPM_END_PARALLEL_TRY_CATCH_LOG(obptc_logger, obptc_prefix, obptc_output, comm)
Catch exception, log, and throw in a parallel try-catch clause.
Definition: DeferredLoggingErrorHelpers.hpp:202
#define OPM_BEGIN_PARALLEL_TRY_CATCH()
Macro to setup the try of a parallel try-catch.
Definition: DeferredLoggingErrorHelpers.hpp:158
A datahandle sending data located in multiple vectors.
Definition: DeferredLogger.hpp:57
Definition: GenericTracerModel.hpp:56
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::numTracers int numTracers() const
Return the number of tracers considered by the tracerModel.
Definition: GenericTracerModel_impl.hpp:162
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::doInit void doInit(bool rst, std::size_t numGridDof, std::size_t gasPhaseIdx, std::size_t oilPhaseIdx, std::size_t waterPhaseIdx)
Initialize all internal data structures needed by the tracer module.
Definition: GenericTracerModel_impl.hpp:227
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::tracerConcentration_ std::vector< TracerVector > tracerConcentration_
Definition: GenericTracerModel.hpp:158
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::tracerPhaseIdx_ std::vector< int > tracerPhaseIdx_
Definition: GenericTracerModel.hpp:156
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::wellFreeTracerRate_ std::unordered_map< int, std::vector< WellTracerRate< GetPropType< TypeTag, Properties::Scalar > > > > wellFreeTracerRate_
Definition: GenericTracerModel.hpp:165
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::wellTracerRate_ std::unordered_map< int, std::vector< WellTracerRate< GetPropType< TypeTag, Properties::Scalar > > > > wellTracerRate_
Definition: GenericTracerModel.hpp:164
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::mSwTracerRate_ std::unordered_map< int, std::vector< MSWellTracerRate< GetPropType< TypeTag, Properties::Scalar > > > > mSwTracerRate_
Definition: GenericTracerModel.hpp:168
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::wellfname std::string wellfname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:183
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::name const std::string & name(int tracerIdx) const
Return the tracer name.
Definition: GenericTracerModel_impl.hpp:220
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::wellsname std::string wellsname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:190
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::freeTracerConcentration_ std::vector< TracerVectorSingle > freeTracerConcentration_
Definition: GenericTracerModel.hpp:160
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::TracerVector Dune::BlockVector< Dune::FieldVector< GetPropType< TypeTag, Properties::Scalar >, 2 > > TracerVector
Definition: GenericTracerModel.hpp:60
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::TracerTypeIdx TracerTypeIdx
Tracer type index.
Definition: GenericTracerModel.hpp:146
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::Free @ Free
Definition: GenericTracerModel.hpp:147
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::Solution @ Solution
Definition: GenericTracerModel.hpp:148
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::linearSolveBatchwise_ bool linearSolveBatchwise_(const TracerMatrix &M, std::vector< TracerVector > &x, std::vector< TracerVector > &b)
Definition: GenericTracerModel_impl.hpp:444
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::TracerMatrix Dune::BCRSMatrix< Opm::MatrixBlock< GetPropType< TypeTag, Properties::Scalar >, 2, 2 > > TracerMatrix
Definition: GenericTracerModel.hpp:59
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::solTracerConcentration_ std::vector< TracerVectorSingle > solTracerConcentration_
Definition: GenericTracerModel.hpp:161
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::currentConcentration_ GetPropType< TypeTag, Properties::Scalar > currentConcentration_(const Well &eclWell, const std::string &trName, const SummaryState &summaryState) const
Definition: GenericTracerModel_impl.hpp:211
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::TracerVectorSingle Dune::BlockVector< Dune::FieldVector< GetPropType< TypeTag, Properties::Scalar >, 1 > > TracerVectorSingle
Definition: GenericTracerModel.hpp:58
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::tracerMatrix_ std::unique_ptr< TracerMatrix > tracerMatrix_
Definition: GenericTracerModel.hpp:159
Opm::GenericTracerModel< GetPropType< TypeTag, Properties::Grid >, GetPropType< TypeTag, Properties::GridView >, GetPropType< TypeTag, Properties::DofMapper >, GetPropType< TypeTag, Properties::Stencil >, GetPropType< TypeTag, Properties::FluidSystem >, GetPropType< TypeTag, Properties::Scalar > >::wellSolTracerRate_ std::unordered_map< int, std::vector< WellTracerRate< GetPropType< TypeTag, Properties::Scalar > > > > wellSolTracerRate_
Definition: GenericTracerModel.hpp:166
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition: threadmanager.hpp:66
A class which handles tracers as specified in by ECL.
Definition: TracerModel.hpp:75
void updateStorageCache()
Definition: TracerModel.hpp:723
std::array< std::array< std::vector< Scalar >, numPhases >, 2 > vol1_
Definition: TracerModel.hpp:976
TracerBatch< TracerVector > & oil_
Definition: TracerModel.hpp:974
void advanceTracerFields()
Definition: TracerModel.hpp:797
void init(bool rst)
Definition: TracerModel.hpp:138
void assembleTracerEquationSource(TrRe &tr, const Scalar dt, unsigned I)
Definition: TracerModel.hpp:527
TracerModel(Simulator &simulator)
Definition: TracerModel.hpp:105
void assignRates(const TrRe &tr, const Well &eclWell, const std::size_t i, const std::size_t I, const Scalar rate, std::vector< WellTracerRate< Scalar > > &tracerRate, std::vector< MSWellTracerRate< Scalar > > *mswTracerRate, std::vector< WellTracerRate< Scalar > > &splitRate)
Definition: TracerModel.hpp:775
void copyForOutput(TrRe &tr, const std::vector< TracerVector > &dx, const Scalar S, const unsigned tIdx, const unsigned globalDofIdx, std::vector< TracerVectorSingle > &sc)
Definition: TracerModel.hpp:759
void assembleTracerEquationFlux(TrRe &tr, const ElementContext &elemCtx, unsigned scvfIdx, unsigned I, unsigned J, const Scalar dt)
Definition: TracerModel.hpp:394
void assembleTracerEquationWell(TrRe &tr, const Well &well)
Definition: TracerModel.hpp:429
void updateElem(TrRe &tr, const Scalar scvVolume, const unsigned globalDofIdx)
Definition: TracerModel.hpp:710
Scalar computeVolume_(const int tracerPhaseIdx, const unsigned globalDofIdx, const unsigned timeIdx) const
Definition: TracerModel.hpp:252
typename BaseType::TracerTypeIdx TracerTypeIdx
Definition: TracerModel.hpp:246
void assembleTracerEquationVolume(TrRe &tr, const ElementContext &elemCtx, const Scalar scvVolume, const Scalar dt, unsigned I, unsigned I1)
Definition: TracerModel.hpp:358
Scalar storage1_(const TrRe &tr, const unsigned tIdx, const unsigned I, const unsigned I1, const bool cache)
Definition: TracerModel.hpp:343
void serialize(Restarter &)
This method writes the complete state of all tracer to the hard disk.
Definition: TracerModel.hpp:225
TracerBatch< TracerVector > & gas_
Definition: TracerModel.hpp:975
void assembleTracerEquations_()
Definition: TracerModel.hpp:573
std::array< TracerBatch< TracerVector >, numPhases > tbatch
Definition: TracerModel.hpp:972
std::pair< TracerEvaluation, bool > computeFlux_(const int tracerPhaseIdx, const ElementContext &elemCtx, const unsigned scvfIdx, const unsigned timeIdx) const
Definition: TracerModel.hpp:290
void beginTimeStep()
Definition: TracerModel.hpp:197
void serializeOp(Serializer &serializer)
Definition: TracerModel.hpp:239
void prepareTracerBatches()
Definition: TracerModel.hpp:144
std::array< std::array< std::vector< Scalar >, numPhases >, 2 > dVol_
Definition: TracerModel.hpp:977
ElementChunks< GridView, Dune::Partitions::All > element_chunks_
Definition: TracerModel.hpp:978
TracerBatch< TracerVector > & wat_
Definition: TracerModel.hpp:973
void endTimeStep()
Informs the tracer model that a time step has just been finished.
Definition: TracerModel.hpp:210
Simulator & simulator_
Definition: TracerModel.hpp:910
void deserialize(Restarter &)
This method restores the complete state of the tracer from disk.
Definition: TracerModel.hpp:235
A data handle sending multiple data store in vectors attached to cells.
Definition: VectorVectorDataHandle.hpp:50
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:44
Definition: blackoilmodel.hh:80
Definition: blackoilbioeffectsmodules.hh:43
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
The Opm property system, traits with inheritance.
Definition: WellTracerRate.hpp:60
Definition: TracerModel.hpp:55
a tag to mark properties as undefined
Definition: propertysystem.hh:38
Definition: TracerModel.hpp:922
const int phaseIdx_
Definition: TracerModel.hpp:924
void addTracer(const int idx, const TV &concentration)
Definition: TracerModel.hpp:961
bool operator==(const TracerBatch &rhs) const
Definition: TracerModel.hpp:931
static TracerBatch serializationTestObject()
Definition: TracerModel.hpp:937
std::vector< TV > concentrationInitial_
Definition: TracerModel.hpp:925
void serializeOp(Serializer &serializer)
Definition: TracerModel.hpp:950
TracerBatch(int phaseIdx=0)
Definition: TracerModel.hpp:956
int numTracer() const
Definition: TracerModel.hpp:958
std::vector< int > idx_
Definition: TracerModel.hpp:923
std::unique_ptr< TracerMatrix > mat
Definition: TracerModel.hpp:929
std::vector< TV > storageOfTimeIndex1_
Definition: TracerModel.hpp:927
std::vector< TV > residual_
Definition: TracerModel.hpp:928
std::vector< TV > concentration_
Definition: TracerModel.hpp:926
Definition: WellTracerRate.hpp:33