Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::la Namespace Reference

Namespaces

namespace  internal

Classes

struct  DataBoomerAMG
struct  DataGAMG
class  LinearSolver
 A linear solver class wrapping PETSc KSP solvers. More...
class  SparseMatrix
class  Tensor
 Ultra-lightweight wrapper for PETSc Vec with Eigen mapping. Loads only the data and maps it using externally provided cell IDs. For now it considers only tensors which are stored in a flatten array. More...
class  Vector
 A wrapper around PETSc Vec for distributed vectors. More...

Enumerations

enum  DataLayout { ColumnMajor , RowMajor }

Functions

template<typename CellManagerType, typename DofHandlerType>
Vector constantModalCoefficients (CellManagerType &cell_manager, const DofHandlerType &dof_handler, double value=1.0)
 Coefficients of a constant function in a modal DG space.
void setPETScOptionValue (const std::string &name, const std::string &value)
double dot (const Vector &a, const Vector &b)
void extractComponent (const Vector &blocked_vec, std::size_t f, Vector &comp)
 Extract one scalar component from a blocked vector into an existing scalar vector (owned entries; ghost entries untouched).
template<typename DofHandlerType>
Vector extractComponent (const Vector &blocked_vec, const DofHandlerType &dof_handler, std::size_t f)
 Extract one scalar component from a blocked vector into a new vector.
template<std::size_t NFields, typename DofHandlerType>
std::vector< Vector > extractAllComponents (const Vector &blocked_vec, const DofHandlerType &dof_handler)
 Extract all scalar components from a blocked vector.
template<std::size_t NFields, typename DofHandlerType>
Vector mergeBlockedVector (const std::vector< Vector > &scalars, const DofHandlerType &dof_handler)
 Merge scalar vectors into a blocked vector.
void addComponent (const Vector &scalar_vec, Vector &blocked_vec, std::size_t f)
 Add a scalar vector into one stride of a blocked vector.
void extractDiagonalBlockComponent (const SparseMatrix &blocked_mat, std::size_t component, SparseMatrix &scalar_mat, double zero_tol=0.0)
 Extract one scalar diagonal component from a blocked matrix.
template<std::size_t NFields>
void mergeDiagonalBlockedMatrix (const std::array< std::reference_wrapper< const SparseMatrix >, NFields > &scalar_components, SparseMatrix &blocked_mat, double zero_tol=0.0)
 Merge scalar diagonal component matrices into a blocked matrix.

Variables

static constexpr PetscInt kMaxDenseExtractSize = 2000
 Largest scalar dimension for which the dense helpers below call toEigenDense(). Beyond it the O(N^2) dense allocation would exhaust memory, so these helpers abort.

Enumeration Type Documentation

◆ DataLayout

Enumerator
ColumnMajor 
RowMajor 

Function Documentation

◆ addComponent()

void vulpes::la::addComponent ( const Vector & scalar_vec,
Vector & blocked_vec,
std::size_t f )
inline

Add a scalar vector into one stride of a blocked vector.

Deduces the block size from the size ratio blocked/scalar and calls VecSetBlockSize before scattering, so this works even when blocked_vec was constructed without an explicit block size (e.g. from a size-only constructor).

Parameters
scalar_vecScalar source vector (block size 1)
blocked_vecBlocked destination vector (accumulates with ADD_VALUES)
fComponent (stride) index to scatter into

◆ constantModalCoefficients()

template<typename CellManagerType, typename DofHandlerType>
Vector vulpes::la::constantModalCoefficients ( CellManagerType & cell_manager,
const DofHandlerType & dof_handler,
double value = 1.0 )

Coefficients of a constant function in a modal DG space.

The constant is represented exactly by the first basis function of each cell, which is the constant mode of the modal Legendre basis, so the coefficients are computed cell by cell without solving any system. Only the coefficients of the owned cells are set (the others are zero). Typical use: near null space of the Laplacian for algebraic multigrid (see la::SparseMatrix::setNearNullSpace()).

Parameters
cell_managerCell manager of the modal FE space
dof_handlerThe DOF handler
valueThe constant value
Returns
Modal coefficients of the constant function

◆ dot()

double vulpes::la::dot ( const Vector & a,
const Vector & b )

◆ extractAllComponents()

template<std::size_t NFields, typename DofHandlerType>
std::vector< Vector > vulpes::la::extractAllComponents ( const Vector & blocked_vec,
const DofHandlerType & dof_handler )
inline

Extract all scalar components from a blocked vector.

Template Parameters
NFieldsNumber of components in the blocked vector
DofHandlerTypeType of the DOF handler used to build output vectors
Parameters
blocked_vecInput blocked vector
dof_handlerDOF handler for extracted scalar vectors
Returns
Vector of scalar vectors, one per component

◆ extractComponent() [1/2]

template<typename DofHandlerType>
Vector vulpes::la::extractComponent ( const Vector & blocked_vec,
const DofHandlerType & dof_handler,
std::size_t f )
inline

Extract one scalar component from a blocked vector into a new vector.

Template Parameters
DofHandlerTypeType of the DOF handler used to build output vector
Parameters
blocked_vecInput blocked vector
dof_handlerDOF handler for the extracted scalar vector
fComponent index to extract
Returns
Scalar vector containing component f of the blocked input

◆ extractComponent() [2/2]

void vulpes::la::extractComponent ( const Vector & blocked_vec,
std::size_t f,
Vector & comp )
inline

Extract one scalar component from a blocked vector into an existing scalar vector (owned entries; ghost entries untouched).

Deduces the block size from the size ratio blocked/scalar and calls VecSetBlockSize before gathering, so this works even when blocked_vec was constructed without an explicit block size (e.g. from a size-only constructor such as an RK stage scratch vector). Symmetric counterpart to addComponent (which uses VecStrideScatter).

Parameters
blocked_vecInput blocked vector
fComponent index to extract
compScalar vector receiving component f

◆ extractDiagonalBlockComponent()

void vulpes::la::extractDiagonalBlockComponent ( const SparseMatrix & blocked_mat,
std::size_t component,
SparseMatrix & scalar_mat,
double zero_tol = 0.0 )
inline

Extract one scalar diagonal component from a blocked matrix.

Parameters
blocked_matInput blocked matrix
componentComponent index to extract from diagonal blocks
scalar_matOutput scalar matrix receiving extracted entries
zero_tolValues with absolute value <= zero_tol are skipped
Note
Goes through a dense copy and aborts above kMaxDenseExtractSize scalar rows. For larger matrices, project with the blocked matrix itself (assemble::dg::l2ProjectExpressionBlockedSubset) or assemble the scalar matrix directly from a scalar weak form.

◆ mergeBlockedVector()

template<std::size_t NFields, typename DofHandlerType>
Vector vulpes::la::mergeBlockedVector ( const std::vector< Vector > & scalars,
const DofHandlerType & dof_handler )
inline

Merge scalar vectors into a blocked vector.

Template Parameters
NFieldsNumber of components in the output blocked vector
DofHandlerTypeType of the DOF handler used to build output vector
Parameters
scalarsScalar vectors to merge, one per component
dof_handlerDOF handler for the merged blocked vector
Returns
Blocked vector with block size NFields

◆ mergeDiagonalBlockedMatrix()

template<std::size_t NFields>
void vulpes::la::mergeDiagonalBlockedMatrix ( const std::array< std::reference_wrapper< const SparseMatrix >, NFields > & scalar_components,
SparseMatrix & blocked_mat,
double zero_tol = 0.0 )
inline

Merge scalar diagonal component matrices into a blocked matrix.

Template Parameters
NFieldsNumber of fields/components in blocked matrix
Parameters
scalar_componentsScalar component matrices to merge on block diagonal
blocked_matOutput blocked matrix
zero_tolValues with absolute value <= zero_tol are skipped
Note
Goes through dense copies and aborts above kMaxDenseExtractSize scalar rows. For larger matrices, assemble the blocked matrix directly from an NFields-component weak form.

◆ setPETScOptionValue()

void vulpes::la::setPETScOptionValue ( const std::string & name,
const std::string & value )
inline

Set an option in the global PETSc database. This function just wraps PetscOptionsSetValue and checks the error return value.

Variable Documentation

◆ kMaxDenseExtractSize

PetscInt vulpes::la::kMaxDenseExtractSize = 2000
staticconstexpr

Largest scalar dimension for which the dense helpers below call toEigenDense(). Beyond it the O(N^2) dense allocation would exhaust memory, so these helpers abort.