27 #ifndef EWOMS_OUTFLOW_PROBLEM_HH
28 #define EWOMS_OUTFLOW_PROBLEM_HH
30 #include <opm/models/pvs/pvsproperties.hh>
32 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
33 #include <opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp>
34 #include <opm/material/common/Unused.hpp>
36 #include <dune/grid/yaspgrid.hh>
37 #include <dune/grid/io/file/dgfparser/dgfyasp.hh>
39 #include <dune/common/version.hh>
40 #include <dune/common/fvector.hh>
41 #include <dune/common/fmatrix.hh>
44 template <
class TypeTag>
48 namespace Opm::Properties {
57 template<
class TypeTag>
58 struct Grid<TypeTag, TTag::OutflowBaseProblem> {
using type = Dune::YaspGrid<2>; };
61 template<
class TypeTag>
65 template<
class TypeTag>
66 struct FluidSystem<TypeTag, TTag::OutflowBaseProblem>
69 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
73 using type = Opm::H2ON2LiquidPhaseFluidSystem<Scalar>;
77 template<
class TypeTag>
78 struct EnableGravity<TypeTag, TTag::OutflowBaseProblem> {
static constexpr
bool value =
false; };
81 template<
class TypeTag>
82 struct VtkWriteMassFractions<TypeTag, TTag::OutflowBaseProblem> {
static constexpr
bool value =
true; };
85 template<
class TypeTag>
86 struct EndTime<TypeTag, TTag::OutflowBaseProblem>
88 using type = GetPropType<TypeTag, Scalar>;
89 static constexpr type value = 100;
93 template<
class TypeTag>
94 struct InitialTimeStepSize<TypeTag, TTag::OutflowBaseProblem>
96 using type = GetPropType<TypeTag, Scalar>;
97 static constexpr type value = 1;
101 template<
class TypeTag>
102 struct GridFile<TypeTag, TTag::OutflowBaseProblem> {
static constexpr
auto value =
"./data/outflow.dgf"; };
124 template <
class TypeTag>
127 using ParentType = GetPropType<TypeTag, Properties::BaseProblem>;
129 using GridView = GetPropType<TypeTag, Properties::GridView>;
130 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
131 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
132 using EqVector = GetPropType<TypeTag, Properties::EqVector>;
133 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
134 using BoundaryRateVector = GetPropType<TypeTag, Properties::BoundaryRateVector>;
135 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
136 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
137 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
142 dim = GridView::dimension,
143 dimWorld = GridView::dimensionworld,
145 numPhases = FluidSystem::numPhases,
148 H2OIdx = FluidSystem::H2OIdx,
149 N2Idx = FluidSystem::N2Idx
152 using CoordScalar =
typename GridView::ctype;
153 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
155 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
162 : ParentType(simulator)
171 ParentType::finishInit();
173 temperature_ = 273.15 + 20;
174 FluidSystem::init(temperature_ - 1, temperature_ + 2,
179 perm_ = this->toDimMatrix_(1e-10);
193 {
return "outflow"; }
201 this->model().checkConservativeness();
205 this->model().globalStorage(storage);
208 if (this->gridView().comm().rank() == 0) {
209 std::cout <<
"Storage: " << storage << std::endl << std::flush;
219 template <
class Context>
221 unsigned spaceIdx OPM_UNUSED,
222 unsigned timeIdx OPM_UNUSED)
const
223 {
return temperature_; }
230 template <
class Context>
232 unsigned spaceIdx OPM_UNUSED,
233 unsigned timeIdx OPM_UNUSED)
const
241 template <
class Context>
243 unsigned spaceIdx OPM_UNUSED,
244 unsigned timeIdx OPM_UNUSED)
const
245 {
return porosity_; }
252 template <
class Context>
253 Scalar tortuosity(
const Context& context,
unsigned spaceIdx,
unsigned timeIdx)
const
254 {
return tortuosity_; }
260 template <
class Context>
261 Scalar dispersivity(
const Context& context,
262 unsigned spaceIdx,
unsigned timeIdx)
const
276 template <
class Context>
277 void boundary(BoundaryRateVector& values,
const Context& context,
278 unsigned spaceIdx,
unsigned timeIdx)
const
280 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
282 if (onLeftBoundary_(globalPos)) {
283 Opm::CompositionalFluidState<Scalar, FluidSystem,
285 initialFluidState_(fs, context, spaceIdx, timeIdx);
286 fs.setPressure(0, fs.pressure(0) + 1e5);
289 fs.setMoleFraction(0, N2Idx, xlN2);
290 fs.setMoleFraction(0, H2OIdx, 1 - xlN2);
292 typename FluidSystem::template ParameterCache<Scalar> paramCache;
293 paramCache.updateAll(fs);
294 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
295 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
296 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
300 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
302 else if (onRightBoundary_(globalPos)) {
303 Opm::CompositionalFluidState<Scalar, FluidSystem,
305 initialFluidState_(fs, context, spaceIdx, timeIdx);
308 values.setOutFlow(context, spaceIdx, timeIdx, fs);
325 template <
class Context>
327 const Context& context,
329 unsigned timeIdx)
const
331 Opm::CompositionalFluidState<Scalar, FluidSystem,
false> fs;
332 initialFluidState_(fs, context, spaceIdx, timeIdx);
334 values.assignNaive(fs);
343 template <
class Context>
345 const Context& context OPM_UNUSED,
346 unsigned spaceIdx OPM_UNUSED,
347 unsigned timeIdx OPM_UNUSED)
const
348 { rate = Scalar(0.0); }
353 bool onLeftBoundary_(
const GlobalPosition& pos)
const
354 {
return pos[0] < eps_; }
356 bool onRightBoundary_(
const GlobalPosition& pos)
const
357 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
359 template <
class Flu
idState,
class Context>
360 void initialFluidState_(FluidState& fs,
const Context& context,
361 unsigned spaceIdx,
unsigned timeIdx)
const
363 Scalar T =
temperature(context, spaceIdx, timeIdx);
370 fs.setSaturation(0, 1.0);
371 fs.setPressure(0, 1e5 );
372 fs.setMoleFraction(0, H2OIdx, 1.0);
373 fs.setMoleFraction(0, N2Idx, 0);
374 fs.setTemperature(T);
376 typename FluidSystem::template ParameterCache<Scalar> paramCache;
377 paramCache.updateAll(fs);
378 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
379 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
380 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
386 MaterialLawParams materialParams_;
Problem where dissolved nitrogen is transported with the water phase from the left side to the right.
Definition: outflowproblem.hh:126
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: outflowproblem.hh:326
void finishInit()
Definition: outflowproblem.hh:169
void endTimeStep()
Definition: outflowproblem.hh:198
OutflowProblem(Simulator &simulator)
Definition: outflowproblem.hh:161
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: outflowproblem.hh:277
Scalar temperature(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: outflowproblem.hh:220
const DimMatrix & intrinsicPermeability(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: outflowproblem.hh:231
void source(RateVector &rate, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: outflowproblem.hh:344
std::string name() const
Definition: outflowproblem.hh:192
Scalar porosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: outflowproblem.hh:242
Definition: outflowproblem.hh:52