version 3.11-dev
Loading...
Searching...
No Matches
multidomain/fvassembler.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// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_MULTIDOMAIN_FV_ASSEMBLER_HH
15#define DUMUX_MULTIDOMAIN_FV_ASSEMBLER_HH
16
17#include <algorithm>
18#include <type_traits>
19#include <tuple>
20
21#include <dune/common/hybridutilities.hh>
22#include <dune/istl/matrixindexset.hh>
23
35
40#include "assemblerview.hh"
41#include "assemblytraits.hh"
42
44#if HAVE_DUMUX_OLD_STAGGERED
45#include <dumux/multidomain/subdomainstaggeredlocalassembler.hh>
46#endif
47
49
50namespace Dumux {
51
52template<std::size_t id, class TypeTag, class Assembler, DiffMethod DM, bool implicit>
54
64template<class MDTraits, class CMType, DiffMethod diffMethod, bool useImplicitAssembly = true>
66{
67 template<std::size_t id>
68 using SubDomainTypeTag = typename MDTraits::template SubDomain<id>::TypeTag;
69
70public:
71 using Traits = MDTraits;
72
73 using Scalar = typename MDTraits::Scalar;
74
75 template<std::size_t id>
76 using LocalResidual = typename MDTraits::template SubDomain<id>::LocalResidual;
77
78 template<std::size_t id>
79 using GridVariables = typename MDTraits::template SubDomain<id>::GridVariables;
80
81 template<std::size_t id>
82 using GridGeometry = typename MDTraits::template SubDomain<id>::GridGeometry;
83
84 template<std::size_t id>
85 using Problem = typename MDTraits::template SubDomain<id>::Problem;
86
87 using JacobianMatrix = typename MDTraits::JacobianMatrix;
88 using SolutionVector = typename MDTraits::SolutionVector;
89 using ResidualType = typename MDTraits::ResidualVector;
90
91 using CouplingManager = CMType;
92
96 static constexpr bool isImplicit()
97 { return useImplicitAssembly; }
98
99private:
100
101 using ProblemTuple = typename MDTraits::template TupleOfSharedPtrConst<Problem>;
102 using GridGeometryTuple = typename MDTraits::template TupleOfSharedPtrConst<GridGeometry>;
103 using GridVariablesTuple = typename MDTraits::template TupleOfSharedPtr<GridVariables>;
104
106 using ThisType = MultiDomainFVAssembler<MDTraits, CouplingManager, diffMethod, isImplicit()>;
107
108 template<std::size_t id>
109 using SubDomainAssemblerView = MultiDomainAssemblerSubDomainView<ThisType, id>;
110
111 template<class DiscretizationMethod, std::size_t id>
112 struct SubDomainAssemblerType;
113
114 template<std::size_t id>
115 struct SubDomainAssemblerType<DiscretizationMethods::CCTpfa, id>
116 {
117 using type = SubDomainCCLocalAssembler<id, SubDomainTypeTag<id>, SubDomainAssemblerView<id>, diffMethod, isImplicit()>;
118 };
119
120 template<std::size_t id>
121 struct SubDomainAssemblerType<DiscretizationMethods::CCMpfa, id>
122 {
123 using type = SubDomainCCLocalAssembler<id, SubDomainTypeTag<id>, SubDomainAssemblerView<id>, diffMethod, isImplicit()>;
124 };
125
126 template<std::size_t id, class DM>
127 struct SubDomainAssemblerType<DiscretizationMethods::CVFE<DM>, id>
128 {
129 using type = SubDomainCVFELocalAssembler<id, SubDomainTypeTag<id>, SubDomainAssemblerView<id>, diffMethod, isImplicit()>;
130 };
131
132 template<std::size_t id>
133 struct SubDomainAssemblerType<DiscretizationMethods::Staggered, id>
134 {
135 using type = SubDomainStaggeredLocalAssembler<id, SubDomainTypeTag<id>, SubDomainAssemblerView<id>, diffMethod, isImplicit()>;
136 };
137
138 template<std::size_t id>
139 struct SubDomainAssemblerType<DiscretizationMethods::FCStaggered, id>
140 {
141 using type = SubDomainFaceCenteredLocalAssembler<id, SubDomainTypeTag<id>, SubDomainAssemblerView<id>, diffMethod, isImplicit()>;
142 };
143
144 template<std::size_t id>
145 using SubDomainAssembler = typename SubDomainAssemblerType<typename GridGeometry<id>::DiscretizationMethod, id>::type;
146
147public:
148
149
156 GridGeometryTuple gridGeometry,
157 GridVariablesTuple gridVariables,
158 std::shared_ptr<CouplingManager> couplingManager)
160 , problemTuple_(std::move(problem))
161 , gridGeometryTuple_(std::move(gridGeometry))
162 , gridVariablesTuple_(std::move(gridVariables))
163 , timeLoop_()
164 , isStationaryProblem_(true)
165 , warningIssued_(false)
166 {
167 static_assert(isImplicit(), "Explicit assembler for stationary problem doesn't make sense!");
168 std::cout << "Instantiated assembler for a stationary problem." << std::endl;
169
173 && getParam<bool>("Assembly.Multithreading", true);
174
175 maybeComputeColors_();
176 }
177
184 GridGeometryTuple gridGeometry,
185 GridVariablesTuple gridVariables,
186 std::shared_ptr<CouplingManager> couplingManager,
187 std::shared_ptr<const TimeLoop> timeLoop,
188 const SolutionVector& prevSol)
190 , problemTuple_(std::move(problem))
191 , gridGeometryTuple_(std::move(gridGeometry))
192 , gridVariablesTuple_(std::move(gridVariables))
193 , timeLoop_(timeLoop)
194 , prevSol_(&prevSol)
195 , isStationaryProblem_(false)
196 , warningIssued_(false)
197 {
198 std::cout << "Instantiated assembler for an instationary problem." << std::endl;
199
203 && getParam<bool>("Assembly.Multithreading", true);
204
205 maybeComputeColors_();
206 }
207
213 {
214 checkAssemblerState_();
215 resetJacobian_();
216 resetResidual_();
217
218 using namespace Dune::Hybrid;
219 forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto domainId)
220 {
221 auto& jacRow = (*jacobian_)[domainId];
222 auto& subRes = (*residual_)[domainId];
223 const auto& subSol = curSol[domainId];
224 this->assembleJacobianAndResidual_(domainId, jacRow, subRes, curSol);
225
226 const auto gridGeometry = std::get<domainId>(gridGeometryTuple_);
227 enforcePeriodicConstraints_(domainId, jacRow, subRes, *gridGeometry, subSol);
228 enforceProblemConstraints_(domainId, jacRow, subRes, *gridGeometry, subSol);
229 });
230 }
231
234 {
235 resetResidual_();
236 assembleResidual(*residual_, curSol);
237 }
238
241 {
242 r = 0.0;
243
244 checkAssemblerState_();
245
246 // update the grid variables for the case of active caching
247 updateGridVariables(curSol);
248
249 using namespace Dune::Hybrid;
250 forEach(integralRange(Dune::Hybrid::size(r)), [&](const auto domainId)
251 {
252 auto& subRes = r[domainId];
253 const auto& subSol = curSol[domainId];
254 this->assembleResidual_(domainId, subRes, curSol);
255
256 const auto gridGeometry = std::get<domainId>(gridGeometryTuple_);
257 enforcePeriodicConstraints_(domainId, subRes, *gridGeometry, subSol);
258 enforceProblemConstraints_(domainId, subRes, *gridGeometry, subSol);
259 });
260 }
261
267 void setLinearSystem(std::shared_ptr<JacobianMatrix> A,
268 std::shared_ptr<ResidualType> r)
269 {
270 jacobian_ = A;
271 residual_ = r;
272
273 setJacobianBuildMode(*jacobian_);
274 setJacobianPattern_(*jacobian_);
275 setResidualSize_(*residual_);
276 }
277
283 {
284 jacobian_ = std::make_shared<JacobianMatrix>();
285 residual_ = std::make_shared<ResidualType>();
286
287 setJacobianBuildMode(*jacobian_);
288 setJacobianPattern_(*jacobian_);
289 setResidualSize_(*residual_);
290 }
291
296 {
297 using namespace Dune::Hybrid;
298 forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto i)
299 {
300 forEach(jac[i], [&](auto& jacBlock)
301 {
302 using BlockType = std::decay_t<decltype(jacBlock)>;
303 if (jacBlock.buildMode() == BlockType::BuildMode::unknown)
304 jacBlock.setBuildMode(BlockType::BuildMode::random);
305 else if (jacBlock.buildMode() != BlockType::BuildMode::random)
306 DUNE_THROW(Dune::NotImplemented, "Only BCRS matrices with random build mode are supported at the moment");
307 });
308 });
309 }
310
315 {
316 setJacobianPattern_(*jacobian_);
317 setResidualSize_(*residual_);
318 maybeComputeColors_();
319 }
320
325 {
326 using namespace Dune::Hybrid;
327 forEach(integralRange(Dune::Hybrid::size(gridVariablesTuple_)), [&](const auto domainId)
328 { this->gridVariables(domainId).update(curSol[domainId]); });
329 }
330
334 void resetTimeStep(const SolutionVector& curSol)
335 {
336 using namespace Dune::Hybrid;
337 forEach(integralRange(Dune::Hybrid::size(gridVariablesTuple_)), [&](const auto domainId)
338 { this->gridVariables(domainId).resetTimeStep(curSol[domainId]); });
339 }
340
342 template<std::size_t i>
343 std::size_t numDofs(Dune::index_constant<i> domainId) const
344 { return std::get<domainId>(gridGeometryTuple_)->numDofs(); }
345
347 template<std::size_t i>
348 const auto& problem(Dune::index_constant<i> domainId) const
349 { return *std::get<domainId>(problemTuple_); }
350
352 template<std::size_t i>
353 const auto& gridGeometry(Dune::index_constant<i> domainId) const
354 { return *std::get<domainId>(gridGeometryTuple_); }
355
357 template<std::size_t i>
358 const auto& gridView(Dune::index_constant<i> domainId) const
359 { return gridGeometry(domainId).gridView(); }
360
362 template<std::size_t i>
363 GridVariables<i>& gridVariables(Dune::index_constant<i> domainId)
364 { return *std::get<domainId>(gridVariablesTuple_); }
365
367 template<std::size_t i>
368 const GridVariables<i>& gridVariables(Dune::index_constant<i> domainId) const
369 { return *std::get<domainId>(gridVariablesTuple_); }
370
373 { return *couplingManager_; }
374
377 { return *jacobian_; }
378
381 { return *residual_; }
382
384 const SolutionVector& prevSol() const
385 { return *prevSol_; }
386
391 void setTimeManager(std::shared_ptr<const TimeLoop> timeLoop)
392 { timeLoop_ = timeLoop; isStationaryProblem_ = !(static_cast<bool>(timeLoop)); }
393
399 { prevSol_ = &u; }
400
405 { return isStationaryProblem_; }
406
410 template<std::size_t i>
411 LocalResidual<i> localResidual(Dune::index_constant<i> domainId) const
412 { return LocalResidual<i>(std::get<domainId>(problemTuple_).get(), timeLoop_.get()); }
413
414protected:
416 std::shared_ptr<CouplingManager> couplingManager_;
417
418private:
422 void setJacobianPattern_(JacobianMatrix& jac) const
423 {
424 using namespace Dune::Hybrid;
425 forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto domainI)
426 {
427 forEach(integralRange(Dune::Hybrid::size(jac[domainI])), [&](const auto domainJ)
428 {
429 const auto pattern = this->getJacobianPattern_(domainI, domainJ);
430 pattern.exportIdx(jac[domainI][domainJ]);
431 });
432 });
433 }
434
438 void setResidualSize_(ResidualType& res) const
439 {
440 using namespace Dune::Hybrid;
441 forEach(integralRange(Dune::Hybrid::size(res)), [&](const auto domainId)
442 { res[domainId].resize(this->numDofs(domainId)); });
443 }
444
445 // reset the residual vector to 0.0
446 void resetResidual_()
447 {
448 if(!residual_)
449 {
450 residual_ = std::make_shared<ResidualType>();
451 setResidualSize_(*residual_);
452 }
453
454 (*residual_) = 0.0;
455 }
456
457 // reset the jacobian vector to 0.0
458 void resetJacobian_()
459 {
460 if(!jacobian_)
461 {
462 jacobian_ = std::make_shared<JacobianMatrix>();
463 setJacobianBuildMode(*jacobian_);
464 setJacobianPattern_(*jacobian_);
465 }
466
467 (*jacobian_) = 0.0;
468 }
469
471 void maybeComputeColors_()
472 {
473 if constexpr (CouplingManagerSupportsMultithreadedAssembly<CouplingManager>::value)
474 if (enableMultithreading_)
475 couplingManager_->computeColorsForAssembly();
476 }
477
478 // check if the assembler is in a correct state for assembly
479 void checkAssemblerState_() const
480 {
481 if (!isStationaryProblem_ && !prevSol_)
482 DUNE_THROW(Dune::InvalidStateException, "Assembling instationary problem but previous solution was not set!");
483
484 if (isStationaryProblem_ && prevSol_)
485 DUNE_THROW(Dune::InvalidStateException, "Assembling stationary problem but a previous solution was set."
486 << " Did you forget to set the timeLoop to make this problem instationary?");
487 }
488
489 template<std::size_t i, class JacRow, class SubRes>
490 void assembleJacobianAndResidual_(Dune::index_constant<i> domainId, JacRow& jacRow, SubRes& subRes,
491 const SolutionVector& curSol)
492 {
493 assemble_(domainId, [&](const auto& element)
494 {
495 MultiDomainAssemblerSubDomainView view{*this, domainId};
496 SubDomainAssembler<i> subDomainAssembler(view, element, curSol, *couplingManager_);
497 subDomainAssembler.assembleJacobianAndResidual(jacRow, subRes, gridVariablesTuple_);
498 });
499 }
500
501 template<std::size_t i, class SubRes>
502 void assembleResidual_(Dune::index_constant<i> domainId, SubRes& subRes,
503 const SolutionVector& curSol)
504 {
505 assemble_(domainId, [&](const auto& element)
506 {
507 MultiDomainAssemblerSubDomainView view{*this, domainId};
508 SubDomainAssembler<i> subDomainAssembler(view, element, curSol, *couplingManager_);
509 subDomainAssembler.assembleResidual(subRes);
510 });
511 }
512
518 template<std::size_t i, class AssembleElementFunc>
519 void assemble_(Dune::index_constant<i> domainId, AssembleElementFunc&& assembleElement) const
520 {
521 // a state that will be checked on all processes
522 bool succeeded = false;
523
524 // try assembling using the local assembly function
525 try
526 {
527 if constexpr (CouplingManagerSupportsMultithreadedAssembly<CouplingManager>::value)
528 {
529 if (enableMultithreading_)
530 {
531 couplingManager_->assembleMultithreaded(
532 domainId, std::forward<AssembleElementFunc>(assembleElement)
533 );
534 return;
535 }
536 }
537
538 // fallback for coupling managers that don't support multithreaded assembly (yet)
539 // or if multithreaded assembly is disabled
540 // let the local assembler add the element contributions
541 for (const auto& element : elements(gridView(domainId)))
542 assembleElement(element);
543
544 // if we get here, everything worked well on this process
545 succeeded = true;
546 }
547 // throw exception if a problem occurred
548 catch (NumericalProblem &e)
549 {
550 std::cout << "rank " << gridView(domainId).comm().rank()
551 << " caught an exception while assembling:" << e.what()
552 << "\n";
553 succeeded = false;
554 }
555
556 // make sure everything worked well on all processes
557 if (gridView(domainId).comm().size() > 1)
558 succeeded = gridView(domainId).comm().min(succeeded);
559
560 // if not succeeded rethrow the error on all processes
561 if (!succeeded)
562 DUNE_THROW(NumericalProblem, "A process did not succeed in linearizing the system");
563 }
564
565 // get diagonal block pattern
566 template<std::size_t i, std::size_t j, typename std::enable_if_t<(i==j), int> = 0>
567 Dune::MatrixIndexSet getJacobianPattern_(Dune::index_constant<i> domainI,
568 Dune::index_constant<j> domainJ) const
569 {
570 const auto& gg = gridGeometry(domainI);
571 auto pattern = getJacobianPattern<isImplicit()>(gg);
572 couplingManager_->extendJacobianPattern(domainI, pattern);
573 return pattern;
574 }
575
576 // get coupling block pattern
577 template<std::size_t i, std::size_t j, typename std::enable_if_t<(i!=j), int> = 0>
578 Dune::MatrixIndexSet getJacobianPattern_(Dune::index_constant<i> domainI,
579 Dune::index_constant<j> domainJ) const
580 {
582 domainI, gridGeometry(domainI),
583 domainJ, gridGeometry(domainJ));
584 }
585
586 // build periodic constraints into the system matrix
587 template<std::size_t i, class JacRow, class Res, class GG, class Sol>
588 void enforcePeriodicConstraints_(Dune::index_constant<i> domainI, JacRow& jacRow, Res& res, const GG& gridGeometry, const Sol& curSol) const
589 {
590 if constexpr (Detail::hasPeriodicDofMap<GG>())
591 {
592 for (const auto& m : gridGeometry.periodicDofMap())
593 {
594 const auto& periodicallyMappedDofs = Dumux::Deprecated::ensureRangeOfPeriodicDofs(m.second);
595 if (std::ranges::all_of(periodicallyMappedDofs, [&](auto second){ return m.first < second; }))
596 {
597 for (const auto& second : periodicallyMappedDofs)
598 {
599 auto& jac = jacRow[domainI];
600
601 // add the second row to the first
602 res[m.first] += res[second];
603
604 const auto end = jac[second].end();
605 for (auto it = jac[second].begin(); it != end; ++it)
606 jac[m.first][it.index()] += (*it);
607
608
609 // enforce the solution of the first periodic DOF to the second one
610 res[second] = curSol[second] - curSol[m.first];
611
612 // set derivatives accordingly in jacobian, i.e. id for second and -id for m.first
613 auto setMatrixBlock = [] (auto& matrixBlock, double diagValue)
614 {
615 for (int eIdx = 0; eIdx < matrixBlock.N(); ++eIdx)
616 matrixBlock[eIdx][eIdx] = diagValue;
617 };
618
619 for (auto it = jac[second].begin(); it != end; ++it)
620 {
621 auto& matrixBlock = *it;
622 matrixBlock = 0.0;
623
624 assert(matrixBlock.N() == matrixBlock.M());
625 if(it.index() == second)
626 setMatrixBlock(matrixBlock, 1.0);
627
628 if(it.index() == m.first)
629 setMatrixBlock(matrixBlock, -1.0);
630
631 }
632
633 using namespace Dune::Hybrid;
634 forEach(makeIncompleteIntegerSequence<JacRow::size(), domainI>(), [&](const auto couplingDomainId)
635 {
636 auto& jacCoupling = jacRow[couplingDomainId];
637
638 for (auto it = jacCoupling[second].begin(); it != jacCoupling[second].end(); ++it)
639 jacCoupling[m.first][it.index()] += (*it);
640
641 for (auto it = jacCoupling[second].begin(); it != jacCoupling[second].end(); ++it)
642 (*it) = 0.0;
643 });
644 }
645 }
646 }
647 }
648 }
649
650 // enforce global constraints into the system matrix
651 template<std::size_t i, class JacRow, class Res, class GG, class Sol>
652 void enforceProblemConstraints_(Dune::index_constant<i> domainI, JacRow& jacRow, Res& res, const GG& gridGeometry, const Sol& curSol) const
653 {
655 {
656 auto& jac = jacRow[domainI];
657 auto applyDirichletConstraint = [&] (const auto& dofIdx,
658 const auto& values,
659 const auto eqIdx,
660 const auto pvIdx)
661 {
662 (res)[dofIdx][eqIdx] = curSol[dofIdx][pvIdx] - values[pvIdx];
663
664 auto& row = jac[dofIdx];
665 for (auto col = row.begin(); col != row.end(); ++col)
666 row[col.index()][eqIdx] = 0.0;
667
668 jac[dofIdx][dofIdx][eqIdx][pvIdx] = 1.0;
669
670 using namespace Dune::Hybrid;
671 forEach(makeIncompleteIntegerSequence<JacRow::size(), domainI>(), [&](const auto couplingDomainId)
672 {
673 auto& jacCoupling = jacRow[couplingDomainId];
674
675 auto& rowCoupling = jacCoupling[dofIdx];
676 for (auto colCoupling = rowCoupling.begin(); colCoupling != rowCoupling.end(); ++colCoupling)
677 rowCoupling[colCoupling.index()][eqIdx] = 0.0;
678 });
679
680 };
681
682 for (const auto& constraintData : this->problem(domainI).constraints())
683 {
684 const auto& constraintInfo = constraintData.constraintInfo();
685 const auto& values = constraintData.values();
686 const auto dofIdx = constraintData.dofIndex();
687 // set the constraint in residual and jacobian
688 for (int eqIdx = 0; eqIdx < constraintInfo.size(); ++eqIdx)
689 {
690 if (constraintInfo.isConstraintEquation(eqIdx))
691 {
692 const auto pvIdx = constraintInfo.eqToPriVarIndex(eqIdx);
693 assert(0 <= pvIdx && pvIdx < constraintInfo.size());
694 applyDirichletConstraint(dofIdx, values, eqIdx, pvIdx);
695 }
696 }
697 }
698 }
699 }
700
701 // build periodic constraints in residual only
702 template<std::size_t i, class Res, class GG, class Sol>
703 void enforcePeriodicConstraints_(Dune::index_constant<i> domainI, Res& res, const GG& gridGeometry, const Sol& curSol) const
704 {
705 if constexpr (Detail::hasPeriodicDofMap<GG>())
706 {
707 for (const auto& m : gridGeometry.periodicDofMap())
708 {
709 const auto& periodicallyMappedDofs = Dumux::Deprecated::ensureRangeOfPeriodicDofs(m.second);
710 if (std::ranges::all_of(periodicallyMappedDofs, [&](auto second){ return m.first < second; }))
711 {
712 for (const auto& second : periodicallyMappedDofs)
713 {
714 // add the second row to the first
715 res[m.first] += res[second];
716
717 // enforce the solution of the first periodic DOF to the second one
718 res[second] = curSol[second] - curSol[m.first];
719 }
720 }
721 }
722 }
723 }
724
725 // enforce global constraints in residual only
726 template<std::size_t i, class Res, class GG, class Sol>
727 void enforceProblemConstraints_(Dune::index_constant<i> domainI, Res& res, const GG& gridGeometry, const Sol& curSol) const
728 {
730 {
731 for (const auto& constraintData : this->problem(domainI).constraints())
732 {
733 const auto& constraintInfo = constraintData.constraintInfo();
734 const auto& values = constraintData.values();
735 const auto dofIdx = constraintData.dofIndex();
736 for (int eqIdx = 0; eqIdx < constraintInfo.size(); ++eqIdx)
737 {
738 if (constraintInfo.isConstraintEquation(eqIdx))
739 {
740 const auto pvIdx = constraintInfo.eqToPriVarIndex(eqIdx);
741 assert(0 <= pvIdx && pvIdx < constraintInfo.size());
742 res[dofIdx][eqIdx] = curSol[dofIdx][pvIdx] - values[pvIdx];
743 }
744 }
745 }
746 }
747 }
748
750 ProblemTuple problemTuple_;
751
753 GridGeometryTuple gridGeometryTuple_;
754
756 GridVariablesTuple gridVariablesTuple_;
757
759 std::shared_ptr<const TimeLoop> timeLoop_;
760
762 const SolutionVector* prevSol_ = nullptr;
763
765 bool isStationaryProblem_;
766
768 std::shared_ptr<JacobianMatrix> jacobian_;
769 std::shared_ptr<ResidualType> residual_;
770
772 mutable bool warningIssued_;
773
775 bool enableMultithreading_ = false;
776};
777
778} // end namespace Dumux
779
780#endif
Subdomain-specific views on multidomain assemblers.
Traits shared by the multi-domain assemblers.
The interface of the coupling manager for multi domain problems.
Definition multidomain/couplingmanager.hh:37
Subdomain-specific view on a multidomain assembler. Allows retrieval of sub-domain specific objects w...
Definition assemblerview.hh:33
A linear system assembler (residual and Jacobian) for finite volume schemes (box, tpfa,...
Definition multidomain/fvassembler.hh:66
std::size_t numDofs(Dune::index_constant< i > domainId) const
the number of dof locations of domain i
Definition multidomain/fvassembler.hh:343
void updateGridVariables(const SolutionVector &curSol)
Updates the grid variables with the given solution.
Definition multidomain/fvassembler.hh:324
void updateAfterGridAdaption()
Resizes jacobian and residual and recomputes colors.
Definition multidomain/fvassembler.hh:314
typename MDTraits::SolutionVector SolutionVector
Definition multidomain/fvassembler.hh:88
typename MDTraits::template SubDomain< id >::Problem Problem
Definition multidomain/fvassembler.hh:85
JacobianMatrix & jacobian()
the full Jacobian matrix
Definition multidomain/fvassembler.hh:376
static constexpr bool isImplicit()
Returns true if the assembler considers implicit assembly.
Definition multidomain/fvassembler.hh:96
void assembleResidual(ResidualType &r, const SolutionVector &curSol)
assemble a residual r
Definition multidomain/fvassembler.hh:240
typename MDTraits::JacobianMatrix JacobianMatrix
Definition multidomain/fvassembler.hh:87
CMType CouplingManager
Definition multidomain/fvassembler.hh:91
void assembleResidual(const SolutionVector &curSol)
compute the residuals using the internal residual
Definition multidomain/fvassembler.hh:233
void resetTimeStep(const SolutionVector &curSol)
Resets the grid variables to the last time step.
Definition multidomain/fvassembler.hh:334
const GridVariables< i > & gridVariables(Dune::index_constant< i > domainId) const
the grid variables of domain i
Definition multidomain/fvassembler.hh:368
void setPreviousSolution(const SolutionVector &u)
Sets the solution from which to start the time integration. Has to be called prior to assembly for ti...
Definition multidomain/fvassembler.hh:398
typename MDTraits::template SubDomain< id >::GridVariables GridVariables
Definition multidomain/fvassembler.hh:79
const auto & gridGeometry(Dune::index_constant< i > domainId) const
Definition multidomain/fvassembler.hh:353
void setLinearSystem()
The version without arguments uses the default constructor to create the jacobian and residual object...
Definition multidomain/fvassembler.hh:282
const auto & gridView(Dune::index_constant< i > domainId) const
the grid view of domain i
Definition multidomain/fvassembler.hh:358
typename MDTraits::template SubDomain< id >::GridGeometry GridGeometry
Definition multidomain/fvassembler.hh:82
const CouplingManager & couplingManager() const
Definition multidomain/fvassembler.hh:372
void setTimeManager(std::shared_ptr< const TimeLoop > timeLoop)
Set time loop for instationary problems.
Definition multidomain/fvassembler.hh:391
const SolutionVector & prevSol() const
Definition multidomain/fvassembler.hh:384
GridVariables< i > & gridVariables(Dune::index_constant< i > domainId)
Definition multidomain/fvassembler.hh:363
std::shared_ptr< CouplingManager > couplingManager_
Definition multidomain/fvassembler.hh:416
MDTraits Traits
Definition multidomain/fvassembler.hh:71
MultiDomainFVAssembler(ProblemTuple problem, GridGeometryTuple gridGeometry, GridVariablesTuple gridVariables, std::shared_ptr< CouplingManager > couplingManager, std::shared_ptr< const TimeLoop > timeLoop, const SolutionVector &prevSol)
The constructor for instationary problems.
Definition multidomain/fvassembler.hh:183
void setJacobianBuildMode(JacobianMatrix &jac) const
Sets the jacobian build mode.
Definition multidomain/fvassembler.hh:295
typename MDTraits::template SubDomain< id >::LocalResidual LocalResidual
Definition multidomain/fvassembler.hh:76
LocalResidual< i > localResidual(Dune::index_constant< i > domainId) const
Create a local residual object (used by the local assembler).
Definition multidomain/fvassembler.hh:411
const auto & problem(Dune::index_constant< i > domainId) const
Definition multidomain/fvassembler.hh:348
typename MDTraits::ResidualVector ResidualType
Definition multidomain/fvassembler.hh:89
MultiDomainFVAssembler(ProblemTuple problem, GridGeometryTuple gridGeometry, GridVariablesTuple gridVariables, std::shared_ptr< CouplingManager > couplingManager)
The constructor for stationary problems.
Definition multidomain/fvassembler.hh:155
void assembleJacobianAndResidual(const SolutionVector &curSol)
Assembles the global Jacobian of the residual and the residual for the current solution.
Definition multidomain/fvassembler.hh:212
bool isStationaryProblem() const
Whether we are assembling a stationary or instationary problem.
Definition multidomain/fvassembler.hh:404
typename MDTraits::Scalar Scalar
Definition multidomain/fvassembler.hh:73
ResidualType & residual()
the full residual vector
Definition multidomain/fvassembler.hh:380
void setLinearSystem(std::shared_ptr< JacobianMatrix > A, std::shared_ptr< ResidualType > r)
Tells the assembler which jacobian and residual to use. This also resizes the containers to the requi...
Definition multidomain/fvassembler.hh:267
The cell-centered scheme multidomain local assembler.
Definition multidomain/subdomaincclocalassembler.hh:270
Definition multidomain/fvassembler.hh:53
Manages the handling of time dependent problems.
Definition common/timeloop.hh:84
The default time loop for instationary simulations.
Definition common/timeloop.hh:139
Defines all properties used in Dumux.
Manages the handling of time dependent problems.
Helper function to generate Jacobian pattern for multi domain models.
Helpers for deprecation.
An enum class to define various differentiation methods available in order to compute the derivatives...
Some exceptions thrown in DuMux.
dune-grid capabilities compatibility layer
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry &gridGeometry)
Helper function to generate Jacobian pattern for cell-centered methods.
Definition jacobianpattern.hh:29
Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager &couplingManager, Dune::index_constant< i > domainI, const GridGeometryI &gridGeometryI, Dune::index_constant< j > domainJ, const GridGeometryJ &gridGeometryJ)
Helper function to generate coupling Jacobian pattern (off-diagonal blocks) for cell-centered schemes...
Definition couplingjacobianpattern.hh:33
constexpr bool isSerial()
Checking whether the backend is serial.
Definition multithreading.hh:45
T getParam(Args &&... args)
A free function to get a parameter from the parameter tree singleton.
Definition parameters.hh:155
Helper function to generate Jacobian pattern for different discretization methods.
The available discretization methods in Dumux.
A multidomain local assembler for Jacobian and residual contribution per element (cell-centered metho...
An assembler for Jacobian and residual contribution per element (CVFE methods) for multidomain proble...
Multithreading in Dumux.
constexpr bool hasPeriodicDofMap()
Definition periodic.hh:24
constexpr bool hasSubProblemGlobalConstraints()
Definition assemblytraits.hh:30
Definition method.hh:20
bool allGridsSupportsMultithreading(const std::tuple< GridDiscretizations... > &gridDiscretizations)
Whether the grid views of all grid discretizations support multithreading.
Definition gridcapabilities.hh:44
Definition adapt.hh:17
const Scalar PengRobinsonMixture< Scalar, StaticParameters >::u
Definition pengrobinsonmixture.hh:138
typename Detail::ConcatSeq< decltype(std::make_index_sequence< e >{}), e+1, decltype(std::make_index_sequence<(n > e) ?(n - e - 1) :0 >{})>::type makeIncompleteIntegerSequence
Definition utility.hh:58
Provides a helper class for nonoverlapping decomposition.
Type traits to detect periodicity support.
Type trait that is specialized for coupling manager supporting multithreaded assembly.
Definition assemblytraits.hh:43
An assembler for Jacobian and residual contribution per element (face-centered staggered methods) for...
Utilities for template meta programming.