25#ifndef DUMUX_HETEROGENEOUS_PROBLEM_HH
26#define DUMUX_HETEROGENEOUS_PROBLEM_HH
29#include <dune/alugrid/grid.hh>
53template <
class TypeTag>
54class HeterogeneousProblem;
65template<
class TypeTag>
66struct Grid<TypeTag, TTag::Heterogeneous> {
using type = Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>; };
69template<
class TypeTag>
73template<
class TypeTag>
81template<
class TypeTag>
85 HeterogeneousCO2Tables::CO2Tables,
91template<
class TypeTag>
92struct UseMoles<TypeTag, TTag::Heterogeneous> {
static constexpr bool value =
false; };
97struct HeterogeneousNI {
using InheritsFrom = std::tuple<TwoPTwoCCO2NI>; };
98struct HeterogeneousNIBox {
using InheritsFrom = std::tuple<HeterogeneousNI, BoxModel>; };
99struct HeterogeneousNICCTpfa {
using InheritsFrom = std::tuple<HeterogeneousNI, CCTpfaModel>; };
103template<
class TypeTag>
104struct Grid<TypeTag, TTag::HeterogeneousNI> {
using type = Dune::ALUGrid<2, 2, Dune::cube, Dune::nonconforming>; };
107template<
class TypeTag>
108struct Problem<TypeTag, TTag::HeterogeneousNI> {
using type = HeterogeneousProblem<TypeTag>; };
111template<
class TypeTag>
112struct SpatialParams<TypeTag, TTag::HeterogeneousNI>
114 using type = HeterogeneousSpatialParams<GetPropType<TypeTag, Properties::GridGeometry>,
115 GetPropType<TypeTag, Properties::Scalar>>;
119template<
class TypeTag>
120struct FluidSystem<TypeTag, TTag::HeterogeneousNI>
122 using type = FluidSystems::BrineCO2<GetPropType<TypeTag, Properties::Scalar>,
123 HeterogeneousCO2Tables::CO2Tables,
124 Components::TabulatedComponent<Components::H2O<GetPropType<TypeTag, Properties::Scalar>>>,
125 FluidSystems::BrineCO2DefaultPolicy<
true,
true>>;
129template<
class TypeTag>
130struct UseMoles<TypeTag, TTag::HeterogeneousNI> {
static constexpr bool value =
false; };
162template <
class TypeTag >
170 using ElementVolumeVariables =
typename GridVariables::GridVolumeVariables::LocalView;
171 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
172 using VolumeVariables =
typename GridVariables::GridVolumeVariables::VolumeVariables;
181 pressureIdx = Indices::pressureIdx,
182 switchIdx = Indices::switchIdx,
185 firstPhaseOnly = Indices::firstPhaseOnly,
188 BrineIdx = FluidSystem::BrineIdx,
189 CO2Idx = FluidSystem::CO2Idx,
192 conti0EqIdx = Indices::conti0EqIdx,
193 contiCO2EqIdx = conti0EqIdx + CO2Idx
198 temperatureIdx = Indices::temperatureIdx,
199 energyEqIdx = Indices::energyEqIdx,
206 using Element =
typename GridView::template Codim<0>::Entity;
207 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
210 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
211 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
216 static constexpr bool useMoles = ModelTraits::useMoles();
222 static constexpr int dimWorld = GridView::dimensionworld;
225 template<
class SpatialParams>
229 , injectionBottom_(2)
230 , dirichletBoundary_(3)
233 nTemperature_ = getParam<int>(
"FluidSystem.NTemperature");
234 nPressure_ = getParam<int>(
"FluidSystem.NPressure");
235 pressureLow_ = getParam<Scalar>(
"FluidSystem.PressureLow");
236 pressureHigh_ = getParam<Scalar>(
"FluidSystem.PressureHigh");
237 temperatureLow_ = getParam<Scalar>(
"FluidSystem.TemperatureLow");
238 temperatureHigh_ = getParam<Scalar>(
"FluidSystem.TemperatureHigh");
239 depthBOR_ = getParam<Scalar>(
"Problem.DepthBOR");
240 name_ = getParam<std::string>(
"Problem.Name");
241 injectionRate_ = getParam<Scalar>(
"Problem.InjectionRate");
244 injectionPressure_ = getParam<Scalar>(
"Problem.InjectionPressure");
245 injectionTemperature_ = getParam<Scalar>(
"Problem.InjectionTemperature");
252 FluidSystem::init(temperatureLow_,
261 std::cout<<
"problem uses mole fractions"<<std::endl;
263 std::cout<<
"problem uses mass fractions"<<std::endl;
266 scvfToScvBoundaryTypes_.computeBoundaryTypes(*
this);
274 template<
class VTKWriter>
277 const auto numElements = this->
gridGeometry().gridView().size(0);
280 vtkKxx_.resize(numElements);
281 vtkPorosity_.resize(numElements);
282 vtkBoxVolume_.resize(numDofs, 0.0);
284 vtk.addField(vtkKxx_,
"Kxx");
285 vtk.addField(vtkPorosity_,
"cellwisePorosity");
286 vtk.addField(vtkBoxVolume_,
"boxVolume");
289 vtk.addVolumeVariable([](
const VolumeVariables& v){
return v.enthalpy(BrineIdx); },
"enthalpyW");
290 vtk.addVolumeVariable([](
const VolumeVariables& v){
return v.enthalpy(CO2Idx); },
"enthalpyN");
292 vtkTemperature_.resize(numDofs, 0.0);
293 vtk.addField(vtkTemperature_,
"T");
297 for (
const auto& element : elements(gridView))
299 const auto eIdx = this->
gridGeometry().elementMapper().index(element);
301 fvGeometry.bindElement(element);
303 for (
const auto& scv : scvs(fvGeometry))
305 const auto dofIdxGlobal = scv.dofIndex();
306 vtkBoxVolume_[dofIdxGlobal] += scv.volume();
308 vtkTemperature_[dofIdxGlobal] = initialTemperatureField_(scv.dofPosition());
313 vtkPorosity_[eIdx] = 1- this->
spatialParams().inertVolumeFraction(eIdx);
327 const std::string&
name()
const
339 {
return initialTemperatureField_(globalPos); }
356 const SubControlVolume &scv)
const
357 {
return scvfToScvBoundaryTypes_.boundaryTypes(scv); }
367 const SubControlVolumeFace &scvf)
const
369 BoundaryTypes bcTypes;
370 const auto boundaryId = scvf.boundaryFlag();
372 if (boundaryId < 1 || boundaryId > 4)
373 DUNE_THROW(Dune::InvalidStateException,
"Invalid boundary ID: " << boundaryId);
375 if (boundaryId == dirichletBoundary_)
376 bcTypes.setAllDirichlet();
378 bcTypes.setAllNeumann();
391 {
return initial_(globalPos); }
411 const FVElementGeometry& fvGeometry,
412 const ElementVolumeVariables& elemVolVars,
413 const ElementFluxVariablesCache& elemFluxVarsCache,
414 const SubControlVolumeFace& scvf)
const
416 const auto boundaryId = scvf.boundaryFlag();
418 NumEqVector fluxes(0.0);
420 if (boundaryId == injectionBottom_)
422 fluxes[contiCO2EqIdx] = useMoles ? -injectionRate_/FluidSystem::molarMass(CO2Idx) : -injectionRate_;
426 injectionTemperature_, injectionPressure_);
449 return initial_(globalPos);
462 PrimaryVariables initial_(
const GlobalPosition &globalPos)
const
464 PrimaryVariables values(0.0);
465 values.setState(firstPhaseOnly);
467 const Scalar temp = initialTemperatureField_(globalPos);
468 const Scalar densityW = FluidSystem::Brine::liquidDensity(temp, 1e7);
470 const Scalar moleFracLiquidCO2 = 0.00;
471 const Scalar moleFracLiquidBrine = 1.0 - moleFracLiquidCO2;
473 const Scalar meanM = FluidSystem::molarMass(BrineIdx)*moleFracLiquidBrine
474 + FluidSystem::molarMass(CO2Idx)*moleFracLiquidCO2;
477 values[switchIdx] = moleFracLiquidCO2;
479 values[switchIdx] = moleFracLiquidCO2*FluidSystem::molarMass(CO2Idx)/meanM;
481 values[pressureIdx] = 1.0e5 - densityW*this->
spatialParams().gravity(globalPos)[dimWorld-1]*(depthBOR_ - globalPos[dimWorld-1]);
484 values[temperatureIdx] = temp;
489 Scalar initialTemperatureField_(
const GlobalPosition globalPos)
const
491 return 283.0 + (depthBOR_ - globalPos[dimWorld-1])*0.03;
495 Scalar injectionRate_;
498 Scalar injectionPressure_, injectionTemperature_;
506 Scalar pressureLow_, pressureHigh_;
507 Scalar temperatureLow_, temperatureHigh_;
510 int injectionBottom_;
511 int dirichletBoundary_;
515 std::vector<Scalar> vtkKxx_, vtkPorosity_, vtkBoxVolume_, vtkTemperature_;
516 ScvfToScvBoundaryTypes<BoundaryTypes, discMethod> scvfToScvBoundaryTypes_;
Convert intersection boundary types to vertex boundary types.
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with TPFA.
Material properties of pure water .
Tabulates all thermodynamic properties of a given untabulated chemical species.
A compositional fluid with brine (H2O & NaCl) and carbon dioxide as components in both the liquid and...
Provides the class with the tabulated values of CO2 density and enthalpy.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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:149
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
UndefinedProperty type
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
UndefinedProperty type
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The type of the spatial parameters object.
Definition: common/properties.hh:221
UndefinedProperty type
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
UndefinedProperty type
Definition: common/properties.hh:223
A class for the CO2 fluid properties.
Definition: co2.hh:56
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of gaseous CO2 .
Definition: co2.hh:161
Tabulates all thermodynamic properties of a given untabulated chemical species.
Definition: tabulatedcomponent.hh:82
Default policy for the Brine-CO2 fluid system.
Definition: brineco2.hh:97
A compositional fluid with brine (H2O & NaCl) and carbon dioxide as components in both the liquid and...
Definition: brineco2.hh:119
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Definition of a problem, where CO2 is injected in a reservoir.
Definition: test/porousmediumflow/co2/implicit/problem.hh:164
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/co2/implicit/problem.hh:390
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature within the domain.
Definition: test/porousmediumflow/co2/implicit/problem.hh:338
HeterogeneousProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< SpatialParams > spatialParams)
Definition: test/porousmediumflow/co2/implicit/problem.hh:226
BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/co2/implicit/problem.hh:366
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/co2/implicit/problem.hh:410
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial values at a position.
Definition: test/porousmediumflow/co2/implicit/problem.hh:447
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/co2/implicit/problem.hh:327
BoundaryTypes boundaryTypes(const Element &element, const SubControlVolume &scv) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/co2/implicit/problem.hh:355
void addFieldsToWriter(VTKWriter &vtk)
Appends all quantities of interest which can be derived from the solution of the current time step to...
Definition: test/porousmediumflow/co2/implicit/problem.hh:275
Definition: test/porousmediumflow/co2/implicit/problem.hh:59
std::tuple< TwoPTwoCCO2 > InheritsFrom
Definition: test/porousmediumflow/co2/implicit/problem.hh:59
Definition: test/porousmediumflow/co2/implicit/problem.hh:60
std::tuple< Heterogeneous, BoxModel > InheritsFrom
Definition: test/porousmediumflow/co2/implicit/problem.hh:60
Definition: test/porousmediumflow/co2/implicit/problem.hh:61
std::tuple< Heterogeneous, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/co2/implicit/problem.hh:61
Dune::ALUGrid< 2, 2, Dune::cube, Dune::nonconforming > type
Definition: test/porousmediumflow/co2/implicit/problem.hh:66
Definition of the spatial parameters for the heterogeneous problem which uses the non-isothermal or i...
Definition: porousmediumflow/co2/implicit/spatialparams.hh:50
Adaption of the fully implicit scheme to the CO2Model model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.