16#ifndef DUMUX_ASSEMBLY_PERIODIC_CONSTRAINTS_HH
17#define DUMUX_ASSEMBLY_PERIODIC_CONSTRAINTS_HH
28template<
class Gr
idGeometry,
class Function>
33 for (
const auto& m : gridGeometry.periodicDofMap())
35 const auto& periodicallyMappedDofs = Dumux::Deprecated::ensureRangeOfPeriodicDofs(m.second);
36 if (std::ranges::all_of(periodicallyMappedDofs, [&](
auto second){
return m.first < second; }))
37 for (
const auto& second : periodicallyMappedDofs)
44template<
class Gr
idGeometry,
class Res
idual,
class Solution>
45void enforceInResidual(
const GridGeometry& gridGeometry, Residual& res,
const Solution& curSol)
49 res[first] += res[second];
50 res[second] = curSol[second] - curSol[first];
55template<
class Gr
idGeometry,
class Matrix>
60 const auto end = jac[second].end();
61 for (
auto it = jac[second].begin(); it != end; ++it)
62 jac[first][it.index()] += (*it);
64 for (
auto it = jac[second].begin(); it != end; ++it)
66 auto& matrixBlock = *it;
69 assert(matrixBlock.N() == matrixBlock.M());
70 const double diagValue = it.index() == second ? 1.0 : (it.index() == first ? -1.0 : 0.0);
72 for (
int eIdx = 0; eIdx < matrixBlock.N(); ++eIdx)
73 matrixBlock[eIdx][eIdx] = diagValue;
Definition periodicconstraints.hh:25
void enforceInResidual(const GridGeometry &gridGeometry, Residual &res, const Solution &curSol)
Add the residual of each periodic degree of freedom to the one it is mapped to and replace it by the ...
Definition periodicconstraints.hh:45
void forEachPeriodicPair(const GridGeometry &gridGeometry, Function &&f)
Call f(first, second) for each periodically mapped degree of freedom second of the degree of freedom ...
Definition periodicconstraints.hh:29
void enforceInJacobian(const GridGeometry &gridGeometry, Matrix &jac)
Add the matrix row of each periodic degree of freedom to the one it is mapped to and replace it by th...
Definition periodicconstraints.hh:56
constexpr bool hasPeriodicDofMap()
Definition periodic.hh:24
Type traits to detect periodicity support.