BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::fem::dofmgr::SolverData Class Reference

#include <cl_FEM_DofMgr_SolverData.hpp>

Public Member Functions

 SolverData (DofManager *aParent, DofData *aDofData, BlockData *aBlockData, SideSetData *aSideSetData)
 ~SolverData ()
void extract_graph_from_mesh (Vector< id_t > &aGraphData)
void allocate_matrices (const Vector< id_t > &aGraphData, Graph &aFreeDofs, Graph &aFixedDofs)
 Allocates sparse matrices for the finite element system.
void compute_memory ()
void create_assembly_tables ()
void reset ()
void reset_convection ()
void reset_matrices (const bool aFullForce=false)
void reset_rhs_vector ()
void reset_rhs_matrix ()
void assemble_jacobian (Element *aElement, const Matrix< real > &aJacobian)
void assemble_full_matrices (Element *aElement, const Matrix< real > &aMass, const Matrix< real > &aStiffness)
void assemble_newton (Element *aElement, const Matrix< real > &adJdx)
void assemble_rhs (Element *aElement, const Vector< real > &aRHS)
void assemble_volume_loads (Element *aElement, const Vector< real > &aRHS)
void asseble_surface_loads (Element *aElement, const Vector< real > &aRHS)
void assemble_rhs (Element *aElement, const Matrix< real > &aRHS)
void collect_matrices (const bool aFullForce=false)
void collect_rhs_vector ()
void collect_vector (Vector< real > &aVector)
void collect_rhs_matrix ()
void update_field_values ()
void set_solver (const SolverParameters &aParams)
 set the solver type for this field
Solversolver ()
 expose the solver
void solve ()
 solve the system.
void compute_residual ()
 Phase 1 of the two-phase iterative solve: prepare the load-adjusted RHS b, capture ||b||, and overwrite mRhsVector with the residual r = A x - b of the COMMITTED state under the current assembly — without solving.
void solve_from_residual ()
 Phase 2: consume the residual left by compute_residual(), run the linear solve and the algorithm's update ( relaxed / Anderson Picard, or the Newton step with its post-update recompute ).
void invalidate_residual ()
 invalidate the two-phase handshake; called by a fresh assembly
real residual (const uint aIteration)
 return the residual
real absolute_residual () const
 absolute residual norm of the last residual() call ( rank-uniform, broadcast alongside the relative value )
real pre_update_residual () const
 pre-update residual of the entry state under the current assembly ( Newton iterates only, QUIET_NAN otherwise; rank-uniform after residual() ).
real fixed_point_residual () const
 fixed-point residual ||G(x)-x|| / ||x|| of the last Anderson update ( rank-uniform after residual() )
void set_anderson_depth (const uint aDepth)
 activate ( depth > 0 ) or deactivate ( depth = 0 ) Anderson mixing of the Picard branch; allocates the history registers
void anderson_commit ()
 move the staged ( x, r ) pair into the history; called by the controller once the trial iterate is accepted.
void anderson_discard ()
 drop the staged pair ( trial was rejected )
void anderson_clear ()
 invalidate the history ( new attempt, algorithm switch, restore, ... ); also drops any staged pair
SpMatrixsystem_matrix ()
SpMatrixenforcement ()
SpMatrixdirichlet ()
SpMatriximposition ()
SpMatrixmatrix (const MatrixType aType)
Cell< Vector< index_t > > & tables (const MatrixType aType)
Vector< real > & rhs_vector ()
real rhs_norm ()
Vector< real > & volume_loads ()
Vector< real > & surface_loads ()
index_t number_of_free_dofs () const
index_t number_of_fixed_dofs () const
index_t my_number_of_free_dofs () const
index_t my_number_of_fixed_dofs () const
void save_system (const string &aPath)
void load_system (const string &aPath)
void remember_initialization_values (const bool aSaveRHS)
void use_reset_values (const bool aFlag)
void use_jedi_force (const bool aFlag)
void use_full_force (const bool aFlag)
void populate_graph (const Vector< id_t > &aData, const MatrixType aMatrixType, Graph &aFreeDofs, Graph &aFixedDofs, bool aLinkToSelf=true)
 Builds vertex connectivity for sparse matrix sparsity patterns.

Constructor & Destructor Documentation

◆ SolverData()

belfem::fem::dofmgr::SolverData::SolverData ( DofManager * aParent,
DofData * aDofData,
BlockData * aBlockData,
SideSetData * aSideSetData )

◆ ~SolverData()

belfem::fem::dofmgr::SolverData::~SolverData ( )

Member Function Documentation

◆ absolute_residual()

real belfem::fem::dofmgr::SolverData::absolute_residual ( ) const
inline

absolute residual norm of the last residual() call ( rank-uniform, broadcast alongside the relative value )

◆ allocate_matrices()

void belfem::fem::dofmgr::SolverData::allocate_matrices ( const Vector< id_t > & aGraphData,
Graph & aFreeDofs,
Graph & aFixedDofs )

Allocates sparse matrices for the finite element system.

Purpose:

  • Creates sparse matrix structures with optimized sparsity patterns
  • Supports both JEDI Force matrices (J, D, E, I) and Full matrices (M, K)
  • Allocates RHS vectors/matrices for solution

Matrix Types: JEDI Force:

  • Jacobian (J): n×n matrix (free-free interactions)
  • Dirichlet (D): n×m matrix (free-fixed interactions, negative sign in assembly)
  • Enforcement (E): m×n matrix (fixed-free, computes reaction forces) [if mUseJediForce]
  • Imposition (I): m×m matrix (fixed-fixed self-coupling) [if mUseJediForce]

Full Force (if mUseFullForce):

  • FullMass (M): (n+m)×(n+m) matrix (all DOFs, eigenvalue analysis)
  • FullStiffness (K): (n+m)×(n+m) matrix (all DOFs, eigenvalue analysis)

Workflow:

  1. If mUseFullForce: allocate FullMass / FullStiffness in the combined index space
  2. Allocate the Dirichlet matrix (always)
  3. If mUseJediForce: allocate Enforcement and Imposition
  4. Allocate the System matrix from the System graph (must be last), then the Jacobian as its child (shared pointers and indices)
  5. Allocate RHS vector or matrix

Index Space Handling for Full Matrices:

  • Free DOFs normally use indices 0..n-1 (SEPARATE mode)
  • Fixed DOFs normally use indices 0..m-1 (SEPARATE mode)
  • Full matrices require combined indexing: free=0..n-1, fixed=n..n+m-1
  • Temporarily shift fixed DOF indices, merge graphs, create matrices, restore

Graph Requirements:

  • aFreeDofs: Contains free DOF vertices with reordered indices 0..n-1
  • aFixedDofs: Contains fixed DOF vertices with reordered indices 0..m-1
  • For matrix rows: Graph passed to SpMatrix must match row DOF type • Jacobian (J) → aFreeDofs (free rows × free cols) • Dirichlet (D) → aFreeDofs (free rows × fixed cols) • Enforcement (E) → aFixedDofs (fixed rows × free cols) • Imposition (I) → aFixedDofs (fixed rows × fixed cols)

Preconditions:

  • DOFs must be reordered (via reorder_dofs())
  • aGraphData contains complete DOF-to-DOF connectivity
  • Solver must be initialized

Postconditions:

  • All required sparse matrices allocated with correct sparsity patterns
  • RHS vectors/matrices allocated

◆ anderson_clear()

void belfem::fem::dofmgr::SolverData::anderson_clear ( )

invalidate the history ( new attempt, algorithm switch, restore, ... ); also drops any staged pair

◆ anderson_commit()

void belfem::fem::dofmgr::SolverData::anderson_commit ( )

move the staged ( x, r ) pair into the history; called by the controller once the trial iterate is accepted.

No-op if mixing is off or nothing is staged.

◆ anderson_discard()

void belfem::fem::dofmgr::SolverData::anderson_discard ( )

drop the staged pair ( trial was rejected )

◆ asseble_surface_loads()

void belfem::fem::dofmgr::SolverData::asseble_surface_loads ( Element * aElement,
const Vector< real > & aRHS )

◆ assemble_full_matrices()

void belfem::fem::dofmgr::SolverData::assemble_full_matrices ( Element * aElement,
const Matrix< real > & aMass,
const Matrix< real > & aStiffness )

◆ assemble_jacobian()

void belfem::fem::dofmgr::SolverData::assemble_jacobian ( Element * aElement,
const Matrix< real > & aJacobian )

◆ assemble_newton()

void belfem::fem::dofmgr::SolverData::assemble_newton ( Element * aElement,
const Matrix< real > & adJdx )

◆ assemble_rhs() [1/2]

void belfem::fem::dofmgr::SolverData::assemble_rhs ( Element * aElement,
const Matrix< real > & aRHS )

◆ assemble_rhs() [2/2]

void belfem::fem::dofmgr::SolverData::assemble_rhs ( Element * aElement,
const Vector< real > & aRHS )

◆ assemble_volume_loads()

void belfem::fem::dofmgr::SolverData::assemble_volume_loads ( Element * aElement,
const Vector< real > & aRHS )

◆ collect_matrices()

void belfem::fem::dofmgr::SolverData::collect_matrices ( const bool aFullForce = false)

◆ collect_rhs_matrix()

void belfem::fem::dofmgr::SolverData::collect_rhs_matrix ( )

◆ collect_rhs_vector()

void belfem::fem::dofmgr::SolverData::collect_rhs_vector ( )

◆ collect_vector()

void belfem::fem::dofmgr::SolverData::collect_vector ( Vector< real > & aVector)

◆ compute_memory()

void belfem::fem::dofmgr::SolverData::compute_memory ( )

◆ compute_residual()

void belfem::fem::dofmgr::SolverData::compute_residual ( )

Phase 1 of the two-phase iterative solve: prepare the load-adjusted RHS b, capture ||b||, and overwrite mRhsVector with the residual r = A x - b of the COMMITTED state under the current assembly — without solving.

residual() then reports the head certificate. One-shot per assembly ( load terms would double-add ); requires a fresh compute_jacobian_and_rhs.

◆ create_assembly_tables()

void belfem::fem::dofmgr::SolverData::create_assembly_tables ( )

◆ dirichlet()

SpMatrix * belfem::fem::dofmgr::SolverData::dirichlet ( )
inline

◆ enforcement()

SpMatrix * belfem::fem::dofmgr::SolverData::enforcement ( )
inline

◆ extract_graph_from_mesh()

void belfem::fem::dofmgr::SolverData::extract_graph_from_mesh ( Vector< id_t > & aGraphData)

◆ fixed_point_residual()

real belfem::fem::dofmgr::SolverData::fixed_point_residual ( ) const
inline

fixed-point residual ||G(x)-x|| / ||x|| of the last Anderson update ( rank-uniform after residual() )

◆ imposition()

SpMatrix * belfem::fem::dofmgr::SolverData::imposition ( )
inline

◆ invalidate_residual()

void belfem::fem::dofmgr::SolverData::invalidate_residual ( )
inline

invalidate the two-phase handshake; called by a fresh assembly

◆ load_system()

void belfem::fem::dofmgr::SolverData::load_system ( const string & aPath)

◆ matrix()

SpMatrix * belfem::fem::dofmgr::SolverData::matrix ( const MatrixType aType)
inline

◆ my_number_of_fixed_dofs()

index_t belfem::fem::dofmgr::SolverData::my_number_of_fixed_dofs ( ) const
inline

◆ my_number_of_free_dofs()

index_t belfem::fem::dofmgr::SolverData::my_number_of_free_dofs ( ) const
inline

◆ number_of_fixed_dofs()

index_t belfem::fem::dofmgr::SolverData::number_of_fixed_dofs ( ) const
inline

◆ number_of_free_dofs()

index_t belfem::fem::dofmgr::SolverData::number_of_free_dofs ( ) const
inline

◆ populate_graph()

void belfem::fem::dofmgr::SolverData::populate_graph ( const Vector< id_t > & aData,
const MatrixType aMatrixType,
Graph & aFreeDofs,
Graph & aFixedDofs,
bool aLinkToSelf = true )

Builds vertex connectivity for sparse matrix sparsity patterns.

Purpose:

  • Creates graph connectivity by linking DOF vertices based on element topology
  • Filters connections by DOF type (free/fixed) to match specific matrix structure
  • Supports both JEDI Force matrices (J, D, E, I) and Full matrices (M, K)
  • Optionally excludes self-connections for graph reordering algorithms

Matrix Type Mapping (rows × columns):

  • Jacobian (J): free × free (standard stiffness, used for solving)
  • Dirichlet (D): free × fixed (BC enforcement, negative sign in assembly)
  • Enforcement (E): fixed × free (computes reaction forces at constraints)
  • Imposition (I): fixed × fixed (self-coupling of prescribed DOFs)
  • FullMass (M): all × all (eigenvalue analysis, combined index space)
  • FullStiffness (K):all × all (eigenvalue analysis, combined index space)

Algorithm:

  1. Determine row/column DOF types from matrix type
  2. For each DOF in connectivity data: a. Check if DOF should be a row vertex (matches tRowIsFixed) b. Loop over all connected DOFs from elements c. Filter connections by column type (matches tColIsFixed) d. Mark connections in bitset using my_index + offset e. [Optional] Remove self-connection if aLinkToSelf=false f. Convert bitset to index list g. Insert vertex pointers into DOF's connectivity list

Index Space Handling:

  • Free DOFs: my_index = 0..n-1, offset = 0
  • Fixed DOFs: my_index = 0..m-1, offset = tMyNumberOfFreeDofs
  • Bitset size: (n+m) to accommodate both types with offset
  • For full matrices: uses combined space, fixed DOFs already offset

Bitset Mechanism:

  • Efficiently tracks unique connections (prevents duplicates)
  • Position i in bitset represents DOF with my_index i (or i-offset for fixed)
  • bitset.where() extracts set positions into index list

Graph Vertex Container:

  • Each Dof inherits from graph::Vertex
  • Vertex has container of connected vertices (adjacency list)
  • SpMatrix constructor reads this connectivity to build sparsity pattern

Parameters:

Parameters
aDataDOF-to-DOF connectivity from extract_graph_from_mesh() Format: [num_dofs, dof_id, num_connected, dof_id, ...]
aMatrixTypeWhich matrix to populate (J, D, E, I, FullMass, FullStiffness)
aFreeDofsGraph vertices for free DOFs (indices 0..n-1)
aFixedDofsGraph vertices for fixed DOFs (indices 0..m-1)
aLinkToSelfInclude diagonal connections (default true)
  • true: Include self-connections (for matrix allocation)
  • false: Exclude self-connections (for METIS/SCOTCH reordering)

Preconditions:

  • aData contains complete DOF connectivity from extract_graph_from_mesh()
  • aFreeDofs and aFixedDofs contain reordered DOF vertices
  • Each DOF's my_index is set to its position in respective graph (0..n-1 or 0..m-1)

Postconditions:

  • Each row DOF has vertex container populated with column DOF vertices
  • Connectivity matches requested matrix type structure
  • Ready for SpMatrix construction

Usage Example: // For Jacobian (free × free): populate_graph(graphData, Jacobian, freeDofs, fixedDofs, true); // Result: Each free DOF points to all connected free DOFs

// For Dirichlet (free × fixed): populate_graph(graphData, Dirichlet, freeDofs, fixedDofs, false); // Result: Each free DOF points to all connected fixed DOFs, no self-links

◆ pre_update_residual()

real belfem::fem::dofmgr::SolverData::pre_update_residual ( ) const
inline

pre-update residual of the entry state under the current assembly ( Newton iterates only, QUIET_NAN otherwise; rank-uniform after residual() ).

The honest backtracking reference — see the member comment

◆ remember_initialization_values()

void belfem::fem::dofmgr::SolverData::remember_initialization_values ( const bool aSaveRHS)

◆ reset()

void belfem::fem::dofmgr::SolverData::reset ( )

◆ reset_convection()

void belfem::fem::dofmgr::SolverData::reset_convection ( )

◆ reset_matrices()

void belfem::fem::dofmgr::SolverData::reset_matrices ( const bool aFullForce = false)

◆ reset_rhs_matrix()

void belfem::fem::dofmgr::SolverData::reset_rhs_matrix ( )

◆ reset_rhs_vector()

void belfem::fem::dofmgr::SolverData::reset_rhs_vector ( )

◆ residual()

real belfem::fem::dofmgr::SolverData::residual ( const uint aIteration)

return the residual

◆ rhs_norm()

real belfem::fem::dofmgr::SolverData::rhs_norm ( )
inline

◆ rhs_vector()

Vector< real > & belfem::fem::dofmgr::SolverData::rhs_vector ( )
inline

◆ save_system()

void belfem::fem::dofmgr::SolverData::save_system ( const string & aPath)

◆ set_anderson_depth()

void belfem::fem::dofmgr::SolverData::set_anderson_depth ( const uint aDepth)

activate ( depth > 0 ) or deactivate ( depth = 0 ) Anderson mixing of the Picard branch; allocates the history registers

◆ set_solver()

void belfem::fem::dofmgr::SolverData::set_solver ( const SolverParameters & aParams)

set the solver type for this field

◆ solve()

void belfem::fem::dofmgr::SolverData::solve ( )

solve the system.

For the iterative vector-RHS path this is the fused composition compute_residual() + solve_from_residual(); Direct mode and matrix-RHS callers keep the single-call contract unchanged.

◆ solve_from_residual()

void belfem::fem::dofmgr::SolverData::solve_from_residual ( )

Phase 2: consume the residual left by compute_residual(), run the linear solve and the algorithm's update ( relaxed / Anderson Picard, or the Newton step with its post-update recompute ).

Must be entered on EVERY rank — the collective barrier pairing lives here.

◆ solver()

Solver * belfem::fem::dofmgr::SolverData::solver ( )
inline

expose the solver

◆ surface_loads()

Vector< real > & belfem::fem::dofmgr::SolverData::surface_loads ( )
inline

◆ system_matrix()

SpMatrix * belfem::fem::dofmgr::SolverData::system_matrix ( )
inline

◆ tables()

Cell< Vector< index_t > > & belfem::fem::dofmgr::SolverData::tables ( const MatrixType aType)
inline

◆ update_field_values()

void belfem::fem::dofmgr::SolverData::update_field_values ( )

◆ use_full_force()

void belfem::fem::dofmgr::SolverData::use_full_force ( const bool aFlag)

◆ use_jedi_force()

void belfem::fem::dofmgr::SolverData::use_jedi_force ( const bool aFlag)

◆ use_reset_values()

void belfem::fem::dofmgr::SolverData::use_reset_values ( const bool aFlag)
inline

◆ volume_loads()

Vector< real > & belfem::fem::dofmgr::SolverData::volume_loads ( )
inline

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