Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::composite Namespace Reference

Classes

struct  Triplet
 (row, column, value) of a matrix entry with global indices More...
struct  OwnedCSR
 Rows owned by this rank in CSR form, columns sorted within each row and duplicates summed. More...

Functions

std::string to_sci (double x)
 Scientific notation for messages (std::to_string prints 0.000000 for 1e-7).
Vector< Triplet > exchange_triplets (Vector< Triplet > &&trips, Vector< Long > const &rank_offset, MPI_Comm comm)
 Send each triplet to the rank owning its row (rank p owns rows [rank_offset[p], rank_offset[p+1])) and return the triplets received by this rank, including its own.
void triplets_to_spmatrix (Gpu::DeviceVector< Long > &rows, Gpu::DeviceVector< Long > &cols, Gpu::DeviceVector< Real > &vals, Long row_begin, Long nrows, Vector< Long > const &rank_offset, MPI_Comm comm, SpMatrix< Real > &mat)
 Build an SpMatrix of this rank's rows [row_begin, row_begin+nrows) from (row, column, value) triplets in device memory, without copying them to the host: the device counterpart of exchange_triplets, OwnedCSR::define and OwnedCSR::toSpMatrix.
std::map< std::string, int > & dump_counters ()
 Dumps written so far per dump prefix, over all solver objects of the run.
bool dump_pending (std::string const &prefix, int max)
 Whether a dump with this prefix is still pending (fewer than max written).
int next_dump_index (std::string const &prefix, int max)
 Index of the next dump for this prefix, or -1 once max have been written.
template<typename T>
Vector< T > gather_on_root (Vector< T > const &v, MPI_Comm comm)
 Gather the chunks of a distributed array on rank 0 (ranks in order); other ranks return an empty vector. The total must fit in int.
bool dump_single_file (Long total, Long gather_max, MPI_Comm comm)
 Whether a dump of total values goes to one file written by rank 0 (always on one rank). Above gather_max, or above what MPI's int counts can address, every rank writes its own part to <file>.<rank>.
std::ofstream open_dump (std::string const &name)
 Open a dump file for writing, aborting on failure.
void check_dump (std::ofstream const &ofs, std::string const &name)
 Abort if writing a dump file failed.
void write_row_map (std::string const &file, std::string const &title, Vector< std::array< Long, 4 > > const &info, Vector< Real > const &scaling, Long row_begin, MPI_Comm comm, Long gather_max)
 Write the row map of a composite system: one line per row with the 1-based row, AMR level, index (i j k) and the unknown's scaling. info holds (level,i,j,k) of this rank's rows, which start at the global row row_begin. Gathered on rank 0 or one file per rank, see dump_single_file.
void algmg_parse_options (AlgMG< Real > &mg, std::string const &prefix, AlgMGKrylovSolver krylov)
 Configure an AlgMG solver from <prefix>.algmg.*: verbose, krylov (none|bicgstab|gmres|pcg; default krylov), smoother (jacobi|l1_jacobi|chebyshev|l1_gauss_seidel), interp_type (direct|mm_ext|mm_ext_i), bottom_solver (jacobi|bicgstab|gmres|direct), strong_threshold, max_levels, max_coarse_size, agg_num_levels, pmax_elmts, trunc_factor, pre_smooth, post_smooth, cheby_degree.
void write_matrix_market (std::string const &file, OwnedCSR const &csr, Long nglobal, MPI_Comm comm, Long gather_max)
 Write a distributed matrix in Matrix Market coordinate format (1-based indices, "general"), gathered on rank 0 or one file per rank (see dump_single_file). A per-rank file holds this rank's rows with the global dimensions; concatenating the entry lines gives the matrix.
void write_vector_market (std::string const &file, Vector< Real > const &v, Long nglobal, Long row_begin, MPI_Comm comm, Long gather_max)
 Write a distributed vector (this rank's rows start at the global row row_begin) as a Matrix Market dense array, gathered on rank 0 or one file per rank (see dump_single_file); a per-rank file gives its global row range in a comment.

Function Documentation

◆ algmg_parse_options()

void amrex::composite::algmg_parse_options ( AlgMG< Real > & mg,
std::string const & prefix,
AlgMGKrylovSolver krylov )
inline

Configure an AlgMG solver from <prefix>.algmg.*: verbose, krylov (none|bicgstab|gmres|pcg; default krylov), smoother (jacobi|l1_jacobi|chebyshev|l1_gauss_seidel), interp_type (direct|mm_ext|mm_ext_i), bottom_solver (jacobi|bicgstab|gmres|direct), strong_threshold, max_levels, max_coarse_size, agg_num_levels, pmax_elmts, trunc_factor, pre_smooth, post_smooth, cheby_degree.

◆ check_dump()

void amrex::composite::check_dump ( std::ofstream const & ofs,
std::string const & name )
inline

Abort if writing a dump file failed.

◆ dump_counters()

std::map< std::string, int > & amrex::composite::dump_counters ( )
inline

Dumps written so far per dump prefix, over all solver objects of the run.

◆ dump_pending()

bool amrex::composite::dump_pending ( std::string const & prefix,
int max )
inline

Whether a dump with this prefix is still pending (fewer than max written).

◆ dump_single_file()

bool amrex::composite::dump_single_file ( Long total,
Long gather_max,
MPI_Comm comm )
inline

Whether a dump of total values goes to one file written by rank 0 (always on one rank). Above gather_max, or above what MPI's int counts can address, every rank writes its own part to <file>.<rank>.

◆ exchange_triplets()

Vector< Triplet > amrex::composite::exchange_triplets ( Vector< Triplet > && trips,
Vector< Long > const & rank_offset,
MPI_Comm comm )
inline

Send each triplet to the rank owning its row (rank p owns rows [rank_offset[p], rank_offset[p+1])) and return the triplets received by this rank, including its own.

◆ gather_on_root()

template<typename T>
Vector< T > amrex::composite::gather_on_root ( Vector< T > const & v,
MPI_Comm comm )

Gather the chunks of a distributed array on rank 0 (ranks in order); other ranks return an empty vector. The total must fit in int.

◆ next_dump_index()

int amrex::composite::next_dump_index ( std::string const & prefix,
int max )
inline

Index of the next dump for this prefix, or -1 once max have been written.

◆ open_dump()

std::ofstream amrex::composite::open_dump ( std::string const & name)
inline

Open a dump file for writing, aborting on failure.

◆ to_sci()

std::string amrex::composite::to_sci ( double x)
inline

Scientific notation for messages (std::to_string prints 0.000000 for 1e-7).

◆ triplets_to_spmatrix()

void amrex::composite::triplets_to_spmatrix ( Gpu::DeviceVector< Long > & rows,
Gpu::DeviceVector< Long > & cols,
Gpu::DeviceVector< Real > & vals,
Long row_begin,
Long nrows,
Vector< Long > const & rank_offset,
MPI_Comm comm,
SpMatrix< Real > & mat )
inline

Build an SpMatrix of this rank's rows [row_begin, row_begin+nrows) from (row, column, value) triplets in device memory, without copying them to the host: the device counterpart of exchange_triplets, OwnedCSR::define and OwnedCSR::toSpMatrix.

Triplets of rows owned by other ranks are sent to their owners through the host (collective over comm). The triplets of each row are sorted by (column, triplet index) and duplicates are summed in that order, so the values do not depend on thread scheduling. The triplet arrays are consumed.

◆ write_matrix_market()

void amrex::composite::write_matrix_market ( std::string const & file,
OwnedCSR const & csr,
Long nglobal,
MPI_Comm comm,
Long gather_max )
inline

Write a distributed matrix in Matrix Market coordinate format (1-based indices, "general"), gathered on rank 0 or one file per rank (see dump_single_file). A per-rank file holds this rank's rows with the global dimensions; concatenating the entry lines gives the matrix.

◆ write_row_map()

void amrex::composite::write_row_map ( std::string const & file,
std::string const & title,
Vector< std::array< Long, 4 > > const & info,
Vector< Real > const & scaling,
Long row_begin,
MPI_Comm comm,
Long gather_max )
inline

Write the row map of a composite system: one line per row with the 1-based row, AMR level, index (i j k) and the unknown's scaling. info holds (level,i,j,k) of this rank's rows, which start at the global row row_begin. Gathered on rank 0 or one file per rank, see dump_single_file.

◆ write_vector_market()

void amrex::composite::write_vector_market ( std::string const & file,
Vector< Real > const & v,
Long nglobal,
Long row_begin,
MPI_Comm comm,
Long gather_max )
inline

Write a distributed vector (this rank's rows start at the global row row_begin) as a Matrix Market dense array, gathered on rank 0 or one file per rank (see dump_single_file); a per-rank file gives its global row range in a comment.