28 #ifndef EWOMS_MULTI_PHASE_BASE_PROBLEM_HH
29 #define EWOMS_MULTI_PHASE_BASE_PROBLEM_HH
36 #include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
37 #include <opm/material/common/Means.hpp>
38 #include <opm/common/Unused.hpp>
39 #include <opm/common/ErrorMacros.hpp>
40 #include <opm/common/Exceptions.hpp>
42 #include <dune/common/fvector.hh>
43 #include <dune/common/fmatrix.hh>
46 namespace Properties {
58 template<
class TypeTag>
66 typedef typename GET_PROP_TYPE(TypeTag, Problem) Implementation;
68 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
70 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
72 typedef typename GET_PROP_TYPE(TypeTag, HeatConductionLawParams) HeatConductionLawParams;
73 typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw)::Params MaterialLawParams;
75 enum { dimWorld = GridView::dimensionworld };
77 typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
78 typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
86 : ParentType(simulator)
94 ParentType::registerParameters();
97 "Use the gravity correction for the pressure gradients.");
109 template <
class Context>
111 const Context& context,
112 unsigned intersectionIdx,
113 unsigned timeIdx)
const
115 const auto& scvf = context.stencil(timeIdx).interiorFace(intersectionIdx);
117 const DimMatrix& K1 = asImp_().intrinsicPermeability(context, scvf.interiorIndex(), timeIdx);
118 const DimMatrix& K2 = asImp_().intrinsicPermeability(context, scvf.exteriorIndex(), timeIdx);
122 for (
unsigned i = 0; i < dimWorld; ++i)
123 for (
unsigned j = 0; j < dimWorld; ++j)
124 result[i][j] = Opm::harmonicMean(K1[i][j], K2[i][j]);
140 template <
class Context>
142 unsigned spaceIdx OPM_UNUSED,
143 unsigned timeIdx OPM_UNUSED)
const
145 OPM_THROW(std::logic_error,
146 "Not implemented: Problem::intrinsicPermeability()");
158 template <
class Context>
160 unsigned spaceIdx OPM_UNUSED,
161 unsigned timeIdx OPM_UNUSED)
const
163 OPM_THROW(std::logic_error,
164 "Not implemented: Problem::porosity()");
176 template <
class Context>
178 unsigned spaceIdx OPM_UNUSED,
179 unsigned timeIdx OPM_UNUSED)
const
181 OPM_THROW(std::logic_error,
182 "Not implemented: Problem::heatCapacitySolid()");
194 template <
class Context>
195 const HeatConductionLawParams&
197 unsigned spaceIdx OPM_UNUSED,
198 unsigned timeIdx OPM_UNUSED)
const
200 OPM_THROW(std::logic_error,
201 "Not implemented: Problem::heatConductionParams()");
212 template <
class Context>
214 unsigned spaceIdx OPM_UNUSED,
215 unsigned timeIdx OPM_UNUSED)
const
217 OPM_THROW(std::logic_error,
218 "Not implemented: Problem::tortuosity()");
229 template <
class Context>
231 unsigned spaceIdx OPM_UNUSED,
232 unsigned timeIdx OPM_UNUSED)
const
234 OPM_THROW(std::logic_error,
235 "Not implemented: Problem::dispersivity()");
251 template <
class Context>
252 const MaterialLawParams &
254 unsigned spaceIdx OPM_UNUSED,
255 unsigned timeIdx OPM_UNUSED)
const
257 static MaterialLawParams dummy;
269 template <
class Context>
271 unsigned spaceIdx OPM_UNUSED,
272 unsigned timeIdx OPM_UNUSED)
const
273 {
return asImp_().temperature(); }
283 { OPM_THROW(std::logic_error,
284 "Not implemented:temperature() method not implemented by the actual problem"); }
295 template <
class Context>
296 const DimVector&
gravity(
const Context& context OPM_UNUSED,
297 unsigned spaceIdx OPM_UNUSED,
298 unsigned timeIdx OPM_UNUSED)
const
299 {
return asImp_().gravity(); }
320 typedef Opm::MathToolbox<Evaluation> Toolbox;
322 unsigned numMarked = 0;
323 ElementContext elemCtx( this->
simulator() );
326 auto elemIt =
gridView.template begin<0, Dune::Interior_Partition>();
327 auto elemEndIt =
gridView.template end<0, Dune::Interior_Partition>();
328 for (; elemIt != elemEndIt; ++elemIt)
330 const auto& element = *elemIt ;
331 elemCtx.updateAll( element );
334 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
335 Scalar minSat = 1e100 ;
336 Scalar maxSat = -1e100;
337 size_t nDofs = elemCtx.numDof(0);
338 for (
unsigned dofIdx = 0; dofIdx < nDofs; ++dofIdx)
340 const auto& intQuant = elemCtx.intensiveQuantities( dofIdx, 0 );
341 minSat = std::min(minSat,
342 Toolbox::value(intQuant.fluidState().saturation(phaseIdx)));
343 maxSat = std::max(maxSat,
344 Toolbox::value(intQuant.fluidState().saturation(phaseIdx)));
347 const Scalar indicator =
348 (maxSat - minSat)/(std::max<Scalar>(0.01, maxSat+minSat)/2);
349 if( indicator > 0.2 && element.level() < 2 ) {
350 grid.mark( 1, element );
353 else if ( indicator < 0.025 ) {
354 grid.mark( -1, element );
359 grid.mark( 0, element );
386 for (
unsigned i = 0; i < DimMatrix::rows; ++i)
395 Implementation& asImp_()
396 {
return *
static_cast<Implementation *
>(
this); }
398 const Implementation& asImp_()
const
399 {
return *
static_cast<const Implementation *
>(
this); }
405 gravity_[dimWorld-1] = -9.81;
const HeatConductionLawParams & heatConductionParams(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the parameter object for the heat conductivity law in a sub-control volume.
Definition: multiphasebaseproblem.hh:196
const DimVector & gravity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the acceleration due to gravity .
Definition: multiphasebaseproblem.hh:296
static void registerParameters()
Register all run-time parameters for the problem and the model.
Definition: multiphasebaseproblem.hh:92
Scalar porosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the porosity [] of the porous medium for a given control volume.
Definition: multiphasebaseproblem.hh:159
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Scalar tortuosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Define the tortuosity.
Definition: multiphasebaseproblem.hh:213
Scalar dispersivity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Define the dispersivity.
Definition: multiphasebaseproblem.hh:230
Defines the common properties required by the porous medium multi-phase models.
const MaterialLawParams & materialLawParams(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the material law parameters within a control volume.
Definition: multiphasebaseproblem.hh:253
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
Base class for all problems which use a finite volume spatial discretization.
MultiPhaseBaseProblem(Simulator &simulator)
Definition: multiphasebaseproblem.hh:85
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
Scalar temperature() const
Returns the temperature for an isothermal problem.
Definition: multiphasebaseproblem.hh:282
DimMatrix toDimMatrix_(Scalar val) const
Converts a Scalar value to an isotropic Tensor.
Definition: multiphasebaseproblem.hh:383
GridManager & gridManager()
Return a reference to the grid manager of simulation.
Definition: simulator.hh:171
Declare the properties used by the infrastructure code of the finite volume discretizations.
const DimVector & gravity() const
Returns the acceleration due to gravity .
Definition: multiphasebaseproblem.hh:310
const DimMatrix & intrinsicPermeability(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the intrinsic permeability tensor at a given position.
Definition: multiphasebaseproblem.hh:141
const GridView & gridView() const
The GridView which used by the problem.
Definition: fvbaseproblem.hh:494
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
Scalar temperature(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the temperature within a control volume.
Definition: multiphasebaseproblem.hh:270
void intersectionIntrinsicPermeability(DimMatrix &result, const Context &context, unsigned intersectionIdx, unsigned timeIdx) const
Returns the intrinsic permeability of an intersection.
Definition: multiphasebaseproblem.hh:110
Simulator & simulator()
Returns Simulator object used by the simulation.
Definition: fvbaseproblem.hh:526
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
The base class for the problems of ECFV discretizations which deal with a multi-phase flow through a ...
Definition: multiphasebaseproblem.hh:59
Scalar heatCapacitySolid(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Returns the heat capacity [J/(K m^3)] of the solid phase with no pores in the sub-control volume...
Definition: multiphasebaseproblem.hh:177
Base class for all problems which use a finite volume spatial discretization.
Definition: fvbaseproblem.hh:59
unsigned markForGridAdaptation()
Mark grid cells for refinement or coarsening.
Definition: multiphasebaseproblem.hh:318