28 #ifndef EWOMS_FV_BASE_DISCRETIZATION_HH
29 #define EWOMS_FV_BASE_DISCRETIZATION_HH
31 #include <opm/material/densead/Math.hpp>
58 #include <opm/material/common/MathToolbox.hpp>
59 #include <opm/common/Valgrind.hpp>
60 #include <opm/common/Unused.hpp>
61 #include <opm/common/ErrorMacros.hpp>
62 #include <opm/common/Exceptions.hpp>
64 #include <dune/common/fvector.hh>
65 #include <dune/common/fmatrix.hh>
66 #include <dune/istl/bvector.hh>
69 #include <dune/fem/space/common/adaptmanager.hh>
70 #include <dune/fem/space/common/restrictprolongtuple.hh>
71 #include <dune/fem/function/blockvectorfunction.hh>
72 #include <dune/fem/misc/capabilities.hh>
82 template<
class TypeTag>
85 namespace Properties {
91 Dune::MultipleCodimMultipleGeomTypeMapper<
typename GET_PROP_TYPE(TypeTag, GridView),
92 Dune::MCMGVertexLayout>);
96 Dune::MultipleCodimMultipleGeomTypeMapper<
typename GET_PROP_TYPE(TypeTag, GridView),
97 Dune::MCMGElementLayout>);
102 typedef typename GET_PROP_TYPE(TypeTag, DofMapper) DofMapper;
105 typedef Ewoms::Linear::NullBorderListCreator<GridView, DofMapper> type;
117 SET_PROP(FvBaseDiscretization, JacobianMatrix)
122 typedef typename Dune::FieldMatrix<Scalar, numEq, numEq> MatrixBlock;
124 typedef typename Dune::BCRSMatrix<MatrixBlock> type;
129 SET_INT_PROP(FvBaseDiscretization, MaxTimeStepDivisions, 10);
161 Dune::BlockVector<
typename GET_PROP_TYPE(TypeTag, EqVector)>);
167 Dune::BlockVector<
typename GET_PROP_TYPE(TypeTag, EqVector)>);
178 Dune::BlockVector<
typename GET_PROP_TYPE(TypeTag, PrimaryVariables)>);
198 SET_INT_PROP(FvBaseDiscretization, ThreadsPerProcess, 1);
199 SET_BOOL_PROP(FvBaseDiscretization, UseLinearizationLock,
true);
209 SET_SCALAR_PROP(FvBaseDiscretization, MaxTimeStepSize, std::numeric_limits<Scalar>::infinity());
217 SET_BOOL_PROP(FvBaseDiscretization, EnableGridAdaptation,
false);
223 SET_INT_PROP(FvBaseDiscretization, VtkOutputFormat, Dune::VTK::ascii);
226 SET_BOOL_PROP(FvBaseDiscretization, EnableStorageCache,
false);
229 SET_BOOL_PROP(FvBaseDiscretization, EnableConstraints,
false);
235 SET_BOOL_PROP(FvBaseDiscretization, EnableIntensiveQuantityCache,
false);
239 SET_BOOL_PROP(FvBaseDiscretization, EnableThermodynamicHints,
false);
248 SET_INT_PROP(FvBaseDiscretization, TimeDiscHistorySize, 2);
252 SET_BOOL_PROP(FvBaseDiscretization, ExtensiveStorageTerm,
false);
255 SET_BOOL_PROP(FvBaseDiscretization, UseVolumetricResidual,
true);
264 template<
class TypeTag>
265 class FvBaseDiscretization
267 typedef typename GET_PROP_TYPE(TypeTag, Model) Implementation;
268 typedef typename
GET_PROP_TYPE(TypeTag, Discretization) Discretization;
269 typedef typename
GET_PROP_TYPE(TypeTag, Simulator) Simulator;
273 typedef typename
GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
274 typedef typename
GET_PROP_TYPE(TypeTag, ElementMapper) ElementMapper;
275 typedef typename
GET_PROP_TYPE(TypeTag, VertexMapper) VertexMapper;
276 typedef typename
GET_PROP_TYPE(TypeTag, DofMapper) DofMapper;
277 typedef typename
GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
278 typedef typename
GET_PROP_TYPE(TypeTag, GlobalEqVector) GlobalEqVector;
280 typedef typename
GET_PROP_TYPE(TypeTag, RateVector) RateVector;
281 typedef typename
GET_PROP_TYPE(TypeTag, BoundaryRateVector) BoundaryRateVector;
282 typedef typename
GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
283 typedef typename
GET_PROP_TYPE(TypeTag, Linearizer) Linearizer;
284 typedef typename
GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
285 typedef typename
GET_PROP_TYPE(TypeTag, BoundaryContext) BoundaryContext;
286 typedef typename
GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
287 typedef typename
GET_PROP_TYPE(TypeTag, ExtensiveQuantities) ExtensiveQuantities;
288 typedef typename
GET_PROP_TYPE(TypeTag, GradientCalculator) GradientCalculator;
290 typedef typename
GET_PROP_TYPE(TypeTag, DiscBaseOutputModule) DiscBaseOutputModule;
291 typedef typename
GET_PROP_TYPE(TypeTag, GridCommHandleFactory) GridCommHandleFactory;
292 typedef typename
GET_PROP_TYPE(TypeTag, NewtonMethod) NewtonMethod;
293 typedef typename
GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
295 typedef typename
GET_PROP_TYPE(TypeTag, LocalLinearizer) LocalLinearizer;
296 typedef typename
GET_PROP_TYPE(TypeTag, LocalResidual) LocalResidual;
303 typedef std::vector<IntensiveQuantities, Ewoms::aligned_allocator<IntensiveQuantities, alignof(IntensiveQuantities)> > IntensiveQuantitiesVector;
305 typedef typename GridView::template Codim<0>::Entity Element;
306 typedef typename GridView::template Codim<0>::Iterator ElementIterator;
308 typedef Opm::MathToolbox<Evaluation> Toolbox;
309 typedef Dune::FieldVector<Evaluation, numEq> VectorBlock;
310 typedef Dune::FieldVector<Evaluation, numEq> EvalEqVector;
312 typedef typename LocalResidual::LocalEvalBlockVector LocalEvalBlockVector;
314 class BlockVectorWrapper
317 SolutionVector blockVector_;
319 BlockVectorWrapper(
const std::string& name OPM_UNUSED,
const size_t size)
323 SolutionVector& blockVector()
324 {
return blockVector_; }
325 const SolutionVector& blockVector()
const
326 {
return blockVector_; }
330 typedef typename GET_PROP_TYPE(TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
333 typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables> DiscreteFunction;
337 typedef typename Problem :: RestrictProlongOperator ProblemRestrictProlongOperator;
340 typedef Dune::Fem::RestrictProlongDefault< DiscreteFunction > DiscreteFunctionRestrictProlong;
341 typedef Dune::Fem::RestrictProlongTuple< DiscreteFunctionRestrictProlong, ProblemRestrictProlongOperator > RestrictProlong;
343 typedef Dune::Fem::AdaptationManager<Grid, RestrictProlong > AdaptationManager;
345 typedef BlockVectorWrapper DiscreteFunction;
346 typedef size_t DiscreteFunctionSpace;
350 FvBaseDiscretization(
const FvBaseDiscretization& );
356 FvBaseDiscretization(Simulator& simulator)
357 : simulator_(simulator)
358 , gridView_(simulator.gridView())
359 , elementMapper_(gridView_)
360 , vertexMapper_(gridView_)
361 , newtonMethod_(simulator)
362 , localLinearizer_(ThreadManager::maxThreads())
363 , linearizer_(new Linearizer())
365 , space_( simulator.gridManager().gridPart() )
367 , space_( asImp_().numGridDof() )
369 , enableGridAdaptation_(
EWOMS_GET_PARAM(TypeTag, bool, EnableGridAdaptation) )
372 if (enableGridAdaptation_ && !Dune::Fem::Capabilities::isLocallyAdaptive<Grid>::v)
373 OPM_THROW(Opm::NotImplemented,
374 "Grid adaptation enabled, but chosen Grid is not capable of adaptivity");
376 if (enableGridAdaptation_)
377 OPM_THROW(Opm::NotImplemented,
378 "Grid adaptation currently requires the presence of the dune-fem module");
380 bool isEcfv = std::is_same<Discretization, EcfvDiscretization<TypeTag> >::value;
381 if (enableGridAdaptation_ && !isEcfv)
382 OPM_THROW(Opm::NotImplemented,
383 "Grid adaptation currently only works for the element-centered finite "
384 "volume discretization (is: " << Dune::className<Discretization>() <<
")");
386 enableStorageCache_ =
EWOMS_GET_PARAM(TypeTag,
bool, EnableStorageCache);
388 size_t numDof = asImp_().numGridDof();
389 for (
unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx) {
390 solution_[timeIdx].reset(
new DiscreteFunction(
"solution", space_));
392 if (storeIntensiveQuantities()) {
393 intensiveQuantityCache_[timeIdx].resize(numDof);
394 intensiveQuantityCacheUpToDate_[timeIdx].resize(numDof,
false);
397 if (enableStorageCache_)
398 storageCache_[timeIdx].resize(numDof);
401 resizeAndResetIntensiveQuantitiesCache_();
402 asImp_().registerOutputModules_();
405 ~FvBaseDiscretization()
408 auto modIt = outputModules_.begin();
409 const auto& modEndIt = outputModules_.end();
410 for (; modIt != modEndIt; ++modIt)
421 Linearizer::registerParameters();
422 LocalLinearizer::registerParameters();
423 LocalResidual::registerParameters();
424 GradientCalculator::registerParameters();
425 IntensiveQuantities::registerParameters();
426 ExtensiveQuantities::registerParameters();
432 EWOMS_REGISTER_PARAM(TypeTag,
bool, EnableGridAdaptation,
"Enable adaptive grid refinement/coarsening");
433 EWOMS_REGISTER_PARAM(TypeTag,
bool, EnableVtkOutput,
"Global switch for turing on writing VTK files");
435 EWOMS_REGISTER_PARAM(TypeTag,
bool, EnableIntensiveQuantityCache,
"Turn on caching of intensive quantities");
436 EWOMS_REGISTER_PARAM(TypeTag,
bool, EnableStorageCache,
"Store previous storage terms and avoid re-calculating them.");
445 size_t numDof = asImp_().numGridDof();
446 dofTotalVolume_.resize(numDof);
447 std::fill(dofTotalVolume_.begin(), dofTotalVolume_.end(), 0.0);
449 ElementContext elemCtx(simulator_);
450 gridTotalVolume_ = 0.0;
453 ElementIterator elemIt = gridView_.template begin<0>();
454 const ElementIterator& elemEndIt = gridView_.template end<0>();
455 for (; elemIt != elemEndIt; ++elemIt) {
456 const Element& elem = *elemIt;
457 const bool isInteriorElement = elem.partitionType() == Dune::InteriorEntity;
460 if (!isInteriorElement)
464 elemCtx.updateStencil(elem);
465 const auto& stencil = elemCtx.stencil(0);
468 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); dofIdx++) {
470 unsigned globalIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
472 Scalar dofVolume = stencil.subControlVolume(dofIdx).volume();
473 dofTotalVolume_[globalIdx] += dofVolume;
474 if (isInteriorElement)
475 gridTotalVolume_ += dofVolume;
482 isLocalDof_.resize(numDof);
483 for (
unsigned dofIdx = 0; dofIdx < numDof; ++dofIdx)
484 isLocalDof_[dofIdx] = (dofTotalVolume_[dofIdx] != 0.0);
487 const auto sumHandle =
488 GridCommHandleFactory::template sumHandle<Scalar>(dofTotalVolume_,
489 asImp_().dofMapper());
490 gridView_.communicate(*sumHandle,
491 Dune::InteriorBorder_All_Interface,
492 Dune::ForwardCommunication);
495 gridTotalVolume_ = gridView_.comm().sum(gridTotalVolume_);
497 linearizer_->init(simulator_);
499 localLinearizer_[threadId].init(simulator_);
501 resizeAndResetIntensiveQuantitiesCache_();
502 if (storeIntensiveQuantities()) {
504 for (
unsigned timeIdx = 0; timeIdx < historySize; ++ timeIdx)
505 invalidateIntensiveQuantitiesCache(timeIdx);
513 {
return enableGridAdaptation_; }
522 SolutionVector& uCur = asImp_().solution(0);
525 ElementContext elemCtx(simulator_);
528 ElementIterator elemIt = gridView_.template begin<0>();
529 const ElementIterator& elemEndIt = gridView_.template end<0>();
530 for (; elemIt != elemEndIt; ++elemIt) {
531 const Element& elem = *elemIt;
534 if (elem.partitionType() != Dune::InteriorEntity)
538 elemCtx.updateStencil(elem);
541 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); dofIdx++)
544 unsigned globalIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
548 simulator_.problem().initial(uCur[globalIdx], elemCtx, dofIdx, 0);
549 asImp_().supplementInitialSolution_(uCur[globalIdx], elemCtx, dofIdx, 0);
550 uCur[globalIdx].checkDefined();
555 asImp_().syncOverlap();
559 for (
unsigned timeIdx = 1; timeIdx < historySize; ++timeIdx)
560 solution(timeIdx) = solution(0);
562 simulator_.problem().initialSolutionApplied();
569 void prefetch(
const Element& elem OPM_UNUSED)
const
578 {
return newtonMethod_; }
584 {
return newtonMethod_; }
603 if (!enableThermodynamicHints_())
607 return cachedIntensiveQuantities(globalIdx, timeIdx);
623 if (!enableIntensiveQuantitiesCache_() ||
624 !intensiveQuantityCacheUpToDate_[timeIdx][globalIdx])
627 if (timeIdx > 0 && enableStorageCache_)
632 return &intensiveQuantityCache_[timeIdx][globalIdx];
645 unsigned timeIdx)
const
647 if (!storeIntensiveQuantities())
650 intensiveQuantityCache_[timeIdx][globalIdx] = intQuants;
651 intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] =
true;
665 if (!storeIntensiveQuantities())
668 intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] = newValue;
678 if (storeIntensiveQuantities()) {
679 std::fill(intensiveQuantityCacheUpToDate_[timeIdx].begin(),
680 intensiveQuantityCacheUpToDate_[timeIdx].end(),
695 if (!storeIntensiveQuantities())
698 if (enableStorageCache()) {
705 assert(numSlots > 0);
707 for (
unsigned timeIdx = 0; timeIdx < historySize - numSlots; ++ timeIdx) {
708 intensiveQuantityCache_[timeIdx + numSlots] = intensiveQuantityCache_[timeIdx];
709 intensiveQuantityCacheUpToDate_[timeIdx + numSlots] = intensiveQuantityCacheUpToDate_[timeIdx];
724 {
return enableStorageCache_; }
738 assert(enableStorageCache_);
739 return storageCache_[timeIdx][globalIdx];
755 assert(enableStorageCache_);
756 storageCache_[timeIdx][globalIdx] = value;
767 const SolutionVector& u)
const
769 SolutionVector tmp(asImp_().solution(0));
770 mutableSolution(0) = u;
771 Scalar res = asImp_().globalResidual(dest);
772 mutableSolution(0) = tmp;
795 ElementContext elemCtx(simulator_);
796 ElementIterator elemIt = threadedElemIt.beginParallel();
797 LocalEvalBlockVector residual, storageTerm;
799 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
800 const Element& elem = *elemIt;
801 if (elem.partitionType() != Dune::InteriorEntity)
804 elemCtx.updateAll(elem);
805 residual.resize(elemCtx.numDof(0));
806 storageTerm.resize(elemCtx.numPrimaryDof(0));
807 asImp_().localResidual(threadId).eval(residual, elemCtx);
809 size_t numPrimaryDof = elemCtx.numPrimaryDof(0);
811 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx) {
812 unsigned globalI = elemCtx.globalSpaceIndex(dofIdx, 0);
813 for (
unsigned eqIdx = 0; eqIdx < numEq; ++ eqIdx)
814 dest[globalI][eqIdx] += Toolbox::value(residual[dofIdx][eqIdx]);
821 const auto sumHandle =
822 GridCommHandleFactory::template sumHandle<EqVector>(dest, asImp_().dofMapper());
823 gridView_.communicate(*sumHandle,
824 Dune::InteriorBorder_InteriorBorder_Interface,
825 Dune::ForwardCommunication);
831 Scalar result2 = dest.two_norm2();
832 result2 = asImp_().gridView().comm().sum(result2);
834 return std::sqrt(result2);
856 ElementContext elemCtx(simulator_);
857 ElementIterator elemIt = threadedElemIt.beginParallel();
858 LocalEvalBlockVector elemStorage;
862 elemCtx.setEnableStorageCache(
false);
864 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
865 const Element& elem = *elemIt;
866 if (elem.partitionType() != Dune::InteriorEntity)
869 elemCtx.updateStencil(elem);
870 elemCtx.updatePrimaryIntensiveQuantities(timeIdx);
872 size_t numPrimaryDof = elemCtx.numPrimaryDof(timeIdx);
873 elemStorage.resize(numPrimaryDof);
875 localResidual(threadId).evalStorage(elemStorage, elemCtx, timeIdx);
878 for (
unsigned dofIdx = 0; dofIdx < numPrimaryDof; ++dofIdx)
879 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx)
880 storage[eqIdx] += Toolbox::value(elemStorage[dofIdx][eqIdx]);
885 storage = gridView_.comm().sum(storage);
898 Scalar totalBoundaryArea(0.0);
899 Scalar totalVolume(0.0);
900 EvalEqVector totalRate(0.0);
904 if (tolerance <= 0) {
906 simulator_.model().newtonMethod().tolerance()
907 * simulator_.model().gridTotalVolume()
912 assert(historySize == 2);
914 EqVector storageBeginTimeStep(0.0);
915 globalStorage(storageBeginTimeStep, 1);
917 EqVector storageEndTimeStep(0.0);
918 globalStorage(storageEndTimeStep, 0);
921 ElementContext elemCtx(simulator_);
922 elemCtx.setEnableStorageCache(
false);
923 auto eIt = simulator_.gridView().template begin<0>();
924 const auto& elemEndIt = simulator_.gridView().template end<0>();
925 for (; eIt != elemEndIt; ++eIt) {
926 if (eIt->partitionType() != Dune::InteriorEntity)
929 elemCtx.updateAll(*eIt);
932 if (elemCtx.onBoundary()) {
933 BoundaryContext boundaryCtx(elemCtx);
935 for (
unsigned faceIdx = 0; faceIdx < boundaryCtx.numBoundaryFaces(0); ++faceIdx) {
936 BoundaryRateVector values;
937 simulator_.problem().boundary(values,
941 Opm::Valgrind::CheckDefined(values);
943 unsigned dofIdx = boundaryCtx.interiorScvIndex(faceIdx, 0);
944 const auto& insideIntQuants = elemCtx.intensiveQuantities(dofIdx, 0);
947 boundaryCtx.boundarySegmentArea(faceIdx, 0)
948 * insideIntQuants.extrusionFactor();
950 for (
unsigned i = 0; i < values.size(); ++i)
953 totalBoundaryArea += bfArea;
954 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx)
955 totalRate[eqIdx] += values[eqIdx];
960 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++ dofIdx) {
962 simulator_.problem().source(values,
966 Opm::Valgrind::CheckDefined(values);
968 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
970 elemCtx.dofVolume(dofIdx, 0)
971 * intQuants.extrusionFactor();
972 for (
unsigned eqIdx = 0; eqIdx < numEq; ++ eqIdx)
973 totalRate[eqIdx] += -dofVolume*Toolbox::value(values[eqIdx]);
974 totalVolume += dofVolume;
979 const auto& comm = simulator_.gridView().comm();
980 totalRate = comm.sum(totalRate);
981 totalBoundaryArea = comm.sum(totalBoundaryArea);
982 totalVolume = comm.sum(totalVolume);
984 if (comm.rank() == 0) {
985 EqVector storageRate = storageBeginTimeStep;
986 storageRate -= storageEndTimeStep;
987 storageRate /= simulator_.timeStepSize();
989 std::cout <<
"storage at beginning of time step: " << storageBeginTimeStep <<
"\n";
990 std::cout <<
"storage at end of time step: " << storageEndTimeStep <<
"\n";
991 std::cout <<
"rate based on storage terms: " << storageRate <<
"\n";
992 std::cout <<
"rate based on source and boundary terms: " << totalRate <<
"\n";
993 std::cout <<
"difference in rates: ";
994 for (
unsigned eqIdx = 0; eqIdx < EqVector::dimension; ++eqIdx)
995 std::cout << (storageRate[eqIdx] - Toolbox::value(totalRate[eqIdx])) <<
" ";
998 for (
unsigned eqIdx = 0; eqIdx < EqVector::dimension; ++eqIdx) {
1000 (std::abs(storageRate[eqIdx]) + Toolbox::value(totalRate[eqIdx]))*tolerance;
1001 eps = std::max(tolerance, eps);
1002 assert(std::abs(storageRate[eqIdx] - Toolbox::value(totalRate[eqIdx])) <= eps);
1014 {
return dofTotalVolume_[globalIdx]; }
1022 {
return isLocalDof_[globalIdx]; }
1029 {
return gridTotalVolume_; }
1038 return solution_[timeIdx]->blockVector();
1046 return solution_[timeIdx]->blockVector();
1055 return solution_[timeIdx]->blockVector();
1064 {
return *linearizer_; }
1071 {
return *linearizer_; }
1082 {
return localLinearizer_[openMpThreadId]; }
1087 {
return localLinearizer_[openMpThreadId]; }
1093 {
return asImp_().localLinearizer(openMpThreadId).localResidual(); }
1098 {
return asImp_().localLinearizer(openMpThreadId).localResidual(); }
1109 Scalar absPv = std::abs(asImp_().solution(1)[globalDofIdx][pvIdx]);
1110 return 1.0/std::max(absPv, 1.0);
1119 Scalar
eqWeight(
unsigned globalVertexIdx OPM_UNUSED,
unsigned eqIdx OPM_UNUSED)
const
1132 const PrimaryVariables& pv1,
1133 const PrimaryVariables& pv2)
const
1135 Scalar result = 0.0;
1136 for (
unsigned j = 0; j < numEq; ++j) {
1137 Scalar weight = asImp_().primaryVarWeight(vertexIdx, j);
1138 Scalar eqErr = std::abs((pv1[j] - pv2[j])*weight);
1142 result = std::max(result, eqErr);
1157 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i)
1158 asImp_().solution(0)[i].checkDefined();
1159 #endif // HAVE_VALGRIND
1162 prePostProcessTimer_.halt();
1163 linearizeTimer_.halt();
1165 updateTimer_.halt();
1167 prePostProcessTimer_.start();
1168 asImp_().updateBegin();
1169 prePostProcessTimer_.stop();
1171 bool converged =
false;
1174 converged = newtonMethod_.apply();
1177 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1178 linearizeTimer_ += newtonMethod_.linearizeTimer();
1179 solveTimer_ += newtonMethod_.solveTimer();
1180 updateTimer_ += newtonMethod_.updateTimer();
1185 prePostProcessTimer_ += newtonMethod_.prePostProcessTimer();
1186 linearizeTimer_ += newtonMethod_.linearizeTimer();
1187 solveTimer_ += newtonMethod_.solveTimer();
1188 updateTimer_ += newtonMethod_.updateTimer();
1190 prePostProcessTimer_.start();
1192 asImp_().updateSuccessful();
1194 asImp_().updateFailed();
1195 prePostProcessTimer_.stop();
1201 for (
size_t i = 0; i < asImp_().solution(0).size(); ++i) {
1202 for (
size_t eqIdx = 0; eqIdx < numEq; ++eqIdx)
1203 Opm::Valgrind::CheckDefined(asImp_().solution(0)[i][eqIdx]);
1205 #endif // HAVE_VALGRIND
1243 if (enableGridAdaptation_)
1246 if( simulator_.problem().markForGridAdaptation() )
1249 adaptationManager().adapt();
1257 simulator_.problem().gridChanged();
1260 elementMapper_.update();
1261 vertexMapper_.update();
1264 auto outIt = outputModules_.begin();
1265 auto outEndIt = outputModules_.end();
1266 for (; outIt != outEndIt; ++outIt)
1267 (*outIt)->allocBuffers();
1283 solution(0) = solution(1);
1284 invalidateIntensiveQuantitiesCache(0);
1297 asImp_().adaptGrid();
1300 solution(1) = solution(0);
1304 asImp_().shiftIntensiveQuantityCache(1);
1314 template <
class Restarter>
1317 OPM_THROW(std::runtime_error,
1318 "Not implemented: The discretization chosen for this problem does not support"
1319 " restart files. (serialize() method unimplemented)");
1329 template <
class Restarter>
1332 OPM_THROW(std::runtime_error,
1333 "Not implemented: The discretization chosen for this problem does not support"
1334 " restart files. (deserialize() method unimplemented)");
1345 template <
class DofEntity>
1347 const DofEntity& dof)
1349 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
1352 if (!outstream.good()) {
1353 OPM_THROW(std::runtime_error,
"Could not serialize degree of freedom " << dofIdx);
1356 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
1357 outstream << solution(0)[dofIdx][eqIdx] <<
" ";
1369 template <
class DofEntity>
1371 const DofEntity& dof)
1373 unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
1375 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
1376 if (!instream.good())
1377 OPM_THROW(std::runtime_error,
1378 "Could not deserialize degree of freedom " << dofIdx);
1379 instream >> solution(0)[dofIdx][eqIdx];
1387 { OPM_THROW(std::logic_error,
1388 "The discretization class must implement the numGridDof() method!"); }
1396 auto auxModIt = auxEqModules_.begin();
1397 const auto& auxModEndIt = auxEqModules_.end();
1398 for (; auxModIt != auxModEndIt; ++auxModIt)
1399 result += (*auxModIt)->numDofs();
1408 {
return asImp_().numGridDof() + numAuxiliaryDof(); }
1415 { OPM_THROW(std::logic_error,
1416 "The discretization class must implement the dofMapper() method!"); }
1422 {
return vertexMapper_; }
1428 {
return elementMapper_; }
1437 linearizer_ =
new Linearizer;
1438 linearizer_->init(simulator_);
1454 std::ostringstream oss;
1455 oss <<
"primary variable_" << pvIdx;
1466 std::ostringstream oss;
1467 oss <<
"equation_" << eqIdx;
1484 { outputModules_.push_back(newModule); }
1494 template <
class VtkMultiWriter>
1496 const SolutionVector& u,
1497 const GlobalEqVector& deltaU)
const
1499 typedef std::vector<double> ScalarBuffer;
1501 GlobalEqVector globalResid(u.size());
1502 asImp_().globalResidual(globalResid, u);
1505 size_t numGridDof = asImp_().numGridDof();
1508 ScalarBuffer* def[numEq];
1509 ScalarBuffer* delta[numEq];
1510 ScalarBuffer* priVars[numEq];
1511 ScalarBuffer* priVarWeight[numEq];
1513 for (
unsigned pvIdx = 0; pvIdx < numEq; ++pvIdx) {
1520 for (
unsigned globalIdx = 0; globalIdx < numGridDof; ++ globalIdx)
1522 for (
unsigned pvIdx = 0; pvIdx < numEq; ++pvIdx) {
1523 (*priVars[pvIdx])[globalIdx] = u[globalIdx][pvIdx];
1524 (*priVarWeight[pvIdx])[globalIdx] = asImp_().primaryVarWeight(globalIdx, pvIdx);
1525 (*delta[pvIdx])[globalIdx] = - deltaU[globalIdx][pvIdx];
1526 (*def[pvIdx])[globalIdx] = globalResid[globalIdx][pvIdx];
1529 PrimaryVariables uOld(u[globalIdx]);
1530 PrimaryVariables uNew(uOld);
1531 uNew -= deltaU[globalIdx];
1532 (*relError)[globalIdx] = asImp_().relativeDofError(globalIdx, uOld, uNew);
1535 DiscBaseOutputModule::attachScalarDofData_(writer, *relError,
"relErr");
1537 for (
unsigned i = 0; i < numEq; ++i) {
1538 std::ostringstream oss;
1539 oss.str(
""); oss <<
"priVar_" << asImp_().primaryVarName(i);
1540 DiscBaseOutputModule::attachScalarDofData_(writer,
1544 oss.str(
""); oss <<
"delta_" << asImp_().primaryVarName(i);
1545 DiscBaseOutputModule::attachScalarDofData_(writer,
1549 oss.str(
""); oss <<
"weight_" << asImp_().primaryVarName(i);
1550 DiscBaseOutputModule::attachScalarDofData_(writer,
1554 oss.str(
""); oss <<
"defect_" << asImp_().eqName(i);
1555 DiscBaseOutputModule::attachScalarDofData_(writer,
1560 asImp_().prepareOutputFields();
1561 asImp_().appendOutputFields(writer);
1570 bool needFullContextUpdate =
false;
1571 auto modIt = outputModules_.begin();
1572 const auto& modEndIt = outputModules_.end();
1573 for (; modIt != modEndIt; ++modIt) {
1574 (*modIt)->allocBuffers();
1575 needFullContextUpdate = needFullContextUpdate || (*modIt)->needExtensiveQuantities();
1581 #pragma omp parallel
1584 ElementContext elemCtx(simulator_);
1585 ElementIterator elemIt = threadedElemIt.beginParallel();
1586 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
1587 const auto& elem = *elemIt;
1588 if (elem.partitionType() != Dune::InteriorEntity)
1592 if (needFullContextUpdate)
1593 elemCtx.updateAll(elem);
1595 elemCtx.updatePrimaryStencil(elem);
1596 elemCtx.updatePrimaryIntensiveQuantities(0);
1599 modIt = outputModules_.begin();
1600 for (; modIt != modEndIt; ++modIt)
1601 (*modIt)->processElement(elemCtx);
1612 auto modIt = outputModules_.begin();
1613 const auto& modEndIt = outputModules_.end();
1614 for (; modIt != modEndIt; ++modIt)
1615 (*modIt)->commitBuffers(writer);
1622 {
return gridView_; }
1637 auxMod->setDofOffset(numTotalDof());
1638 auxEqModules_.push_back(auxMod);
1641 if (enableGridAdaptation_
1642 && !std::is_same<DiscreteFunction, BlockVectorWrapper>::value)
1644 OPM_THROW(Opm::NotImplemented,
1645 "Problems which require auxiliary modules cannot be used in conjunction "
1649 size_t numDof = numTotalDof();
1650 for (
unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx)
1651 solution(timeIdx).resize(numDof);
1653 auxMod->applyInitial();
1663 auxEqModules_.clear();
1664 linearizer_->eraseMatrix();
1665 newtonMethod_.eraseMatrix();
1672 {
return auxEqModules_.size(); }
1678 {
return auxEqModules_[auxEqModIdx]; }
1683 std::shared_ptr<const BaseAuxiliaryModule<TypeTag> >
auxiliaryModule(
unsigned auxEqModIdx)
const
1684 {
return auxEqModules_[auxEqModIdx]; }
1690 {
return enableIntensiveQuantitiesCache_() || enableThermodynamicHints_(); }
1693 AdaptationManager& adaptationManager()
1695 if( ! adaptationManager_ )
1699 restrictProlong_.reset(
1700 new RestrictProlong( DiscreteFunctionRestrictProlong(*(solution_[ 0] )),
1701 simulator_.problem().restrictProlongOperator() ) );
1702 adaptationManager_.reset(
new AdaptationManager( simulator_.gridManager().grid(), *restrictProlong_ ) );
1704 return *adaptationManager_;
1709 {
return prePostProcessTimer_; }
1712 {
return linearizeTimer_; }
1715 {
return solveTimer_; }
1718 {
return updateTimer_; }
1721 void resizeAndResetIntensiveQuantitiesCache_()
1724 if (enableStorageCache()) {
1725 size_t numDof = asImp_().numGridDof();
1726 for (
unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx) {
1727 storageCache_[timeIdx].resize(numDof);
1732 if (storeIntensiveQuantities()) {
1733 size_t numDof = asImp_().numGridDof();
1734 for(
unsigned timeIdx=0; timeIdx<historySize; ++timeIdx) {
1735 intensiveQuantityCache_[timeIdx].resize(numDof);
1736 intensiveQuantityCacheUpToDate_[timeIdx].resize(numDof);
1737 invalidateIntensiveQuantitiesCache(timeIdx);
1741 template <
class Context>
1742 void supplementInitialSolution_(PrimaryVariables& priVars OPM_UNUSED,
1743 const Context& context OPM_UNUSED,
1744 unsigned dofIdx OPM_UNUSED,
1745 unsigned timeIdx OPM_UNUSED)
1748 static bool enableIntensiveQuantitiesCache_()
1749 {
return EWOMS_GET_PARAM(TypeTag,
bool, EnableIntensiveQuantityCache); }
1751 static bool enableThermodynamicHints_()
1765 this->outputModules_.push_back(mod);
1772 {
return localLinearizer_.localResidual(); }
1778 {
return gridView_.comm().rank() == 0; }
1780 Implementation& asImp_()
1781 {
return *
static_cast<Implementation*
>(
this); }
1782 const Implementation& asImp_()
const
1783 {
return *
static_cast<const Implementation*
>(
this); }
1787 Simulator& simulator_;
1793 ElementMapper elementMapper_;
1794 VertexMapper vertexMapper_;
1797 std::vector<std::shared_ptr<BaseAuxiliaryModule<TypeTag> > > auxEqModules_;
1799 NewtonMethod newtonMethod_;
1807 std::vector<LocalLinearizer> localLinearizer_;
1810 Linearizer *linearizer_;
1814 mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize];
1815 mutable std::vector<bool> intensiveQuantityCacheUpToDate_[historySize];
1817 DiscreteFunctionSpace space_;
1818 mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;
1821 std::unique_ptr< RestrictProlong > restrictProlong_;
1822 std::unique_ptr< AdaptationManager> adaptationManager_;
1826 std::list<BaseOutputModule<TypeTag>*> outputModules_;
1828 Scalar gridTotalVolume_;
1829 std::vector<Scalar> dofTotalVolume_;
1830 std::vector<bool> isLocalDof_;
1832 bool enableGridAdaptation_;
1833 mutable GlobalEqVector storageCache_[historySize];
1834 bool enableStorageCache_;
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition: fvbasediscretization.hh:1346
void addOutputModule(BaseOutputModule< TypeTag > *newModule)
Add an module for writing visualization output after a timestep.
Definition: fvbasediscretization.hh:1483
This is a stand-alone version of boost::alignment::aligned_allocator from Boost 1.58.
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition: timerguard.hh:40
The base class for all output writers.
Definition: baseoutputwriter.hh:43
Manages the initializing and running of time dependent problems.
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization's degrees of freedoms are to indices...
Definition: fvbasediscretization.hh:1414
SolutionVector & mutableSolution(unsigned timeIdx) const
const
Definition: fvbasediscretization.hh:1053
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
The common code for the linearizers of non-linear systems of equations.
Definition: fvbaselinearizer.hh:65
Scalar globalResidual(GlobalEqVector &dest) const
Compute the global residual for the current solution vector.
Definition: fvbasediscretization.hh:782
Simplifies multi-threaded capabilities.
Definition: threadmanager.hh:52
bool enableStorageCache() const
Returns true iff the storage term is cached.
Definition: fvbasediscretization.hh:723
bool verbose_() const
Returns whether messages should be printed.
Definition: fvbasediscretization.hh:1777
Scalar gridTotalVolume() const
Returns the volume of the whole grid which represents the spatial domain.
Definition: fvbasediscretization.hh:1028
ScalarBuffer * allocateManagedScalarBuffer(size_t numEntities)
Allocate a managed buffer for a scalar field.
Definition: vtkmultiwriter.hh:154
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition: fvbasediscretization.hh:1217
This class stores an array of IntensiveQuantities objects, one intensive quantities object for each o...
Linearizer & linearizer()
Returns the object which linearizes the global system of equations at the current solution...
Definition: fvbasediscretization.hh:1070
Base class for specifying auxiliary equations.
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:63
void finishInit()
Apply the initial conditions to the model.
Definition: fvbasediscretization.hh:442
void prepareOutputFields() const
Prepare the quantities relevant for the current solution to be appended to the output writers...
Definition: fvbasediscretization.hh:1568
void applyInitialSolution()
Applies the initial solution for all degrees of freedom to which the model applies.
Definition: fvbasediscretization.hh:519
Represents all quantities which available on boundary segments.
Definition: fvbaseboundarycontext.hh:45
SolutionVector & solution(unsigned timeIdx)
const
Definition: fvbasediscretization.hh:1044
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition: fvbasediscretization.hh:1225
Scalar globalResidual(GlobalEqVector &dest, const SolutionVector &u) const
Compute the global residual for an arbitrary solution vector.
Definition: fvbasediscretization.hh:766
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition: threadedentityiterator.hh:41
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
size_t numAuxiliaryModules() const
Returns the number of modules for auxiliary equations.
Definition: fvbasediscretization.hh:1671
This is a grid manager which does not create any border list.
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: fvbasediscretization.hh:1107
bool enableGridAdaptation() const
Returns whether the grid ought to be adapted to the solution during the simulation.
Definition: fvbasediscretization.hh:512
Simplifies multi-threaded capabilities.
Provide the properties at a face which make sense indepentently of the conserved quantities.
Definition: fvbaseextensivequantities.hh:44
const EqVector & cachedStorage(unsigned globalIdx, unsigned timeIdx) const
Retrieve an entry of the cache for the storage term.
Definition: fvbasediscretization.hh:736
void appendOutputFields(BaseOutputWriter &writer) const
Append the quantities relevant for the current solution to an output writer.
Definition: fvbasediscretization.hh:1610
bool isLocalDof(unsigned globalIdx) const
Returns if the overlap of the volume ofa degree of freedom is non-zero.
Definition: fvbasediscretization.hh:1021
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
Represents all quantities which available for calculating constraints.
void invalidateIntensiveQuantitiesCache(unsigned timeIdx) const
Invalidate the whole intensive quantity cache for time index.
Definition: fvbasediscretization.hh:676
void updateSuccessful()
Called by the update() method if it was successful.
Definition: fvbasediscretization.hh:1232
Base class for the model specific class which provides access to all intensive (i.e., volume averaged) quantities.
Definition: fvbaseintensivequantities.hh:45
A Newton method for models using a finite volume discretization.
LocalResidual & localResidual_()
Reference to the local residal object.
Definition: fvbasediscretization.hh:1771
#define SET_INT_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant integer value.
Definition: propertysystem.hh:345
void registerOutputModules_()
Register all output modules which make sense for the model.
Definition: fvbasediscretization.hh:1761
static unsigned threadId()
Return the index of the current OpenMP thread.
Definition: threadmanager.hh:119
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
Base class for the model specific class which provides access to all intensive (i.e., volume averaged) quantities.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Provides data handles for parallel communication which operate on DOFs.
This class calculates gradients of arbitrary quantities at flux integration points using the two-poin...
The base class for writer modules.
Definition: baseoutputmodule.hh:80
This class calculates gradients of arbitrary quantities at flux integration points using the two-poin...
Definition: fvbasegradientcalculator.hh:48
The base class for the finite volume discretization schemes.
Provides an encapsulation to measure the system time.
Definition: timer.hh:48
LocalLinearizer & localLinearizer(unsigned openMpThreadId)
Returns the local jacobian which calculates the local stiffness matrix for an arbitrary element...
Definition: fvbasediscretization.hh:1086
void clearAuxiliaryModules()
Causes the list of auxiliary equations to be cleared.
Definition: fvbasediscretization.hh:1661
This class implements an exception-safe scoped lock-keeper.
Definition: locks.hh:65
Represents all quantities which available on boundary segments.
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices.
Definition: fvbasediscretization.hh:1427
void checkConservativeness(Scalar OPM_OPTIM_UNUSED tolerance=-1, bool OPM_OPTIM_UNUSED 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:895
bool update()
Try to progress the model to the next timestep.
Definition: fvbasediscretization.hh:1152
Represents all quantities which available for calculating constraints.
Definition: fvbaseconstraintscontext.hh:43
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition: threadmanager.hh:113
size_t numAuxiliaryDof() const
Returns the number of degrees of freedom (DOFs) of the auxiliary equations.
Definition: fvbasediscretization.hh:1393
void updateCachedStorage(unsigned globalIdx, unsigned timeIdx, const EqVector &value) const
Set an entry of the cache for the storage term.
Definition: fvbasediscretization.hh:753
Calculates the Jacobian of the local residual for finite volume spatial discretizations using a finit...
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
static std::string discretizationName()
Returns a string of discretization's human-readable name.
Definition: fvbasediscretization.hh:1444
Scalar relativeDofError(unsigned vertexIdx, const PrimaryVariables &pv1, const PrimaryVariables &pv2) const
Returns the relative error between two vectors of primary variables.
Definition: fvbasediscretization.hh:1131
The multi-dimensional Newton method.
Definition: newtonmethod.hh:56
Calculates the local residual and its Jacobian for a single element of the grid.
void updatePVWeights(const ElementContext &elemCtx OPM_UNUSED) const
Update the weights of all primary variables within an element given the complete set of intensive qua...
Definition: fvbasediscretization.hh:1477
Element-wise caculation of the residual matrix for models based on a finite volume spatial discretiza...
Definition: fvbaselocalresidual.hh:60
Class to specify constraints for a finite volume spatial discretization.
Definition: fvbaseconstraints.hh:48
const GridView & gridView() const
Reference to the grid view of the spatial domain.
Definition: fvbasediscretization.hh:1621
The common code for the linearizers of non-linear systems of equations.
const LocalLinearizer & localLinearizer(unsigned openMpThreadId) const
Returns the local jacobian which calculates the local stiffness matrix for an arbitrary element...
Definition: fvbasediscretization.hh:1081
Scalar eqWeight(unsigned globalVertexIdx OPM_UNUSED, unsigned eqIdx OPM_UNUSED) const
Returns the relative weight of an equation.
Definition: fvbasediscretization.hh:1119
The base class for the finite volume discretization schemes.
Definition: fvbasediscretization.hh:83
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition: newtonmethod.hh:209
void setIntensiveQuantitiesCacheEntryValidity(unsigned globalIdx, unsigned timeIdx, bool newValue) const
Invalidate the cache for a given intensive quantities object.
Definition: fvbasediscretization.hh:661
std::shared_ptr< BaseAuxiliaryModule< TypeTag > > auxiliaryModule(unsigned auxEqModIdx)
Returns a given module for auxiliary equations.
Definition: fvbasediscretization.hh:1677
void prefetch(const Element &elem OPM_UNUSED) const
Allows to improve the performance by prefetching all data which is associated with a given element...
Definition: fvbasediscretization.hh:569
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:48
const Linearizer & linearizer() const
Returns the operator linearizer for the global jacobian of the problem.
Definition: fvbasediscretization.hh:1063
Provides an encapsulation to measure the system time.
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: fvbasediscretization.hh:1452
NewtonMethod & newtonMethod()
Returns the newton method object.
Definition: fvbasediscretization.hh:577
const LocalResidual & localResidual(unsigned openMpThreadId) const
Returns the object to calculate the local residual function.
Definition: fvbasediscretization.hh:1092
std::shared_ptr< const BaseAuxiliaryModule< TypeTag > > auxiliaryModule(unsigned auxEqModIdx) const
Returns a given module for auxiliary equations.
Definition: fvbasediscretization.hh:1683
This class stores an array of IntensiveQuantities objects, one intensive quantities object for each o...
Definition: fvbaseelementcontext.hh:52
void adaptGrid()
Called by the update() method when the grid should be refined.
Definition: fvbasediscretization.hh:1238
Class to specify constraints for a finite volume spatial discretization.
Scalar dofTotalVolume(unsigned globalIdx) const
Returns the volume of a given control volume.
Definition: fvbasediscretization.hh:1013
const IntensiveQuantities * thermodynamicHint(unsigned globalIdx, unsigned timeIdx) const
Return the thermodynamic hint for a entity on the grid at given time.
Definition: fvbasediscretization.hh:601
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: fvbasediscretization.hh:1464
LocalResidual & localResidual(unsigned openMpThreadId)
Returns the object to calculate the local residual function. const
Definition: fvbasediscretization.hh:1097
const SolutionVector & solution(unsigned timeIdx) const
Reference to the solution at a given history index as a block vector.
Definition: fvbasediscretization.hh:1036
Represents the primary variables used by the a model.
Element-wise caculation of the residual matrix for models based on a finite volume spatial discretiza...
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:1495
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:621
A simple class which makes sure that a timer gets stopped if an exception is thrown.
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices.
Definition: fvbasediscretization.hh:1421
Provide the properties at a face which make sense indepentently of the conserved quantities.
VTK output module for the fluid composition.
Definition: vtkprimaryvarsmodule.hh:60
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:643
void serialize(Restarter &res OPM_UNUSED)
Serializes the current state of the model.
Definition: fvbasediscretization.hh:1315
size_t numTotalDof() const
Returns the total number of degrees of freedom (i.e., grid plux auxiliary DOFs)
Definition: fvbasediscretization.hh:1407
void addAuxiliaryModule(std::shared_ptr< BaseAuxiliaryModule< TypeTag > > auxMod)
Add a module for an auxiliary equation.
Definition: fvbasediscretization.hh:1635
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkprimaryvarsmodule.hh:84
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
void advanceTimeLevel()
Called by the problem if a time integration was successful, post processing of the solution is done a...
Definition: fvbasediscretization.hh:1294
Base class for specifying auxiliary equations.
Definition: baseauxiliarymodule.hh:59
void deserialize(Restarter &res OPM_UNUSED)
Deserializes the state of the model.
Definition: fvbasediscretization.hh:1330
size_t numGridDof() const
Returns the number of degrees of freedom (DOFs) for the computational grid.
Definition: fvbasediscretization.hh:1386
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
static bool storeIntensiveQuantities()
Returns true if the cache for intensive quantities is enabled.
Definition: fvbasediscretization.hh:1689
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:843
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:1370
void resetLinearizer()
Resets the Jacobian matrix linearizer, so that the boundary types can be altered. ...
Definition: fvbasediscretization.hh:1434
const NewtonMethod & newtonMethod() const
Returns the newton method object.
Definition: fvbasediscretization.hh:583
#define SET_SCALAR_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant scalar value.
Definition: propertysystem.hh:394
static void registerParameters()
Register all run-time parameters for the model.
Definition: fvbasediscretization.hh:419
void updateFailed()
Called by the update() method if it was unsuccessful.
Definition: fvbasediscretization.hh:1278
void shiftIntensiveQuantityCache(unsigned numSlots=1)
Move the intensive quantities for a given time index to the back.
Definition: fvbasediscretization.hh:693