flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
scalar_krylov.hpp File Reference
#include <cmath>
#include <functional>
#include <Kokkos_Core.hpp>
#include <stdexcept>
#include <utility>
#include "mac_cutcell.hpp"

Go to the source code of this file.

Classes

struct  peclet::flow::ScalarKrylovResult
 Outcome of one scalarBiCGStab call. More...
struct  peclet::flow::ScalarVec
 A Krylov vector (§5.1): the fluid field and, for a conjugate scalar, the solid field (WO-7). More...
struct  peclet::flow::ScalarKrylovOps
 The injected pieces as callables (host-side calls that launch kernels; the overhead of the indirection is nothing next to a block-wide kernel). More...
struct  peclet::flow::skr::BiCGStabArgs
 The vectors and settings of one scalarBiCGStab call: the right-hand side, the iterate (the initial guess and the result), the scratch r, rh, p, v, t, z, z2, the iteration cap, the absolute stop threshold rtol * ref and the singular flag (§5.1). More...

Namespaces

namespace  peclet
namespace  peclet::flow
namespace  peclet::flow::skr
 The device slots of the resident pass, and the stop codes (exact in double).

Typedefs

using peclet::flow::skr::Slot = Kokkos::View<double, CCMem>

Enumerations

enum  : int {
  peclet::flow::skr::kRho = 0 , peclet::flow::skr::kAlpha = 1 , peclet::flow::skr::kOmega = 2 , peclet::flow::skr::kBeta = 3 ,
  peclet::flow::skr::kRhoNew = 4 , peclet::flow::skr::kRhv = 5 , peclet::flow::skr::kTr = 6 , peclet::flow::skr::kTt = 7 ,
  peclet::flow::skr::kStop = 8 , peclet::flow::skr::kRn = 9 , peclet::flow::skr::kRnS = 10 , peclet::flow::skr::kNSlots = 11
}

Functions

void peclet::flow::skr::axpy (CCField y, double a, CCConst x, C3 e, int g)
 y += a x over inner cells.
void peclet::flow::skr::aypx (CCField y, double a, CCConst x, C3 e, int g)
 y = x + a y over inner cells.
void peclet::flow::skr::residualFrom (CCField y, CCConst b, C3 e, int g)
 y = b - y over inner cells (the residual from a matvec result held in y).
void peclet::flow::skr::axpy (const ScalarVec &y, double a, const ScalarVec &x, C3 e, int g)
 The same three operations on a ScalarVec, phase by phase.
void peclet::flow::skr::aypx (const ScalarVec &y, double a, const ScalarVec &x, C3 e, int g)
void peclet::flow::skr::residualFrom (const ScalarVec &y, const ScalarVec &b, C3 e, int g)
void peclet::flow::skr::copy (const ScalarVec &y, const ScalarVec &x)
void peclet::flow::skr::zero (const ScalarVec &y)
Slot peclet::flow::skr::slot (const Kokkos::View< double *, CCMem > &ks, int k)
template<class State>
void peclet::flow::residentKrylov (State &st, ScalarKrylovOps &ops)
 Arm ops for the resident pass with the persistent slots of st (ks, pk, allocated once).
template<class F>
void peclet::flow::skr::scalarKernel (const char *name, F f)
 One-thread kernel on the slots (the coefficient arithmetic of the host pass, on the device).
void peclet::flow::skr::residentInit (const Kokkos::View< double *, CCMem > &ks)
void peclet::flow::skr::residentBeta (const Kokkos::View< double *, CCMem > &ks)
 (rh, r) breakdown, else beta = (rhoNew / rho) (alpha / omega) and rho = rhoNew.
void peclet::flow::skr::residentAlpha (const Kokkos::View< double *, CCMem > &ks)
 (rh, v) breakdown, else alpha = rho / (rh, v).
void peclet::flow::skr::residentOmega (const Kokkos::View< double *, CCMem > &ks)
 The tt breakdown, else omega = (t, r) / (t, t) and its breakdown.
void peclet::flow::skr::residentP (const ScalarVec &p, const ScalarVec &v, const ScalarVec &r, const Kokkos::View< double *, CCMem > &ks, C3 e, int g)
 p = r + beta (p - omega v): axpy(p, -omega, v) then aypx(p, beta, r), per phase; skipped on a stop.
void peclet::flow::skr::residentS (const ScalarVec &r, const ScalarVec &v, const Kokkos::View< double *, CCMem > &ks, C3 e, int g)
 r <- s = r - alpha v (axpy(r, -alpha, v)); skipped on a stop.
void peclet::flow::skr::residentXHalf (const ScalarVec &x, const ScalarVec &z, const Kokkos::View< double *, CCMem > &ks, C3 e, int g)
 x += alpha z (the half-step exit).
void peclet::flow::skr::residentXR (const ScalarVec &x, const ScalarVec &r, const ScalarVec &z, const ScalarVec &z2, const ScalarVec &t, const Kokkos::View< double *, CCMem > &ks, C3 e, int g)
 x += alpha z; x += omega z2; r -= omega t (the three axpys) — or, after a tt / omega breakdown, the alpha half-step alone.
void peclet::flow::skr::requireFinite (double rn)
 A residual max-norm that is not finite ends the solve.
template<class Ops>
void peclet::flow::skr::residualOf (Ops &ops, const BiCGStabArgs &w)
 r = b - A x (t as scratch), mean removed in the singular case.
bool peclet::flow::skr::stagnated (double rn, double &best, int &lastImprove, int it)
 The stagnation stop: true once 30 iterations brought no 0.1 % improvement of the best residual (the best-so-far level is then accepted); otherwise records an improvement.
template<class Ops>
void peclet::flow::skr::bicgPass (Ops &ops, const BiCGStabArgs &w, int &it)
 One BiCGStab pass from the current x (CutcellMG::solveBiCGStab's loop, with the §5.1 stop).
template<class Ops>
double peclet::flow::skr::readPacket (Ops &ops, const BiCGStabArgs &w, double &stop)
 The resident pass's packet {stop, max|r|} (both phases combined with std::fmax, as ops.maxabs): THE device-to-host read of a half or full step.
template<class Ops>
void peclet::flow::skr::bicgPassResident (Ops &ops, const BiCGStabArgs &w, int &it)
 The same pass with the scalars on the device (WO-9b; see the file comment).
template<class Ops>
double peclet::flow::skr::bicgTrueResidual (Ops &ops, const BiCGStabArgs &w)
 The true residual max|b - A x| after a pass (mean removed in the singular case).
template<class Ops>
ScalarKrylovResult peclet::flow::scalarBiCGStab (Ops &ops, const ScalarVec &b, const ScalarVec &x, const ScalarVec &r, const ScalarVec &rh, const ScalarVec &p, const ScalarVec &v, const ScalarVec &t, const ScalarVec &z, const ScalarVec &z2, int maxit, double rtol, bool singular)
 BiCGStab on A x = b.

Variables

constexpr double peclet::flow::skr::kBrkRho = 1.0
constexpr double peclet::flow::skr::kBrkRhv = 2.0
constexpr double peclet::flow::skr::kBrkTt = 3.0
constexpr double peclet::flow::skr::kBrkOmega = 4.0