182 const auto element = *problem_.gridView().template begin<0>();
183 FluidState fluidState;
184 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
185 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
186 fluidState.setTemperature(problem_.temperature(element));
187 fluidState.setSaturation(wPhaseIdx, 1.);
188 fluidState.setSaturation(nPhaseIdx, 0.);
189 density_[wPhaseIdx] = FluidSystem::density(fluidState, wPhaseIdx);
190 density_[nPhaseIdx] = FluidSystem::density(fluidState, nPhaseIdx);
191 viscosity_[wPhaseIdx] = FluidSystem::viscosity(fluidState, wPhaseIdx);
192 viscosity_[nPhaseIdx] = FluidSystem::viscosity(fluidState, nPhaseIdx);
196 pressTrace_.resize(problem_.gridView().size(1));
197 f_.resize(problem_.gridView().size(1));
198 lstiff_.initialize();
243 int size = problem_.gridView().size(0);
244 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
245 ScalarSolutionType *pressure = 0;
246 ScalarSolutionType *pressureSecond = 0;
247 ScalarSolutionType *potentialSecond = 0;
248 Dune::BlockVector < DimVector > *velocityWetting = 0;
249 Dune::BlockVector < DimVector > *velocityNonwetting = 0;
251 if (vtkOutputLevel_ > 0)
253 pressure = writer.allocateManagedBuffer(size);
254 pressureSecond = writer.allocateManagedBuffer(size);
255 potentialSecond = writer.allocateManagedBuffer(size);
256 velocityWetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
257 velocityNonwetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
261 for (
const auto& element : elements(problem_.gridView()))
263 int eIdxGlobal = problem_.variables().index(element);
264 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
266 if (pressureType == pw)
268 (*potential)[eIdxGlobal] = cellData.potential(wPhaseIdx);
271 if (pressureType == pn)
273 (*potential)[eIdxGlobal] = cellData.potential(nPhaseIdx);
276 if (vtkOutputLevel_ > 0)
279 if (pressureType == pw)
281 (*pressure)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
282 (*potentialSecond)[eIdxGlobal] = cellData.potential(nPhaseIdx);
283 (*pressureSecond)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
286 if (pressureType == pn)
288 (*pressure)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
289 (*potentialSecond)[eIdxGlobal] = cellData.potential(wPhaseIdx);
290 (*pressureSecond)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
293 const typename Element::Geometry& geometry = element.geometry();
296 const auto refElement = referenceElement(geometry);
298 const int numberOfFaces=refElement.size(1);
299 std::vector<Scalar> fluxW(numberOfFaces,0);
300 std::vector<Scalar> fluxNw(numberOfFaces,0);
303 for (
const auto& intersection : intersections(problem_.gridView(), element))
305 int isIndex = intersection.indexInInside();
307 fluxW[isIndex] += intersection.geometry().volume()
308 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(wPhaseIdx, isIndex));
309 fluxNw[isIndex] += intersection.geometry().volume()
310 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(nPhaseIdx, isIndex));
315 Dune::FieldVector<Scalar, dim> refVelocity;
317 if (refElement.type().isSimplex()) {
318 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
320 refVelocity[dimIdx] = -fluxW[dim - 1 - dimIdx];
321 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
323 refVelocity[dimIdx] += fluxW[fIdx]/(dim + 1);
328 else if (refElement.type().isCube()){
329 for (
int i = 0; i < dim; i++)
330 refVelocity[i] = 0.5 * (fluxW[2*i + 1] - fluxW[2*i]);
334 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
337 const DimVector& localPos = refElement.position(0, 0);
340 const JacobianTransposed jacobianT = geometry.jacobianTransposed(localPos);
343 DimVector elementVelocity(0);
344 jacobianT.umtv(refVelocity, elementVelocity);
345 elementVelocity /= geometry.integrationElement(localPos);
347 (*velocityWetting)[eIdxGlobal] = elementVelocity;
352 if (refElement.type().isSimplex()) {
353 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
355 refVelocity[dimIdx] = -fluxNw[dim - 1 - dimIdx];
356 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
358 refVelocity[dimIdx] += fluxNw[fIdx]/(dim + 1);
363 else if (refElement.type().isCube()){
364 for (
int i = 0; i < dim; i++)
365 refVelocity[i] = 0.5 * (fluxNw[2*i + 1] - fluxNw[2*i]);
369 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
374 jacobianT.umtv(refVelocity, elementVelocity);
375 elementVelocity /= geometry.integrationElement(localPos);
377 (*velocityNonwetting)[eIdxGlobal] = elementVelocity;
381 if (pressureType == pw)
383 writer.attachCellData(*potential,
"wetting potential");
386 if (pressureType == pn)
388 writer.attachCellData(*potential,
"nonwetting potential");
391 if (vtkOutputLevel_ > 0)
393 if (pressureType == pw)
395 writer.attachCellData(*pressure,
"wetting pressure");
396 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
397 writer.attachCellData(*potentialSecond,
"nonwetting potential");
400 if (pressureType == pn)
402 writer.attachCellData(*pressure,
"nonwetting pressure");
403 writer.attachCellData(*pressureSecond,
"wetting pressure");
404 writer.attachCellData(*potentialSecond,
"wetting potential");
407 writer.attachCellData(*velocityWetting,
"wetting-velocity", dim);
408 writer.attachCellData(*velocityNonwetting,
"nonwetting-velocity", dim);