3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
celldatamultiphysics.hh
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program 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 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_ELEMENTDATA2P2C_MULTYPHYSICS_HH
25#define DUMUX_ELEMENTDATA2P2C_MULTYPHYSICS_HH
26
28#include "properties.hh"
29#include "celldata.hh"
30
31namespace Dumux {
43template<class TypeTag>
45{
46private:
47 using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
48 using FluidState = typename GET_PROP_TYPE(TypeTag, FluidState);
49 using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
51
52 using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
53
54 enum
55 {
56 wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx
57 };
58 enum
59 {
60 complex = 0, simple = 1
61 };
62private:
63 int subdomain_;
64 int fluidStateType_;
65 std::shared_ptr<SimpleFluidState> simpleFluidState_;
66
67// FluxData fluxData_;
68public:
69
72 subdomain_(2), fluidStateType_(complex)
73 {
74 }
75
79 Scalar pressure(int phaseIdx)
80 {
81 if(fluidStateType_ == simple)
82 {
83 return simpleFluidState_->pressure(phaseIdx);
84 }
85 else
86 return this->fluidState_->pressure(phaseIdx);
87 }
89 const Scalar pressure(int phaseIdx) const
90 {
91 if(fluidStateType_ == simple)
92 {
93 return simpleFluidState_->pressure(phaseIdx);
94 }
95 else
96 return this->fluidState_->pressure(phaseIdx);
97 }
99 void setPressure(int phaseIdx, Scalar value)
100 {
101 if(fluidStateType_ == simple)
102 manipulateSimpleFluidState().setPressure(phaseIdx, value);
103 else
104 manipulateFluidState().setPressure(phaseIdx, value);
105 }
107
108
110 // functions returning the vectors of secondary variables
112
119 {
120 return subdomain_;
121 }
122
128 const int& subdomain() const
129 {
130 return subdomain_;
131 }
132
137 {
138 subdomain_ = index;
139 if(index == 2)
140 fluidStateType_ = complex;
141 else
142 fluidStateType_ = simple;
143 }
144
148 void setSaturation(int phaseIdx, Scalar value)
149 {
150 if(fluidStateType_ == simple)
151 {
152 // saturation is triggered by presentPhaseIdx
153 manipulateSimpleFluidState().setPresentPhaseIdx((value==0.) ? nPhaseIdx : wPhaseIdx);
154 }
155 else
156 {
157 manipulateFluidState().setSaturation(phaseIdx, value);
158 manipulateFluidState().setSaturation(1-phaseIdx, 1.0-value);
159 }
160 }
162 const Scalar saturation(int phaseIdx) const
163 {
164 if(fluidStateType_ == simple)
165 {
166 return simpleFluidState_->saturation(phaseIdx);
167 }
168 else
169 return this->fluidState_->saturation(phaseIdx);
170 }
171
173 void setViscosity(int phaseIdx, Scalar value)
174 {
175 if(fluidStateType_ == simple)
176 {
177 assert(phaseIdx == simpleFluidState_->presentPhaseIdx());
178 manipulateSimpleFluidState().setViscosity(phaseIdx, value);
179 }
180 else
181 manipulateFluidState().setViscosity(phaseIdx, value);
182 }
184 const Scalar viscosity(int phaseIdx) const
185 {
186 if(fluidStateType_ == simple)
187 {
188 if(phaseIdx != simpleFluidState_->presentPhaseIdx())
189 return 0.; // This should only happend for output
190 return simpleFluidState_->viscosity(phaseIdx);
191 }
192 else
193 return this->fluidState_->viscosity(phaseIdx);
194 }
195
196
198 const Scalar capillaryPressure() const
199 {
200 if(fluidStateType_ == simple)
201 return simpleFluidState_->pressure(nPhaseIdx) - simpleFluidState_->pressure(wPhaseIdx);
202 else
203 return this->fluidState_->pressure(nPhaseIdx) - this->fluidState_->pressure(wPhaseIdx);
204 }
205
207 const Scalar density(int phaseIdx) const
208 {
209 if(fluidStateType_ == simple)
210 {
211 return simpleFluidState_->density(phaseIdx);
212 }
213 else
214 return this->fluidState_->density(phaseIdx);
215 }
216
218 const Scalar massFraction(int phaseIdx, int compIdx) const
219 {
220 if(fluidStateType_ == simple)
221 {
222 return simpleFluidState_->massFraction(phaseIdx, compIdx);
223 }
224 else
225 return this->fluidState_->massFraction(phaseIdx, compIdx);
226 }
227
229 const Scalar moleFraction(int phaseIdx, int compIdx) const
230 {
231 if(fluidStateType_ == simple)
232 {
233 return simpleFluidState_->moleFraction(phaseIdx, compIdx);
234 }
235 else
236 return this->fluidState_->moleFraction(phaseIdx, compIdx);
237 }
239 const Scalar temperature(int phaseIdx) const
240 {
241 if(fluidStateType_ == simple)
242 {
243 return simpleFluidState_->temperature(phaseIdx);
244 }
245 else
246 return this->fluidState_->temperature(phaseIdx);
247 }
248
250 const Scalar phaseMassFraction(int phaseIdx) const
251 {
252 if(fluidStateType_ == simple)
253 {
254 if(phaseIdx == simpleFluidState_->presentPhaseIdx())
255 return 1.; // phase is present => nu = 1
256 else
257 return 0.;
258 }
259 else
260 return this->fluidState_->phaseMassFraction(phaseIdx);
261 }
262
265 {
266 assert(simpleFluidState_);
267 return *simpleFluidState_;
268 }
269
271
281 {
282 assert (this->subdomain() != 2);
283 fluidStateType_ = simple;
284 simpleFluidState_ = &simpleFluidState;
285 }
288 {
289 fluidStateType_ = simple;
290 if(this->fluidState_)
291 {
292 this->fluidState_.template reset<FluidState>(0);
293 }
294
295 if(!simpleFluidState_)
296 simpleFluidState_ = std::make_shared<SimpleFluidState>();
297 return *simpleFluidState_;
298 }
299
308 {
309 fluidStateType_ = complex;
310 if(simpleFluidState_)
311 {
312 simpleFluidState_.template reset<SimpleFluidState>(0);
313 }
314
315 if(!this->fluidState_)
316 {
317 this->fluidState_ = std::make_shared<FluidState>();
318 // properly initialize pressure, since it is evaluated later:
319 this->fluidState_->setPressure(wPhaseIdx, 1e5);
320 this->fluidState_->setPressure(nPhaseIdx, 1e5);
321 }
322
323 return *this->fluidState_;
324 }
325
327 bool fluidStateType() const
328 { return fluidStateType_;}
329
330};
331
332} // end namespace Dumux
333#endif
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:283
Calculates phase state for a single phase but two-component state.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Container for compositional variables in a 1p2c situation.
Definition: pseudo1p2c.hh:44
void setPresentPhaseIdx(int phaseIdx)
Sets the phase Index that is present in this fluidState.
Definition: pseudo1p2c.hh:257
void setPressure(int phaseIdx, Scalar value)
Sets the phase pressure .
Definition: pseudo1p2c.hh:282
void setViscosity(int phaseIdx, Scalar value)
Sets the viscosity of a phase .
Definition: pseudo1p2c.hh:203
Storage container for discretized data of the constitutive relations for one element.
Definition: 2p2c/sequential/celldata.hh:44
std::shared_ptr< FluidState > fluidState_
Definition: 2p2c/sequential/celldata.hh:80
Storage container for discretized data for multiphysics models.
Definition: celldatamultiphysics.hh:45
const Scalar massFraction(int phaseIdx, int compIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:218
const Scalar moleFraction(int phaseIdx, int compIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:229
Scalar pressure(int phaseIdx)
DOC ME!
Definition: celldatamultiphysics.hh:79
const int & subdomain() const
Return subdomain information.
Definition: celldatamultiphysics.hh:128
void setPressure(int phaseIdx, Scalar value)
Modify the phase pressure.
Definition: celldatamultiphysics.hh:99
const Scalar density(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:207
const Scalar saturation(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:162
const Scalar phaseMassFraction(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:250
const Scalar viscosity(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:184
void setViscosity(int phaseIdx, Scalar value)
DOC ME!
Definition: celldatamultiphysics.hh:173
void setSaturation(int phaseIdx, Scalar value)
DOC ME!
Definition: celldatamultiphysics.hh:148
int & subdomain()
Return subdomain information.
Definition: celldatamultiphysics.hh:118
const Scalar capillaryPressure() const
DOC ME!
Definition: celldatamultiphysics.hh:198
void setSubdomainAndFluidStateType(int index)
Specify subdomain information and fluidStateType.
Definition: celldatamultiphysics.hh:136
const Scalar temperature(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:239
SimpleFluidState & manipulateSimpleFluidState()
Manipulates a simple fluidstate for a cell in the simple domain.
Definition: celldatamultiphysics.hh:287
const Scalar pressure(int phaseIdx) const
DOC ME!
Definition: celldatamultiphysics.hh:89
CellData2P2CMultiPhysics()
Constructor for a local storage object.
Definition: celldatamultiphysics.hh:71
FluidState & manipulateFluidState()
Allows manipulation of the complex fluid state.
Definition: celldatamultiphysics.hh:307
void setSimpleFluidState(SimpleFluidState &simpleFluidState)
Set a simple fluidstate for a cell in the simple domain Uses a simplified fluidstate with less storag...
Definition: celldatamultiphysics.hh:280
bool fluidStateType() const
Returns the type of the fluidState.
Definition: celldatamultiphysics.hh:327
const SimpleFluidState & simpleFluidState() const
Returns a reference to the cells simple fluid state.
Definition: celldatamultiphysics.hh:264
Base file for properties related to sequential models.
Storage container for discretized data of the constitutive relations for one element.