185 const auto element = *problem_.gridView().template begin<0>();
186 FluidState fluidState;
187 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
188 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
189 fluidState.setTemperature(problem_.temperature(element));
190 fluidState.setSaturation(wPhaseIdx, 1.);
191 fluidState.setSaturation(nPhaseIdx, 0.);
192 density_[wPhaseIdx] = FluidSystem::density(fluidState, wPhaseIdx);
193 density_[nPhaseIdx] = FluidSystem::density(fluidState, nPhaseIdx);
194 viscosity_[wPhaseIdx] = FluidSystem::viscosity(fluidState, wPhaseIdx);
195 viscosity_[nPhaseIdx] = FluidSystem::viscosity(fluidState, nPhaseIdx);
199 lstiff_.initialize();
258 int size = problem_.gridView().size(0);
259 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
260 ScalarSolutionType *pressure = 0;
261 ScalarSolutionType *pressureSecond = 0;
262 ScalarSolutionType *potentialSecond = 0;
263 Dune::BlockVector < DimVector > *velocityWetting = 0;
264 Dune::BlockVector < DimVector > *velocityNonwetting = 0;
266 if (vtkOutputLevel_ > 0)
268 pressure = writer.allocateManagedBuffer(size);
269 pressureSecond = writer.allocateManagedBuffer(size);
270 potentialSecond = writer.allocateManagedBuffer(size);
271 velocityWetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
272 velocityNonwetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
276 for (
const auto& element : elements(problem_.gridView()))
278 int eIdxGlobal = problem_.variables().index(element);
279 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
281 if (pressureType == pw)
283 (*potential)[eIdxGlobal] = cellData.potential(wPhaseIdx);
286 if (pressureType == pn)
288 (*potential)[eIdxGlobal] = cellData.potential(nPhaseIdx);
291 if (vtkOutputLevel_ > 0)
294 if (pressureType == pw)
296 (*pressure)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
297 (*potentialSecond)[eIdxGlobal] = cellData.potential(nPhaseIdx);
298 (*pressureSecond)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
301 if (pressureType == pn)
303 (*pressure)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
304 (*potentialSecond)[eIdxGlobal] = cellData.potential(wPhaseIdx);
305 (*pressureSecond)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
308 const typename Element::Geometry& geometry = element.geometry();
311 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
312 const auto refElement = ReferenceElements::general(geometry.type());
314 const int numberOfFaces=refElement.size(1);
315 std::vector<Scalar> fluxW(numberOfFaces,0);
316 std::vector<Scalar> fluxNw(numberOfFaces,0);
319 for (
const auto& intersection : intersections(problem_.gridView(), element))
321 int isIndex = intersection.indexInInside();
323 fluxW[isIndex] += intersection.geometry().volume()
324 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(wPhaseIdx, isIndex));
325 fluxNw[isIndex] += intersection.geometry().volume()
326 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(nPhaseIdx, isIndex));
331 Dune::FieldVector<Scalar, dim> refVelocity;
333 if (refElement.type().isSimplex()) {
334 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
336 refVelocity[dimIdx] = -fluxW[dim - 1 - dimIdx];
337 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
339 refVelocity[dimIdx] += fluxW[fIdx]/(dim + 1);
344 else if (refElement.type().isCube()){
345 for (
int i = 0; i < dim; i++)
346 refVelocity[i] = 0.5 * (fluxW[2*i + 1] - fluxW[2*i]);
350 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
353 const DimVector& localPos = refElement.position(0, 0);
356 const JacobianTransposed jacobianT = geometry.jacobianTransposed(localPos);
359 DimVector elementVelocity(0);
360 jacobianT.umtv(refVelocity, elementVelocity);
361 elementVelocity /= geometry.integrationElement(localPos);
363 (*velocityWetting)[eIdxGlobal] = elementVelocity;
368 if (refElement.type().isSimplex()) {
369 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
371 refVelocity[dimIdx] = -fluxNw[dim - 1 - dimIdx];
372 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
374 refVelocity[dimIdx] += fluxNw[fIdx]/(dim + 1);
379 else if (refElement.type().isCube()){
380 for (
int i = 0; i < dim; i++)
381 refVelocity[i] = 0.5 * (fluxNw[2*i + 1] - fluxNw[2*i]);
385 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
390 jacobianT.umtv(refVelocity, elementVelocity);
391 elementVelocity /= geometry.integrationElement(localPos);
393 (*velocityNonwetting)[eIdxGlobal] = elementVelocity;
397 if (pressureType == pw)
399 writer.attachCellData(*potential,
"wetting potential");
402 if (pressureType == pn)
404 writer.attachCellData(*potential,
"nonwetting potential");
407 if (vtkOutputLevel_ > 0)
409 if (pressureType == pw)
411 writer.attachCellData(*pressure,
"wetting pressure");
412 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
413 writer.attachCellData(*potentialSecond,
"nonwetting potential");
416 if (pressureType == pn)
418 writer.attachCellData(*pressure,
"nonwetting pressure");
419 writer.attachCellData(*pressureSecond,
"wetting pressure");
420 writer.attachCellData(*potentialSecond,
"wetting potential");
423 writer.attachCellData(*velocityWetting,
"wetting-velocity", dim);
424 writer.attachCellData(*velocityNonwetting,
"non-wetting-velocity", dim);