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>
35#include <dune/grid/yaspgrid.hh>
36#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
38#include <dune/common/version.hh>
39#include <dune/common/fvector.hh>
40#include <dune/common/fmatrix.hh>
43template <
class TypeTag>
47namespace Opm::Properties {
56template<
class TypeTag>
57struct Grid<TypeTag, TTag::OutflowBaseProblem> {
using type = Dune::YaspGrid<2>; };
60template<
class TypeTag>
64template<
class TypeTag>
65struct FluidSystem<TypeTag, TTag::OutflowBaseProblem>
68 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
72 using type = Opm::H2ON2LiquidPhaseFluidSystem<Scalar>;
76template<
class TypeTag>
77struct EnableGravity<TypeTag, TTag::OutflowBaseProblem> {
static constexpr bool value =
false; };
80template<
class TypeTag>
81struct VtkWriteMassFractions<TypeTag, TTag::OutflowBaseProblem> {
static constexpr bool value =
true; };
84template<
class TypeTag>
85struct EndTime<TypeTag, TTag::OutflowBaseProblem>
87 using type = GetPropType<TypeTag, Scalar>;
88 static constexpr type value = 100;
92template<
class TypeTag>
93struct InitialTimeStepSize<TypeTag, TTag::OutflowBaseProblem>
95 using type = GetPropType<TypeTag, Scalar>;
96 static constexpr type value = 1;
100template<
class TypeTag>
101struct GridFile<TypeTag, TTag::OutflowBaseProblem> {
static constexpr auto value =
"./data/outflow.dgf"; };
123template <
class TypeTag>
126 using ParentType = GetPropType<TypeTag, Properties::BaseProblem>;
128 using GridView = GetPropType<TypeTag, Properties::GridView>;
129 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
130 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
131 using EqVector = GetPropType<TypeTag, Properties::EqVector>;
132 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
133 using BoundaryRateVector = GetPropType<TypeTag, Properties::BoundaryRateVector>;
134 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
135 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
136 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
141 dim = GridView::dimension,
142 dimWorld = GridView::dimensionworld,
144 numPhases = FluidSystem::numPhases,
147 H2OIdx = FluidSystem::H2OIdx,
148 N2Idx = FluidSystem::N2Idx
151 using CoordScalar =
typename GridView::ctype;
152 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
154 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
161 : ParentType(simulator)
170 ParentType::finishInit();
172 temperature_ = 273.15 + 20;
173 FluidSystem::init(temperature_ - 1, temperature_ + 2,
178 perm_ = this->toDimMatrix_(1e-10);
192 {
return "outflow"; }
200 this->model().checkConservativeness();
204 this->model().globalStorage(storage);
207 if (this->gridView().comm().rank() == 0) {
208 std::cout <<
"Storage: " << storage << std::endl << std::flush;
218 template <
class Context>
222 {
return temperature_; }
229 template <
class Context>
240 template <
class Context>
244 {
return porosity_; }
251 template <
class Context>
252 Scalar tortuosity(
const Context& context,
unsigned spaceIdx,
unsigned timeIdx)
const
253 {
return tortuosity_; }
259 template <
class Context>
260 Scalar dispersivity(
const Context& context,
261 unsigned spaceIdx,
unsigned timeIdx)
const
275 template <
class Context>
276 void boundary(BoundaryRateVector& values,
const Context& context,
277 unsigned spaceIdx,
unsigned timeIdx)
const
279 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
281 if (onLeftBoundary_(globalPos)) {
282 Opm::CompositionalFluidState<Scalar, FluidSystem,
284 initialFluidState_(fs, context, spaceIdx, timeIdx);
285 fs.setPressure(0, fs.pressure(0) + 1e5);
288 fs.setMoleFraction(0, N2Idx, xlN2);
289 fs.setMoleFraction(0, H2OIdx, 1 - xlN2);
291 typename FluidSystem::template ParameterCache<Scalar> paramCache;
292 paramCache.updateAll(fs);
293 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
294 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
295 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
299 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
301 else if (onRightBoundary_(globalPos)) {
302 Opm::CompositionalFluidState<Scalar, FluidSystem,
304 initialFluidState_(fs, context, spaceIdx, timeIdx);
307 values.setOutFlow(context, spaceIdx, timeIdx, fs);
324 template <
class Context>
326 const Context& context,
328 unsigned timeIdx)
const
330 Opm::CompositionalFluidState<Scalar, FluidSystem,
false> fs;
331 initialFluidState_(fs, context, spaceIdx, timeIdx);
333 values.assignNaive(fs);
342 template <
class Context>
347 { rate = Scalar(0.0); }
352 bool onLeftBoundary_(
const GlobalPosition& pos)
const
353 {
return pos[0] < eps_; }
355 bool onRightBoundary_(
const GlobalPosition& pos)
const
356 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
358 template <
class Flu
idState,
class Context>
359 void initialFluidState_(FluidState& fs,
const Context& context,
360 unsigned spaceIdx,
unsigned timeIdx)
const
362 Scalar T =
temperature(context, spaceIdx, timeIdx);
369 fs.setSaturation(0, 1.0);
370 fs.setPressure(0, 1e5 );
371 fs.setMoleFraction(0, H2OIdx, 1.0);
372 fs.setMoleFraction(0, N2Idx, 0);
373 fs.setTemperature(T);
375 typename FluidSystem::template ParameterCache<Scalar> paramCache;
376 paramCache.updateAll(fs);
377 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
378 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
379 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
385 MaterialLawParams materialParams_;
Problem where dissolved nitrogen is transported with the water phase from the left side to the right.
Definition: outflowproblem.hh:125
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: outflowproblem.hh:325
void finishInit()
Definition: outflowproblem.hh:168
void endTimeStep()
Definition: outflowproblem.hh:197
OutflowProblem(Simulator &simulator)
Definition: outflowproblem.hh:160
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:343
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:219
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:241
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: outflowproblem.hh:276
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:230
std::string name() const
Definition: outflowproblem.hh:191
Definition: outflowproblem.hh:51