26#ifndef DUMUX_TISSUE_PROBLEM_HH
27#define DUMUX_TISSUE_PROBLEM_HH
29#include <dune/grid/yaspgrid.hh>
31#include <dune/geometry/quadraturerules.hh>
32#include <dune/geometry/referenceelements.hh>
33#include <dune/localfunctions/lagrange/pqkfactory.hh>
54template <
class TypeTag>
67template<
class TypeTag>
68struct Grid<TypeTag, TTag::Tissue> {
using type = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, 3> >; };
70template<
class TypeTag>
72template<
class TypeTag>
74template<
class TypeTag>
76template<
class TypeTag>
78template<
class TypeTag>
80template<
class TypeTag>
84template<
class TypeTag>
88template<
class TypeTag>
92template<
class TypeTag>
100template<
class TypeTag>
114template <
class TypeTag>
120 using FVElementGeometry =
typename GridGeometry::LocalView;
121 using SubControlVolume =
typename GridGeometry::SubControlVolume;
122 using GridView =
typename GridGeometry::GridView;
130 using Element =
typename GridView::template Codim<0>::Entity;
131 using GlobalPosition =
typename GridGeometry::GlobalCoordinate;
142 name_ = getParam<std::string>(
"Vtk.OutputName") +
"_" + getParamFromGroup<std::string>(this->
paramGroup(),
"Problem.Name");
145 for (
const auto& element : elements(this->
gridGeometry().gridView()))
148 fvGeometry.bindElement(element);
150 for (
auto&& scv : scvs(fvGeometry))
151 exactPressure_[scv.dofIndex()] =
exactSolution(scv.dofPosition());
160 const std::string&
name()
const
169 {
return 273.15 + 37; }
186 BoundaryTypes values;
187 values.setAllDirichlet();
200 PrimaryVariables values;
243 template<
class ElementVolumeVariables>
245 const Element &element,
246 const FVElementGeometry& fvGeometry,
247 const ElementVolumeVariables& elemVolVars,
248 const SubControlVolume &scv)
const
251 const Scalar pressure3D = this->
couplingManager().bulkPriVars(source.id())[Indices::pressureIdx];
252 const Scalar pressure1D = this->
couplingManager().lowDimPriVars(source.id())[Indices::pressureIdx];
256 const Scalar beta = 2*M_PI/(2*M_PI + std::log(radius));
257 const Scalar sourceValue = beta*(pressure1D - pressure3D);
279 template<
class ElementVolumeVariables,
281 std::enable_if_t<enable, int> = 0>
282 NumEqVector
source(
const Element &element,
283 const FVElementGeometry& fvGeometry,
284 const ElementVolumeVariables& elemVolVars,
285 const SubControlVolume &scv)
const
287 static const Scalar kernelWidth = getParam<Scalar>(
"MixedDimension.KernelWidth");
288 static const Scalar kernelFactor = std::log(kernelWidth)-9.0/10.0;
292 const auto eIdx = this->
gridGeometry().elementMapper().index(element);
294 const auto& sourceWeights = this->
couplingManager().bulkSourceWeights(eIdx);
296 for (
int i = 0; i < sourceIds.size(); ++i)
298 const auto id = sourceIds[i];
299 const auto weight = sourceWeights[i];
302 const Scalar pressure3D = this->
couplingManager().bulkPriVars(
id)[Indices::pressureIdx];
303 const Scalar pressure1D = this->
couplingManager().lowDimPriVars(
id)[Indices::pressureIdx];
306 const Scalar beta = 2*M_PI/(2*M_PI + std::log(radius));
307 const Scalar sourceValue = beta*(pressure1D - pressure3D / kernelFactor * std::log(radius));
309 source[Indices::conti0EqIdx] += sourceValue*weight;
312 const auto volume = scv.volume()*elemVolVars[scv].extrusionFactor();
313 source[Indices::conti0EqIdx] /= volume;
319 template<
class ElementVolumeVariables,
321 std::enable_if_t<!enable, int> = 0>
322 NumEqVector
source(
const Element &element,
323 const FVElementGeometry& fvGeometry,
324 const ElementVolumeVariables& elemVolVars,
325 const SubControlVolume &scv)
const
326 {
return NumEqVector(0.0); }
330 template<
class MatrixBlock,
class VolumeVariables>
332 const Element& element,
333 const FVElementGeometry& fvGeometry,
334 const VolumeVariables& curElemVolVars,
335 const SubControlVolume& scv)
const
337 const auto eIdx = this->
gridGeometry().elementMapper().index(element);
339 auto key = std::make_pair(eIdx, 0);
347 for (
const auto&
source : pointSources)
348 block[0][0] -= this->
couplingManager().pointSourceDerivative(
source, Dune::index_constant<0>{}, Dune::index_constant<0>{});
361 {
return PrimaryVariables(0.0); }
366 Dune::FieldVector<double, 2> xy({globalPos[0], globalPos[1]});
369 static const auto R = getParam<Scalar>(
"SpatialParams.Radius");
370 if (xy.two_norm() > R)
371 return -1.0*(1+globalPos[2])/(2*M_PI)*std::log(xy.two_norm());
373 return -1.0*(1+globalPos[2])/(2*M_PI)*std::log(R);
378 static const auto rho = getParam<Scalar>(
"MixedDimension.KernelWidth");
379 const auto& r = xy.two_norm();
380 if (xy.two_norm() >= rho)
381 return -1.0*(1+globalPos[2])/(2*M_PI)*std::log(xy.two_norm());
383 return -1.0*(1+globalPos[2])/(2*M_PI)*(11.0/15.0*std::pow(r/rho, 5)
384 - 3.0/2.0*std::pow(r/rho, 4)
385 + 5.0/3.0*std::pow(r/rho, 2)
386 - 9.0/10.0 + std::log(rho));
389 return -1.0*(1+globalPos[2])/(2*M_PI)*std::log(xy.two_norm());
396 PrimaryVariables
source(0.0);
397 for (
const auto& element : elements(this->
gridGeometry().gridView()))
400 fvGeometry.bindElement(element);
402 auto elemVolVars =
localView(gridVars.curGridVolVars());
403 elemVolVars.bindElement(element, fvGeometry, sol);
405 for (
auto&& scv : scvs(fvGeometry))
407 auto pointSources = this->
scvPointSources(element, fvGeometry, elemVolVars, scv);
408 pointSources += this->
source(element, fvGeometry, elemVolVars, scv);
409 pointSources *= scv.volume()*elemVolVars[scv].extrusionFactor();
414 std::cout <<
"Global integrated source (3D): " <<
source <<
'\n';
422 template<
class VtkOutputModule>
425 vtk.
addField(exactPressure_,
"exact pressure");
430 {
return *couplingManager_; }
433 std::vector<Scalar> exactPressure_;
435 static constexpr Scalar eps_ = 1.5e-7;
438 std::shared_ptr<CouplingManager> couplingManager_;
Define some often used mathematical functions.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
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.
Setting constant fluid properties via the input file.
A liquid phase consisting of a single component.
Coupling manager for low-dimensional domains embedded in the bulk domain. Point sources on each integ...
Definition of the spatial parameters for the tissue problem.
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
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition: common/fvproblem.hh:505
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 VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:66
void addField(const Vector &v, const std::string &name, FieldType fieldType=FieldType::automatic)
Definition: io/vtkoutputmodule.hh:161
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
Definition of a problem, for the 1p2c problem: Component transport of oxygen in interstitial fluid.
Definition: problem_tissue.hh:116
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: problem_tissue.hh:198
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: problem_tissue.hh:168
void addSourceDerivatives(MatrixBlock &block, const Element &element, const FVElementGeometry &fvGeometry, const VolumeVariables &curElemVolVars, const SubControlVolume &scv) const
Definition: problem_tissue.hh:331
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: problem_tissue.hh:222
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_tissue.hh:184
void addVtkOutputFields(VtkOutputModule &vtk) const
Adds additional VTK output data to the VTKWriter.
Definition: problem_tissue.hh:423
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: problem_tissue.hh:429
const std::string & name() const
The problem name.
Definition: problem_tissue.hh:160
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_tissue.hh:244
Scalar exactSolution(const GlobalPosition &globalPos) const
The exact solution.
Definition: problem_tissue.hh:364
TissueProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: problem_tissue.hh:136
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: problem_tissue.hh:282
void computeSourceIntegral(const SolutionVector &sol, const GridVariables &gridVars)
Definition: problem_tissue.hh:394
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: problem_tissue.hh:360
Definition: problem_tissue.hh:61
std::tuple< OneP > InheritsFrom
Definition: problem_tissue.hh:61
Definition: problem_tissue.hh:62
std::tuple< Tissue, CCTpfaModel > InheritsFrom
Definition: problem_tissue.hh:62
Definition: problem_tissue.hh:63
std::tuple< Tissue, BoxModel > InheritsFrom
Definition: problem_tissue.hh:63
Dune::YaspGrid< 3, Dune::EquidistantOffsetCoordinates< GetPropType< TypeTag, Properties::Scalar >, 3 > > type
Definition: problem_tissue.hh:68
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: problem_tissue.hh:95
Definition of the spatial parameters for the tissue problem.
Definition: spatialparams_tissue.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,...