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;
492 const auto& stencil =
elemCtx.stencil(0);
499 Scalar dofVolume = stencil.subControlVolume(
dofIdx).volume();
500 dofTotalVolume_[globalIdx] += dofVolume;
502 gridTotalVolume_ += dofVolume;
509 isLocalDof_.resize(numDof);
514 const auto sumHandle =
517 gridView_.communicate(*sumHandle,
518 Dune::InteriorBorder_All_Interface,
519 Dune::ForwardCommunication);
522 gridTotalVolume_ = gridView_.comm().sum(gridTotalVolume_);
524 linearizer_->init(simulator_);
526 localLinearizer_[threadId].init(simulator_);
528 resizeAndResetIntensiveQuantitiesCache_();
535 newtonMethod_.finishInit();
542 {
return enableGridAdaptation_; }
551 SolutionVector&
uCur = asImp_().solution(0);
554 ElementContext
elemCtx(simulator_);
560 if (
elem.partitionType() != Dune::InteriorEntity)
576 uCur[globalIdx].checkDefined();
581 asImp_().syncOverlap();
587 simulator_.problem().initialSolutionApplied();
611 {
return newtonMethod_; }
617 {
return newtonMethod_; }
636 if (!enableThermodynamicHints_)
656 if (!enableIntensiveQuantityCache_ || !intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx]) {
665 if (
timeIdx > 0 && enableStorageCache_ && intensiveQuantityCache_[
timeIdx].empty()) {
669 return &intensiveQuantityCache_[
timeIdx][globalIdx];
688 intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx] = 1;
705 intensiveQuantityCacheUpToDate_[
timeIdx][globalIdx] =
newValue ? 1 : 0;
716 std::fill(intensiveQuantityCacheUpToDate_[
timeIdx].begin(),
717 intensiveQuantityCacheUpToDate_[
timeIdx].end(),
722 void invalidateAndUpdateIntensiveQuantities(
unsigned timeIdx)
const
732 ElementContext
elemCtx(simulator_);
742 template <
class Gr
idViewType>
752 ElementContext
elemCtx(simulator_);
755 if (
elemIt->partitionType() != Dune::InteriorEntity) {
767 elemCtx.updatePrimaryIntensiveQuantities(0);
814 {
return enableStorageCache_; }
837 assert(enableStorageCache_);
838 return storageCache_[
timeIdx][globalIdx];
854 assert(enableStorageCache_);
855 storageCache_[
timeIdx][globalIdx] = value;
866 const SolutionVector&
u)
const
868 SolutionVector tmp(asImp_().
solution(0));
870 Scalar
res = asImp_().globalResidual(
dest);
894 ElementContext
elemCtx(simulator_);
900 if (
elem.partitionType() != Dune::InteriorEntity)
904 residual.resize(
elemCtx.numDof(0));
906 asImp_().localResidual(threadId).eval(residual,
elemCtx);
908 size_t numPrimaryDof =
elemCtx.numPrimaryDof(0);
920 const auto sumHandle =
922 gridView_.communicate(*sumHandle,
923 Dune::InteriorBorder_InteriorBorder_Interface,
924 Dune::ForwardCommunication);
955 ElementContext
elemCtx(simulator_);
961 elemCtx.setEnableStorageCache(
false);
965 if (
elem.partitionType() != Dune::InteriorEntity)
1004 if (tolerance <= 0) {
1006 simulator_.model().newtonMethod().tolerance()
1007 * simulator_.model().gridTotalVolume()
1012 assert(historySize == 2);
1021 ElementContext
elemCtx(simulator_);
1022 elemCtx.setEnableStorageCache(
false);
1023 auto eIt = simulator_.gridView().template begin<0>();
1024 const auto&
elemEndIt = simulator_.gridView().template end<0>();
1026 if (
eIt->partitionType() != Dune::InteriorEntity)
1036 BoundaryRateVector values;
1037 simulator_.problem().boundary(values,
1041 Valgrind::CheckDefined(values);
1050 for (
unsigned i = 0; i < values.size(); ++i)
1062 simulator_.problem().source(values,
1066 Valgrind::CheckDefined(values);
1079 const auto& comm = simulator_.gridView().comm();
1084 if (comm.rank() == 0) {
1091 std::cout <<
"rate based on storage terms: " <<
storageRate <<
"\n";
1092 std::cout <<
"rate based on source and boundary terms: " <<
totalRate <<
"\n";
1093 std::cout <<
"difference in rates: ";
1101 eps = std::max(tolerance,
eps);
1114 {
return dofTotalVolume_[globalIdx]; }
1122 {
return isLocalDof_[globalIdx]; }
1129 {
return gridTotalVolume_; }
1137 {
return solution_[
timeIdx]->blockVector(); }
1143 {
return solution_[
timeIdx]->blockVector(); }
1150 {
return solution_[
timeIdx]->blockVector(); }
1158 {
return *linearizer_; }
1165 {
return *linearizer_; }
1187 {
return asImp_().localLinearizer(
openMpThreadId).localResidual(); }
1192 {
return asImp_().localLinearizer(
openMpThreadId).localResidual(); }
1204 return 1.0/std::max(
absPv, 1.0);
1226 const PrimaryVariables&
pv1,
1227 const PrimaryVariables&
pv2)
const
1230 for (
unsigned j = 0; j < numEq; ++j) {
1231 Scalar weight = asImp_().primaryVarWeight(
vertexIdx, j);
1232 Scalar
eqErr = std::abs((
pv1[j] -
pv2[j])*weight);
1255 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1256 asImp_().solution(
timeIdx)[i].checkDefined();
1262 prePostProcessTimer_.
halt();
1263 linearizeTimer_.
halt();
1265 updateTimer_.
halt();
1267 prePostProcessTimer_.
start();
1268 asImp_().updateBegin();
1269 prePostProcessTimer_.
stop();
1271 bool converged =
false;
1274 converged = newtonMethod_.apply();
1277 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1278 linearizeTimer_ += newtonMethod_.linearizeTimer();
1279 solveTimer_ += newtonMethod_.solveTimer();
1280 updateTimer_ += newtonMethod_.updateTimer();
1290 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1291 asImp_().solution(
timeIdx)[i].checkDefined();
1296 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1297 linearizeTimer_ += newtonMethod_.linearizeTimer();
1298 solveTimer_ += newtonMethod_.solveTimer();
1299 updateTimer_ += newtonMethod_.updateTimer();
1301 prePostProcessTimer_.
start();
1303 asImp_().updateSuccessful();
1305 asImp_().updateFailed();
1306 prePostProcessTimer_.
stop();
1313 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1314 asImp_().solution(
timeIdx)[i].checkDefined();
1352 throw std::invalid_argument(
"Grid adaptation need to be implemented for "
1353 "specific settings of grid and function spaces");
1367 invalidateAndUpdateIntensiveQuantities(0);
1374 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i)
1375 asImp_().solution(
timeIdx)[i].checkDefined();
1390 if (this->enableGridAdaptation_) {
1391 asImp_().adaptGrid();
1399 asImp_().shiftIntensiveQuantityCache(1);
1409 template <
class Restarter>
1412 throw std::runtime_error(
"Not implemented: The discretization chosen for this problem "
1413 "does not support restart files. (serialize() method unimplemented)");
1423 template <
class Restarter>
1426 throw std::runtime_error(
"Not implemented: The discretization chosen for this problem "
1427 "does not support restart files. (deserialize() method unimplemented)");
1438 template <
class DofEntity>
1442 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(
dof));
1446 throw std::runtime_error(
"Could not serialize degree of freedom "
1447 +std::to_string(
dofIdx));
1463 template <
class DofEntity>
1467 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(
dof));
1471 throw std::runtime_error(
"Could not deserialize degree of freedom "
1472 +std::to_string(
dofIdx));
1481 {
throw std::logic_error(
"The discretization class must implement the numGridDof() method!"); }
1489 auto auxModIt = auxEqModules_.begin();
1492 result += (*auxModIt)->numDofs();
1508 {
throw std::logic_error(
"The discretization class must implement the dofMapper() method!"); }
1514 {
return vertexMapper_; }
1520 {
return elementMapper_; }
1529 linearizer_ =
new Linearizer;
1530 linearizer_->init(simulator_);
1546 std::ostringstream
oss;
1547 oss <<
"primary variable_" <<
pvIdx;
1558 std::ostringstream
oss;
1576 { outputModules_.push_back(
newModule); }
1586 template <
class VtkMultiWriter>
1588 const SolutionVector&
u,
1589 const GlobalEqVector&
deltaU)
const
1591 using ScalarBuffer = std::vector<double>;
1600 ScalarBuffer*
def[numEq];
1601 ScalarBuffer*
delta[numEq];
1602 ScalarBuffer* priVars[numEq];
1615 for (
unsigned globalIdx = 0; globalIdx <
numGridDof; ++ globalIdx) {
1617 (*priVars[
pvIdx])[globalIdx] =
u[globalIdx][
pvIdx];
1623 PrimaryVariables
uOld(
u[globalIdx]);
1627 Scalar err = asImp_().relativeDofError(globalIdx,
uOld,
uNew);
1628 (*relError)[globalIdx] = err;
1629 (*normalizedRelError)[globalIdx] = err;
1635 Scalar alpha = std::max(Scalar{1
e-20},
1638 for (
unsigned globalIdx = 0; globalIdx <
numGridDof; ++ globalIdx)
1641 DiscBaseOutputModule::attachScalarDofData_(
writer, *
relError,
"relative error");
1644 for (
unsigned i = 0; i < numEq; ++i) {
1645 std::ostringstream
oss;
1646 oss.str(
"");
oss <<
"priVar_" << asImp_().primaryVarName(i);
1647 DiscBaseOutputModule::attachScalarDofData_(
writer,
1651 oss.str(
"");
oss <<
"delta_" << asImp_().primaryVarName(i);
1652 DiscBaseOutputModule::attachScalarDofData_(
writer,
1656 oss.str(
"");
oss <<
"weight_" << asImp_().primaryVarName(i);
1657 DiscBaseOutputModule::attachScalarDofData_(
writer,
1661 oss.str(
"");
oss <<
"defect_" << asImp_().eqName(i);
1662 DiscBaseOutputModule::attachScalarDofData_(
writer,
1667 asImp_().prepareOutputFields();
1668 asImp_().appendOutputFields(
writer);
1678 auto modIt = outputModules_.begin();
1679 const auto&
modEndIt = outputModules_.end();
1681 (*modIt)->allocBuffers();
1691 ElementContext
elemCtx(simulator_);
1695 if (
elem.partitionType() != Dune::InteriorEntity)
1703 elemCtx.updatePrimaryIntensiveQuantities(0);
1709 auto modIt2 = outputModules_.begin();
1711 (*modIt2)->processElement(
elemCtx);
1722 auto modIt = outputModules_.begin();
1723 const auto&
modEndIt = outputModules_.end();
1725 (*modIt)->commitBuffers(
writer);
1732 {
return gridView_; }
1748 auxEqModules_.push_back(
auxMod);
1751 if (enableGridAdaptation_
1752 && !std::is_same<DiscreteFunction, BlockVectorWrapper>::value)
1754 throw std::invalid_argument(
"Problems which require auxiliary modules cannot be used in"
1755 " conjunction with dune-fem");
1772 auxEqModules_.clear();
1773 linearizer_->eraseMatrix();
1774 newtonMethod_.eraseMatrix();
1781 {
return auxEqModules_.size(); }
1799 {
return enableIntensiveQuantityCache_ || enableThermodynamicHints_; }
1801 const Timer& prePostProcessTimer()
const
1802 {
return prePostProcessTimer_; }
1804 const Timer& linearizeTimer()
const
1805 {
return linearizeTimer_; }
1807 const Timer& solveTimer()
const
1808 {
return solveTimer_; }
1810 const Timer& updateTimer()
const
1811 {
return updateTimer_; }
1813 template<
class Serializer>
1821 bool operator==(
const FvBaseDiscretization& rhs)
const
1823 return std::equal(this->solution_.begin(),
this->solution_.end(),
1824 rhs.solution_.begin(), rhs.solution_.end(),
1825 [](
const auto& x,
const auto&
y)
1832 void resizeAndResetIntensiveQuantitiesCache_()
1836 size_t numDof = asImp_().numGridDof();
1838 storageCache_[
timeIdx].resize(numDof);
1844 size_t numDof = asImp_().numGridDof();
1846 intensiveQuantityCache_[
timeIdx].resize(numDof);
1847 intensiveQuantityCacheUpToDate_[
timeIdx].resize(numDof);
1852 template <
class Context>
1853 void supplementInitialSolution_(PrimaryVariables&,
1870 this->outputModules_.push_back(
mod);
1877 {
return localLinearizer_.localResidual(); }
1883 {
return gridView_.comm().rank() == 0; }
1885 Implementation& asImp_()
1886 {
return *
static_cast<Implementation*
>(
this); }
1887 const Implementation& asImp_()
const
1888 {
return *
static_cast<const Implementation*
>(
this); }
1892 Simulator& simulator_;
1898 ElementMapper elementMapper_;
1899 VertexMapper vertexMapper_;
1902 std::vector<BaseAuxiliaryModule<TypeTag>*> auxEqModules_;
1904 NewtonMethod newtonMethod_;
1906 Timer prePostProcessTimer_;
1907 Timer linearizeTimer_;
1912 std::vector<LocalLinearizer> localLinearizer_;
1915 Linearizer *linearizer_;
1919 mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize];
1921 mutable std::vector<unsigned char> intensiveQuantityCacheUpToDate_[historySize];
1923 mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;
1925 std::list<BaseOutputModule<TypeTag>*> outputModules_;
1927 Scalar gridTotalVolume_;
1928 std::vector<Scalar> dofTotalVolume_;
1929 std::vector<bool> isLocalDof_;
1931 mutable GlobalEqVector storageCache_[historySize];
1933 bool enableGridAdaptation_;
1934 bool enableIntensiveQuantityCache_;
1935 bool enableStorageCache_;
1936 bool enableThermodynamicHints_;
1944template<
class TypeTag>
1954 template<
class Serializer>
1956 template<
class SolutionType>
1957 static void serializeOp(Serializer&
serializer,
1969 if (this->enableGridAdaptation_) {
1970 throw std::invalid_argument(
"Grid adaptation need to use"
1971 " BaseDiscretization = FvBaseDiscretizationFemAdapt"
1972 " which currently requires the presence of the"
1973 " dune-fem module");
1975 size_t numDof = this->asImp_().numGridDof();
1977 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:1946
Definition fvbasediscretization.hh:343
The base class for the finite volume discretization schemes.
Definition fvbasediscretization.hh:293
LocalLinearizer & localLinearizer(unsigned openMpThreadId)
Definition fvbasediscretization.hh:1180
size_t numAuxiliaryDof() const
Returns the number of degrees of freedom (DOFs) of the auxiliary equations.
Definition fvbasediscretization.hh:1486
void prepareOutputFields() const
Prepare the quantities relevant for the current solution to be appended to the output writers.
Definition fvbasediscretization.hh:1675
void shiftIntensiveQuantityCache(unsigned numSlots=1)
Move the intensive quantities for a given time index to the back.
Definition fvbasediscretization.hh:780
void adaptGrid()
Called by the update() method when the grid should be refined.
Definition fvbasediscretization.hh:1350
void addAuxiliaryModule(BaseAuxiliaryModule< TypeTag > *auxMod)
Add a module for an auxiliary equation.
Definition fvbasediscretization.hh:1745
void setIntensiveQuantitiesCacheEntryValidity(unsigned globalIdx, unsigned timeIdx, bool newValue) const
Invalidate the cache for a given intensive quantities object.
Definition fvbasediscretization.hh:698
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:602
void updateSuccessful()
Called by the update() method if it was successful.
Definition fvbasediscretization.hh:1344
static std::string discretizationName()
Returns a string of discretization's human-readable name.
Definition fvbasediscretization.hh:1536
BaseAuxiliaryModule< TypeTag > * auxiliaryModule(unsigned auxEqModIdx)
Returns a given module for auxiliary equations.
Definition fvbasediscretization.hh:1786
bool isLocalDof(unsigned globalIdx) const
Returns if the overlap of the volume ofa degree of freedom is non-zero.
Definition fvbasediscretization.hh:1121
LocalResidual & localResidual_()
Reference to the local residal object.
Definition fvbasediscretization.hh:1876
void registerOutputModules_()
Register all output modules which make sense for the model.
Definition fvbasediscretization.hh:1866
bool enableGridAdaptation() const
Returns whether the grid ought to be adapted to the solution during the simulation.
Definition fvbasediscretization.hh:541
const NewtonMethod & newtonMethod() const
Returns the newton method object.
Definition fvbasediscretization.hh:616
SolutionVector & mutableSolution(unsigned timeIdx) const
Definition fvbasediscretization.hh:1149
void advanceTimeLevel()
Called by the problem if a time integration was successful, post processing of the solution is done a...
Definition fvbasediscretization.hh:1387
NewtonMethod & newtonMethod()
Returns the newton method object.
Definition fvbasediscretization.hh:610
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices.
Definition fvbasediscretization.hh:1513
const EqVector & cachedStorage(unsigned globalIdx, unsigned timeIdx) const
Retrieve an entry of the cache for the storage term.
Definition fvbasediscretization.hh:835
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:1569
void updateFailed()
Called by the update() method if it was unsuccessful.
Definition fvbasediscretization.hh:1361
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition fvbasediscretization.hh:1337
Scalar globalResidual(GlobalEqVector &dest) const
Compute the global residual for the current solution vector.
Definition fvbasediscretization.hh:881
LocalResidual & localResidual(unsigned openMpThreadId)
Definition fvbasediscretization.hh:1191
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition fvbasediscretization.hh:1439
void setEnableStorageCache(bool enableStorageCache)
Set the value of enable storage cache.
Definition fvbasediscretization.hh:822
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition fvbasediscretization.hh:1556
Scalar eqWeight(unsigned, unsigned) const
Returns the relative weight of an equation.
Definition fvbasediscretization.hh:1213
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition fvbasediscretization.hh:1201
void deserialize(Restarter &)
Deserializes the state of the model.
Definition fvbasediscretization.hh:1424
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:994
Scalar gridTotalVolume() const
Returns the volume of the whole grid which represents the spatial domain.
Definition fvbasediscretization.hh:1128
const IntensiveQuantities * thermodynamicHint(unsigned globalIdx, unsigned timeIdx) const
Return the thermodynamic hint for a entity on the grid at given time.
Definition fvbasediscretization.hh:634
const Linearizer & linearizer() const
Returns the operator linearizer for the global jacobian of the problem.
Definition fvbasediscretization.hh:1157
void updateCachedStorage(unsigned globalIdx, unsigned timeIdx, const EqVector &value) const
Set an entry of the cache for the storage term.
Definition fvbasediscretization.hh:852
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:1587
Scalar relativeDofError(unsigned vertexIdx, const PrimaryVariables &pv1, const PrimaryVariables &pv2) const
Returns the relative error between two vectors of primary variables.
Definition fvbasediscretization.hh:1225
Scalar globalResidual(GlobalEqVector &dest, const SolutionVector &u) const
Compute the global residual for an arbitrary solution vector.
Definition fvbasediscretization.hh:865
SolutionVector & solution(unsigned timeIdx)
Definition fvbasediscretization.hh:1142
void addOutputModule(BaseOutputModule< TypeTag > *newModule)
Add an module for writing visualization output after a timestep.
Definition fvbasediscretization.hh:1575
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:1464
const LocalLinearizer & localLinearizer(unsigned openMpThreadId) const
Returns the local jacobian which calculates the local stiffness matrix for an arbitrary element.
Definition fvbasediscretization.hh:1175
bool update()
Try to progress the model to the next timestep.
Definition fvbasediscretization.hh:1246
void clearAuxiliaryModules()
Causes the list of auxiliary equations to be cleared.
Definition fvbasediscretization.hh:1770
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices.
Definition fvbasediscretization.hh:1519
size_t numGridDof() const
Returns the number of degrees of freedom (DOFs) for the computational grid.
Definition fvbasediscretization.hh:1480
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition fvbasediscretization.hh:1329
void appendOutputFields(BaseOutputWriter &writer) const
Append the quantities relevant for the current solution to an output writer.
Definition fvbasediscretization.hh:1720
void applyInitialSolution()
Applies the initial solution for all degrees of freedom to which the model applies.
Definition fvbasediscretization.hh:548
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:680
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition fvbasediscretization.hh:1544
void invalidateIntensiveQuantitiesCache(unsigned timeIdx) const
Invalidate the whole intensive quantity cache for time index.
Definition fvbasediscretization.hh:713
Linearizer & linearizer()
Returns the object which linearizes the global system of equations at the current solution.
Definition fvbasediscretization.hh:1164
const BaseAuxiliaryModule< TypeTag > * auxiliaryModule(unsigned auxEqModIdx) const
Returns a given module for auxiliary equations.
Definition fvbasediscretization.hh:1792
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:942
Scalar dofTotalVolume(unsigned globalIdx) const
Returns the volume of a given control volume.
Definition fvbasediscretization.hh:1113
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:1136
bool verbose_() const
Returns whether messages should be printed.
Definition fvbasediscretization.hh:1882
const LocalResidual & localResidual(unsigned openMpThreadId) const
Returns the object to calculate the local residual function.
Definition fvbasediscretization.hh:1186
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization's degrees of freedoms are to indices.
Definition fvbasediscretization.hh:1507
bool storeIntensiveQuantities() const
Returns true if the cache for intensive quantities is enabled.
Definition fvbasediscretization.hh:1798
void serialize(Restarter &)
Serializes the current state of the model.
Definition fvbasediscretization.hh:1410
size_t numTotalDof() const
Returns the total number of degrees of freedom (i.e., grid plux auxiliary DOFs)
Definition fvbasediscretization.hh:1500
void resetLinearizer()
Resets the Jacobian matrix linearizer, so that the boundary types can be altered.
Definition fvbasediscretization.hh:1526
bool enableStorageCache() const
Returns true iff the storage term is cached.
Definition fvbasediscretization.hh:813
size_t numAuxiliaryModules() const
Returns the number of modules for auxiliary equations.
Definition fvbasediscretization.hh:1780
const GridView & gridView() const
Reference to the grid view of the spatial domain.
Definition fvbasediscretization.hh:1731
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:654
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:92
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:1955
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.