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) {
467 simulator_.problem().wellModel().summaryState());
471 const auto& ws =
simulator_.problem().wellModel().wellState().well(well.name());
472 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
473 const auto I = ws.perf_data.cell_index[i];
474 const Scalar rate = well.volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
476 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
477 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
479 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
480 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
486 const Scalar rate_f = rate - rate_s;
488 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
489 const Scalar delta = rate_f * wtracer[tIdx];
491 tr.residual_[tIdx][I][
Free] -= delta;
495 tracerRate[tIdx].rate += delta;
496 freeTracerRate[tIdx].rate += delta;
497 if (eclWell.isMultiSegment()) {
498 (*mswTracerRate)[tIdx].rate[eclWell.getConnections().get(i).segment()] += delta;
501 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
503 else if (rate_f < 0) {
504 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
505 const Scalar delta = rate_f * wtracer[tIdx];
508 tracerRate[tIdx].rate += delta;
509 freeTracerRate[tIdx].rate += delta;
512 tr.residual_[tIdx][I][
Free] -= rate_f * tr.concentration_[tIdx][I][
Free];
514 dVol_[
Free][tr.phaseIdx_][I] -= rate_f * dt;
517 (*tr.mat)[I][I][
Free][
Free] -= rate_f * variable<TracerEvaluation>(1.0, 0).derivative(0);
520 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
522 tr.residual_[tIdx][I][
Solution] -= rate_s * tr.concentration_[tIdx][I][
Solution];
527 (*tr.mat)[I][I][
Solution][
Solution] -= rate_s * variable<TracerEvaluation>(1.0, 0).derivative(0);
537 if (tr.numTracer() == 0) {
542 if (tr.phaseIdx_ == FluidSystem::waterPhaseIdx ||
543 (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && !FluidSystem::enableDissolvedGas()) ||
544 (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && !FluidSystem::enableVaporizedOil()))
550 const Scalar& dfVol =
dVol_[
Free][tr.phaseIdx_][I];
553 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
555 const auto delta = (dfVol / dt) * tr.concentration_[tIdx][I][
Free];
556 tr.residual_[tIdx][I][
Free] -= delta;
557 tr.residual_[tIdx][I][
Solution] += delta;
560 const auto delta = (dsVol / dt) * tr.concentration_[tIdx][I][
Solution];
561 tr.residual_[tIdx][I][
Free] += delta;
562 tr.residual_[tIdx][I][
Solution] -= delta;
568 const auto delta = (dfVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
569 (*tr.mat)[I][I][
Free][
Free] -= delta;
573 const auto delta = (dsVol / dt) * variable<TracerEvaluation>(1.0, 0).derivative(0);
590 OPM_TIMEBLOCK(tracerAssemble);
592 if (tr.numTracer() != 0) {
594 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
595 tr.residual_[tIdx] = 0.0;
609 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
614 for (
const auto& wellPtr : wellPtrs) {
622 #pragma omp parallel for
626 const Scalar dt = elemCtx.simulator().timeStepSize();
628 for (
const auto& elem : chunk) {
629 elemCtx.updateStencil(elem);
630 const std::size_t I = elemCtx.globalSpaceIndex( 0, 0);
632 if (elem.partitionType() != Dune::InteriorEntity) {
636 for (
const auto& tr :
tbatch) {
637 if (tr.numTracer() != 0) {
638 (*tr.mat)[I][I][0][0] = 1.;
639 (*tr.mat)[I][I][1][1] = 1.;
644 elemCtx.updateAllIntensiveQuantities();
645 elemCtx.updateAllExtensiveQuantities();
647 const Scalar extrusionFactor =
648 elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
649 Valgrind::CheckDefined(extrusionFactor);
650 assert(isfinite(extrusionFactor));
651 assert(extrusionFactor > 0.0);
652 const Scalar scvVolume =
653 elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
654 const std::size_t I1 = elemCtx.globalSpaceIndex( 0, 1);
659 if (tr.numTracer() == 0) {
665 const std::size_t numInteriorFaces = elemCtx.numInteriorFaces(0);
666 for (
unsigned scvfIdx = 0; scvfIdx < numInteriorFaces; scvfIdx++) {
667 const auto& face = elemCtx.stencil(0).interiorFace(scvfIdx);
668 const unsigned j = face.exteriorIndex();
669 const unsigned J = elemCtx.globalSpaceIndex( j, 0);
671 if (tr.numTracer() == 0) {
680 if (tr.numTracer() == 0) {
689 "assembleTracerEquations() failed: ",
694 if (tr.numTracer() == 0) {
699 simulator_.gridView().communicate(handle, Dune::InteriorBorder_All_Interface,
700 Dune::ForwardCommunication);
704 template<TracerTypeIdx Index,
class TrRe>
706 const Scalar scvVolume,
707 const unsigned globalDofIdx)
709 const Scalar vol1 = computeVolume_<Index>(tr.phaseIdx_, globalDofIdx, 0);
710 vol1_[
Index][tr.phaseIdx_][globalDofIdx] = vol1 * scvVolume;
711 dVol_[
Index][tr.phaseIdx_][globalDofIdx] = 0.0;
712 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
713 tr.storageOfTimeIndex1_[tIdx][globalDofIdx][
Index] =
714 vol1 * tr.concentrationInitial_[tIdx][globalDofIdx][
Index];
721 if (tr.numTracer() != 0) {
722 tr.concentrationInitial_ = tr.concentration_;
728 #pragma omp parallel for
733 for (
const auto& elem : chunk) {
734 elemCtx.updatePrimaryStencil(elem);
735 elemCtx.updatePrimaryIntensiveQuantities(0);
736 const Scalar extrusionFactor = elemCtx.intensiveQuantities( 0, 0).extrusionFactor();
737 const Scalar scvVolume = elemCtx.stencil(0).subControlVolume( 0).volume() * extrusionFactor;
738 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(0, 0);
741 if (tr.numTracer() == 0) {
746 updateElem<Free>(tr, scvVolume, globalDofIdx);
747 updateElem<Solution>(tr, scvVolume, globalDofIdx);
753 template<TracerTypeIdx Index,
class TrRe>
755 const std::vector<TracerVector>& dx,
758 const unsigned globalDofIdx,
759 std::vector<TracerVectorSingle>& sc)
761 constexpr Scalar tol_gas_sat = 1e-6;
762 tr.concentration_[tIdx][globalDofIdx][
Index] -= dx[tIdx][globalDofIdx][
Index];
763 if (tr.concentration_[tIdx][globalDofIdx][
Index] < 0.0 || S < tol_gas_sat) {
764 tr.concentration_[tIdx][globalDofIdx][
Index] = 0.0;
766 sc[tr.idx_[tIdx]][globalDofIdx] = tr.concentration_[tIdx][globalDofIdx][
Index];
769 template<TracerTypeIdx Index,
class TrRe>
780 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
782 const Scalar delta = rate * tr.concentration_[tIdx][I][
Index];
783 tracerRate[tIdx].rate += delta;
784 splitRate[tIdx].rate += delta;
785 if (eclWell.isMultiSegment()) {
786 (*mswTracerRate)[tIdx].rate[eclWell.getConnections().get(i).segment()] += delta;
797 if (tr.numTracer() == 0) {
803 std::vector<TracerVector> dx(tr.concentration_);
804 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
810 OpmLog::warning(
"### Tracer model: Linear solver did not converge. ###");
813 OPM_TIMEBLOCK(tracerPost);
815 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
816 for (std::size_t globalDofIdx = 0; globalDofIdx < tr.concentration_[tIdx].size(); ++globalDofIdx) {
819 const auto& intQuants =
simulator_.model().intensiveQuantities(globalDofIdx, 0);
820 const auto& fs = intQuants.fluidState();
821 const Scalar Sf = decay<Scalar>(fs.saturation(tr.phaseIdx_));
824 if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
825 Ss = decay<Scalar>(fs.saturation(FluidSystem::oilPhaseIdx));
827 else if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
828 Ss = decay<Scalar>(fs.saturation(FluidSystem::gasPhaseIdx));
837 const auto& wellPtrs =
simulator_.problem().wellModel().localNonshutWells();
838 for (
const auto& wellPtr : wellPtrs) {
839 const auto& eclWell = wellPtr->wellEcl();
842 if (!eclWell.isProducer()) {
846 Scalar rateWellPos = 0.0;
847 Scalar rateWellNeg = 0.0;
848 const std::size_t well_index =
simulator_.problem().wellModel().wellState().index(eclWell.name()).value();
849 const auto& ws =
simulator_.problem().wellModel().wellState().well(well_index);
853 auto* mswTracerRate = eclWell.isMultiSegment() ? &this->
mSwTracerRate_[eclWell.seqIndex()] :
nullptr;
855 for (std::size_t i = 0; i < ws.perf_data.size(); ++i) {
856 const auto I = ws.perf_data.cell_index[i];
857 const Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
860 if (tr.phaseIdx_ == FluidSystem::oilPhaseIdx && FluidSystem::enableVaporizedOil()) {
861 rate_s = ws.perf_data.phase_mixing_rates[i][ws.vaporized_oil];
863 else if (tr.phaseIdx_ == FluidSystem::gasPhaseIdx && FluidSystem::enableDissolvedGas()) {
864 rate_s = ws.perf_data.phase_mixing_rates[i][ws.dissolved_gas];
870 const Scalar rate_f = rate - rate_s;
871 assignRates<Free>(tr, eclWell, i, I, rate_f,
872 tracerRate, mswTracerRate, freeTracerRate);
873 assignRates<Solution>(tr, eclWell, i, I, rate_s,
874 tracerRate, mswTracerRate, solTracerRate);
889 const Scalar official_well_rate_total =
890 simulator_.problem().wellModel().wellState().well(well_index).surface_rates[tr.phaseIdx_];
892 const Scalar rateWellTotal = official_well_rate_total;
894 if (rateWellTotal > rateWellNeg) {
895 constexpr Scalar bucketPrDay = 10.0 / (1000. * 3600. * 24.);
896 const Scalar factor = (rateWellTotal < -bucketPrDay) ? rateWellTotal / rateWellNeg : 0.0;
897 for (
int tIdx = 0; tIdx < tr.numTracer(); ++tIdx) {
898 tracerRate[tIdx].rate *= factor;
915 template <
typename TV>
924 std::unique_ptr<TracerMatrix>
mat;
935 result.
idx_ = {1,2,3};
944 template<
class Serializer>
954 {
return idx_.size(); }
958 const int numGridDof = concentration.size();
959 idx_.emplace_back(idx);
967 std::array<TracerBatch<TracerVector>,numPhases>
tbatch;
971 std::array<std::array<std::vector<Scalar>,numPhases>,2>
vol1_;
972 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:718
std::array< std::array< std::vector< Scalar >, numPhases >, 2 > vol1_
Definition: TracerModel.hpp:971
TracerBatch< TracerVector > & oil_
Definition: TracerModel.hpp:969
void advanceTracerFields()
Definition: TracerModel.hpp:792
void init(bool rst)
Definition: TracerModel.hpp:138
void assembleTracerEquationSource(TrRe &tr, const Scalar dt, unsigned I)
Definition: TracerModel.hpp:533
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:770
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:754
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:705
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:970
void assembleTracerEquations_()
Definition: TracerModel.hpp:579
std::array< TracerBatch< TracerVector >, numPhases > tbatch
Definition: TracerModel.hpp:967
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:972
ElementChunks< GridView, Dune::Partitions::All > element_chunks_
Definition: TracerModel.hpp:973
TracerBatch< TracerVector > & wat_
Definition: TracerModel.hpp:968
void endTimeStep()
Informs the tracer model that a time step has just been finished.
Definition: TracerModel.hpp:210
Simulator & simulator_
Definition: TracerModel.hpp:905
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: 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:917
const int phaseIdx_
Definition: TracerModel.hpp:919
void addTracer(const int idx, const TV &concentration)
Definition: TracerModel.hpp:956
bool operator==(const TracerBatch &rhs) const
Definition: TracerModel.hpp:926
static TracerBatch serializationTestObject()
Definition: TracerModel.hpp:932
std::vector< TV > concentrationInitial_
Definition: TracerModel.hpp:920
void serializeOp(Serializer &serializer)
Definition: TracerModel.hpp:945
TracerBatch(int phaseIdx=0)
Definition: TracerModel.hpp:951
int numTracer() const
Definition: TracerModel.hpp:953
std::vector< int > idx_
Definition: TracerModel.hpp:918
std::unique_ptr< TracerMatrix > mat
Definition: TracerModel.hpp:924
std::vector< TV > storageOfTimeIndex1_
Definition: TracerModel.hpp:922
std::vector< TV > residual_
Definition: TracerModel.hpp:923
std::vector< TV > concentration_
Definition: TracerModel.hpp:921
Definition: WellTracerRate.hpp:33