28#ifndef EWOMS_FV_BASE_DISCRETIZATION_HH
29#define EWOMS_FV_BASE_DISCRETIZATION_HH
31#include <dune/common/version.hh>
32#include <dune/common/fvector.hh>
33#include <dune/common/fmatrix.hh>
34#include <dune/istl/bvector.hh>
36#include <opm/material/common/MathToolbox.hpp>
37#include <opm/material/common/Valgrind.hpp>
38#include <opm/material/densead/Math.hpp>
79template<
class TypeTag>
80class FvBaseDiscretizationNoAdapt;
81template<
class TypeTag>
82class FvBaseDiscretization;
86namespace Opm::Properties {
89template<
class TypeTag>
94template<
class TypeTag>
96{
using type = Dune::MultipleCodimMultipleGeomTypeMapper<GetPropType<TypeTag, Properties::GridView>>; };
99template<
class TypeTag>
101{
using type = Dune::MultipleCodimMultipleGeomTypeMapper<GetPropType<TypeTag, Properties::GridView>>; };
104template<
class TypeTag>
114template<
class TypeTag>
118template<
class TypeTag>
122template<
class TypeTag>
127template<
class TypeTag>
134template<
class TypeTag>
137 using type = Dune::FieldVector<GetPropType<TypeTag, Properties::Scalar>,
146template<
class TypeTag>
153template<
class TypeTag>
160template<
class TypeTag>
167template<
class TypeTag>
169{
using type = Dune::BlockVector<GetPropType<TypeTag, Properties::EqVector>>; };
174template<
class TypeTag>
176{
using type = Dune::BlockVector<GetPropType<TypeTag, Properties::EqVector>>; };
181template<
class TypeTag>
188template<
class TypeTag>
190{
using type = Dune::BlockVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; };
197template<
class TypeTag>
204template<
class TypeTag>
208template<
class TypeTag>
212template<
class TypeTag>
219template<
class TypeTag>
223template<
class TypeTag>
225{
static constexpr bool value =
true; };
230template<
class TypeTag>
235template<
class TypeTag>
237{
static constexpr int value = Dune::VTK::ascii; };
240template<
class TypeTag>
242{
static constexpr bool value =
false; };
245template<
class TypeTag>
247{
static constexpr int value = 2; };
251template<
class TypeTag>
253{
static constexpr bool value =
false; };
256template<
class TypeTag>
258{
static constexpr bool value =
true; };
262template<
class TypeTag>
264{
static constexpr bool value =
true; };
266template <
class TypeTag,
class MyTypeTag>
270template<
class TypeTag>
274template<
class TypeTag>
291template<
class TypeTag>
330 using IntensiveQuantitiesVector = std::vector<IntensiveQuantities,
aligned_allocator<IntensiveQuantities,
alignof(IntensiveQuantities)> >;
332 using Element =
typename GridView::template Codim<0>::Entity;
333 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
336 using VectorBlock = Dune::FieldVector<Evaluation, numEq>;
337 using EvalEqVector = Dune::FieldVector<Evaluation, numEq>;
339 using LocalEvalBlockVector =
typename LocalResidual::LocalEvalBlockVector;
345 SolutionVector blockVector_;
356 result.blockVector_[0] = 1.0;
357 result.blockVector_[1] = 2.0;
358 result.blockVector_[2] = 3.0;
363 SolutionVector& blockVector()
364 {
return blockVector_; }
365 const SolutionVector& blockVector()
const
366 {
return blockVector_; }
370 return std::equal(this->blockVector_.begin(),
this->blockVector_.end(),
374 template<
class Serializer>
393 : simulator_(simulator)
397 , newtonMethod_(simulator)
398 , localLinearizer_(ThreadManager::maxThreads())
399 , linearizer_(
new Linearizer())
400 , enableGridAdaptation_(Parameters::Get<Parameters::EnableGridAdaptation>() )
401 , enableIntensiveQuantityCache_(Parameters::Get<Parameters::EnableIntensiveQuantityCache>())
402 , enableStorageCache_(Parameters::Get<Parameters::EnableStorageCache>())
403 , enableThermodynamicHints_(Parameters::Get<Parameters::EnableThermodynamicHints>())
405 bool isEcfv = std::is_same<Discretization, EcfvDiscretization<TypeTag> >::value;
406 if (enableGridAdaptation_ && !
isEcfv)
407 throw std::invalid_argument(
"Grid adaptation currently only works for the "
408 "element-centered finite volume discretization (is: "
409 +Dune::className<Discretization>()+
")");
411 PrimaryVariables::init();
412 size_t numDof = asImp_().numGridDof();
415 intensiveQuantityCache_[
timeIdx].resize(numDof);
416 intensiveQuantityCacheUpToDate_[
timeIdx].resize(numDof,
false);
419 if (enableStorageCache_)
420 storageCache_[
timeIdx].resize(numDof);
423 resizeAndResetIntensiveQuantitiesCache_();
424 asImp_().registerOutputModules_();
427 ~FvBaseDiscretization()
430 auto modIt = outputModules_.begin();
431 const auto&
modEndIt = outputModules_.end();
443 Linearizer::registerParameters();
444 LocalLinearizer::registerParameters();
445 LocalResidual::registerParameters();
446 GradientCalculator::registerParameters();
447 IntensiveQuantities::registerParameters();
448 ExtensiveQuantities::registerParameters();
450 Linearizer::registerParameters();
451 PrimaryVariables::registerParameters();
455 Parameters::Register<Parameters::EnableGridAdaptation>
456 (
"Enable adaptive grid refinement/coarsening");
457 Parameters::Register<Parameters::EnableVtkOutput>
458 (
"Global switch for turning on writing VTK files");
459 Parameters::Register<Parameters::EnableThermodynamicHints>
460 (
"Enable thermodynamic hints");
461 Parameters::Register<Parameters::EnableIntensiveQuantityCache>
462 (
"Turn on caching of intensive quantities");
463 Parameters::Register<Parameters::EnableStorageCache>
464 (
"Store previous storage terms and avoid re-calculating them.");
465 Parameters::Register<Parameters::OutputDir>
466 (
"The directory to which result files are written");
475 size_t numDof = asImp_().numGridDof();
476 dofTotalVolume_.resize(numDof);
477 std::fill(dofTotalVolume_.begin(), dofTotalVolume_.end(), 0.0);
479 ElementContext elemCtx(simulator_);
480 gridTotalVolume_ = 0.0;
491 elemCtx.updateStencil(
elem);
492 const auto& stencil = elemCtx.stencil(0);
495 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); dofIdx++) {
497 unsigned globalIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
499 Scalar dofVolume = stencil.subControlVolume(dofIdx).volume();
500 dofTotalVolume_[globalIdx] += dofVolume;
501 gridTotalVolume_ += dofVolume;
508 isLocalDof_.resize(numDof);
509 for (
unsigned dofIdx = 0; dofIdx < numDof; ++dofIdx)
510 isLocalDof_[dofIdx] = (dofTotalVolume_[dofIdx] != 0.0);
513 const auto sumHandle =
516 gridView_.communicate(*sumHandle,
517 Dune::InteriorBorder_All_Interface,
518 Dune::ForwardCommunication);
521 gridTotalVolume_ = gridView_.comm().sum(gridTotalVolume_);
523 linearizer_->init(simulator_);
525 localLinearizer_[threadId].init(simulator_);
527 resizeAndResetIntensiveQuantitiesCache_();
534 newtonMethod_.finishInit();
541 {
return enableGridAdaptation_; }
550 SolutionVector&
uCur = asImp_().solution(0);
553 ElementContext elemCtx(simulator_);
559 if (
elem.partitionType() != Dune::InteriorEntity)
563 elemCtx.updateStencil(
elem);
566 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); dofIdx++)
569 unsigned globalIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
573 simulator_.problem().initial(
uCur[globalIdx], elemCtx, dofIdx, 0);
574 asImp_().supplementInitialSolution_(
uCur[globalIdx], elemCtx, dofIdx, 0);
575 uCur[globalIdx].checkDefined();
580 asImp_().syncOverlap();
586 simulator_.problem().initialSolutionApplied();
591 for (
unsigned dofIdx = 0; dofIdx <
sol.size(); ++dofIdx)
592 sol[dofIdx].checkDefined();
610 {
return newtonMethod_; }
616 {
return newtonMethod_; }
635 if (!enableThermodynamicHints_)
655 if (!enableIntensiveQuantityCache_ || !intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx]) {
664 if (
timeIdx > 0 && enableStorageCache_ && intensiveQuantityCache_[
timeIdx].empty()) {
668 return &intensiveQuantityCache_[
timeIdx][globalIdx];
686 intensiveQuantityCache_[
timeIdx][globalIdx] = intQuants;
687 intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx] = 1;
704 intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx] =
newValue ? 1 : 0;
715 std::fill(intensiveQuantityCacheUpToDate_[
timeIdx].begin(),
716 intensiveQuantityCacheUpToDate_[
timeIdx].end(),
721 void invalidateAndUpdateIntensiveQuantities(
unsigned timeIdx)
const
731 ElementContext elemCtx(simulator_);
735 elemCtx.updatePrimaryStencil(
elem);
736 elemCtx.updatePrimaryIntensiveQuantities(
timeIdx);
741 template <
class Gr
idViewType>
751 ElementContext elemCtx(simulator_);
754 if (
elemIt->partitionType() != Dune::InteriorEntity) {
758 elemCtx.updatePrimaryStencil(
elem);
760 const std::size_t numPrimaryDof = elemCtx.numPrimaryDof(
timeIdx);
761 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
766 elemCtx.updatePrimaryIntensiveQuantities(0);
813 {
return enableStorageCache_; }
836 assert(enableStorageCache_);
837 return storageCache_[
timeIdx][globalIdx];
853 assert(enableStorageCache_);
854 storageCache_[
timeIdx][globalIdx] = value;
865 const SolutionVector&
u)
const
867 SolutionVector tmp(asImp_().
solution(0));
869 Scalar
res = asImp_().globalResidual(
dest);
893 ElementContext elemCtx(simulator_);
899 if (
elem.partitionType() != Dune::InteriorEntity)
902 elemCtx.updateAll(
elem);
903 residual.resize(elemCtx.numDof(0));
905 asImp_().localResidual(threadId).eval(residual, elemCtx);
907 size_t numPrimaryDof = elemCtx.numPrimaryDof(0);
909 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
910 unsigned globalI = elemCtx.globalSpaceIndex(dofIdx, 0);
919 const auto sumHandle =
921 gridView_.communicate(*sumHandle,
922 Dune::InteriorBorder_InteriorBorder_Interface,
923 Dune::ForwardCommunication);
954 ElementContext elemCtx(simulator_);
960 elemCtx.setEnableStorageCache(
false);
964 if (
elem.partitionType() != Dune::InteriorEntity)
967 elemCtx.updateStencil(
elem);
968 elemCtx.updatePrimaryIntensiveQuantities(
timeIdx);
970 size_t numPrimaryDof = elemCtx.numPrimaryDof(
timeIdx);
976 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx)
1003 if (tolerance <= 0) {
1005 simulator_.model().newtonMethod().tolerance()
1006 * simulator_.model().gridTotalVolume()
1011 assert(historySize == 2);
1020 ElementContext elemCtx(simulator_);
1021 elemCtx.setEnableStorageCache(
false);
1022 auto eIt = simulator_.gridView().template begin<0>();
1023 const auto&
elemEndIt = simulator_.gridView().template end<0>();
1025 if (
eIt->partitionType() != Dune::InteriorEntity)
1028 elemCtx.updateAll(*
eIt);
1031 if (elemCtx.onBoundary()) {
1034 for (
unsigned faceIdx = 0; faceIdx <
boundaryCtx.numBoundaryFaces(0); ++faceIdx) {
1035 BoundaryRateVector values;
1036 simulator_.problem().boundary(values,
1040 Valgrind::CheckDefined(values);
1042 unsigned dofIdx =
boundaryCtx.interiorScvIndex(faceIdx, 0);
1049 for (
unsigned i = 0; i < values.size(); ++i)
1059 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++ dofIdx) {
1061 simulator_.problem().source(values,
1065 Valgrind::CheckDefined(values);
1067 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
1069 elemCtx.dofVolume(dofIdx, 0)
1070 * intQuants.extrusionFactor();
1078 const auto& comm = simulator_.gridView().comm();
1083 if (comm.rank() == 0) {
1090 std::cout <<
"rate based on storage terms: " <<
storageRate <<
"\n";
1091 std::cout <<
"rate based on source and boundary terms: " <<
totalRate <<
"\n";
1092 std::cout <<
"difference in rates: ";
1100 eps = std::max(tolerance, eps);
1113 {
return dofTotalVolume_[globalIdx]; }
1121 {
return isLocalDof_[globalIdx]; }
1128 {
return gridTotalVolume_; }
1136 {
return solution_[
timeIdx]->blockVector(); }
1142 {
return solution_[
timeIdx]->blockVector(); }
1149 {
return solution_[
timeIdx]->blockVector(); }
1157 {
return *linearizer_; }
1164 {
return *linearizer_; }
1186 {
return asImp_().localLinearizer(
openMpThreadId).localResidual(); }
1191 {
return asImp_().localLinearizer(
openMpThreadId).localResidual(); }
1203 return 1.0/std::max(
absPv, 1.0);
1225 const PrimaryVariables&
pv1,
1226 const PrimaryVariables&
pv2)
const
1229 for (
unsigned j = 0; j < numEq; ++j) {
1230 Scalar weight = asImp_().primaryVarWeight(
vertexIdx, j);
1231 Scalar
eqErr = std::abs((
pv1[j] -
pv2[j])*weight);
1254 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1255 asImp_().solution(
timeIdx)[i].checkDefined();
1261 prePostProcessTimer_.
halt();
1262 linearizeTimer_.
halt();
1264 updateTimer_.
halt();
1266 prePostProcessTimer_.
start();
1267 asImp_().updateBegin();
1268 prePostProcessTimer_.
stop();
1270 bool converged =
false;
1273 converged = newtonMethod_.apply();
1276 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1277 linearizeTimer_ += newtonMethod_.linearizeTimer();
1278 solveTimer_ += newtonMethod_.solveTimer();
1279 updateTimer_ += newtonMethod_.updateTimer();
1289 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1290 asImp_().solution(
timeIdx)[i].checkDefined();
1295 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1296 linearizeTimer_ += newtonMethod_.linearizeTimer();
1297 solveTimer_ += newtonMethod_.solveTimer();
1298 updateTimer_ += newtonMethod_.updateTimer();
1300 prePostProcessTimer_.
start();
1302 asImp_().updateSuccessful();
1304 asImp_().updateFailed();
1305 prePostProcessTimer_.
stop();
1312 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1313 asImp_().solution(
timeIdx)[i].checkDefined();
1351 throw std::invalid_argument(
"Grid adaptation need to be implemented for "
1352 "specific settings of grid and function spaces");
1366 invalidateAndUpdateIntensiveQuantities(0);
1373 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i)
1374 asImp_().solution(
timeIdx)[i].checkDefined();
1389 if (this->enableGridAdaptation_) {
1390 asImp_().adaptGrid();
1398 asImp_().shiftIntensiveQuantityCache(1);
1408 template <
class Restarter>
1411 throw std::runtime_error(
"Not implemented: The discretization chosen for this problem "
1412 "does not support restart files. (serialize() method unimplemented)");
1422 template <
class Restarter>
1425 throw std::runtime_error(
"Not implemented: The discretization chosen for this problem "
1426 "does not support restart files. (deserialize() method unimplemented)");
1437 template <
class DofEntity>
1441 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(
dof));
1445 throw std::runtime_error(
"Could not serialize degree of freedom "
1446 +std::to_string(dofIdx));
1462 template <
class DofEntity>
1466 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(
dof));
1470 throw std::runtime_error(
"Could not deserialize degree of freedom "
1471 +std::to_string(dofIdx));
1480 {
throw std::logic_error(
"The discretization class must implement the numGridDof() method!"); }
1488 auto auxModIt = auxEqModules_.begin();
1491 result += (*auxModIt)->numDofs();
1507 {
throw std::logic_error(
"The discretization class must implement the dofMapper() method!"); }
1513 {
return vertexMapper_; }
1519 {
return elementMapper_; }
1528 linearizer_ =
new Linearizer;
1529 linearizer_->init(simulator_);
1545 std::ostringstream
oss;
1546 oss <<
"primary variable_" <<
pvIdx;
1557 std::ostringstream
oss;
1575 { outputModules_.push_back(
newModule); }
1585 template <
class VtkMultiWriter>
1587 const SolutionVector&
u,
1588 const GlobalEqVector&
deltaU)
const
1590 using ScalarBuffer = std::vector<double>;
1599 ScalarBuffer*
def[numEq];
1600 ScalarBuffer*
delta[numEq];
1601 ScalarBuffer* priVars[numEq];
1614 for (
unsigned globalIdx = 0; globalIdx <
numGridDof; ++ globalIdx) {
1616 (*priVars[
pvIdx])[globalIdx] =
u[globalIdx][
pvIdx];
1622 PrimaryVariables
uOld(
u[globalIdx]);
1626 Scalar err = asImp_().relativeDofError(globalIdx,
uOld,
uNew);
1627 (*relError)[globalIdx] = err;
1628 (*normalizedRelError)[globalIdx] = err;
1634 Scalar alpha = std::max(Scalar{1
e-20},
1637 for (
unsigned globalIdx = 0; globalIdx <
numGridDof; ++ globalIdx)
1640 DiscBaseOutputModule::attachScalarDofData_(
writer, *
relError,
"relative error");
1643 for (
unsigned i = 0; i < numEq; ++i) {
1644 std::ostringstream
oss;
1645 oss.str(
"");
oss <<
"priVar_" << asImp_().primaryVarName(i);
1646 DiscBaseOutputModule::attachScalarDofData_(
writer,
1650 oss.str(
"");
oss <<
"delta_" << asImp_().primaryVarName(i);
1651 DiscBaseOutputModule::attachScalarDofData_(
writer,
1655 oss.str(
"");
oss <<
"weight_" << asImp_().primaryVarName(i);
1656 DiscBaseOutputModule::attachScalarDofData_(
writer,
1660 oss.str(
"");
oss <<
"defect_" << asImp_().eqName(i);
1661 DiscBaseOutputModule::attachScalarDofData_(
writer,
1666 asImp_().prepareOutputFields();
1667 asImp_().appendOutputFields(
writer);
1677 auto modIt = outputModules_.begin();
1678 const auto&
modEndIt = outputModules_.end();
1680 (*modIt)->allocBuffers();
1690 ElementContext elemCtx(simulator_);
1694 if (
elem.partitionType() != Dune::InteriorEntity)
1699 elemCtx.updateAll(
elem);
1701 elemCtx.updatePrimaryStencil(
elem);
1702 elemCtx.updatePrimaryIntensiveQuantities(0);
1708 auto modIt2 = outputModules_.begin();
1710 (*modIt2)->processElement(elemCtx);
1721 auto modIt = outputModules_.begin();
1722 const auto&
modEndIt = outputModules_.end();
1724 (*modIt)->commitBuffers(
writer);
1731 {
return gridView_; }
1747 auxEqModules_.push_back(
auxMod);
1750 if (enableGridAdaptation_
1751 && !std::is_same<DiscreteFunction, BlockVectorWrapper>::value)
1753 throw std::invalid_argument(
"Problems which require auxiliary modules cannot be used in"
1754 " conjunction with dune-fem");
1771 auxEqModules_.clear();
1772 linearizer_->eraseMatrix();
1773 newtonMethod_.eraseMatrix();
1780 {
return auxEqModules_.size(); }
1798 {
return enableIntensiveQuantityCache_ || enableThermodynamicHints_; }
1800 const Timer& prePostProcessTimer()
const
1801 {
return prePostProcessTimer_; }
1803 const Timer& linearizeTimer()
const
1804 {
return linearizeTimer_; }
1806 const Timer& solveTimer()
const
1807 {
return solveTimer_; }
1809 const Timer& updateTimer()
const
1810 {
return updateTimer_; }
1812 template<
class Serializer>
1820 bool operator==(
const FvBaseDiscretization& rhs)
const
1822 return std::equal(this->solution_.begin(),
this->solution_.end(),
1823 rhs.solution_.begin(), rhs.solution_.end(),
1824 [](
const auto& x,
const auto&
y)
1831 void resizeAndResetIntensiveQuantitiesCache_()
1835 size_t numDof = asImp_().numGridDof();
1837 storageCache_[
timeIdx].resize(numDof);
1843 size_t numDof = asImp_().numGridDof();
1845 intensiveQuantityCache_[
timeIdx].resize(numDof);
1846 intensiveQuantityCacheUpToDate_[
timeIdx].resize(numDof);
1851 template <
class Context>
1852 void supplementInitialSolution_(PrimaryVariables&,
1869 this->outputModules_.push_back(
mod);
1876 {
return localLinearizer_.localResidual(); }
1882 {
return gridView_.comm().rank() == 0; }
1884 Implementation& asImp_()
1885 {
return *
static_cast<Implementation*
>(
this); }
1886 const Implementation& asImp_()
const
1887 {
return *
static_cast<const Implementation*
>(
this); }
1891 Simulator& simulator_;
1897 ElementMapper elementMapper_;
1898 VertexMapper vertexMapper_;
1901 std::vector<BaseAuxiliaryModule<TypeTag>*> auxEqModules_;
1903 NewtonMethod newtonMethod_;
1905 Timer prePostProcessTimer_;
1906 Timer linearizeTimer_;
1911 std::vector<LocalLinearizer> localLinearizer_;
1914 Linearizer *linearizer_;
1918 mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize];
1920 mutable std::vector<unsigned char> intensiveQuantityCacheUpToDate_[historySize];
1922 mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;
1924 std::list<BaseOutputModule<TypeTag>*> outputModules_;
1926 Scalar gridTotalVolume_;
1927 std::vector<Scalar> dofTotalVolume_;
1928 std::vector<bool> isLocalDof_;
1930 mutable GlobalEqVector storageCache_[historySize];
1932 bool enableGridAdaptation_;
1933 bool enableIntensiveQuantityCache_;
1934 bool enableStorageCache_;
1935 bool enableThermodynamicHints_;
1943template<
class TypeTag>
1953 template<
class Serializer>
1955 template<
class SolutionType>
1956 static void serializeOp(Serializer&
serializer,
1968 if (this->enableGridAdaptation_) {
1969 throw std::invalid_argument(
"Grid adaptation need to use"
1970 " BaseDiscretization = FvBaseDiscretizationFemAdapt"
1971 " which currently requires the presence of the"
1972 " dune-fem module");
1974 size_t numDof = this->asImp_().numGridDof();
1976 this->solution_[
timeIdx] = std::make_unique<DiscreteFunction>(
"solution", numDof);
This is a stand-alone version of boost::alignment::aligned_allocator from Boost 1....
Base class for specifying auxiliary equations.
Base class for specifying auxiliary equations.
Definition baseauxiliarymodule.hh:56
The base class for writer modules.
Definition baseoutputmodule.hh:67
The base class for all output writers.
Definition baseoutputwriter.hh:44
Represents all quantities which available on boundary segments.
Definition fvbaseboundarycontext.hh:44
Represents all quantities which available for calculating constraints.
Definition fvbaseconstraintscontext.hh:44
Class to specify constraints for a finite volume spatial discretization.
Definition fvbaseconstraints.hh:46
The base class for the finite volume discretization schemes without adaptation.
Definition fvbasediscretization.hh:1945
Definition fvbasediscretization.hh:343
The base class for the finite volume discretization schemes.
Definition fvbasediscretization.hh:293
LocalLinearizer & localLinearizer(unsigned openMpThreadId)
Definition fvbasediscretization.hh:1179
size_t numAuxiliaryDof() const
Returns the number of degrees of freedom (DOFs) of the auxiliary equations.
Definition fvbasediscretization.hh:1485
void prepareOutputFields() const
Prepare the quantities relevant for the current solution to be appended to the output writers.
Definition fvbasediscretization.hh:1674
void shiftIntensiveQuantityCache(unsigned numSlots=1)
Move the intensive quantities for a given time index to the back.
Definition fvbasediscretization.hh:779
void adaptGrid()
Called by the update() method when the grid should be refined.
Definition fvbasediscretization.hh:1349
void addAuxiliaryModule(BaseAuxiliaryModule< TypeTag > *auxMod)
Add a module for an auxiliary equation.
Definition fvbasediscretization.hh:1744
void setIntensiveQuantitiesCacheEntryValidity(unsigned globalIdx, unsigned timeIdx, bool newValue) const
Invalidate the cache for a given intensive quantities object.
Definition fvbasediscretization.hh:697
void finishInit()
Apply the initial conditions to the model.
Definition fvbasediscretization.hh:472
void prefetch(const Element &) const
Allows to improve the performance by prefetching all data which is associated with a given element.
Definition fvbasediscretization.hh:601
void updateSuccessful()
Called by the update() method if it was successful.
Definition fvbasediscretization.hh:1343
static std::string discretizationName()
Returns a string of discretization's human-readable name.
Definition fvbasediscretization.hh:1535
BaseAuxiliaryModule< TypeTag > * auxiliaryModule(unsigned auxEqModIdx)
Returns a given module for auxiliary equations.
Definition fvbasediscretization.hh:1785
bool isLocalDof(unsigned globalIdx) const
Returns if the overlap of the volume ofa degree of freedom is non-zero.
Definition fvbasediscretization.hh:1120
LocalResidual & localResidual_()
Reference to the local residal object.
Definition fvbasediscretization.hh:1875
void registerOutputModules_()
Register all output modules which make sense for the model.
Definition fvbasediscretization.hh:1865
bool enableGridAdaptation() const
Returns whether the grid ought to be adapted to the solution during the simulation.
Definition fvbasediscretization.hh:540
const NewtonMethod & newtonMethod() const
Returns the newton method object.
Definition fvbasediscretization.hh:615
SolutionVector & mutableSolution(unsigned timeIdx) const
Definition fvbasediscretization.hh:1148
void advanceTimeLevel()
Called by the problem if a time integration was successful, post processing of the solution is done a...
Definition fvbasediscretization.hh:1386
NewtonMethod & newtonMethod()
Returns the newton method object.
Definition fvbasediscretization.hh:609
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices.
Definition fvbasediscretization.hh:1512
const EqVector & cachedStorage(unsigned globalIdx, unsigned timeIdx) const
Retrieve an entry of the cache for the storage term.
Definition fvbasediscretization.hh:834
void updatePVWeights(const ElementContext &) const
Update the weights of all primary variables within an element given the complete set of intensive qua...
Definition fvbasediscretization.hh:1568
void updateFailed()
Called by the update() method if it was unsuccessful.
Definition fvbasediscretization.hh:1360
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition fvbasediscretization.hh:1336
Scalar globalResidual(GlobalEqVector &dest) const
Compute the global residual for the current solution vector.
Definition fvbasediscretization.hh:880
LocalResidual & localResidual(unsigned openMpThreadId)
Definition fvbasediscretization.hh:1190
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition fvbasediscretization.hh:1438
void setEnableStorageCache(bool enableStorageCache)
Set the value of enable storage cache.
Definition fvbasediscretization.hh:821
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition fvbasediscretization.hh:1555
Scalar eqWeight(unsigned, unsigned) const
Returns the relative weight of an equation.
Definition fvbasediscretization.hh:1212
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition fvbasediscretization.hh:1200
void deserialize(Restarter &)
Deserializes the state of the model.
Definition fvbasediscretization.hh:1423
void checkConservativeness(Scalar tolerance=-1, bool verbose=false) const
Ensure that the difference between the storage terms of the last and of the current time step is cons...
Definition fvbasediscretization.hh:993
Scalar gridTotalVolume() const
Returns the volume of the whole grid which represents the spatial domain.
Definition fvbasediscretization.hh:1127
const IntensiveQuantities * thermodynamicHint(unsigned globalIdx, unsigned timeIdx) const
Return the thermodynamic hint for a entity on the grid at given time.
Definition fvbasediscretization.hh:633
const Linearizer & linearizer() const
Returns the operator linearizer for the global jacobian of the problem.
Definition fvbasediscretization.hh:1156
void updateCachedStorage(unsigned globalIdx, unsigned timeIdx, const EqVector &value) const
Set an entry of the cache for the storage term.
Definition fvbasediscretization.hh:851
void addConvergenceVtkFields(VtkMultiWriter &writer, const SolutionVector &u, const GlobalEqVector &deltaU) const
Add the vector fields for analysing the convergence of the newton method to the a VTK writer.
Definition fvbasediscretization.hh:1586
Scalar relativeDofError(unsigned vertexIdx, const PrimaryVariables &pv1, const PrimaryVariables &pv2) const
Returns the relative error between two vectors of primary variables.
Definition fvbasediscretization.hh:1224
Scalar globalResidual(GlobalEqVector &dest, const SolutionVector &u) const
Compute the global residual for an arbitrary solution vector.
Definition fvbasediscretization.hh:864
SolutionVector & solution(unsigned timeIdx)
Definition fvbasediscretization.hh:1141
void addOutputModule(BaseOutputModule< TypeTag > *newModule)
Add an module for writing visualization output after a timestep.
Definition fvbasediscretization.hh:1574
void deserializeEntity(std::istream &instream, const DofEntity &dof)
Reads the current solution variables for a degree of freedom from a restart file.
Definition fvbasediscretization.hh:1463
const LocalLinearizer & localLinearizer(unsigned openMpThreadId) const
Returns the local jacobian which calculates the local stiffness matrix for an arbitrary element.
Definition fvbasediscretization.hh:1174
bool update()
Try to progress the model to the next timestep.
Definition fvbasediscretization.hh:1245
void clearAuxiliaryModules()
Causes the list of auxiliary equations to be cleared.
Definition fvbasediscretization.hh:1769
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices.
Definition fvbasediscretization.hh:1518
size_t numGridDof() const
Returns the number of degrees of freedom (DOFs) for the computational grid.
Definition fvbasediscretization.hh:1479
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition fvbasediscretization.hh:1328
void appendOutputFields(BaseOutputWriter &writer) const
Append the quantities relevant for the current solution to an output writer.
Definition fvbasediscretization.hh:1719
void applyInitialSolution()
Applies the initial solution for all degrees of freedom to which the model applies.
Definition fvbasediscretization.hh:547
void updateCachedIntensiveQuantities(const IntensiveQuantities &intQuants, unsigned globalIdx, unsigned timeIdx) const
Update the intensive quantity cache for a entity on the grid at given time.
Definition fvbasediscretization.hh:679
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition fvbasediscretization.hh:1543
void invalidateIntensiveQuantitiesCache(unsigned timeIdx) const
Invalidate the whole intensive quantity cache for time index.
Definition fvbasediscretization.hh:712
Linearizer & linearizer()
Returns the object which linearizes the global system of equations at the current solution.
Definition fvbasediscretization.hh:1163
const BaseAuxiliaryModule< TypeTag > * auxiliaryModule(unsigned auxEqModIdx) const
Returns a given module for auxiliary equations.
Definition fvbasediscretization.hh:1791
void globalStorage(EqVector &storage, unsigned timeIdx=0) const
Compute the integral over the domain of the storage terms of all conservation quantities.
Definition fvbasediscretization.hh:941
Scalar dofTotalVolume(unsigned globalIdx) const
Returns the volume of a given control volume.
Definition fvbasediscretization.hh:1112
static void registerParameters()
Register all run-time parameters for the model.
Definition fvbasediscretization.hh:441
const SolutionVector & solution(unsigned timeIdx) const
Reference to the solution at a given history index as a block vector.
Definition fvbasediscretization.hh:1135
bool verbose_() const
Returns whether messages should be printed.
Definition fvbasediscretization.hh:1881
const LocalResidual & localResidual(unsigned openMpThreadId) const
Returns the object to calculate the local residual function.
Definition fvbasediscretization.hh:1185
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization's degrees of freedoms are to indices.
Definition fvbasediscretization.hh:1506
bool storeIntensiveQuantities() const
Returns true if the cache for intensive quantities is enabled.
Definition fvbasediscretization.hh:1797
void serialize(Restarter &)
Serializes the current state of the model.
Definition fvbasediscretization.hh:1409
size_t numTotalDof() const
Returns the total number of degrees of freedom (i.e., grid plux auxiliary DOFs)
Definition fvbasediscretization.hh:1499
void resetLinearizer()
Resets the Jacobian matrix linearizer, so that the boundary types can be altered.
Definition fvbasediscretization.hh:1525
bool enableStorageCache() const
Returns true iff the storage term is cached.
Definition fvbasediscretization.hh:812
size_t numAuxiliaryModules() const
Returns the number of modules for auxiliary equations.
Definition fvbasediscretization.hh:1779
const GridView & gridView() const
Reference to the grid view of the spatial domain.
Definition fvbasediscretization.hh:1730
const IntensiveQuantities * cachedIntensiveQuantities(unsigned globalIdx, unsigned timeIdx) const
Return the cached intensive quantities for a entity on the grid at given time.
Definition fvbasediscretization.hh:653
This class stores an array of IntensiveQuantities objects, one intensive quantities object for each o...
Definition fvbaseelementcontext.hh:52
Provide the properties at a face which make sense indepentently of the conserved quantities.
Definition fvbaseextensivequantities.hh:46
This class calculates gradients of arbitrary quantities at flux integration points using the two-poin...
Definition fvbasegradientcalculator.hh:47
Base class for the model specific class which provides access to all intensive (i....
Definition fvbaseintensivequantities.hh:45
The common code for the linearizers of non-linear systems of equations.
Definition fvbaselinearizer.hh:71
Element-wise caculation of the residual matrix for models based on a finite volume spatial discretiza...
Definition fvbaselocalresidual.hh:58
Represents the primary variables used by the a model.
Definition fvbaseprimaryvariables.hh:52
This is a grid manager which does not create any border list.
Definition nullborderlistmanager.hh:44
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition newtonmethod.hh:129
Manages the initializing and running of time dependent problems.
Definition simulator.hh:97
Simplifies multi-threaded capabilities.
Definition threadmanager.hpp:36
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition threadmanager.hpp:66
static unsigned threadId()
Return the index of the current OpenMP thread.
Definition threadmanager.cpp:84
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition threadedentityiterator.hh:43
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition timerguard.hh:41
Provides an encapsulation to measure the system time.
Definition timer.hpp:46
void start()
Start counting the time resources used by the simulation.
Definition timer.cpp:46
void halt()
Stop the measurement reset all timing values.
Definition timer.cpp:75
double stop()
Stop counting the time resources.
Definition timer.cpp:52
Simplifies writing multi-file VTK datasets.
Definition vtkmultiwriter.hh:66
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkprimaryvarsmodule.hpp:73
Definition alignedallocator.hh:94
Calculates the local residual and its Jacobian for a single element of the grid.
Represents all quantities which available on boundary segments.
Class to specify constraints for a finite volume spatial discretization.
Represents all quantities which available for calculating constraints.
This class stores an array of IntensiveQuantities objects, one intensive quantities object for each o...
Provide the properties at a face which make sense indepentently of the conserved quantities.
Calculates the Jacobian of the local residual for finite volume spatial discretizations using a finit...
This class calculates gradients of arbitrary quantities at flux integration points using the two-poin...
Base class for the model specific class which provides access to all intensive (i....
The common code for the linearizers of non-linear systems of equations.
Element-wise caculation of the residual matrix for models based on a finite volume spatial discretiza...
A Newton method for models using a finite volume discretization.
Represents the primary variables used by the a model.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Provides data handles for parallel communication which operate on DOFs.
Declares the parameters for the black oil model.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:235
This is a grid manager which does not create any border list.
Manages the initializing and running of time dependent problems.
Definition fvbasediscretization.hh:1954
Definition fvbasediscretization.hh:267
The class which marks the border indices associated with the degrees of freedom on a process boundary...
Definition basicproperties.hh:125
The secondary variables of a boundary segment.
Definition fvbaseproperties.hh:143
Type of object for specifying boundary conditions.
Definition fvbaseproperties.hh:119
The secondary variables of a constraint degree of freedom.
Definition fvbaseproperties.hh:146
The class which represents a constraint degree of freedom.
Definition fvbaseproperties.hh:122
The part of the extensive quantities which is specific to the spatial discretization.
Definition fvbaseproperties.hh:160
The discretization specific part of the intensive quantities.
Definition fvbaseproperties.hh:136
The discretization specific part of the local residual.
Definition fvbaseproperties.hh:91
Definition fvbaseproperties.hh:77
The secondary variables of all degrees of freedom in an element's stencil.
Definition fvbaseproperties.hh:140
A vector of holding a quantity for each equation for each DOF of an element.
Definition fvbaseproperties.hh:112
The mapper to find the global index of an element.
Definition fvbaseproperties.hh:213
Specify whether the some degrees of fredom can be constraint.
Definition fvbaseproperties.hh:199
Specify if experimental features should be enabled or not.
Definition fvbaseproperties.hh:241
A vector of holding a quantity for each equation (usually at a given spatial location)
Definition fvbaseproperties.hh:109
Specify whether the storage terms use extensive quantities or not.
Definition fvbaseproperties.hh:233
Vector containing a quantity of for equation for each DOF of the whole grid.
Definition linalgproperties.hh:54
Calculates gradients of arbitrary quantities at flux integration points.
Definition fvbaseproperties.hh:152
The secondary variables within a sub-control volume.
Definition fvbaseproperties.hh:133
The class which linearizes the non-linear system of equations.
Definition newtonmethodproperties.hh:36
A vector of primary variables within a sub-control volume.
Definition fvbaseproperties.hh:130
Vector containing volumetric or areal rates of quantities.
Definition fvbaseproperties.hh:116
Manages the simulation time.
Definition basicproperties.hh:116
Vector containing all primary variables of the grid.
Definition fvbaseproperties.hh:126
The OpenMP threads manager.
Definition fvbaseproperties.hh:174
The history size required by the time discretization.
Definition fvbaseproperties.hh:225
a tag to mark properties as undefined
Definition propertysystem.hh:40
use locking to prevent race conditions when linearizing the global system of equations in multi-threa...
Definition fvbaseproperties.hh:181
Specify whether to use volumetric residuals or not.
Definition fvbaseproperties.hh:237
The mapper to find the global index of a vertex.
Definition fvbaseproperties.hh:207
Simplifies multi-threaded capabilities.
Provides an encapsulation to measure the system time.
A simple class which makes sure that a timer gets stopped if an exception is thrown.
VTK output module for the fluid composition.