core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::solver::AndersonCore Class Reference

#include <anderson.hpp>

Public Types

enum class  Status : int { Active = 0 , Disabled = 1 }
 

Public Member Functions

 AndersonCore (AndersonState state, int window=5, double mixing=1.0)
 Allocates the history (design §6.3: (2m+3)·n_s·8·n_pad bytes).
 
 AndersonCore (const AndersonCore &)=delete
 
AndersonCore & operator= (const AndersonCore &)=delete
 
 AndersonCore (AndersonCore &&)=default
 
AndersonCore & operator= (AndersonCore &&)=default
 
bool prepare (bool accelerate)
 §4.3 steps 0–1.
 
bool stepFailed (const std::string &what)
 §4.3 step 2, the caller's step threw.
 
void complete (bool pressureSolveFailed=false)
 §4.3 steps 3–7, after the caller's step.
 
void reset ()
 Clears the history and the counters (design §4.2); keeps the previous evaluation, so the next call forms a column at once.
 
void invalidate ()
 The caller's map changed (flow: its parameter signature) or the state was written: reset() and forget the previous evaluation; counts in numResets().
 
void disable ()
 Stops acceleration for good: prepare/complete become no-ops around a plain step.
 
Status status () const
 
const char * statusName () const
 "active" | "disabled".
 
const std::string & reason () const
 
double residual () const
 Relative velocity residual of the last evaluation whose output the state holds (design §3.2; after a restart, the restored output's); +inf before the first.
 
int numRestarts () const
 
int numResets () const
 
int numColumns () const
 Window columns in use (mk).
 
int window () const
 
double mixing () const
 
bool engaged () const
 
bool pending () const
 A mix is pending for the next accelerated call.
 
std::vector< double > gamma () const
 The pending coefficients γ, oldest column first (numColumns() of them).
 
std::size_t memoryBytes () const
 Bytes held by the history, X, Rprev and Gprev: equals memoryBytesFor(window(), n_s, n_pad).
 
const AndersonState & state () const
 

Static Public Member Functions

static std::size_t memoryBytesFor (int window, std::size_t numFields, Index nPad)
 The §6.3 memory formula: (2m + 3)·n_s·8·n_pad bytes.
 

Static Public Attributes

static constexpr int kMaxWindow = detail::anderson::kMaxWindow
 
static constexpr int kEngageDecreases = 2
 
static constexpr double kRestartGrowth = 4.0
 
static constexpr int kMaxRestarts = 5
 
static constexpr double kNoiseFloor = 1e-10
 
static constexpr double kCondMin = 1e-12
 

Detailed Description

Definition at line 329 of file anderson.hpp.

Member Enumeration Documentation

◆ Status

Enumerator
Active 
Disabled 

Definition at line 342 of file anderson.hpp.

Constructor & Destructor Documentation

◆ AndersonCore() [1/3]

peclet::core::solver::AndersonCore::AndersonCore ( AndersonState  state,
int  window = 5,
double  mixing = 1.0 
)
inlineexplicit

Allocates the history (design §6.3: (2m+3)·n_s·8·n_pad bytes).

Collective over state.comm (one 2-double sum {invalid descriptor, failed allocation}, so that every rank throws when one rank's descriptor is inconsistent or one rank's allocation fails). Throws std::invalid_argument (on every rank) for an inconsistent descriptor and std::runtime_error (on every rank) when the history does not fit.

Definition at line 349 of file anderson.hpp.

References peclet::core::solver::AndersonState::fields, and memoryBytesFor().

◆ AndersonCore() [2/3]

peclet::core::solver::AndersonCore::AndersonCore ( const AndersonCore &  )
delete

◆ AndersonCore() [3/3]

peclet::core::solver::AndersonCore::AndersonCore ( AndersonCore &&  )
default

Member Function Documentation

◆ operator=() [1/2]

AndersonCore & peclet::core::solver::AndersonCore::operator= ( const AndersonCore &  )
delete

◆ operator=() [2/2]

AndersonCore & peclet::core::solver::AndersonCore::operator= ( AndersonCore &&  )
default

◆ memoryBytesFor()

static std::size_t peclet::core::solver::AndersonCore::memoryBytesFor ( int  window,
std::size_t  numFields,
Index  nPad 
)
inlinestatic

The §6.3 memory formula: (2m + 3)·n_s·8·n_pad bytes.

Definition at line 406 of file anderson.hpp.

References window().

Referenced by AndersonCore().

◆ prepare()

bool peclet::core::solver::AndersonCore::prepare ( bool  accelerate)
inline

§4.3 steps 0–1.

Detects an external write of the state (inner entries only), then either applies the pending mix (accelerate, pending, active) or records the input. Returns whether the state now holds a mixed iterate. Collective (one 1-double sum) while active; one host synchronisation (the COUNT read-back).

Definition at line 417 of file anderson.hpp.

References Active, peclet::core::solver::detail::anderson::MixColumns::count, peclet::core::solver::detail::anderson::countChanged(), peclet::core::solver::AndersonState::extent, peclet::core::solver::AndersonState::fields, peclet::core::solver::AndersonState::ghost, invalidate(), and peclet::core::solver::detail::anderson::mix().

◆ stepFailed()

bool peclet::core::solver::AndersonCore::stepFailed ( const std::string &  what)
inline

§4.3 step 2, the caller's step threw.

Returns true when the failure was absorbed: the input was a mixed iterate, so the state is restored to the last map output, acceleration is disabled and the caller continues (plain). Returns false when the caller must rethrow.

Definition at line 461 of file anderson.hpp.

References Active, peclet::core::solver::AndersonState::comm, Disabled, peclet::core::solver::AndersonComm::rank, and reset().

◆ complete()

void peclet::core::solver::AndersonCore::complete ( bool  pressureSolveFailed = false)
inline

§4.3 steps 3–7, after the caller's step.

pressureSolveFailed must be rank-consistent. Collective while active: a (2·columns + 2)-double sum and a broadcast of rank 0's decisions; one host synchronisation (the pass-2 read-back). The device copies are stream-ordered.

Definition at line 480 of file anderson.hpp.

References Active, Disabled, peclet::core::solver::AndersonState::extent, peclet::core::solver::AndersonState::fields, peclet::core::solver::AndersonState::ghost, kCondMin, kEngageDecreases, kMaxRestarts, kMaxWindow, kNoiseFloor, kRestartGrowth, reset(), peclet::core::solver::AndersonState::roles, and peclet::core::solver::Velocity.

◆ reset()

void peclet::core::solver::AndersonCore::reset ( )
inline

Clears the history and the counters (design §4.2); keeps the previous evaluation, so the next call forms a column at once.

Definition at line 638 of file anderson.hpp.

Referenced by complete(), invalidate(), and stepFailed().

◆ invalidate()

void peclet::core::solver::AndersonCore::invalidate ( )
inline

The caller's map changed (flow: its parameter signature) or the state was written: reset() and forget the previous evaluation; counts in numResets().

Definition at line 647 of file anderson.hpp.

References reset().

Referenced by prepare().

◆ disable()

void peclet::core::solver::AndersonCore::disable ( )
inline

Stops acceleration for good: prepare/complete become no-ops around a plain step.

Definition at line 654 of file anderson.hpp.

References Active, and Disabled.

◆ status()

Status peclet::core::solver::AndersonCore::status ( ) const
inline

Definition at line 665 of file anderson.hpp.

◆ statusName()

const char * peclet::core::solver::AndersonCore::statusName ( ) const
inline

"active" | "disabled".

Definition at line 667 of file anderson.hpp.

References Active.

◆ reason()

const std::string & peclet::core::solver::AndersonCore::reason ( ) const
inline

Definition at line 668 of file anderson.hpp.

◆ residual()

double peclet::core::solver::AndersonCore::residual ( ) const
inline

Relative velocity residual of the last evaluation whose output the state holds (design §3.2; after a restart, the restored output's); +inf before the first.

Definition at line 671 of file anderson.hpp.

◆ numRestarts()

int peclet::core::solver::AndersonCore::numRestarts ( ) const
inline

Definition at line 672 of file anderson.hpp.

◆ numResets()

int peclet::core::solver::AndersonCore::numResets ( ) const
inline

Definition at line 673 of file anderson.hpp.

◆ numColumns()

int peclet::core::solver::AndersonCore::numColumns ( ) const
inline

Window columns in use (mk).

Definition at line 675 of file anderson.hpp.

◆ window()

int peclet::core::solver::AndersonCore::window ( ) const
inline

Definition at line 676 of file anderson.hpp.

Referenced by memoryBytesFor().

◆ mixing()

double peclet::core::solver::AndersonCore::mixing ( ) const
inline

Definition at line 677 of file anderson.hpp.

◆ engaged()

bool peclet::core::solver::AndersonCore::engaged ( ) const
inline

Definition at line 678 of file anderson.hpp.

◆ pending()

bool peclet::core::solver::AndersonCore::pending ( ) const
inline

A mix is pending for the next accelerated call.

Definition at line 680 of file anderson.hpp.

◆ gamma()

std::vector< double > peclet::core::solver::AndersonCore::gamma ( ) const
inline

The pending coefficients γ, oldest column first (numColumns() of them).

Definition at line 682 of file anderson.hpp.

◆ memoryBytes()

std::size_t peclet::core::solver::AndersonCore::memoryBytes ( ) const
inline

Bytes held by the history, X, Rprev and Gprev: equals memoryBytesFor(window(), n_s, n_pad).

Definition at line 684 of file anderson.hpp.

References peclet::core::add().

◆ state()

const AndersonState & peclet::core::solver::AndersonCore::state ( ) const
inline

Definition at line 699 of file anderson.hpp.

Member Data Documentation

◆ kMaxWindow

constexpr int peclet::core::solver::AndersonCore::kMaxWindow = detail::anderson::kMaxWindow
staticconstexpr

Definition at line 332 of file anderson.hpp.

Referenced by complete().

◆ kEngageDecreases

constexpr int peclet::core::solver::AndersonCore::kEngageDecreases = 2
staticconstexpr

Definition at line 333 of file anderson.hpp.

Referenced by complete().

◆ kRestartGrowth

constexpr double peclet::core::solver::AndersonCore::kRestartGrowth = 4.0
staticconstexpr

Definition at line 334 of file anderson.hpp.

Referenced by complete().

◆ kMaxRestarts

constexpr int peclet::core::solver::AndersonCore::kMaxRestarts = 5
staticconstexpr

Definition at line 335 of file anderson.hpp.

Referenced by complete().

◆ kNoiseFloor

constexpr double peclet::core::solver::AndersonCore::kNoiseFloor = 1e-10
staticconstexpr

Definition at line 336 of file anderson.hpp.

Referenced by complete().

◆ kCondMin

constexpr double peclet::core::solver::AndersonCore::kCondMin = 1e-12
staticconstexpr

Definition at line 337 of file anderson.hpp.

Referenced by complete().


The documentation for this class was generated from the following file: