179 const auto element = *problem_.gridView().template begin<0>();
180 FluidState fluidState;
181 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
182 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
183 fluidState.setTemperature(problem_.temperature(element));
184 fluidState.setSaturation(wPhaseIdx, 1.);
185 fluidState.setSaturation(nPhaseIdx, 0.);
186 density_[wPhaseIdx] = FluidSystem::density(fluidState, wPhaseIdx);
187 density_[nPhaseIdx] = FluidSystem::density(fluidState, nPhaseIdx);
188 viscosity_[wPhaseIdx] = FluidSystem::viscosity(fluidState, wPhaseIdx);
189 viscosity_[nPhaseIdx] = FluidSystem::viscosity(fluidState, nPhaseIdx);
193 pressTrace_.resize(problem_.gridView().size(1));
194 f_.resize(problem_.gridView().size(1));
195 lstiff_.initialize();
240 int size = problem_.gridView().size(0);
241 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
242 ScalarSolutionType *pressure = 0;
243 ScalarSolutionType *pressureSecond = 0;
244 ScalarSolutionType *potentialSecond = 0;
245 Dune::BlockVector < DimVector > *velocityWetting = 0;
246 Dune::BlockVector < DimVector > *velocityNonwetting = 0;
248 if (vtkOutputLevel_ > 0)
250 pressure = writer.allocateManagedBuffer(size);
251 pressureSecond = writer.allocateManagedBuffer(size);
252 potentialSecond = writer.allocateManagedBuffer(size);
253 velocityWetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
254 velocityNonwetting = writer.template allocateManagedBuffer<Scalar, dim>(size);
258 for (
const auto& element : elements(problem_.gridView()))
260 int eIdxGlobal = problem_.variables().index(element);
261 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
263 if (pressureType == pw)
265 (*potential)[eIdxGlobal] = cellData.potential(wPhaseIdx);
268 if (pressureType == pn)
270 (*potential)[eIdxGlobal] = cellData.potential(nPhaseIdx);
273 if (vtkOutputLevel_ > 0)
276 if (pressureType == pw)
278 (*pressure)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
279 (*potentialSecond)[eIdxGlobal] = cellData.potential(nPhaseIdx);
280 (*pressureSecond)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
283 if (pressureType == pn)
285 (*pressure)[eIdxGlobal] = cellData.pressure(nPhaseIdx);
286 (*potentialSecond)[eIdxGlobal] = cellData.potential(wPhaseIdx);
287 (*pressureSecond)[eIdxGlobal] = cellData.pressure(wPhaseIdx);
290 const typename Element::Geometry& geometry = element.geometry();
293 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
294 const auto refElement = ReferenceElements::general(geometry.type());
296 const int numberOfFaces=refElement.size(1);
297 std::vector<Scalar> fluxW(numberOfFaces,0);
298 std::vector<Scalar> fluxNw(numberOfFaces,0);
301 for (
const auto& intersection :
intersections(problem_.gridView(), element))
303 int isIndex = intersection.indexInInside();
305 fluxW[isIndex] += intersection.geometry().volume()
306 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(wPhaseIdx, isIndex));
307 fluxNw[isIndex] += intersection.geometry().volume()
308 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(nPhaseIdx, isIndex));
313 Dune::FieldVector<Scalar, dim> refVelocity;
315 if (refElement.type().isSimplex()) {
316 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
318 refVelocity[dimIdx] = -fluxW[dim - 1 - dimIdx];
319 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
321 refVelocity[dimIdx] += fluxW[fIdx]/(dim + 1);
326 else if (refElement.type().isCube()){
327 for (
int i = 0; i < dim; i++)
328 refVelocity[i] = 0.5 * (fluxW[2*i + 1] - fluxW[2*i]);
332 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
335 const DimVector& localPos = refElement.position(0, 0);
338 const JacobianTransposed jacobianT = geometry.jacobianTransposed(localPos);
341 DimVector elementVelocity(0);
342 jacobianT.umtv(refVelocity, elementVelocity);
343 elementVelocity /= geometry.integrationElement(localPos);
345 (*velocityWetting)[eIdxGlobal] = elementVelocity;
350 if (refElement.type().isSimplex()) {
351 for (
int dimIdx = 0; dimIdx < dim; dimIdx++)
353 refVelocity[dimIdx] = -fluxNw[dim - 1 - dimIdx];
354 for (
int fIdx = 0; fIdx < dim + 1; fIdx++)
356 refVelocity[dimIdx] += fluxNw[fIdx]/(dim + 1);
361 else if (refElement.type().isCube()){
362 for (
int i = 0; i < dim; i++)
363 refVelocity[i] = 0.5 * (fluxNw[2*i + 1] - fluxNw[2*i]);
367 DUNE_THROW(Dune::NotImplemented,
"velocity output for prism/pyramid not implemented");
372 jacobianT.umtv(refVelocity, elementVelocity);
373 elementVelocity /= geometry.integrationElement(localPos);
375 (*velocityNonwetting)[eIdxGlobal] = elementVelocity;
379 if (pressureType == pw)
381 writer.attachCellData(*potential,
"wetting potential");
384 if (pressureType == pn)
386 writer.attachCellData(*potential,
"nonwetting potential");
389 if (vtkOutputLevel_ > 0)
391 if (pressureType == pw)
393 writer.attachCellData(*pressure,
"wetting pressure");
394 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
395 writer.attachCellData(*potentialSecond,
"nonwetting potential");
398 if (pressureType == pn)
400 writer.attachCellData(*pressure,
"nonwetting pressure");
401 writer.attachCellData(*pressureSecond,
"wetting pressure");
402 writer.attachCellData(*potentialSecond,
"wetting potential");
405 writer.attachCellData(*velocityWetting,
"wetting-velocity", dim);
406 writer.attachCellData(*velocityNonwetting,
"non-wetting-velocity", dim);