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();
440 tracerRate.reserve(tr.numTracer());
442 solTracerRate.reserve(tr.numTracer());
444 freeTracerRate.reserve(tr.numTracer());
445 auto* mswTracerRate = eclWell.isMultiSegment()
449 mswTracerRate->reserve(tr.numTracer());
451 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
452 tracerRate.emplace_back(this->
name(tr.idx_[tIdx]), 0.0);
453 freeTracerRate.emplace_back(this->
wellfname(tr.idx_[tIdx]), 0.0);
454 solTracerRate.emplace_back(this->
wellsname(tr.idx_[tIdx]), 0.0);
455 if (eclWell.isMultiSegment()) {
456 auto& wtr = mswTracerRate->emplace_back(this->
name(tr.idx_[tIdx]));
457 wtr.rate.reserve(eclWell.getConnections().size());
458 for (std::size_t i = 0; i < eclWell.getConnections().size(); ++i) {
459 wtr.rate.emplace(eclWell.getConnections().get(i).segment(), 0.0);
464 std::vector<Scalar> wtracer(tr.numTracer());
465 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
470 const auto& ws =
simulator_.problem().wellModel().wellState().well(well.name());
471 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
472 const auto I = ws.perf_data.cell_index[i];
473 const Scalar rate = well.volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
475 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
476 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
478 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
479 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
485 const Scalar rate_f = rate - rate_s;
487 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
488 const Scalar delta = rate_f * wtracer[tIdx];
490 tr.residual_[tIdx][I][
Free] -= delta;
494 tracerRate[tIdx].rate += delta;
495 freeTracerRate[tIdx].rate += delta;
496 if (eclWell.isMultiSegment()) {
497 (*mswTracerRate)[tIdx].rate[eclWell.getConnections().get(i).segment()] += delta;
500 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
502 else if (rate_f < 0) {
503 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
504 const Scalar delta = rate_f * wtracer[tIdx];
507 tracerRate[tIdx].rate += delta;
508 freeTracerRate[tIdx].rate += delta;
511 tr.residual_[tIdx][I][
Free] -= rate_f * tr.concentration_[tIdx][I][
Free];
513 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
516 (*tr.mat)[I][I][
Free][
Free] -= rate_f * variable<TracerEvaluation>(1.0, 0).derivative(0);
519 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
521 tr.residual_[tIdx][I][
Solution] -= rate_s * tr.concentration_[tIdx][I][
Solution];
526 (*tr.mat)[I][I][
Solution][
Solution] -= rate_s * variable<TracerEvaluation>(1.0, 0).derivative(0);
536 if (tr.numTracer() == 0) {
541 if (tr.phaseIdx_ == FluidSystem::waterPhaseIdx ||
542 (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && !FluidSystem::enableDissolvedGas()) ||
543 (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && !FluidSystem::enableVaporizedOil()))
549 const Scalar& dfVol =
dVol_[
Free][tr.phaseIdx_][I];
552 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
554 const auto delta = (dfVol / dt) * tr.concentration_[tIdx][I][
Free];
555 tr.residual_[tIdx][I][
Free] -= delta;
556 tr.residual_[tIdx][I][
Solution] += delta;
559 const auto delta = (dsVol / dt) * tr.concentration_[tIdx][I][
Solution];
560 tr.residual_[tIdx][I][
Free] += delta;
561 tr.residual_[tIdx][I][
Solution] -= delta;
567 const auto delta = (dfVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
568 (*tr.mat)[I][I][
Free][
Free] -= delta;
572 const auto delta = (dsVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
589 OPM_TIMEBLOCK(tracerAssemble);
591 if (tr.numTracer() != 0) {
593 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
594 tr.residual_[tIdx] = 0.0;
608 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
613 for (
const auto& wellPtr : wellPtrs) {
621 #pragma omp parallel for
625 const Scalar dt = elemCtx.simulator().timeStepSize();
627 for (
const auto& elem : chunk) {
628 elemCtx.updateStencil(elem);
629 const std::size_t I = elemCtx.globalSpaceIndex( 0, 0);
631 if (elem.partitionType() != Dune::InteriorEntity) {
635 for (
const auto& tr :
tbatch) {
636 if (tr.numTracer() != 0) {
637 (*tr.mat)[I][I][0][0] = 1.;
638 (*tr.mat)[I][I][1][1] = 1.;
643 elemCtx.updateAllIntensiveQuantities();
644 elemCtx.updateAllExtensiveQuantities();
646 const Scalar extrusionFactor =
647 elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
648 Valgrind::CheckDefined(extrusionFactor);
649 assert(isfinite(extrusionFactor));
650 assert(extrusionFactor > 0.0);
651 const Scalar scvVolume =
652 elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
653 const std::size_t I1 = elemCtx.globalSpaceIndex( 0, 1);
658 if (tr.numTracer() == 0) {
664 const std::size_t numInteriorFaces = elemCtx.numInteriorFaces(0);
665 for (
unsigned scvfIdx = 0; scvfIdx < numInteriorFaces; scvfIdx++) {
666 const auto& face = elemCtx.stencil(0).interiorFace(scvfIdx);
667 const unsigned j = face.exteriorIndex();
668 const unsigned J = elemCtx.globalSpaceIndex( j, 0);
670 if (tr.numTracer() == 0) {
679 if (tr.numTracer() == 0) {
688 "assembleTracerEquations() failed: ",
693 if (tr.numTracer() == 0) {
698 simulator_.gridView().communicate(handle, Dune::InteriorBorder_All_Interface,
699 Dune::ForwardCommunication);
703 template<TracerTypeIdx Index,
class TrRe>
705 const Scalar scvVolume,
706 const unsigned globalDofIdx)
708 const Scalar vol1 = computeVolume_<Index>(tr.phaseIdx_, globalDofIdx, 0);
709 vol1_[
Index][tr.phaseIdx_][globalDofIdx] = vol1 * scvVolume;
710 dVol_[
Index][tr.phaseIdx_][globalDofIdx] = 0.0;
711 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
712 tr.storageOfTimeIndex1_[tIdx][globalDofIdx][
Index] =
713 vol1 * tr.concentrationInitial_[tIdx][globalDofIdx][
Index];
720 if (tr.numTracer() != 0) {
721 tr.concentrationInitial_ = tr.concentration_;
727 #pragma omp parallel for
732 for (
const auto& elem : chunk) {
733 elemCtx.updatePrimaryStencil(elem);
734 elemCtx.updatePrimaryIntensiveQuantities(0);
735 const Scalar extrusionFactor = elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
736 const Scalar scvVolume = elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
737 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(0, 0);
740 if (tr.numTracer() == 0) {
745 updateElem<Free>(tr, scvVolume, globalDofIdx);
746 updateElem<Solution>(tr, scvVolume, globalDofIdx);
752 template<TracerTypeIdx Index,
class TrRe>
754 const std::vector<TracerVector>& dx,
757 const unsigned globalDofIdx,
758 std::vector<TracerVectorSingle>& sc)
760 constexpr Scalar tol_gas_sat = 1e-6;
761 tr.concentration_[tIdx][globalDofIdx][
Index] -= dx[tIdx][globalDofIdx][
Index];
762 if (tr.concentration_[tIdx][globalDofIdx][
Index] < 0.0 || S < tol_gas_sat) {
763 tr.concentration_[tIdx][globalDofIdx][
Index] = 0.0;
765 sc[tr.idx_[tIdx]][globalDofIdx] = tr.concentration_[tIdx][globalDofIdx][
Index];
768 template<TracerTypeIdx Index,
class TrRe>
779 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
781 const Scalar delta = rate * tr.concentration_[tIdx][I][
Index];
782 tracerRate[tIdx].rate += delta;
783 splitRate[tIdx].rate += delta;
784 if (eclWell.isMultiSegment()) {
785 (*mswTracerRate)[tIdx].rate[eclWell.getConnections().get(i).segment()] += delta;
796 if (tr.numTracer() == 0) {
802 std::vector<TracerVector> dx(tr.concentration_);
803 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
809 OpmLog::warning(
"### Tracer model: Linear solver did not converge. ###");
812 OPM_TIMEBLOCK(tracerPost);
814 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
815 for (std::size_t globalDofIdx = 0; globalDofIdx < tr.concentration_[tIdx].size(); ++globalDofIdx) {
818 const auto& intQuants =
simulator_.model().intensiveQuantities(globalDofIdx, 0);
819 const auto& fs = intQuants.fluidState();
820 const Scalar Sf = decay<Scalar>(fs.saturation(tr.phaseIdx_));
823 if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
824 Ss = decay<Scalar>(fs.saturation(FluidSystem::oilPhaseIdx));
826 else if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
827 Ss = decay<Scalar>(fs.saturation(FluidSystem::gasPhaseIdx));
836 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
837 for (
const auto& wellPtr : wellPtrs) {
838 const auto& eclWell = wellPtr->wellEcl();
841 if (!eclWell.isProducer()) {
845 Scalar rateWellPos = 0.0;
846 Scalar rateWellNeg = 0.0;
847 const std::size_t well_index =
simulator_.problem().wellModel().wellState().index(eclWell.name()).value();
848 const auto& ws =
simulator_.problem().wellModel().wellState().well(well_index);
852 auto* mswTracerRate = eclWell.isMultiSegment() ? &this->
mSwTracerRate_[eclWell.seqIndex()] :
nullptr;
854 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
855 const auto I = ws.perf_data.cell_index[i];
856 const Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
859 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
860 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
862 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
863 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
869 const Scalar rate_f = rate - rate_s;
870 assignRates<Free>(tr, eclWell, i, I, rate_f,
871 tracerRate, mswTracerRate, freeTracerRate);
872 assignRates<Solution>(tr, eclWell, i, I, rate_s,
873 tracerRate, mswTracerRate, solTracerRate);
888 const Scalar official_well_rate_total =
889 simulator_.problem().wellModel().wellState().well(well_index).surface_rates[tr.phaseIdx_];
891 const Scalar rateWellTotal = official_well_rate_total;
893 if (rateWellTotal > rateWellNeg) {
894 constexpr Scalar bucketPrDay = 10.0 / (1000. * 3600. * 24.);
895 const Scalar factor = (rateWellTotal < -bucketPrDay) ? rateWellTotal / rateWellNeg : 0.0;
896 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
897 tracerRate[tIdx].rate *= factor;
914 template <
typename TV>
923 std::unique_ptr<TracerMatrix>
mat;
934 result.
idx_ = {1,2,3};
943 template<
class Serializer>
953 {
return idx_.size(); }
957 const int numGridDof = concentration.size();
958 idx_.emplace_back(idx);
966 std::array<TracerBatch<TracerVector>,numPhases>
tbatch;
970 std::array<std::array<std::vector<Scalar>,numPhases>,2>
vol1_;
971 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 > >::currentConcentration_ GetPropType< TypeTag, Properties::Scalar > currentConcentration_(const Well &eclWell, const std::string &name) 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 > >::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:225
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: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 > >::tracerPhaseIdx_ std::vector< int > tracerPhaseIdx_
Definition: GenericTracerModel.hpp:154
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:163
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: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 > >::mSwTracerRate_ std::unordered_map< int, std::vector< MSWellTracerRate< GetPropType< TypeTag, Properties::Scalar > > > > mSwTracerRate_
Definition: GenericTracerModel.hpp:166
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:218
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: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 > >::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:144
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:145
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: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 > >::linearSolveBatchwise_ bool linearSolveBatchwise_(const TracerMatrix &M, std::vector< TracerVector > &x, std::vector< TracerVector > &b)
Definition: GenericTracerModel_impl.hpp:442
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: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 > >::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:157
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:164
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:717
std::array< std::array< std::vector< Scalar >, numPhases >, 2 > vol1_
Definition: TracerModel.hpp:970
TracerBatch< TracerVector > & oil_
Definition: TracerModel.hpp:968
void advanceTracerFields()
Definition: TracerModel.hpp:791
void init(bool rst)
Definition: TracerModel.hpp:138
void assembleTracerEquationSource(TrRe &tr, const Scalar dt, unsigned I)
Definition: TracerModel.hpp:532
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:769
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:753
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:704
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:969
void assembleTracerEquations_()
Definition: TracerModel.hpp:578
std::array< TracerBatch< TracerVector >, numPhases > tbatch
Definition: TracerModel.hpp:966
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:971
ElementChunks< GridView, Dune::Partitions::All > element_chunks_
Definition: TracerModel.hpp:972
TracerBatch< TracerVector > & wat_
Definition: TracerModel.hpp:967
void endTimeStep()
Informs the tracer model that a time step has just been finished.
Definition: TracerModel.hpp:210
Simulator & simulator_
Definition: TracerModel.hpp:904
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:79
Definition: blackoilboundaryratevector.hh:39
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:916
const int phaseIdx_
Definition: TracerModel.hpp:918
void addTracer(const int idx, const TV &concentration)
Definition: TracerModel.hpp:955
bool operator==(const TracerBatch &rhs) const
Definition: TracerModel.hpp:925
static TracerBatch serializationTestObject()
Definition: TracerModel.hpp:931
std::vector< TV > concentrationInitial_
Definition: TracerModel.hpp:919
void serializeOp(Serializer &serializer)
Definition: TracerModel.hpp:944
TracerBatch(int phaseIdx=0)
Definition: TracerModel.hpp:950
int numTracer() const
Definition: TracerModel.hpp:952
std::vector< int > idx_
Definition: TracerModel.hpp:917
std::unique_ptr< TracerMatrix > mat
Definition: TracerModel.hpp:923
std::vector< TV > storageOfTimeIndex1_
Definition: TracerModel.hpp:921
std::vector< TV > residual_
Definition: TracerModel.hpp:922
std::vector< TV > concentration_
Definition: TracerModel.hpp:920
Definition: WellTracerRate.hpp:33