tpfalinearizer.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef TPFA_LINEARIZER_HH
29#define TPFA_LINEARIZER_HH
30
31#include <dune/common/version.hh>
32#include <dune/common/fvector.hh>
33#include <dune/common/fmatrix.hh>
34
35#include <opm/common/Exceptions.hpp>
36#include <opm/common/TimingMacros.hpp>
37
38#include <opm/common/utility/SparseTable.hpp>
39
40#include <opm/material/common/ConditionalStorage.hpp>
41
42#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
43#include <opm/input/eclipse/Schedule/BCState.hpp>
44
51
53
54#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
55#include <opm/material/fluidsystems/BlackOilFluidSystemNonStatic.hpp>
56
57#include <cassert>
58#include <cstddef>
59#include <exception>
60#include <iostream>
61#include <map>
62#include <memory>
63#include <numeric>
64#include <set>
65#include <stdexcept>
66#include <unordered_map>
67#include <utility>
68#include <vector>
69
70#if HAVE_OPENMP
71#include <omp.h>
72#endif
73
74#include <fmt/format.h>
75
76#include <opm/common/utility/gpuDecorators.hpp>
77#include <opm/common/utility/pointerArithmetic.hpp>
79
80namespace Opm::Parameters {
81
82struct SeparateSparseSourceTerms { static constexpr bool value = false; };
83
84} // namespace Opm::Parameters
85
86namespace Opm {
87
88// forward declarations
89template<class TypeTag>
91
101template<class TypeTag>
103{
111
121
122 using Element = typename GridView::template Codim<0>::Entity;
123 using ElementIterator = typename GridView::template Codim<0>::Iterator;
124
125 using Vector = GlobalEqVector;
126
128
129 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
130 enum { historySize = getPropValue<TypeTag, Properties::TimeDiscHistorySize>() };
131 enum { dimWorld = GridView::dimensionworld };
132
133 constexpr static bool runAssemblyOnGpu = getPropValue<TypeTag, Properties::RunAssemblyOnGpu>();
134
135 using MatrixBlockCPU = typename SparseMatrixAdapter::MatrixBlock;
136 using VectorBlockCPU = Dune::FieldVector<Scalar, numEq>;
137 using ADVectorBlockCPU = GetPropType<TypeTag, Properties::RateVector>;
138
139 using GpuLinearizer = TpfaLinearizerGpu<TypeTag>;
140 friend GpuLinearizer;
141 using MatrixBlock = typename GpuLinearizer::MatrixBlock;
142 using VectorBlock = typename GpuLinearizer::VectorBlock;
143 using ADVectorBlock = typename GpuLinearizer::ADVectorBlock;
144
145 static constexpr bool linearizeNonLocalElements =
146 getPropValue<TypeTag, Properties::LinearizeNonLocalElements>();
147 static constexpr bool enableFullyImplicitThermal = (getPropValue<TypeTag, Properties::EnergyModuleType>() == EnergyModules::FullyImplicitThermal);
148 static constexpr bool enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>();
149 static constexpr bool enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>();
150 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
151 static const bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
152
153 // copying the linearizer is not a good idea
154 TpfaLinearizer(const TpfaLinearizer&) = delete;
156
157public:
159 {
160 simulatorPtr_ = nullptr;
161 separateSparseSourceTerms_ = Parameters::Get<Parameters::SeparateSparseSourceTerms>();
162 exportIndex_=-1;
163 exportCount_=-1;
164 }
165
169 static void registerParameters()
170 {
171 Parameters::Register<Parameters::EnableGpuAssemblySolverBridge>
172 ("Pass source-only serial GPU assembly directly to gpuISTL.");
173 Parameters::Register<Parameters::SeparateSparseSourceTerms>
174 ("Treat well source terms all in one go, instead of on a cell by cell basis.");
175 }
176
186 void init(Simulator& simulator)
187 {
188 simulatorPtr_ = &simulator;
189 eraseMatrix();
190 }
191
200 {
201 // Safe for CPU assembly too: the helper has no GPU buffers to release.
202 gpuLinearizer_.eraseMatrix();
203 jacobian_.reset();
204 }
205
216 {
219 }
220
232 {
233 int succeeded;
234 try {
235 linearizeDomain(fullDomain_);
236 succeeded = 1;
237 }
238 catch (const std::exception& e) {
239 std::cout << "rank " << simulator_().gridView().comm().rank()
240 << " caught an exception while linearizing:" << e.what()
241 << "\n" << std::flush;
242 succeeded = 0;
243 }
244 catch (...) {
245 std::cout << "rank " << simulator_().gridView().comm().rank()
246 << " caught an exception while linearizing"
247 << "\n" << std::flush;
248 succeeded = 0;
249 }
250 OPM_TIMEBLOCK(linearizationSynch);
251 succeeded = simulator_().gridView().comm().min(succeeded);
252
253 if (!succeeded) {
254 throw NumericalProblem("A process did not succeed in linearizing the system");
255 }
256 }
257
270 template <class SubDomainType>
271 void linearizeDomain(const SubDomainType& domain)
272 {
273 OPM_TIMEBLOCK(linearizeDomain);
274 // we defer the initialization of the Jacobian matrix until here because the
275 // auxiliary modules usually assume the problem, model and grid to be fully
276 // initialized...
277 if (!jacobian_) {
278 initFirstIteration_();
279 }
280
281 // Called here because it is no longer called from linearize_().
282 if (problem_().iterationContext().inLocalSolve()) {
283 resetSystem_(domain);
284 }
285 else {
286 resetSystem_();
287 }
288
289 linearize_(domain);
290 }
291
292 void finalize()
293 { jacobian_->finalize(); }
294
295 bool gpuSystemActive() const { return gpuLinearizer_.gpuSystemActive(); }
296
297 decltype(auto) gpuJacobian() { return gpuLinearizer_.gpuJacobian(); }
298 decltype(auto) gpuResidual() { return gpuLinearizer_.gpuResidual(); }
299 decltype(auto) flattenedGpuResidual() { return gpuLinearizer_.flattenedGpuResidual(); }
300
306 {
307 OPM_TIMEBLOCK(linearizeAuxilaryEquations);
308 // flush possible local caches into matrix structure
309 jacobian_->commit();
310
311 auto& model = model_();
312 const auto& comm = simulator_().gridView().comm();
313 for (unsigned auxModIdx = 0; auxModIdx < model.numAuxiliaryModules(); ++auxModIdx) {
314 bool succeeded = true;
315 try {
316 model.auxiliaryModule(auxModIdx)->linearize(*jacobian_, residual_);
317 }
318 catch (const std::exception& e) {
319 succeeded = false;
320
321 std::cout << "rank " << simulator_().gridView().comm().rank()
322 << " caught an exception while linearizing:" << e.what()
323 << "\n" << std::flush;
324 }
325
326 succeeded = comm.min(succeeded);
327
328 if (!succeeded) {
329 throw NumericalProblem("linearization of an auxiliary equation failed");
330 }
331 }
332 }
333
337 const SparseMatrixAdapter& jacobian() const
338 { return *jacobian_; }
339
340 SparseMatrixAdapter& jacobian()
341 { return *jacobian_; }
342
346 const GlobalEqVector& residual() const
347 { return residual_; }
348
349 GlobalEqVector& residual()
350 { return residual_; }
351
355 void exportSystem(const int idx, std::string& tag, const char *path="export")
356 {
357 const bool export_sparsity = exportIndex_ == -1;
358
359 // increment indices and generate tag
360 exportCount_ = exportIndex_ == idx ? ++exportCount_ : 0;
361 exportIndex_ = idx;
362 tag = fmt::format(fmt::runtime("_{:03d}_{:02d}"), exportIndex_, exportCount_);
363
364 fmt::print(fmt::runtime("index = {:d}\n"), exportIndex_);
365 fmt::print(fmt::runtime("count = {:d}\n"), exportCount_);
366
367 // Copies only when the GPU solver bridge owns the current Jacobian;
368 // this is a no-op for CPU assembly.
369 gpuLinearizer_.copyJacobianToHost(*jacobian_);
370 Opm::exportSystem(jacobian_->istlMatrix(), residual_, export_sparsity, tag.c_str(), path);
371 }
372
374 { linearizationType_ = linearizationType; }
375
377 { return linearizationType_; }
378
384 const auto& getFlowsInfo() const
385 { return flowsInfo_; }
386
392 const auto& getFloresInfo() const
393 { return floresInfo_; }
394
401 const auto& getVelocityInfo() const
402 { return velocityInfo_; }
403
404 const auto& getNeighborInfo() const {
405 return neighborInfo_;
406 }
407
408
410 {
411 updateStoredTransmissibilities();
412 }
413
415 {
416 for (auto& bdyInfo : boundaryInfo_) {
417 const auto [type, massrateAD] = problem_().boundaryCondition(bdyInfo.cell, bdyInfo.dir);
418
419 // Strip the unnecessary (and zero anyway) derivatives off massrate.
420 VectorBlockCPU massrate(0.0);
421 for (std::size_t ii = 0; ii < massrate.size(); ++ii) {
422 massrate[ii] = massrateAD[ii].value();
423 }
424 if (type != BCType::NONE) {
425 const auto& exFluidState = problem_().boundaryFluidState(bdyInfo.cell, bdyInfo.dir);
426 bdyInfo.bcdata.type = type;
427 bdyInfo.bcdata.massRate = massrate;
428 bdyInfo.bcdata.exFluidState = exFluidState;
429 }
430 }
431 }
432
438 std::map<unsigned, Constraints> constraintsMap() const
439 { return {}; }
440
441 template <class SubDomainType>
442 void resetSystem_(const SubDomainType& domain)
443 {
444 if (!jacobian_) {
445 initFirstIteration_();
446 }
447 for (int globI : domain.cells) {
448 residual_[globI] = 0.0;
449 jacobian_->clearRow(globI, 0.0);
450 }
451 }
452
453private:
454 Simulator& simulator_()
455 { return *simulatorPtr_; }
456
457 const Simulator& simulator_() const
458 { return *simulatorPtr_; }
459
460 Problem& problem_()
461 { return simulator_().problem(); }
462
463 const Problem& problem_() const
464 { return simulator_().problem(); }
465
466 Model& model_()
467 { return simulator_().model(); }
468
469 const Model& model_() const
470 { return simulator_().model(); }
471
472 const GridView& gridView_() const
473 { return problem_().gridView(); }
474
475 void initFirstIteration_()
476 {
477 // initialize the BCRS matrix for the Jacobian of the residual function
478 createMatrix_();
479
480 // initialize the Jacobian matrix and the vector for the residual function
481 residual_.resize(model_().numTotalDof());
482 resetSystem_();
483
484 // initialize the sparse tables for Flows and Flores
485 createFlows_();
486 }
487
488 // Construct the BCRS matrix for the Jacobian of the residual function
489 void createMatrix_()
490 {
491 OPM_TIMEBLOCK(createMatrix);
492 if (!neighborInfo_.empty()) {
493 // It is ok to call this function multiple times, but it
494 // should not do anything if already called.
495 return;
496 }
497 const auto& model = model_();
498 Stencil stencil(gridView_(), model_().dofMapper());
499
500 // for the main model, find out the global indices of the neighboring degrees of
501 // freedom of each primary degree of freedom
502 using NeighborSet = std::set<unsigned>;
503 std::vector<NeighborSet> sparsityPattern(model.numTotalDof());
504 const Scalar gravity = problem_().gravity()[dimWorld - 1];
505 unsigned numCells = model.numTotalDof();
506 neighborInfo_.reserve(numCells, 6 * numCells); // Expect ~6 neighbors per cell
507 std::vector<NeighborInfoCPU> loc_nbinfo;
508 for (const auto& elem : elements(gridView_())) {
509 stencil.update(elem);
510
511 for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
512 const unsigned myIdx = stencil.globalSpaceIndex(primaryDofIdx);
513 loc_nbinfo.resize(stencil.numDof() - 1); // Do not include the primary dof in neighborInfo_
514
515 for (unsigned dofIdx = 0; dofIdx < stencil.numDof(); ++dofIdx) {
516 const unsigned neighborIdx = stencil.globalSpaceIndex(dofIdx);
517 sparsityPattern[myIdx].insert(neighborIdx);
518 if (dofIdx > 0) {
519 const Scalar trans = problem_().transmissibility(myIdx, neighborIdx);
520 const auto scvfIdx = dofIdx - 1;
521 const auto& scvf = stencil.interiorFace(scvfIdx);
522 const Scalar area = scvf.area();
523 const Scalar Vin = problem_().model().dofTotalVolume(myIdx);
524 const Scalar Vex = problem_().model().dofTotalVolume(neighborIdx);
525 const Scalar zIn = problem_().dofCenterDepth(myIdx);
526 const Scalar zEx = problem_().dofCenterDepth(neighborIdx);
527 const Scalar dZg = (zIn - zEx)*gravity;
528 const Scalar thpresInToEx = problem_().thresholdPressure(myIdx, neighborIdx);
529 const Scalar thpresExToIn = problem_().thresholdPressure(neighborIdx, myIdx);
530 const auto dirId = scvf.dirId();
531 auto faceDir = dirId < 0 ? FaceDir::DirEnum::Unknown
532 : FaceDir::FromIntersectionIndex(dirId);
533 ResidualNBInfo nbinfo{trans,
534 area,
535 thpresInToEx,
536 thpresExToIn,
537 dZg,
538 faceDir,
539 Vin,
540 Vex,
541 {},
542 {},
543 {},
544 {},
545 {}};
546 if constexpr (enableFullyImplicitThermal) {
547 nbinfo.inAlpha = problem_().thermalHalfTransmissibility(myIdx, neighborIdx);
548 nbinfo.outAlpha = problem_().thermalHalfTransmissibility(neighborIdx, myIdx);
549 }
550 if constexpr (enableDiffusion) {
551 nbinfo.diffusivity = problem_().diffusivity(myIdx, neighborIdx);
552 }
553 if constexpr (enableDispersion) {
554 nbinfo.dispersivity = problem_().dispersivity(myIdx, neighborIdx);
555 }
556 if constexpr (enablePolymer) {
557 nbinfo.dist = (stencil.subControlVolume(primaryDofIdx).globalPos()
558 - stencil.subControlVolume(dofIdx).globalPos())
559 .two_norm();
560 }
561 loc_nbinfo[dofIdx - 1] = NeighborInfoCPU{neighborIdx, nbinfo, nullptr};
562 }
563 }
564 neighborInfo_.appendRow(loc_nbinfo.begin(), loc_nbinfo.end());
565 if (problem_().nonTrivialBoundaryConditions()) {
566 for (unsigned bfIndex = 0; bfIndex < stencil.numBoundaryFaces(); ++bfIndex) {
567 const auto& bf = stencil.boundaryFace(bfIndex);
568 const int dir_id = bf.dirId();
569 // not for NNCs
570 if (dir_id < 0) {
571 continue;
572 }
573 const auto [type, massrateAD] = problem_().boundaryCondition(myIdx, dir_id);
574 // Strip the unnecessary (and zero anyway) derivatives off massrate.
575 VectorBlockCPU massrate(0.0);
576 for (std::size_t ii = 0; ii < massrate.size(); ++ii) {
577 massrate[ii] = massrateAD[ii].value();
578 }
579 const auto& exFluidState = problem_().boundaryFluidState(myIdx, dir_id);
580 BoundaryConditionDataCPU bcdata {type,
581 massrate,
582 exFluidState.pvtRegionIndex(),
583 bfIndex,
584 bf.area(),
585 bf.integrationPos()[dimWorld - 1],
586 exFluidState};
587 boundaryInfo_.push_back({myIdx, dir_id, bfIndex, bcdata});
588 }
589 }
590 }
591 }
592
593 // add the additional neighbors and degrees of freedom caused by the auxiliary
594 // equations
595 const std::size_t numAuxMod = model.numAuxiliaryModules();
596 for (unsigned auxModIdx = 0; auxModIdx < numAuxMod; ++auxModIdx) {
597 model.auxiliaryModule(auxModIdx)->addNeighbors(sparsityPattern);
598 }
599
600 // allocate raw matrix
601 jacobian_ = std::make_unique<SparseMatrixAdapter>(simulator_());
602 diagMatAddress_.resize(numCells);
603 // create matrix structure based on sparsity pattern
604 jacobian_->reserve(sparsityPattern);
605 for (unsigned globI = 0; globI < numCells; globI++) {
606 const auto& nbInfos = neighborInfo_[globI];
607 diagMatAddress_[globI] = jacobian_->blockAddress(globI, globI);
608 for (auto& nbInfo : nbInfos) {
609 nbInfo.matBlockAddress = jacobian_->blockAddress(nbInfo.neighbor, globI);
610 }
611 }
612
613 // The helper allocates GPU storage only when RunAssemblyOnGpu is true.
614 // CPU assembly can call this unconditionally without GPU support.
615 gpuLinearizer_.createMatrix(*jacobian_);
616
617 // Create dummy full domain.
618 fullDomain_.cells.resize(numCells);
619 std::iota(fullDomain_.cells.begin(), fullDomain_.cells.end(), 0);
620 }
621
622 // reset the global linear system of equations.
623 void resetSystem_()
624 {
625 residual_ = 0.0;
626 // zero all matrix entries
627 jacobian_->clear();
628
629 // No-op unless RunAssemblyOnGpu requests a GPU matrix.
630 gpuLinearizer_.resetSystem();
631 }
632
633 // Initialize the flows, flores, and velocity sparse tables
634 void createFlows_()
635 {
636 OPM_TIMEBLOCK(createFlows);
637 // If FLOWS/FLORES is set in any RPTRST in the schedule, then we initializate the sparse tables.
638 // If DISPERC is in the deck, we initialize the sparse table here as well.
639 const bool anyFlows = simulator_().problem().eclWriter().outputModule().getFlows().anyFlows();
640 const auto& blockFlows = simulator_().problem().eclWriter().outputModule().getFlows().blockFlows();
641 const auto& blockVelocity = simulator_().problem().eclWriter().outputModule().getFlows().blockVelocity();
642 const bool isTemp = simulator_().vanguard().eclState().getSimulationConfig().isTemp();
643 const bool anyFlores = simulator_().problem().eclWriter().outputModule().getFlows().anyFlores() || isTemp;
644 const bool dispersionActive = simulator_().vanguard().eclState().getSimulationConfig().rock_config().dispersion();
645 if (!dispersionActive && !enableBioeffects && blockVelocity.empty()
646 && !((anyFlows || !blockFlows.empty()) && flowsInfo_.empty())
647 && !(anyFlores && floresInfo_.empty())) {
648 return;
649 }
650 const auto& model = model_();
651 const auto& nncOutput = simulator_().problem().eclWriter().getOutputNnc().front();
652 Stencil stencil(gridView_(), model_().dofMapper());
653 const unsigned numCells = model.numTotalDof();
654 std::unordered_multimap<int, std::pair<int, int>> nncIndices;
655 std::vector<FlowInfo> loc_flinfo;
656 std::vector<VelocityInfo> loc_vlinfo;
657 unsigned int nncId = 0;
658 VectorBlock flow(0.0);
659
660 // Create a nnc structure to use fast lookup
661 for (unsigned nncIdx = 0; nncIdx < nncOutput.size(); ++nncIdx) {
662 const int ci1 = nncOutput[nncIdx].cell1;
663 const int ci2 = nncOutput[nncIdx].cell2;
664 nncIndices.emplace(ci1, std::make_pair(ci2, nncIdx));
665 }
666
667 if (anyFlows) {
668 flowsInfo_.reserve(numCells, 6 * numCells);
669 }
670 else if (!blockFlows.empty()) {
671 flowsInfo_.reserve(numCells, 6 * blockFlows.size());
672 }
673 if (anyFlores) {
674 floresInfo_.reserve(numCells, 6 * numCells);
675 }
676 if (dispersionActive || enableBioeffects) {
677 velocityInfo_.reserve(numCells, 6 * numCells);
678 }
679 else if (!blockVelocity.empty()) {
680 velocityInfo_.reserve(numCells, 6 * blockVelocity.size());
681 }
682
683 for (const auto& elem : elements(gridView_())) {
684 stencil.update(elem);
685 for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
686 const unsigned myIdx = stencil.globalSpaceIndex(primaryDofIdx);
687 bool blockFlowFound = false;
688 bool blockVelocityFound = false;
689 if (!blockFlows.empty()) {
690 if (std::ranges::binary_search(blockFlows,
691 simulator_().vanguard().cartesianIndex(myIdx))) {
692 blockFlowFound = true;
693 }
694 else {
695 flowsInfo_.appendRow(loc_flinfo.begin(), loc_flinfo.begin());
696 if (!dispersionActive && !enableBioeffects && !anyFlores && blockVelocity.empty()) {
697 continue;
698 }
699 }
700 }
701 if (!blockVelocity.empty() && !(dispersionActive || enableBioeffects)) {
702 if (std::ranges::binary_search(blockVelocity,
703 simulator_().vanguard().cartesianIndex(myIdx))) {
704 blockVelocityFound = true;
705 }
706 else {
707 velocityInfo_.appendRow(loc_vlinfo.begin(), loc_vlinfo.begin());
708 if (!anyFlows && blockFlows.empty() && !anyFlores) {
709 continue;
710 }
711 }
712 }
713 const int numFaces = stencil.numBoundaryFaces() + stencil.numInteriorFaces();
714 loc_flinfo.resize(numFaces);
715 loc_vlinfo.resize(stencil.numDof() - 1);
716
717 for (unsigned dofIdx = 0; dofIdx < stencil.numDof(); ++dofIdx) {
718 const unsigned neighborIdx = stencil.globalSpaceIndex(dofIdx);
719 if (dofIdx > 0) {
720 const auto scvfIdx = dofIdx - 1;
721 const auto& scvf = stencil.interiorFace(scvfIdx);
722 int faceId = scvf.dirId();
723 const int cartMyIdx = simulator_().vanguard().cartesianIndex(myIdx);
724 const int cartNeighborIdx = simulator_().vanguard().cartesianIndex(neighborIdx);
725 const auto& range = nncIndices.equal_range(cartMyIdx);
726 for (auto it = range.first; it != range.second; ++it) {
727 if (it->second.first == cartNeighborIdx){
728 // -1 gives problem since is used for the nncInput from the deck
729 faceId = -2;
730 // the index is stored to be used for writting the outputs
731 nncId = it->second.second;
732 }
733 }
734 loc_flinfo[dofIdx - 1] = FlowInfo{faceId, flow, nncId};
735 loc_vlinfo[dofIdx - 1] = VelocityInfo{faceId, flow};
736 }
737 }
738
739 for (unsigned bdfIdx = 0; bdfIdx < stencil.numBoundaryFaces(); ++bdfIdx) {
740 const auto& scvf = stencil.boundaryFace(bdfIdx);
741 const int faceId = scvf.dirId();
742 loc_flinfo[stencil.numInteriorFaces() + bdfIdx] = FlowInfo{faceId, flow, nncId};
743 }
744
745 if (anyFlows || blockFlowFound) {
746 flowsInfo_.appendRow(loc_flinfo.begin(), loc_flinfo.end());
747 }
748 if (anyFlores) {
749 floresInfo_.appendRow(loc_flinfo.begin(), loc_flinfo.end());
750 }
751 if (dispersionActive || enableBioeffects || blockVelocityFound) {
752 velocityInfo_.appendRow(loc_vlinfo.begin(), loc_vlinfo.end());
753 }
754 }
755 }
756 }
757
758public:
759 template <class VectorBlockType, class MatrixBlockType, class ADVectorBlockType>
760 OPM_HOST_DEVICE static void
761 setResAndJacobi(VectorBlockType& res, MatrixBlockType& bMat, const ADVectorBlockType& resid)
762 {
763 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
764 res[eqIdx] = resid[eqIdx].value();
765 }
766
767 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
768 for (unsigned pvIdx = 0; pvIdx < numEq; ++pvIdx) {
769 // A[dofIdx][focusDofIdx][eqIdx][pvIdx] is the partial derivative of
770 // the residual function 'eqIdx' for the degree of freedom 'dofIdx'
771 // with regard to the focus variable 'pvIdx' of the degree of freedom
772 // 'focusDofIdx'
773 bMat[eqIdx][pvIdx] = resid[eqIdx].derivative(pvIdx);
774 }
775 }
776 }
777
779 {
780 OPM_TIMEBLOCK(updateFlows);
781 const bool enableFlows = simulator_().problem().eclWriter().outputModule().getFlows().hasFlows();
782 const auto& blockFlows = simulator_().problem().eclWriter().outputModule().getFlows().blockFlows();
783 // We reuse the fluxes in the TEMP option
784 const bool isTemp = simulator_().vanguard().eclState().getSimulationConfig().isTemp();
785 const bool enableFlores = simulator_().problem().eclWriter().outputModule().getFlows().hasFlores() || isTemp;
786 if (!enableFlows && !enableFlores && blockFlows.empty()) {
787 return;
788 }
789 const unsigned int numCells = model_().numTotalDof();
790#ifdef _OPENMP
791#pragma omp parallel for
792#endif
793 for (unsigned globI = 0; globI < numCells; ++globI) {
794 OPM_TIMEBLOCK_LOCAL(linearizationForEachCell, Subsystem::Assembly);
795 const auto& nbInfos = neighborInfo_[globI];
796 ADVectorBlock adres(0.0);
797 ADVectorBlock darcyFlux(0.0);
798 const IntensiveQuantities& intQuantsIn = model_().intensiveQuantities(globI, /*timeIdx*/ 0);
799 // Flux term.
800 {
801 OPM_TIMEBLOCK_LOCAL(fluxCalculationForEachCell, Subsystem::Assembly);
802 short loc = 0;
803 for (const auto& nbInfo : nbInfos) {
804 OPM_TIMEBLOCK_LOCAL(fluxCalculationForEachFace, Subsystem::Assembly);
805 const unsigned globJ = nbInfo.neighbor;
806 assert(globJ != globI);
807 adres = 0.0;
808 darcyFlux = 0.0;
809 const IntensiveQuantities& intQuantsEx = model_().intensiveQuantities(globJ, /*timeIdx*/ 0);
810 LocalResidual::computeFlux(adres, darcyFlux, globI, globJ, intQuantsIn,
811 intQuantsEx, nbInfo.res_nbinfo, problem_().moduleParams());
812 adres *= nbInfo.res_nbinfo.faceArea;
813 if (!blockFlows.empty()) {
814 if (std::ranges::binary_search(blockFlows,
815 simulator_().vanguard().cartesianIndex(globI))) {
816 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
817 flowsInfo_[globI][loc].flow[eqIdx] = adres[eqIdx].value();
818 }
819 }
820 }
821 else if (enableFlows) {
822 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
823 flowsInfo_[globI][loc].flow[eqIdx] = adres[eqIdx].value();
824 }
825 }
826 if (enableFlores) {
827 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
828 floresInfo_[globI][loc].flow[eqIdx] = darcyFlux[eqIdx].value();
829 }
830 }
831 ++loc;
832 }
833 }
834 }
835
836 // Boundary terms. Only looping over cells with nontrivial bcs.
837 for (const auto& bdyInfo : boundaryInfo_) {
838 if (bdyInfo.bcdata.type == BCType::NONE) {
839 continue;
840 }
841
842 ADVectorBlockCPU adres(0.0);
843 const unsigned globI = bdyInfo.cell;
844 const auto& nbInfos = neighborInfo_[globI];
845 const IntensiveQuantities& insideIntQuants = model_().intensiveQuantities(globI, /*timeIdx*/ 0);
846 LocalResidual::computeBoundaryFlux(adres, problem_(), bdyInfo.bcdata, insideIntQuants, globI);
847 adres *= bdyInfo.bcdata.faceArea;
848 const unsigned bfIndex = bdyInfo.bfIndex;
849 if (enableFlows) {
850 for (unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
851 flowsInfo_[globI][nbInfos.size() + bfIndex].flow[eqIdx] = adres[eqIdx].value();
852 }
853 }
854 // TODO also store Flores?
855 }
856 }
857
858private:
859 template <class SubDomainType>
860 void linearize_(const SubDomainType& domain)
861 {
862 constexpr bool run_assembly_on_gpu = getPropValue<TypeTag, Properties::RunAssemblyOnGpu>();
863 // Returns false without accessing a GPU when RunAssemblyOnGpu is false.
864 const bool useAssemblyLinearsolveBridge = gpuLinearizer_.updateSolverBridge(*this);
865
866 // This check should be removed once this is addressed by
867 // for example storing the previous timesteps' values for
868 // rsmax (for DRSDT) and similar.
869 if (!problem_().recycleFirstIterationStorage()) {
870 if (!model_().storeIntensiveQuantities() && !model_().enableStorageCache()) {
871 OPM_THROW(std::runtime_error, "Must have cached either IQs or storage when we cannot recycle.");
872 }
873 }
874
875 const double dt = simulator_().timeStepSize();
876
877 OPM_TIMEBLOCK(linearize);
878
879 // We do not call resetSystem_() here, since that will set
880 // the full system to zero, not just our part.
881 // Instead, that must be called before starting the linearization.
882 const bool dispersionActive = simulator_().vanguard().eclState().getSimulationConfig().rock_config().dispersion();
883 const unsigned int numCells = domain.cells.size();
884
885 if constexpr (!run_assembly_on_gpu) {
886 linearize_parallelization_wrapper(
887 numCells /*numCells*/,
888 domain,
889 neighborInfo_,
890 diagMatAddress_,
891 residual_,
892 model_(),
893 dt,
894 problem_());
895
896 linearize_bc<IntensiveQuantities, Model, LocalResidual>(
897 diagMatAddress_, residual_, boundaryInfo_);
898 } else {
899 // Reached only when GPU assembly is requested; the helper throws
900 // if the required GPU support is unavailable.
901 gpuLinearizer_.linearize(*this, domain, numCells, dt, dispersionActive);
902 }
903
904 // Source evaluation remains CPU-side because it uses problem_(). The
905 // source-only GPU/gpuISTL path uploads just the resulting block deltas.
906 if (!useAssemblyLinearsolveBridge) {
907 linearize_source_terms(numCells, domain);
908 }
909
910 }
911
912 template <class ModelClass,
913 class DiagPtrType,
914 class DomainType,
915 class NeighborSparseTable,
916 class ResidualType,
917 class ProblemT>
918 void linearize_parallelization_wrapper(const unsigned int numCells,
919 const DomainType& domain,
920 const NeighborSparseTable& neighborInfo,
921 DiagPtrType& diagMatAddress,
922 ResidualType& residual,
923 const ModelClass& model,
924 Scalar dt,
925 const ProblemT& problem)
926 {
927#ifdef _OPENMP
928#pragma omp parallel for
929#endif
930 for (unsigned ii = 0; ii < numCells; ++ii) {
931 linearize_cell<false, LocalResidual>(ii,
932 domain,
933 neighborInfo,
934 diagMatAddress,
935 residual,
936 model,
937 velocityInfo_,
938 dt,
939 problem);
940 }
941 }
942
943 template <class SubDomainType>
944 void linearize_source_terms(unsigned int numCells, const SubDomainType& domain)
945 {
946#ifdef _OPENMP
947#pragma omp parallel for
948#endif
949 for (unsigned ii = 0; ii < numCells; ++ii) {
950 OPM_TIMEBLOCK_LOCAL(linearizationForEachCell, Subsystem::Assembly);
951 const unsigned globI = domain.cells[ii];
952 VectorBlockCPU res(0.0);
953 MatrixBlockCPU bMat(0.0);
954 ADVectorBlockCPU adres(0.0);
955 const IntensiveQuantities& intQuantsIn = model_().intensiveQuantities(globI, /*timeIdx*/ 0);
956 const double volume = model_().dofTotalVolume(globI);
957
958 // Cell-wise source terms.
959 // This will include well sources if SeparateSparseSourceTerms is false.
960 res = 0.0;
961 bMat = 0.0;
962 adres = 0.0;
963 if (separateSparseSourceTerms_) {
964 LocalResidual::computeSourceDense(adres, problem_(), intQuantsIn, globI, 0);
965 } else {
966 LocalResidual::computeSource(adres, problem_(), intQuantsIn, globI, 0);
967 }
968 adres *= -volume;
969 setResAndJacobi(res, bMat, adres);
970 residual_[globI] += res;
971 // SparseAdapter syntax: jacobian_->addToBlock(globI, globI, bMat);
972 *diagMatAddress_[globI] += bMat;
973 } // end of loop for cell globI.
974
975 // Add sparse source terms. For now only wells.
976 if (separateSparseSourceTerms_) {
977 problem_().wellModel().addReservoirSourceTerms(residual_, diagMatAddress_);
978 }
979 }
980
981public:
982 template <bool useGPU,
983 class LocalResidualT,
984 class ProblemType,
985 class VelocityInfoType,
986 class ModelClass,
987 class DiagPtrType,
988 class DomainType,
989 class NeighborSparseTable,
990 class ResidualType>
991 OPM_HOST_DEVICE static void linearize_cell(const unsigned int ii,
992 const DomainType& domain,
993 const NeighborSparseTable& neighborInfo,
994 const DiagPtrType& diagMatAddress,
995 ResidualType& residual,
996 const ModelClass& model,
997 VelocityInfoType& velocityInfo,
998 const Scalar dt,
999 const ProblemType& problem)
1000 {
1001#if OPM_IS_INSIDE_HOST_FUNCTION
1002 OPM_TIMEBLOCK_LOCAL(linearizationForEachCell, Subsystem::Assembly);
1003#endif
1004 const unsigned globI = domain.cells[ii];
1005 const auto& nbInfos = neighborInfo[globI];
1006 VectorBlock res(0.0);
1007 MatrixBlock bMat(0.0);
1008 ADVectorBlock adres(0.0);
1009 ADVectorBlock darcyFlux(0.0);
1010 const auto& intQuantsIn = model.intensiveQuantities(globI, /*timeIdx*/ 0);
1011
1012 // Flux term.
1013 {
1014#if OPM_IS_INSIDE_HOST_FUNCTION
1015 OPM_TIMEBLOCK_LOCAL(fluxCalculationForEachCell, Subsystem::Assembly);
1016#endif
1017 short loc = 0;
1018 for (const auto& nbInfo : nbInfos) {
1019 const unsigned globJ = nbInfo.neighbor;
1020 res = 0.0;
1021 bMat = 0.0;
1022 adres = 0.0;
1023 darcyFlux = 0.0;
1024
1025 const auto& intQuantsEx = model.intensiveQuantities(globJ, /*timeIdx*/ 0);
1026
1027 LocalResidualT::computeFlux(adres,
1028 darcyFlux,
1029 globI,
1030 globJ,
1031 intQuantsIn,
1032 intQuantsEx,
1033 nbInfo.res_nbinfo,
1034 problem.moduleParams());
1035
1036 adres *= nbInfo.res_nbinfo.faceArea;
1037
1038 // currently not supported on GPU
1039 if constexpr (!useGPU) {
1040 // Use std::cmp_less because sparseTable.size() returns signed integer, and globI is unsigned
1041 if (std::cmp_less(globI, velocityInfo.size())) {
1042 if (velocityInfo.rowSize(globI) > 0) {
1043 for (unsigned phaseIdx = 0; phaseIdx < numEq; ++phaseIdx) {
1044 velocityInfo[globI][loc].velocity[phaseIdx]
1045 = darcyFlux[phaseIdx].value() / nbInfo.res_nbinfo.faceArea;
1046 }
1047 }
1048 }
1049 }
1050
1051 setResAndJacobi(res, bMat, adres);
1052 residual[globI] += res;
1053 // SparseAdapter syntax: jacobian_->addToBlock(globI, globI, bMat);
1054 *diagMatAddress[globI] += bMat;
1055 bMat *= -1.0;
1056 // SparseAdapter syntax: jacobian_->addToBlock(globJ, globI, bMat);
1057 *nbInfo.matBlockAddress += bMat;
1058 ++loc;
1059 }
1060 }
1061
1062 // Accumulation term.
1063 adres = 0.0;
1064 {
1065 LocalResidualT::template computeStorage<Evaluation>(adres, intQuantsIn);
1066 }
1067 setResAndJacobi(res, bMat, adres);
1068
1069 if constexpr (!useGPU) { // Cached storage not enabled for GPU
1070 // Either use cached storage term, or compute it on the fly.
1071 if (model.enableStorageCache()) {
1072 // The cached storage for timeIdx 0 (current time) is not
1073 // used, but after storage cache is shifted at the end of the
1074 // timestep, it will become cached storage for timeIdx 1.
1075 model.updateCachedStorage(globI, /*timeIdx=*/0, res);
1076 // We should not update the storage cache here for NLDD local solves.
1077 // This will reset the start-of-step storage to incorrect numbers when
1078 // we do local solves, where the iteration number will start from 0,
1079 // but the starting state may not be identical to the start-of-step state.
1080 // Note that a full assembly must be done before local solves
1081 // otherwise this will be left un-updated.
1082 if (problem.iterationContext().isFirstGlobalIteration()) {
1083 // Need to update the storage cache.
1084 if (problem.recycleFirstIterationStorage()) {
1085 // Assumes nothing have changed in the system which
1086 // affects masses calculated from primary variables.
1087 model.updateCachedStorage(globI, 1, res);
1088 } else {
1089 VectorBlock tmp;
1090 const auto& intQuantOld = model.intensiveQuantities(globI, 1);
1091 LocalResidualT::template computeStorage<Scalar>(tmp, intQuantOld);
1092 model.updateCachedStorage(globI, 1, tmp);
1093 }
1094 }
1095 res -= model.cachedStorage(globI, 1);
1096 } else {
1097#if OPM_IS_INSIDE_HOST_FUNCTION
1098 OPM_TIMEBLOCK_LOCAL(computeStorage0, Subsystem::Assembly);
1099#endif
1100 VectorBlock tmp;
1101 const auto& intQuantOld = model.intensiveQuantities(globI, 1);
1102 LocalResidualT::template computeStorage<Scalar>(tmp, intQuantOld);
1103 // assume volume do not change
1104 res -= tmp;
1105 }
1106 } else {
1107 VectorBlock tmp;
1108 const auto& intQuantOld = model.intensiveQuantities(globI, 1);
1109 LocalResidualT::template computeStorage<Scalar>(tmp, intQuantOld);
1110 // assume volume do not change
1111 res -= tmp;
1112 }
1113
1114 const Scalar volume = model.dofTotalVolume(globI);
1115 const Scalar storefac = volume / dt;
1116 res *= storefac;
1117 bMat *= storefac;
1118 residual[globI] += res;
1119 // SparseAdapter syntax: jacobian_->addToBlock(globI, globI, bMat);
1120 *diagMatAddress[globI] += bMat;
1121 }
1122
1123
1124private:
1125 template <class LocalIntensiveQuantities,
1126 class ModelClass,
1127 class LocalResidualT,
1128 class DiagPtrType,
1129 class ResidualType,
1130 class BoundaryInfoT>
1131 void linearize_bc(DiagPtrType& diagMatAdress,
1132 ResidualType& residual,
1133 const BoundaryInfoT& boundaryInfo)
1134 {
1135 // Boundary terms. Only looping over cells with nontrivial bcs.
1136 for (const auto& bdyInfo : boundaryInfo) {
1137 if (bdyInfo.bcdata.type == BCType::NONE) {
1138 continue;
1139 }
1140 VectorBlock res(0.0);
1141 MatrixBlock bMat(0.0);
1142 ADVectorBlock adres(0.0);
1143 const unsigned globI = bdyInfo.cell;
1144 const LocalIntensiveQuantities& insideIntQuants
1145 = model_().intensiveQuantities(globI, /*timeIdx*/ 0);
1146 LocalResidual::computeBoundaryFlux(
1147 adres, problem_(), bdyInfo.bcdata, insideIntQuants, globI);
1148 adres *= bdyInfo.bcdata.faceArea;
1149 setResAndJacobi(res, bMat, adres);
1150 residual[globI] += res;
1152 *diagMatAdress[globI] += bMat;
1153 }
1154 }
1155
1156 void updateStoredTransmissibilities()
1157 {
1158 if (neighborInfo_.empty()) {
1159 // This function was called before createMatrix_() was called.
1160 // We call initFirstIteration_(), not createMatrix_(), because
1161 // that will also initialize the residual consistently.
1162 initFirstIteration_();
1163 }
1164
1165 const unsigned numCells = model_().numTotalDof();
1166#ifdef _OPENMP
1167#pragma omp parallel for
1168#endif
1169 for (unsigned globI = 0; globI < numCells; globI++) {
1170 auto nbInfos = neighborInfo_[globI]; // nbInfos will be a SparseTable<...>::mutable_iterator_range.
1171 for (auto& nbInfo : nbInfos) {
1172 const unsigned globJ = nbInfo.neighbor;
1173 nbInfo.res_nbinfo.trans = problem_().transmissibility(globI, globJ);
1174 }
1175 }
1176 }
1177
1178 Simulator* simulatorPtr_{};
1179
1180 // the jacobian matrix
1181 std::unique_ptr<SparseMatrixAdapter> jacobian_{};
1182 GpuLinearizer gpuLinearizer_;
1183
1184 // the right-hand side
1185 GlobalEqVector residual_;
1186
1187 LinearizationType linearizationType_{};
1188
1189 using ResidualNBInfo = typename LocalResidual::ResidualNBInfo;
1190 using NeighborInfoCPU = NeighborInfoStruct<ResidualNBInfo, MatrixBlockCPU>;
1191
1192 SparseTable<NeighborInfoCPU> neighborInfo_{};
1193 std::vector<MatrixBlockCPU*> diagMatAddress_ {};
1194
1195 struct FlowInfo
1196 {
1197 int faceId;
1198 VectorBlock flow;
1199 unsigned int nncId;
1200 };
1201 SparseTable<FlowInfo> flowsInfo_;
1202 SparseTable<FlowInfo> floresInfo_;
1203
1204 struct VelocityInfo
1205 {
1206 int faceId;
1207 VectorBlock velocity;
1208 };
1209 SparseTable<VelocityInfo> velocityInfo_;
1210
1211 using ScalarFluidState = typename IntensiveQuantities::ScalarFluidState;
1212
1213 using BoundaryConditionDataCPU = BoundaryConditionData<VectorBlockCPU, ScalarFluidState>;
1214
1215 using BoundaryInfoCPU = BoundaryInfo<BoundaryConditionDataCPU>;
1216
1217 std::vector<BoundaryInfoCPU> boundaryInfo_;
1218
1219 bool separateSparseSourceTerms_ = false;
1220
1221 FullDomain<> fullDomain_;
1222
1223 int exportIndex_;
1224 int exportCount_;
1225};
1226} // namespace Opm
1227
1228#endif // TPFA_LINEARIZER
Declares the properties required by the black oil model.
The base class for the element-centered finite-volume discretization scheme.
Definition: ecfvdiscretization.hh:160
Definition: matrixblock.hh:256
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:87
Scalar timeStepSize() const
Returns the time step length so that we don't miss the beginning of the next episode or cross the en...
Definition: simulator.hh:421
Vanguard & vanguard()
Return a reference to the grid manager of simulation.
Definition: simulator.hh:242
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:273
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition: simulator.hh:254
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:260
Definition: tpfalinearizergpu.hh:64
The common code for the linearizers of non-linear systems of equations.
Definition: tpfalinearizer.hh:103
const auto & getFloresInfo() const
Return constant reference to the floresInfo.
Definition: tpfalinearizer.hh:392
const LinearizationType & getLinearizationType() const
Definition: tpfalinearizer.hh:376
const auto & getNeighborInfo() const
Definition: tpfalinearizer.hh:404
decltype(auto) gpuResidual()
Definition: tpfalinearizer.hh:298
void updateBoundaryConditionData()
Definition: tpfalinearizer.hh:414
void linearize()
Linearize the full system of non-linear equations.
Definition: tpfalinearizer.hh:215
SparseMatrixAdapter & jacobian()
Definition: tpfalinearizer.hh:340
const auto & getFlowsInfo() const
Return constant reference to the flowsInfo.
Definition: tpfalinearizer.hh:384
std::map< unsigned, Constraints > constraintsMap() const
Returns the map of constraint degrees of freedom.
Definition: tpfalinearizer.hh:438
TpfaLinearizer()
Definition: tpfalinearizer.hh:158
void linearizeDomain(const SubDomainType &domain)
Linearize the part of the non-linear system of equations that is associated with a part of the spatia...
Definition: tpfalinearizer.hh:271
void finalize()
Definition: tpfalinearizer.hh:292
void init(Simulator &simulator)
Initialize the linearizer.
Definition: tpfalinearizer.hh:186
void updateFlowsInfo()
Definition: tpfalinearizer.hh:778
static void registerParameters()
Register all run-time parameters for the Jacobian linearizer.
Definition: tpfalinearizer.hh:169
void exportSystem(const int idx, std::string &tag, const char *path="export")
Export block sparse linear system.
Definition: tpfalinearizer.hh:355
void linearizeDomain()
Linearize the part of the non-linear system of equations that is associated with the spatial domain.
Definition: tpfalinearizer.hh:231
const SparseMatrixAdapter & jacobian() const
Return constant reference to global Jacobian matrix backend.
Definition: tpfalinearizer.hh:337
void setLinearizationType(LinearizationType linearizationType)
Definition: tpfalinearizer.hh:373
GlobalEqVector & residual()
Definition: tpfalinearizer.hh:349
void eraseMatrix()
Causes the Jacobian matrix to be recreated from scratch before the next iteration.
Definition: tpfalinearizer.hh:199
const auto & getVelocityInfo() const
Return constant reference to the velocityInfo.
Definition: tpfalinearizer.hh:401
static OPM_HOST_DEVICE void linearize_cell(const unsigned int ii, const DomainType &domain, const NeighborSparseTable &neighborInfo, const DiagPtrType &diagMatAddress, ResidualType &residual, const ModelClass &model, VelocityInfoType &velocityInfo, const Scalar dt, const ProblemType &problem)
Definition: tpfalinearizer.hh:991
void updateDiscretizationParameters()
Definition: tpfalinearizer.hh:409
void resetSystem_(const SubDomainType &domain)
Definition: tpfalinearizer.hh:442
static OPM_HOST_DEVICE void setResAndJacobi(VectorBlockType &res, MatrixBlockType &bMat, const ADVectorBlockType &resid)
Definition: tpfalinearizer.hh:761
decltype(auto) flattenedGpuResidual()
Definition: tpfalinearizer.hh:299
void linearizeAuxiliaryEquations()
Linearize the part of the non-linear system of equations that is associated with the spatial domain.
Definition: tpfalinearizer.hh:305
bool gpuSystemActive() const
Definition: tpfalinearizer.hh:295
decltype(auto) gpuJacobian()
Definition: tpfalinearizer.hh:297
const GlobalEqVector & residual() const
Return constant reference to global residual vector.
Definition: tpfalinearizer.hh:346
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
@ NONE
Definition: DeferredLogger.hpp:46
Definition: blackoilnewtonmethodparams.hpp:31
HYPRE_IJMatrix createMatrix(HYPRE_Int N, HYPRE_Int dof_offset, const CommType &comm)
Create Hypre matrix.
Definition: hypreinterface/HypreSetup.hpp:165
Definition: blackoilbioeffectsmodules.hh:45
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:233
void exportSystem(const IstlMatrix &jacobian, const GlobalEqVector &residual, const bool export_sparsity, const char *tag, const char *path="export")
Export blocks-sparse linear system.
Definition: exportSystem.hpp:42
Storage cells
Definition: tpfalinearizerstructs.hh:39
Definition: linearizationtype.hh:34
Definition: tpfalinearizer.hh:82
static constexpr bool value
Definition: tpfalinearizer.hh:82