19#ifndef DUMUX_FVPRESSURE_HH
20#define DUMUX_FVPRESSURE_HH
58 using Element =
typename GridView::Traits::template Codim<0>::Entity;
59 using Intersection =
typename GridView::Intersection;
66 using SolutionTypes =
typename GET_PROP(TypeTag, SolutionTypes);
67 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
69 using Indices =
typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
130 for (
const auto& element : elements(problem_.gridView()))
132 PrimaryVariables initValues;
133 problem_.initial(initValues, element);
135 int eIdxGlobal = problem_.variables().index(element);
137 pressure_[eIdxGlobal] = initValues[
pressEqIdx];
151 void getSource(
EntryType& entry,
const Element& element,
const CellData& cellData,
const bool first);
173 void getFlux(
EntryType& entry,
const Intersection& intersection,
const CellData& cellData,
const bool first);
185 const Intersection& intersection,
const CellData& cellData,
const bool first);
194 {
return pressure_[eIdxGlobal];}
214 int size = problem_.gridView().size(0);
215 A_.setSize(size, size);
216 A_.setBuildMode(Matrix::random);
218 pressure_.resize(size);
220 asImp_().initializeMatrix();
229 asImp_().assemble(
false); Dune::dinfo <<
"pressure calculation"<< std::endl;
237 DUNE_THROW(Dune::NotImplemented,
"Velocity calculation not implemented in pressure model!");
252 int eIdxGlobal = problem_.variables().index(element);
253 outstream << pressure_[eIdxGlobal][0];
265 int eIdxGlobal = problem_.variables().index(element);
266 instream >> pressure_[eIdxGlobal][0];
280 fixPressure_.insert(std::make_pair(eIdxGlobal,
pressure));
291 fixPressure_.erase(eIdxGlobal);
296 fixPressure_.clear();
309 Implementation &asImp_()
310 {
return *
static_cast<Implementation *
>(
this);}
313 const Implementation &asImp_()
const
314 {
return *
static_cast<const Implementation *
>(
this);}
318 PressureSolution pressure_;
320 std::string solverName_;
321 std::string preconditionerName_;
326 std::map<int, Scalar> fixPressure_;
330template<
class TypeTag>
333 initializeMatrixRowSize();
335 initializeMatrixIndices();
340template<
class TypeTag>
344 for (
const auto& element : elements(problem_.gridView()))
347 int eIdxGlobalI = problem_.variables().index(element);
353 for (
const auto& intersection :
intersections(problem_.gridView(), element))
355 if (intersection.neighbor())
358 A_.setrowsize(eIdxGlobalI, rowSize);
363template<
class TypeTag>
367 for (
const auto& element : elements(problem_.gridView()))
370 int eIdxGlobalI = problem_.variables().index(element);
373 A_.addindex(eIdxGlobalI, eIdxGlobalI);
376 for (
const auto& intersection :
intersections(problem_.gridView(), element))
377 if (intersection.neighbor())
380 int eIdxGlobalJ = problem_.variables().index(intersection.outside());
383 A_.addindex(eIdxGlobalI, eIdxGlobalJ);
399template<
class TypeTag>
406 for (
const auto& element : elements(problem_.gridView()))
409 int eIdxGlobalI = problem_.variables().index(element);
412 if (element.partitionType() == Dune::InteriorEntity)
415 CellData& cellDataI = problem_.variables().cellData(eIdxGlobalI);
420 asImp_().getSource(entries, element, cellDataI, first);
421 f_[eIdxGlobalI] += entries[rhs];
425 for (
const auto& intersection :
intersections(problem_.gridView(), element))
428 if (intersection.neighbor())
430 auto elementNeighbor = intersection.outside();
432 int eIdxGlobalJ = problem_.variables().index(elementNeighbor);
435 bool haveSameLevel = (element.level() == elementNeighbor.level());
440 && (eIdxGlobalI > eIdxGlobalJ) && haveSameLevel
441 && elementNeighbor.partitionType() == Dune::InteriorEntity)
445 asImp_().getFlux(entries, intersection, cellDataI, first);
448 f_[eIdxGlobalI] -= entries[rhs];
451 A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
454 A_[eIdxGlobalI][eIdxGlobalJ] -= entries[matrix];
458 && elementNeighbor.partitionType() == Dune::InteriorEntity)
460 f_[eIdxGlobalJ] += entries[rhs];
461 A_[eIdxGlobalJ][eIdxGlobalJ] += entries[matrix];
462 A_[eIdxGlobalJ][eIdxGlobalI] -= entries[matrix];
471 asImp_().getFluxOnBoundary(entries, intersection, cellDataI, first);
474 f_[eIdxGlobalI] += entries[rhs];
476 A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
483 asImp_().getStorage(entries, element, cellDataI, first);
484 f_[eIdxGlobalI] += entries[rhs];
486 A_[eIdxGlobalI][eIdxGlobalI] += entries[matrix];
491 A_[eIdxGlobalI] = 0.0;
492 A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
493 f_[eIdxGlobalI] = pressure_[eIdxGlobalI];
501template<
class GV,
class T>
506template<
class GV,
class T>
510template<
class Solver,
class Problem>
511typename std::enable_if_t<!Detail::isParallelAMGBackend<Solver>::value, Solver>
517template<
class Solver,
class Problem>
518typename std::enable_if_t<Detail::isParallelAMGBackend<Solver>::value, Solver>
521 return Solver(problem.gridView(), problem.model().dofMapper());
525template<
class TypeTag>
530 int verboseLevelSolver = getParam<int>(
"LinearSolver.Verbosity");
532 if (verboseLevelSolver)
533 std::cout << __FILE__ <<
": solve for pressure" << std::endl;
536 if (fixPressure_.size() > 0)
538 for (
auto it = fixPressure_.begin(); it != fixPressure_.end(); ++it)
541 A_[it->first][it->first] = 1;
542 f_[it->first] = it->second;
549 auto solver = getSolver<Solver>(problem_);
550 solver.solve(A_, pressure_, f_);
#define GET_PROP_VALUE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:282
#define GET_PROP(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:281
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:283
Define some often used mathematical functions.
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition: glue.hh:62
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
std::enable_if_t<!Detail::isParallelAMGBackend< Solver >::value, Solver > getSolver(const Problem &problem)
Definition: sequential/cellcentered/pressure.hh:512
Property tag PressureRHSVector
Type of the right hand side vector given to the linear solver.
Definition: sequential/pressureproperties.hh:60
Property tag VisitFacesOnlyOnce
Type of solution vector or pressure system.
Definition: sequential/pressureproperties.hh:62
Property tag PressureSolutionVector
Definition: sequential/pressureproperties.hh:61
Property tag PressureCoefficientMatrix
Gives maximum number of intersections of an element and neighboring elements.
Definition: porousmediumflow/sequential/properties.hh:74
Property tag PressureModel
The type of the discretization of a pressure model.
Definition: porousmediumflow/sequential/properties.hh:65
A linear solver based on the ISTL AMG preconditioner and the ISTL BiCGSTAB solver.
Definition: amgbackend.hh:81
Base class for linear solvers.
Definition: dumux/linear/solver.hh:37
The finite volume base class for the solution of a pressure equation.
Definition: sequential/cellcentered/pressure.hh:48
void getSource(EntryType &entry, const Element &element, const CellData &cellData, const bool first)
Function which calculates the source entry.
void initializeMatrixIndices()
Initialize the global matrix of the system of equations to solve.
Definition: sequential/cellcentered/pressure.hh:364
void assemble(bool first)
Function which assembles the system of equations to be solved.
Definition: sequential/cellcentered/pressure.hh:400
@ pressEqIdx
Definition: sequential/cellcentered/pressure.hh:94
void getStorage(EntryType &entry, const Element &element, const CellData &cellData, const bool first)
Function which calculates the storage entry.
FVPressure(Problem &problem)
Constructs a FVPressure object.
Definition: sequential/cellcentered/pressure.hh:303
void initialize()
Initialize pressure model.
Definition: sequential/cellcentered/pressure.hh:212
void getFlux(EntryType &entry, const Intersection &intersection, const CellData &cellData, const bool first)
Function which calculates the flux entry.
void updateVelocity()
Definition: sequential/cellcentered/pressure.hh:240
void deserializeEntity(std::istream &instream, const Element &element)
Function for deserialization of the pressure field.
Definition: sequential/cellcentered/pressure.hh:263
void resetFixPressureAtIndex()
Definition: sequential/cellcentered/pressure.hh:294
void unsetFixPressureAtIndex(int eIdxGlobal)
Reset the fixed pressure state.
Definition: sequential/cellcentered/pressure.hh:289
void initializePressure()
Initialization of the pressure solution vector: Initialization with meaningful values may.
Definition: sequential/cellcentered/pressure.hh:128
PressureSolution & pressure()
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:119
const Matrix & globalMatrix()
Returns the global matrix of the last pressure solution step.
Definition: sequential/cellcentered/pressure.hh:197
void serializeEntity(std::ostream &outstream, const Element &element)
Function for serialization of the pressure field.
Definition: sequential/cellcentered/pressure.hh:250
const PressureSolution & pressure() const
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:123
@ rhs
index for the right hand side entry
Definition: sequential/cellcentered/pressure.hh:87
@ matrix
index for the global matrix entry
Definition: sequential/cellcentered/pressure.hh:88
Matrix A_
Global stiffnes matrix (sparse matrix which is build by the initializeMatrix() function)
Definition: sequential/cellcentered/pressure.hh:323
void getFluxOnBoundary(EntryType &entry, const Intersection &intersection, const CellData &cellData, const bool first)
Function which calculates the boundary flux entry.
const RHSVector & rightHandSide()
Returns the right hand side vector of the last pressure solution step.
Definition: sequential/cellcentered/pressure.hh:203
void solve()
Solves the global system of equations to get the spatial distribution of the pressure.
Definition: sequential/cellcentered/pressure.hh:526
const Scalar pressure(const int eIdxGlobal) const
Public access function for the primary pressure variable.
Definition: sequential/cellcentered/pressure.hh:193
void initializeMatrixRowSize()
Initialize the global matrix of the system of equations to solve.
Definition: sequential/cellcentered/pressure.hh:341
void calculateVelocity()
Definition: sequential/cellcentered/pressure.hh:235
RHSVector f_
Right hand side vector.
Definition: sequential/cellcentered/pressure.hh:324
void setFixPressureAtIndex(Scalar pressure, int eIdxGlobal)
Set a pressure to be fixed at a certain cell.
Definition: sequential/cellcentered/pressure.hh:278
void update()
Pressure update.
Definition: sequential/cellcentered/pressure.hh:227
Dune::FieldVector< Scalar, 2 > EntryType
Definition: sequential/cellcentered/pressure.hh:77
void initializeMatrix()
Initialize the global matrix of the system of equations to solve.
Definition: sequential/cellcentered/pressure.hh:331
Definition: sequential/cellcentered/pressure.hh:505
Base file for properties related to sequential IMPET algorithms.