184 const auto element = *problem_.gridView().template begin<0>();
185 FluidState fluidState;
186 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
187 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
188 fluidState.setTemperature(problem_.temperature(element));
189 fluidState.setSaturation(wPhaseIdx, 1.);
190 fluidState.setSaturation(nPhaseIdx, 0.);
191 density_[wPhaseIdx] = FluidSystem::density(fluidState, wPhaseIdx);
192 density_[nPhaseIdx] = FluidSystem::density(fluidState, nPhaseIdx);
193 viscosity_[wPhaseIdx] = FluidSystem::viscosity(fluidState, wPhaseIdx);
194 viscosity_[nPhaseIdx] = FluidSystem::viscosity(fluidState, nPhaseIdx);
198 lstiff_.initialize();
257 int size = problem_.gridView().size(0);
258 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
259 ScalarSolutionType *pressure = 0;
260 ScalarSolutionType *pressureSecond = 0;
261 ScalarSolutionType *potentialSecond = 0;
262 Dune::BlockVector < DimVector > *velocityWetting = 0;
263 Dune::BlockVector < DimVector > *velocityNonwetting = 0;
265 if (vtkOutputLevel_ > 0)
267 pressure = writer.allocateManagedBuffer(size);
268 pressureSecond = writer.allocateManagedBuffer(size);
269 potentialSecond = writer.allocateManagedBuffer(size);
270 velocityWetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
271 velocityNonwetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
275 for (
const auto& element : elements(problem_.gridView()))
277 int eIdxGlobal = problem_.variables().index(element);
278 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
280 if (pressureType == pw)
282 (*potential)[eIdxGlobal] = cellData.potential(wPhaseIdx);
285 if (pressureType == pn)
287 (*potential)[eIdxGlobal] = cellData.potential(nPhaseIdx);
290 if (vtkOutputLevel_ > 0)
293 if (pressureType == pw)
295 (*pressure)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
296 (*potentialSecond)[eIdxGlobal] = cellData.potential(nPhaseIdx);
297 (*pressureSecond)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
300 if (pressureType == pn)
302 (*pressure)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
303 (*potentialSecond)[eIdxGlobal] = cellData.potential(wPhaseIdx);
304 (*pressureSecond)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
307 const typename Element::Geometry& geometry = element.geometry();
310 const auto refElement = referenceElement(geometry);
312 const int numberOfFaces=refElement.size(1);
313 std::vector<Scalar> fluxW(numberOfFaces,0);
314 std::vector<Scalar> fluxNw(numberOfFaces,0);
317 for (
const auto& intersection : intersections(problem_.gridView(), element))
319 int isIndex = intersection.indexInInside();
321 fluxW[isIndex] += intersection.geometry().volume()
322 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(wPhaseIdx, isIndex));
323 fluxNw[isIndex] += intersection.geometry().volume()
324 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(nPhaseIdx, isIndex));
329 Dune::FieldVector<Scalar, dim> refVelocity;
331 if (refElement.type().isSimplex()) {
332 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
334 refVelocity[dimIdx] = -fluxW[dim - 1 - dimIdx];
335 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
337 refVelocity[dimIdx] += fluxW[fIdx]/(dim + 1);
342 else if (refElement.type().isCube()){
343 for (
int i = 0; i < dim; i++)
344 refVelocity[i] = 0.5 * (fluxW[2*i + 1] - fluxW[2*i]);
348 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
351 const DimVector& localPos = refElement.position(0, 0);
354 const JacobianTransposed jacobianT = geometry.jacobianTransposed(localPos);
357 DimVector elementVelocity(0);
358 jacobianT.umtv(refVelocity, elementVelocity);
359 elementVelocity /= geometry.integrationElement(localPos);
361 (*velocityWetting)[eIdxGlobal] = elementVelocity;
366 if (refElement.type().isSimplex()) {
367 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
369 refVelocity[dimIdx] = -fluxNw[dim - 1 - dimIdx];
370 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
372 refVelocity[dimIdx] += fluxNw[fIdx]/(dim + 1);
377 else if (refElement.type().isCube()){
378 for (
int i = 0; i < dim; i++)
379 refVelocity[i] = 0.5 * (fluxNw[2*i + 1] - fluxNw[2*i]);
383 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
388 jacobianT.umtv(refVelocity, elementVelocity);
389 elementVelocity /= geometry.integrationElement(localPos);
391 (*velocityNonwetting)[eIdxGlobal] = elementVelocity;
395 if (pressureType == pw)
397 writer.attachCellData(*potential,
"wetting potential");
400 if (pressureType == pn)
402 writer.attachCellData(*potential,
"nonwetting potential");
405 if (vtkOutputLevel_ > 0)
407 if (pressureType == pw)
409 writer.attachCellData(*pressure,
"wetting pressure");
410 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
411 writer.attachCellData(*potentialSecond,
"nonwetting potential");
414 if (pressureType == pn)
416 writer.attachCellData(*pressure,
"nonwetting pressure");
417 writer.attachCellData(*pressureSecond,
"wetting pressure");
418 writer.attachCellData(*potentialSecond,
"wetting potential");
421 writer.attachCellData(*velocityWetting,
"wetting-velocity", dim);
422 writer.attachCellData(*velocityNonwetting,
"nonwetting-velocity", dim);