3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
problem_matrix.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_MATRIX_ROBLEM_HH
26#define DUMUX_MATRIX_ROBLEM_HH
27
28#include <dune/geometry/quadraturerules.hh>
29#include <dune/geometry/referenceelements.hh>
30#include <dune/grid/yaspgrid.hh>
31#include <dune/localfunctions/lagrange/pqkfactory.hh>
32
33#include <dumux/common/math.hh>
37
41
44
45#include "spatialparams.hh"
46
47namespace Dumux {
48
49template <class TypeTag>
50class MatrixProblem;
51
52namespace Properties {
53
54// Create new type tags
55namespace TTag {
56struct Matrix { using InheritsFrom = std::tuple<OneP, CCTpfaModel>; };
57} // end namespace TTag
58
59// Set the grid type
60template<class TypeTag>
61struct Grid<TypeTag, TTag::Matrix> { using type = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, 3> >; };
62
63template<class TypeTag>
64struct EnableGridGeometryCache<TypeTag, TTag::Matrix> { static constexpr bool value = true; };
65template<class TypeTag>
66struct EnableGridVolumeVariablesCache<TypeTag, TTag::Matrix> { static constexpr bool value = true; };
67template<class TypeTag>
68struct EnableGridFluxVariablesCache<TypeTag, TTag::Matrix> { static constexpr bool value = true; };
69template<class TypeTag>
70struct SolutionDependentAdvection<TypeTag, TTag::Matrix> { static constexpr bool value = false; };
71template<class TypeTag>
72struct SolutionDependentMolecularDiffusion<TypeTag, TTag::Matrix> { static constexpr bool value = false; };
73template<class TypeTag>
74struct SolutionDependentHeatConduction<TypeTag, TTag::Matrix> { static constexpr bool value = false; };
75
76// Set the problem property
77template<class TypeTag>
78struct Problem<TypeTag, TTag::Matrix> { using type = MatrixProblem<TypeTag>; };
79
80// Set the problem property
81template<class TypeTag>
82struct LocalResidual<TypeTag, TTag::Matrix> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
83
84// the fluid system
85template<class TypeTag>
86struct FluidSystem<TypeTag, TTag::Matrix>
87{
90};
91
92// Set the spatial parameters
93template<class TypeTag>
94struct SpatialParams<TypeTag, TTag::Matrix>
95{
98};
99} // end namespace Properties
100
101
106template <class TypeTag>
108{
112 using GridView = typename GridGeometry::GridView;
113 using FVElementGeometry = typename GridGeometry::LocalView;
114 using SubControlVolume = typename GridGeometry::SubControlVolume;
122
123 enum {
124 // world dimension
125 dim = GridView::dimension,
126 dimWorld = GridView::dimensionworld
127 };
128
129 using Element = typename GridView::template Codim<0>::Entity;
130 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
131
133
134public:
135 MatrixProblem(std::shared_ptr<const GridGeometry> gridGeometry,
136 std::shared_ptr<typename ParentType::SpatialParams> spatialParams,
137 std::shared_ptr<CouplingManager> couplingManager,
138 const std::string& paramGroup = "Matrix")
140 , couplingManager_(couplingManager)
141 {
142 // read parameters from input file
143 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
144 }
145
149 // \{
150
156 const std::string& name() const
157 { return name_; }
158
164 Scalar temperature() const
165 { return 273.15 + 37; } // in [K]
166
167 // \}
168
172 // \{
173
180 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
181 {
182 BoundaryTypes values;
183 values.setAllNeumann();
184 return values;
185 }
186
187 // \}
188
192 // \{
193
204 void addPointSources(std::vector<PointSource>& pointSources) const
205 { pointSources = this->couplingManager().bulkPointSources(); }
206
225 template<class ElementVolumeVariables>
226 void pointSource(PointSource& source,
227 const Element &element,
228 const FVElementGeometry& fvGeometry,
229 const ElementVolumeVariables& elemVolVars,
230 const SubControlVolume &scv) const
231 {
232 // compute source at every integration point
233 const Scalar pressure3D = this->couplingManager().bulkPriVars(source.id())[Indices::pressureIdx];
234 const Scalar pressure1D = this->couplingManager().lowDimPriVars(source.id())[Indices::pressureIdx];
235
236 // calculate the source
237 const Scalar meanDistance = this->couplingManager().averageDistance(source.id());
238 static const Scalar matrixPerm = getParamFromGroup<Scalar>("Matrix", "SpatialParams.Permeability");
239 static const Scalar rho = getParam<Scalar>("Component.LiquidDensity");
240 static const Scalar mu = getParam<Scalar>("Component.LiquidKinematicViscosity")*rho;
241 const Scalar sourceValue = rho*(pressure1D - pressure3D)/meanDistance*matrixPerm/mu;
242 source = sourceValue*source.quadratureWeight()*source.integrationElement();
243 }
244
253 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
254 { return PrimaryVariables({1e5}); }
255
258 void computeSourceIntegral(const SolutionVector& sol, const GridVariables& gridVars)
259 {
260 NumEqVector source(0.0);
261 for (const auto& element : elements(this->gridGeometry().gridView()))
262 {
263 auto fvGeometry = localView(this->gridGeometry());
264 fvGeometry.bindElement(element);
265
266 auto elemVolVars = localView(gridVars.curGridVolVars());
267 elemVolVars.bindElement(element, fvGeometry, sol);
268
269 for (auto&& scv : scvs(fvGeometry))
270 {
271 auto pointSources = this->scvPointSources(element, fvGeometry, elemVolVars, scv);
272 pointSources *= scv.volume()*elemVolVars[scv].extrusionFactor();
273 source += pointSources;
274 }
275 }
276
277 std::cout << "Global integrated source (3D): " << source << '\n';
278 }
279
281 const CouplingManager& couplingManager() const
282 { return *couplingManager_; }
283
284private:
285
286 static constexpr Scalar eps_ = 1.5e-7;
287 std::string name_;
288
289 std::shared_ptr<CouplingManager> couplingManager_;
290};
291
292} // end namespace Dumux
293
294#endif
Define some often used mathematical functions.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Properties for all models using cell-centered finite volume scheme with TPFA.
Setting constant fluid properties via the input file.
A liquid phase consisting of a single component.
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
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
NumEqVector scvPointSources(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Adds contribution of point sources for a specific sub control volume to the values....
Definition: common/fvproblem.hh:435
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:592
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:327
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
Definition: common/properties.hh:91
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
specifies if the parameters for the advective fluxes depend on the solution
Definition: common/properties.hh:210
specifies if the parameters for the diffusive fluxes depend on the solution
Definition: common/properties.hh:214
specifies if the parameters for the heat conduction fluxes depend on the solution
Definition: common/properties.hh:218
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
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
Element-wise calculation of the residual and its derivatives for a single-phase, incompressible,...
Definition: 1p/incompressiblelocalresidual.hh:41
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
The matrix problem.
Definition: problem_matrix.hh:108
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: problem_matrix.hh:253
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: problem_matrix.hh:281
void pointSource(PointSource &source, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the point sources (added by addPointSources) for all phases within a given sub-control volu...
Definition: problem_matrix.hh:226
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: problem_matrix.hh:180
const std::string & name() const
The problem name.
Definition: problem_matrix.hh:156
void computeSourceIntegral(const SolutionVector &sol, const GridVariables &gridVars)
Definition: problem_matrix.hh:258
MatrixProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< typename ParentType::SpatialParams > spatialParams, std::shared_ptr< CouplingManager > couplingManager, const std::string &paramGroup="Matrix")
Definition: problem_matrix.hh:135
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: problem_matrix.hh:204
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: problem_matrix.hh:164
Definition: problem_matrix.hh:56
std::tuple< OneP, CCTpfaModel > InheritsFrom
Definition: problem_matrix.hh:56
Dune::YaspGrid< 3, Dune::EquidistantOffsetCoordinates< GetPropType< TypeTag, Properties::Scalar >, 3 > > type
Definition: problem_matrix.hh:61
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: problem_matrix.hh:88
Definition of the spatial parameters for the matrix and fracture problem.
Definition: multidomain/embedded/2d3d/1p_1p/spatialparams.hh:39
Declares all properties used in Dumux.
A single-phase, isothermal flow model using the fully implicit scheme.
Base class for all porous media problems.
Element-wise calculation of the residual and its derivatives for a single-phase, incompressible,...
Definition of the spatial parameters for the MaxwellStefan problem.