27#ifndef EWOMS_OUTFLOW_PROBLEM_HH
28#define EWOMS_OUTFLOW_PROBLEM_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>
56template<
class TypeTag>
57struct Grid<TypeTag, TTag::OutflowBaseProblem> {
using type = Dune::YaspGrid<2>; };
60template<
class TypeTag>
64template<
class TypeTag>
72 using type = Opm::H2ON2LiquidPhaseFluidSystem<Scalar>;
95template <
class TypeTag>
113 dim = GridView::dimension,
114 dimWorld = GridView::dimensionworld,
116 numPhases = FluidSystem::numPhases,
119 H2OIdx = FluidSystem::H2OIdx,
120 N2Idx = FluidSystem::N2Idx
123 using CoordScalar =
typename GridView::ctype;
124 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
126 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
133 : ParentType(simulator)
142 ParentType::finishInit();
144 temperature_ = 273.15 + 20;
145 FluidSystem::init(temperature_ - 1, temperature_ + 2,
150 perm_ = this->toDimMatrix_(1e-10);
160 ParentType::registerParameters();
162 Parameters::SetDefault<Parameters::GridFile>(
"./data/outflow.dgf");
163 Parameters::SetDefault<Parameters::EndTime<Scalar>>(100.0);
164 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1.0);
166 Parameters::SetDefault<Parameters::VtkWriteMassFractions>(
true);
178 {
return "outflow"; }
186 this->model().checkConservativeness();
190 this->model().globalStorage(storage);
193 if (this->gridView().comm().rank() == 0) {
194 std::cout <<
"Storage: " << storage << std::endl << std::flush;
204 template <
class Context>
208 {
return temperature_; }
215 template <
class Context>
226 template <
class Context>
230 {
return porosity_; }
237 template <
class Context>
238 Scalar tortuosity(
const Context& context,
unsigned spaceIdx,
unsigned timeIdx)
const
239 {
return tortuosity_; }
245 template <
class Context>
246 Scalar dispersivity(
const Context& context,
247 unsigned spaceIdx,
unsigned timeIdx)
const
261 template <
class Context>
262 void boundary(BoundaryRateVector& values,
const Context& context,
263 unsigned spaceIdx,
unsigned timeIdx)
const
265 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
267 if (onLeftBoundary_(globalPos)) {
268 Opm::CompositionalFluidState<Scalar, FluidSystem,
270 initialFluidState_(fs, context, spaceIdx, timeIdx);
271 fs.setPressure(0, fs.pressure(0) + 1e5);
274 fs.setMoleFraction(0, N2Idx, xlN2);
275 fs.setMoleFraction(0, H2OIdx, 1 - xlN2);
277 typename FluidSystem::template ParameterCache<Scalar> paramCache;
278 paramCache.updateAll(fs);
279 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
280 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
281 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
285 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
287 else if (onRightBoundary_(globalPos)) {
288 Opm::CompositionalFluidState<Scalar, FluidSystem,
290 initialFluidState_(fs, context, spaceIdx, timeIdx);
293 values.setOutFlow(context, spaceIdx, timeIdx, fs);
310 template <
class Context>
312 const Context& context,
314 unsigned timeIdx)
const
316 Opm::CompositionalFluidState<Scalar, FluidSystem,
false> fs;
317 initialFluidState_(fs, context, spaceIdx, timeIdx);
319 values.assignNaive(fs);
328 template <
class Context>
333 { rate = Scalar(0.0); }
338 bool onLeftBoundary_(
const GlobalPosition& pos)
const
339 {
return pos[0] < eps_; }
341 bool onRightBoundary_(
const GlobalPosition& pos)
const
342 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
344 template <
class Flu
idState,
class Context>
345 void initialFluidState_(FluidState& fs,
const Context& context,
346 unsigned spaceIdx,
unsigned timeIdx)
const
348 Scalar T =
temperature(context, spaceIdx, timeIdx);
355 fs.setSaturation(0, 1.0);
356 fs.setPressure(0, 1e5 );
357 fs.setMoleFraction(0, H2OIdx, 1.0);
358 fs.setMoleFraction(0, N2Idx, 0);
359 fs.setTemperature(T);
361 typename FluidSystem::template ParameterCache<Scalar> paramCache;
362 paramCache.updateAll(fs);
363 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
364 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
365 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
371 MaterialLawParams materialParams_;
Problem where dissolved nitrogen is transported with the water phase from the left side to the right.
Definition: outflowproblem.hh:97
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: outflowproblem.hh:311
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: outflowproblem.hh:140
void endTimeStep()
Called by the simulator after each time integration.
Definition: outflowproblem.hh:183
OutflowProblem(Simulator &simulator)
Definition: outflowproblem.hh:132
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: outflowproblem.hh:329
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:205
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:227
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: outflowproblem.hh:262
static void registerParameters()
Definition: outflowproblem.hh:158
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Definition: outflowproblem.hh:216
std::string name() const
The problem name.
Definition: outflowproblem.hh:177
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:235
Declares the properties required for the compositional multi-phase primary variable switching model.
Opm::H2ON2LiquidPhaseFluidSystem< Scalar > type
Definition: outflowproblem.hh:72
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:69
Dune::YaspGrid< 2 > type
Definition: outflowproblem.hh:57
The type of the DUNE grid.
Definition: basicproperties.hh:100
The type of the problem.
Definition: fvbaseproperties.hh:81
Definition: outflowproblem.hh:51