Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_CompositeSystemUtil.H File Reference
#include <AMReX_Config.H>
#include <AMReX_AlgMG.H>
#include <AMReX_ParallelDescriptor.H>
#include <AMReX_ParallelReduce.H>
#include <AMReX_ParmParse.H>
#include <AMReX_Scan.H>
#include <AMReX_SpMatrix.H>
#include <AMReX_Vector.H>
#include <algorithm>
#include <array>
#include <fstream>
#include <iomanip>
#include <limits>
#include <map>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

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

Namespaces

namespace  amrex
namespace  amrex::composite

Functions

std::string amrex::composite::to_sci (double x)
 Scientific notation for messages (std::to_string prints 0.000000 for 1e-7).
Vector< Triplet > amrex::composite::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 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)
 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 > & amrex::composite::dump_counters ()
 Dumps written so far per dump prefix, over all solver objects of the run.
bool amrex::composite::dump_pending (std::string const &prefix, int max)
 Whether a dump with this prefix is still pending (fewer than max written).
int amrex::composite::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 > 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.
bool amrex::composite::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 amrex::composite::open_dump (std::string const &name)
 Open a dump file for writing, aborting on failure.
void amrex::composite::check_dump (std::ofstream const &ofs, std::string const &name)
 Abort if writing a dump file failed.
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)
 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 amrex::composite::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 amrex::composite::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 amrex::composite::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.

Detailed Description

Helpers for the composite (all AMR levels) solvers such as HypreMLABecLap: an owned-row CSR built from (row, column, value) triplets, the AlgMG backend options, and Matrix Market output of the assembled systems for analysis outside AMReX.