GenericTracerModel.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef OPM_GENERIC_TRACER_MODEL_HPP
29#define OPM_GENERIC_TRACER_MODEL_HPP
30
31#include <opm/grid/common/CartesianIndexMapper.hpp>
32
33#include <opm/input/eclipse/EclipseState/Phase.hpp>
34
36
41
42#include <array>
43#include <cstddef>
44#include <functional>
45#include <memory>
46#include <string>
47#include <unordered_map>
48#include <vector>
49
50namespace Opm {
51
52class EclipseState;
53class Well;
54
55template<class Grid, class GridView, class DofMapper, class Stencil, class FluidSystem, class Scalar>
57public:
62 static constexpr int dimWorld = Grid::dimensionworld;
66 int numTracers() const;
67
71 const std::string& name(int tracerIdx) const;
72 std::string fname(int tracerIdx) const;
73 std::string sname(int tracerIdx) const;
74 std::string wellfname(int tracerIdx) const;
75 std::string wellsname(int tracerIdx) const;
76
77 Phase phase(int tracerIdx) const;
78 const std::vector<bool>& enableSolTracers() const;
79
83 Scalar freeTracerConcentration(int tracerIdx, int globalDofIdx) const;
84 Scalar solTracerConcentration(int tracerIdx, int globalDofIdx) const;
85 void setFreeTracerConcentration(int tracerIdx, int globalDofIdx, Scalar value);
86 void setSolTracerConcentration(int tracerIdx, int globalDofIdx, Scalar value);
87 void setEnableSolTracers(int tracerIdx, bool enableSolTracer);
88
92 const std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>&
94 { return wellTracerRate_; }
95
96 const std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>&
98 { return wellFreeTracerRate_; }
99
100 const std::unordered_map<int, std::vector<WellTracerRate<Scalar>>>&
102 { return wellSolTracerRate_; }
103
104 const std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>>&
106
107 template<class Serializer>
108 void serializeOp(Serializer& serializer)
109 {
110 serializer(tracerConcentration_);
111 serializer(freeTracerConcentration_);
112 serializer(solTracerConcentration_);
113 serializer(wellTracerRate_);
114 serializer(wellFreeTracerRate_);
115 serializer(wellSolTracerRate_);
116 serializer(mSwTracerRate_);
117 }
118
119protected:
120 GenericTracerModel(const GridView& gridView,
121 const EclipseState& eclState,
122 const CartesianIndexMapper& cartMapper,
123 const DofMapper& dofMapper,
124 const std::function<std::array<double,dimWorld>(int)> centroids);
125
129 void doInit(bool rst,
130 std::size_t numGridDof,
131 std::size_t gasPhaseIdx,
132 std::size_t oilPhaseIdx,
133 std::size_t waterPhaseIdx);
134
135 bool linearSolve_(const TracerMatrix& M, TracerVector& x, TracerVector& b);
136
138 std::vector<TracerVector>& x,
139 std::vector<TracerVector>& b);
140
144 bool linearSolveReorder_(const TracerMatrix& M,
145 std::vector<TracerVector>& x,
146 std::vector<TracerVector>& b);
147
148 Scalar currentConcentration_(const Well& eclWell,
149 const std::string& trName,
150 const SummaryState& summaryState) const;
151
154 Free = 0,
156 };
157
158 const GridView& gridView_;
159 const EclipseState& eclState_;
161 const DofMapper& dofMapper_;
162
163 std::vector<int> tracerPhaseIdx_;
164 std::vector<bool> enableSolTracers_;
165 std::vector<TracerVector> tracerConcentration_;
166 std::unique_ptr<TracerMatrix> tracerMatrix_;
167 bool useReorderSolver_ = false;
168 std::vector<TracerVectorSingle> freeTracerConcentration_;
169 std::vector<TracerVectorSingle> solTracerConcentration_;
170
171 // well_index -> tracer rates
172 std::unordered_map<int, std::vector<WellTracerRate<Scalar>>> wellTracerRate_;
173 std::unordered_map<int, std::vector<WellTracerRate<Scalar>>> wellFreeTracerRate_;
174 std::unordered_map<int, std::vector<WellTracerRate<Scalar>>> wellSolTracerRate_;
175
176 std::unordered_map<int, std::vector<MSWellTracerRate<Scalar>>> mSwTracerRate_;
177
179 std::function<std::array<double,dimWorld>(int)> centroids_;
180};
181
182} // namespace Opm
183
184#endif // OPM_GENERIC_TRACER_MODEL_HPP
Definition: CollectDataOnIORank.hpp:50
Definition: GenericTracerModel.hpp:56
void setEnableSolTracers(int tracerIdx, bool enableSolTracer)
Definition: GenericTracerModel_impl.hpp:157
Opm::BlockVector< Dune::FieldVector< Scalar, 2 > > TracerVector
Definition: GenericTracerModel.hpp:60
int numTracers() const
Return the number of tracers considered by the tracerModel.
Definition: GenericTracerModel_impl.hpp:164
bool useReorderSolver_
Definition: GenericTracerModel.hpp:167
const std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > & getWellTracerRates() const
Return well tracer rates.
Definition: GenericTracerModel.hpp:93
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:229
std::string sname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:178
std::vector< TracerVector > tracerConcentration_
Definition: GenericTracerModel.hpp:165
std::vector< int > tracerPhaseIdx_
Definition: GenericTracerModel.hpp:163
std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > wellFreeTracerRate_
Definition: GenericTracerModel.hpp:173
const DofMapper & dofMapper_
Definition: GenericTracerModel.hpp:161
std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > wellTracerRate_
Definition: GenericTracerModel.hpp:172
const GridView & gridView_
Definition: GenericTracerModel.hpp:158
std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > mSwTracerRate_
Definition: GenericTracerModel.hpp:176
const std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > & getWellFreeTracerRates() const
Definition: GenericTracerModel.hpp:97
const EclipseState & eclState_
Definition: GenericTracerModel.hpp:159
void setSolTracerConcentration(int tracerIdx, int globalDofIdx, Scalar value)
Definition: GenericTracerModel_impl.hpp:149
std::string wellfname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:185
GenericTracerModel(const GridView &gridView, const EclipseState &eclState, const CartesianIndexMapper &cartMapper, const DofMapper &dofMapper, const std::function< std::array< double, dimWorld >(int)> centroids)
Definition: GenericTracerModel_impl.hpp:104
const std::string & name(int tracerIdx) const
Return the tracer name.
Definition: GenericTracerModel_impl.hpp:222
const std::vector< bool > & enableSolTracers() const
Definition: GenericTracerModel_impl.hpp:206
Phase phase(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:199
const std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > & getWellSolTracerRates() const
Definition: GenericTracerModel.hpp:101
std::string wellsname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:192
const std::unordered_map< int, std::vector< MSWellTracerRate< Scalar > > > & getMswTracerRates() const
Definition: GenericTracerModel.hpp:105
std::string fname(int tracerIdx) const
Definition: GenericTracerModel_impl.hpp:171
std::vector< TracerVectorSingle > freeTracerConcentration_
Definition: GenericTracerModel.hpp:168
std::function< std::array< double, dimWorld >(int)> centroids_
Function returning the cell centers.
Definition: GenericTracerModel.hpp:179
bool linearSolveReorder_(const TracerMatrix &M, std::vector< TracerVector > &x, std::vector< TracerVector > &b)
Solve the tracer equations cell by cell in the order of the flow.
Definition: GenericTracerModel_impl.hpp:510
bool linearSolve_(const TracerMatrix &M, TracerVector &x, TracerVector &b)
Definition: GenericTracerModel_impl.hpp:391
const CartesianIndexMapper & cartMapper_
Definition: GenericTracerModel.hpp:160
Opm::BCRSMatrix< Opm::MatrixBlock< Scalar, 2, 2 > > TracerMatrix
Definition: GenericTracerModel.hpp:59
Dune::CartesianIndexMapper< Grid > CartesianIndexMapper
Definition: GenericTracerModel.hpp:61
void setFreeTracerConcentration(int tracerIdx, int globalDofIdx, Scalar value)
Definition: GenericTracerModel_impl.hpp:141
std::vector< bool > enableSolTracers_
Definition: GenericTracerModel.hpp:164
Scalar solTracerConcentration(int tracerIdx, int globalDofIdx) const
Definition: GenericTracerModel_impl.hpp:130
TracerTypeIdx
Tracer type index.
Definition: GenericTracerModel.hpp:153
@ Free
Definition: GenericTracerModel.hpp:154
@ Solution
Definition: GenericTracerModel.hpp:155
static constexpr int dimWorld
Definition: GenericTracerModel.hpp:62
bool linearSolveBatchwise_(const TracerMatrix &M, std::vector< TracerVector > &x, std::vector< TracerVector > &b)
Definition: GenericTracerModel_impl.hpp:446
void serializeOp(Serializer &serializer)
Definition: GenericTracerModel.hpp:108
std::vector< TracerVectorSingle > solTracerConcentration_
Definition: GenericTracerModel.hpp:169
Scalar freeTracerConcentration(int tracerIdx, int globalDofIdx) const
Return the tracer concentration for tracer index and global DofIdx.
Definition: GenericTracerModel_impl.hpp:119
Scalar currentConcentration_(const Well &eclWell, const std::string &trName, const SummaryState &summaryState) const
Definition: GenericTracerModel_impl.hpp:213
std::unique_ptr< TracerMatrix > tracerMatrix_
Definition: GenericTracerModel.hpp:166
std::unordered_map< int, std::vector< WellTracerRate< Scalar > > > wellSolTracerRate_
Definition: GenericTracerModel.hpp:174
Opm::BlockVector< Dune::FieldVector< Scalar, 1 > > TracerVectorSingle
Definition: GenericTracerModel.hpp:58
Phase
Phase indices for reservoir coupling, we currently only support black-oil phases (oil,...
Definition: ReservoirCoupling.hpp:184
Definition: blackoilbioeffectsmodules.hh:45
Dune::BCRSMatrix< B, A > BCRSMatrix
Definition: BCRSMatrix.hpp:35
Dune::BlockVector< B, A > BlockVector
Definition: BlockVector.hpp:35