25#ifndef DUMUX_DARCY2P2C_SUBPROBLEM_HH
26#define DUMUX_DARCY2P2C_SUBPROBLEM_HH
28#include <dune/grid/yaspgrid.hh>
41template <
class TypeTag>
55template<
class TypeTag>
59template<
class TypeTag>
63template<
class TypeTag>
68template<
class TypeTag>
69struct ReplaceCompEqIdx<TypeTag, TTag::DarcyTwoPTwoC> {
static constexpr int value = 3; };
72template<
class TypeTag>
73struct Grid<TypeTag, TTag::DarcyTwoPTwoC> {
using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
75template<
class TypeTag>
76struct UseMoles<TypeTag, TTag::DarcyTwoPTwoC> {
static constexpr bool value =
true; };
78template<
class TypeTag>
88template <
class TypeTag>
99 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
100 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
103 using ElementVolumeVariables =
typename GridVariables::GridVolumeVariables::LocalView;
104 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
112 conti0EqIdx = Indices::conti0EqIdx,
113 contiWEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx,
114 contiNEqIdx = Indices::conti0EqIdx + FluidSystem::AirIdx,
115 pressureIdx = Indices::pressureIdx,
116 switchIdx = Indices::switchIdx
119 using Element =
typename GridView::template Codim<0>::Entity;
120 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
122 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
131 pressure_ = getParamFromGroup<Scalar>(this->
paramGroup(),
"Problem.Pressure");
132 initialSw_ = getParamFromGroup<Scalar>(this->
paramGroup(),
"Problem.Saturation");
133 temperature_ = getParamFromGroup<Scalar>(this->
paramGroup(),
"Problem.Temperature");
134 initialPhasePresence_ = getParamFromGroup<int>(this->
paramGroup(),
"Problem.InitPhasePresence");
137 getParamFromGroup<std::string>(this->
paramGroup(),
"Problem.InterfaceDiffusionCoefficientAvg"));
138 problemName_ = getParam<std::string>(
"Vtk.OutputName") +
"_" + getParamFromGroup<std::string>(this->
paramGroup(),
"Problem.Name");
144 const std::string&
name()
const
154 template<
class SolutionVector,
class Gr
idVariables>
156 const GridVariables& gridVariables,
157 const Scalar timeStepSize)
161 Scalar massWater = 0.0;
164 for (
const auto& element : elements(this->
gridGeometry().gridView()))
167 fvGeometry.bindElement(element);
169 auto elemVolVars =
localView(gridVariables.curGridVolVars());
170 elemVolVars.bindElement(element, fvGeometry, curSol);
172 for (
auto&& scv : scvs(fvGeometry))
174 const auto& volVars = elemVolVars[scv];
175 for(
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
177 massWater += volVars.massFraction(phaseIdx, FluidSystem::H2OIdx)*volVars.density(phaseIdx)
178 * scv.volume() * volVars.saturation(phaseIdx) * volVars.porosity() * volVars.extrusionFactor();
183 std::cout << std::setprecision(15) <<
"mass of water is: " << massWater << std::endl;
204 {
return temperature_; }
218 BoundaryTypes
boundaryTypes(
const Element &element,
const SubControlVolumeFace &scvf)
const
220 BoundaryTypes values;
221 values.setAllNeumann();
223 if (
couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
224 values.setAllCouplingNeumann();
237 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolumeFace &scvf)
const
239 PrimaryVariables values(0.0);
255 const FVElementGeometry& fvGeometry,
256 const ElementVolumeVariables& elemVolVars,
257 const ElementFluxVariablesCache& elemFluxVarsCache,
258 const SubControlVolumeFace& scvf)
const
260 NumEqVector values(0.0);
262 if (
couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
265 values =
couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
267 const auto massFlux =
couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
269 for(
int i = 0; i< massFlux.size(); ++i)
270 values[i] = massFlux[i];
272 values[Indices::energyEqIdx] =
couplingManager().couplingData().energyCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
299 NumEqVector
source(
const Element &element,
300 const FVElementGeometry& fvGeometry,
301 const ElementVolumeVariables& elemVolVars,
302 const SubControlVolume &scv)
const
303 {
return NumEqVector(0.0); }
315 PrimaryVariables values(0.0);
316 values.setState(initialPhasePresence_);
318 values[pressureIdx] = pressure_ + 1000. * this->
spatialParams().gravity(globalPos)[1] * (globalPos[1] - this->
gridGeometry().bBoxMax()[1]);
319 values[switchIdx] = initialSw_;
322 values[Indices::temperatureIdx] = temperature_;
331 {
return *couplingManager_; }
334 bool onLeftBoundary_(
const GlobalPosition &globalPos)
const
335 {
return globalPos[0] < this->
gridGeometry().bBoxMin()[0] + eps_; }
337 bool onRightBoundary_(
const GlobalPosition &globalPos)
const
338 {
return globalPos[0] > this->
gridGeometry().bBoxMax()[0] - eps_; }
340 bool onLowerBoundary_(
const GlobalPosition &globalPos)
const
341 {
return globalPos[1] < this->
gridGeometry().bBoxMin()[1] + eps_; }
343 bool onUpperBoundary_(
const GlobalPosition &globalPos)
const
344 {
return globalPos[1] > this->
gridGeometry().bBoxMax()[1] - eps_; }
349 int initialPhasePresence_;
350 std::string problemName_;
353 std::shared_ptr<CouplingManager> couplingManager_;
354 DiffusionCoefficientAveragingType diffCoeffAvgType_;
Properties for all models using cell-centered finite volume scheme with TPFA.
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
@ p1s0
first phase saturation and second phase pressure as primary variables
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
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:38
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:592
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The component balance index that should be replaced by the total mass/mole balance.
Definition: common/properties.hh:104
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
The formulation of the model.
Definition: common/properties.hh:237
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Definition: h2oair.hh:75
DiffusionCoefficientAveragingType
Defines which kind of averanging of diffusion coefficiencients (moleculat diffusion or thermal conduc...
Definition: couplingdata.hh:52
static DiffusionCoefficientAveragingType stringToEnum(DiffusionCoefficientAveragingType, const std::string &diffusionCoefficientAveragingType)
Convenience function to convert user input given as std::string to the corresponding enum class used ...
Definition: couplingdata.hh:60
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: 1p_2p/problem_darcy.hh:79
void printWaterMass(const SolutionVector &curSol, const GridVariables &gridVariables, const Scalar timeStepSize)
Definition: 1p2c_2p2c/problem_darcy.hh:155
bool shouldWriteOutput() const
Definition: 1p2c_2p2c/problem_darcy.hh:197
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:266
bool shouldWriteRestartFile() const
Returns true if a restart file should be written to disk.
Definition: 1p2c_2p2c/problem_darcy.hh:189
DarcySubProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p2c_2p2c/problem_darcy.hh:127
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:313
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:237
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 control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:254
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: 1p2c_2p2c/problem_darcy.hh:203
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 cont...
Definition: 1p2c_2p2c/problem_darcy.hh:218
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all phases within a given sub control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:299
const std::string & name() const
The problem name.
Definition: 1p2c_2p2c/problem_darcy.hh:144
Definition: 1p2c_2p2c/problem_darcy.hh:48
std::tuple< TwoPTwoC, CCTpfaModel > InheritsFrom
Definition: 1p2c_2p2c/problem_darcy.hh:48
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: 1p2c_2p2c/problem_darcy.hh:73
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 1p2c_2p2c/problem_darcy.hh:82
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: 1p2c_2p2c/problem_darcy.hh:81
The spatial parameters class for the test problem using the 1p cc model.
Definition: multidomain/boundary/stokesdarcy/1p2c_2p2c/spatialparams.hh:44
Adaption of the fully implicit scheme to the two-phase two-component fully implicit model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.