25#ifndef DUMUX_FVVELOCITY1P_HH
26#define DUMUX_FVVELOCITY1P_HH
47template<
class TypeTag>
60 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
63 using Element =
typename GridView::Traits::template Codim<0>::Entity;
64 using Intersection =
typename GridView::Intersection;
68 dim = GridView::dimension, dimWorld = GridView::dimensionworld
73 pressEqIdx = Indices::pressureEqIdx
76 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
77 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
78 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
79 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
88 : problem_(problem), gravity_(problem.gravity())
90 const auto element = *problem_.gridView().template begin<0>();
92 Scalar referencePress = problem_.referencePressure(element);
112 template<
class MultiWriter>
115 Dune::BlockVector<Dune::FieldVector<Scalar, dim> > &velocity = *(writer.template allocateManagedBuffer<Scalar, dim> (
116 problem_.gridView().size(0)));
119 for (
const auto& element : elements(problem_.gridView()))
122 int eIdxGlobal = problem_.variables().index(element);
124 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
126 const typename Element::Geometry& geometry = element.geometry();
129 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
130 const auto refElement = ReferenceElements::general(geometry.type());
132 const int numberOfFaces = refElement.size(1);
133 std::vector<Scalar> flux(numberOfFaces,0);
136 for (
const auto& intersection : intersections(problem_.gridView(), element))
138 int isIndex = intersection.indexInInside();
140 flux[isIndex] = intersection.geometry().volume()
141 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(isIndex));
146 Dune::FieldVector<Scalar, dim> refVelocity;
148 if (refElement.type().isSimplex()) {
149 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
151 refVelocity[dimIdx] = -flux[dim - 1 - dimIdx];
152 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
154 refVelocity[dimIdx] += flux[fIdx]/(dim + 1);
159 else if (refElement.type().isCube()){
160 for (
int i = 0; i < dim; i++)
161 refVelocity[i] = 0.5 * (flux[2*i + 1] - flux[2*i]);
165 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
168 const Dune::FieldVector<Scalar, dim>& localPos
169 = refElement.position(0, 0);
172 const typename Element::Geometry::JacobianTransposed& jacobianT =
173 geometry.jacobianTransposed(localPos);
176 Dune::FieldVector<Scalar, dim> elementVelocity(0);
177 jacobianT.umtv(refVelocity, elementVelocity);
178 elementVelocity /= geometry.integrationElement(localPos);
180 velocity[eIdxGlobal] = elementVelocity;
183 writer.attachCellData(velocity,
"velocity", dim);
189 const GravityVector& gravity_;
203template<
class TypeTag>
206 auto elementI = intersection.inside();
207 auto elementJ = intersection.outside();
209 int eIdxGlobalJ = problem_.variables().index(elementJ);
211 CellData& cellDataJ = problem_.variables().cellData(eIdxGlobalJ);
214 const GlobalPosition& globalPosI = elementI.geometry().center();
215 const GlobalPosition& globalPosJ = elementJ.geometry().center();
218 int isIndexI = intersection.indexInInside();
219 int isIndexJ = intersection.indexInOutside();
222 const Dune::FieldVector<Scalar, dim>& unitOuterNormal = intersection.centerUnitOuterNormal();
225 GlobalPosition distVec = globalPosJ - globalPosI;
228 Scalar dist = distVec.two_norm();
231 DimMatrix meanPermeability(0);
233 problem_.spatialParams().meanK(meanPermeability, problem_.spatialParams().intrinsicPermeability(elementI),
234 problem_.spatialParams().intrinsicPermeability(elementJ));
242 Scalar potential = (cellData.pressure() - cellDataJ.pressure()) / dist;
244 potential += density_ * (unitOuterNormal * gravity_);
247 cellData.fluxData().setPotential(isIndexI, potential);
248 cellDataJ.fluxData().setPotential(isIndexJ, -potential);
252 velocity *= (cellData.pressure() - cellDataJ.pressure()) / dist;
254 GravityVector gravityTerm(unitOuterNormal);
257 velocity += gravityTerm;
260 cellData.fluxData().setVelocity(isIndexI, velocity);
261 cellData.fluxData().setVelocityMarker(isIndexI);
263 cellDataJ.fluxData().setVelocity(isIndexJ, velocity);
264 cellDataJ.fluxData().setVelocityMarker(isIndexJ);
277template<
class TypeTag>
280 auto element = intersection.inside();
283 int isIndex = intersection.indexInInside();
286 const Dune::FieldVector<Scalar, dim>& unitOuterNormal = intersection.centerUnitOuterNormal();
288 BoundaryTypes bcType;
290 problem_.boundaryTypes(bcType, intersection);
291 PrimaryVariables boundValues(0.0);
293 if (bcType.isDirichlet(pressEqIdx))
295 problem_.dirichlet(boundValues, intersection);
298 const GlobalPosition& globalPosI = element.geometry().center();
301 const GlobalPosition& globalPosJ = intersection.geometry().center();
304 GlobalPosition distVec = globalPosJ - globalPosI;
307 Scalar dist = distVec.two_norm();
311 DimMatrix meanPermeability(0);
313 problem_.spatialParams().meanK(meanPermeability, problem_.spatialParams().intrinsicPermeability(element));
320 Scalar pressBound = boundValues;
323 Scalar potential = (cellData.pressure() - pressBound) / dist;
325 potential += density_ * (unitOuterNormal * gravity_);
328 cellData.fluxData().setPotential(isIndex, potential);
332 velocity *= (cellData.pressure() - pressBound) / dist;
334 GravityVector gravityTerm(unitOuterNormal);
337 velocity += gravityTerm;
340 cellData.fluxData().setVelocity(isIndex, velocity);
341 cellData.fluxData().setVelocityMarker(isIndex);
347 problem_.neumann(boundValues, intersection);
348 VelocityVector velocity(unitOuterNormal);
350 velocity *= boundValues[pressEqIdx] / density_;
353 cellData.fluxData().setPotential(isIndex, boundValues[pressEqIdx]);
356 cellData.fluxData().setVelocity(isIndex, velocity);
357 cellData.fluxData().setVelocityMarker(isIndex);
void calculateVelocityOnBoundary(const Intersection &, CellData &)
Calculates the velocity at a boundary.
Definition: 1p/sequential/diffusion/cellcentered/velocity.hh:278
void calculateVelocity(const Intersection &, CellData &)
Calculates the velocity at a cell-cell interface.
Definition: 1p/sequential/diffusion/cellcentered/velocity.hh:204
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:140
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
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string permeability() noexcept
I/O name of permeability.
Definition: name.hh:143
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Single phase finite volume velocity reconstruction.
Definition: 1p/sequential/diffusion/cellcentered/velocity.hh:49
FVVelocity1P(Problem &problem)
Constructs a FVVelocity1P object.
Definition: 1p/sequential/diffusion/cellcentered/velocity.hh:87
void addOutputVtkFields(MultiWriter &writer)
Adds velocity output to the output file.
Definition: 1p/sequential/diffusion/cellcentered/velocity.hh:113
Defines the properties required for the single phase sequential model.