DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::Euler::ArrayRECV< nVarsFixed > Class Template Reference

MPI-parallel distributed array of per-cell reconstruction coefficient matrices. More...

#include <Euler.hpp>

Inheritance diagram for DNDS::Euler::ArrayRECV< nVarsFixed >:
[legend]
Collaboration diagram for DNDS::Euler::ArrayRECV< nVarsFixed >:
[legend]

Public Types

using t_self = ArrayRECV< nVarsFixed >
 Self type alias.
 
using t_base = CFV::tURec< nVarsFixed >
 Base distributed reconstruction array type.
 
- Public Types inherited from DNDS::ArrayDof< n_m, n_n >
using t_base = ArrayEigenMatrixPair< n_m, n_n >
 
template<DeviceBackend B>
using t_deviceView = ArrayDofDeviceView< B, n_m, n_n >
 Mutable device view alias.
 
template<DeviceBackend B>
using t_deviceViewConst = ArrayDofDeviceViewConst< B, n_m, n_n >
 Const device view alias.
 
using t_self = ArrayDof< n_m, n_n >
 
template<DeviceBackend B>
using t_ops = ArrayDofOp< B, n_m, n_n >
 Static dispatcher alias selecting host / CUDA implementation.
 
using t_element_mat = Eigen::Matrix< real, RowSize_To_EigenSize(n_m), RowSize_To_EigenSize(n_n)>
 Shape of one DOF row as an Eigen matrix.
 
- Public Types inherited from DNDS::ArrayPair< TArray >
using t_self = ArrayPair< TArray >
 
using t_arr = TArray
 
using TTrans = typename ArrayTransformerType< TArray >::Type
 
template<DeviceBackend B>
using t_deviceView = ArrayPairDeviceView< B, TArray >
 Device-view template alias: t_deviceView<DeviceBackend::CUDA> gives the mutable CUDA view type for this pair.
 
template<DeviceBackend B>
using t_deviceViewConst = ArrayPairDeviceViewConst< B, TArray >
 Const-device-view template alias.
 

Public Member Functions

void setConstant (real R)
 Set all reconstruction coefficients to a uniform scalar value.
 
template<class TR >
void setConstant (const TR &R)
 Set all cells' reconstruction matrices to copies of a given matrix.
 
void operator+= (const t_self &R)
 Element-wise addition: this[i] += R[i] for every cell.
 
void operator-= (const t_self &R)
 Element-wise subtraction: this[i] -= R[i] for every cell.
 
void operator*= (real R)
 Uniform scalar multiplication: this[i] *= R for every cell.
 
void operator*= (const std::vector< real > &R)
 Per-cell scalar multiplication from a vector of cell-wise weights.
 
void operator*= (const ArrayDOFV< 1 > &R)
 Component-wise multiplication by a scalar-per-cell ArrayDOFV<1>.
 
void operator*= (const Eigen::Array< real, 1, nVarsFixed > &R)
 Column-wise scaling by a per-variable multiplier row-vector.
 
void operator= (const t_self &R)
 Deep copy assignment from another ArrayRECV.
 
void addTo (const t_self &R, const Eigen::Array< real, 1, nVarsFixed > &r)
 Column-wise scaled addition: this[i] += R[i] .* r (per-variable scaling).
 
void addTo (const t_self &R, real r)
 Uniform scaled addition: this[i] += r * R[i] for every cell (axpy-style).
 
real norm2 ()
 Compute the global L2 norm of all reconstruction coefficients with MPI reduction.
 
real dot (const t_self &R)
 Compute the global dot product <this, R> with MPI reduction.
 
auto dotV (const t_self &R)
 Compute a per-variable (column-wise) dot product with MPI reduction.
 
- Public Member Functions inherited from DNDS::ArrayDof< n_m, n_n >
template<DeviceBackend B>
t_deviceView< B > deviceView ()
 Build a mutable device view (wraps the base-class implementation).
 
template<DeviceBackend B>
t_deviceViewConst< B > deviceView () const
 Build a const device view.
 
void clone (const t_self &R)
 Deep copy from another ArrayDof. Delegates to the base-class clone.
 
void setConstant (real R)
 Set every entry of every (father+son) row to the scalar R.
 
void setConstant (const Eigen::Ref< const t_element_mat > &R)
 Set every row to the matrix R (must have shape n_m x n_n).
 
void operator+= (const t_self &R)
 In-place element-wise add: this += R.
 
void operator+= (real R)
 Add the scalar R to every entry.
 
void operator+= (const Eigen::Ref< const t_element_mat > &R)
 Add a per-row matrix R (same to every row).
 
void operator-= (const t_self &R)
 In-place element-wise subtract: this -= R.
 
void operator*= (real R)
 Scalar multiply in place.
 
template<int n_m_T = n_m>
std::enable_if_t<!(n_m_T==1 &&n_n==1)> operator*= (const ArrayDof< 1, 1 > &R)
 Scale each row by a corresponding scalar stored in R (a 1x1 ArrayDof).
 
void operator*= (const Eigen::Ref< const t_element_mat > &R)
 In-place multiplication by a small fixed matrix (same applied to every row).
 
void operator*= (const t_self &R)
 Element-wise multiply: this *= R (Hadamard).
 
void operator/= (const t_self &R)
 Element-wise divide: this /= R.
 
void operator= (const t_self &R)
 Value-copy assignment from another ArrayDof of identical layout.
 
void addTo (const t_self &R, real r)
 AXPY: this += r * R. One of the hot-path solver primitives.
 
real norm2 ()
 Global L2 norm (MPI-collective). sqrt(sum_i sum_j x_ij^2).
 
real norm2 (const t_self &R)
 Global L2 distance between this and R (collective).
 
real min ()
 Global minimum across all entries (collective).
 
real max ()
 Global maximum across all entries (collective).
 
real sum ()
 Global sum of all entries (collective).
 
t_element_mat componentWiseNorm1 ()
 Per-component global L1 norm, returned as an n_m x n_n matrix (collective).
 
t_element_mat componentWiseNorm1 (const t_self &R)
 Per-component global L1 distance between this and R (collective).
 
real dot (const t_self &R)
 Global inner product: sum_i sum_j x_ij * R_ij (collective).
 
void to_device (DeviceBackend backend)
 Mirror both father and son to the given device backend.
 
void to_host ()
 Bring both father and son mirrors back to host memory.
 
- Public Member Functions inherited from DNDS::ArrayPair< TArray >
void clone (const t_self &R)
 Deep-copy: allocate new father / son and copy their data; rebind trans.
 
decltype(father->operator[](index(0))) operator[] (index i) const
 Read-only row-pointer access in the combined address space.
 
decltype(father->operator[](index(0))) operator[] (index i)
 Mutable row-pointer access in the combined address space.
 
template<class... TOthers>
decltype(autooperator() (index i, TOthers... aOthers)
 N-ary element access in the combined space (mutable). Arguments after the row index are forwarded to the underlying operator().
 
template<class... TOthers>
decltype(autooperator() (index i, TOthers... aOthers) const
 N-ary element access (const).
 
template<class TF >
auto runFunctionAppendedIndex (index i, TF &&F)
 Invoke F(array, localIndex) on either father or son depending on which range i falls into.
 
auto RowSize () const
 Uniform row width (delegates to father).
 
auto RowSize (index i) const
 Per-row width in the combined address space.
 
void ResizeRow (index i, rowsize rs)
 Resize a single row in the combined address space.
 
template<class... TOthers>
void ResizeRow (index i, TOthers... aOthers)
 Variadic ResizeRow overload that forwards extra args.
 
index Size () const
 Combined row count (father->Size() + son->Size()).
 
void TransAttach ()
 Bind the transformer to the current father / son pointers.
 
template<typename... Args>
void InitPair (const std::string &name, Args &&...args)
 Allocate both father and son arrays, forwarding all args to TArray constructor.
 
template<class TPrimaryPair >
void BorrowAndPull (TPrimaryPair &primary)
 Attach, borrow ghost indexing from a primary pair, create MPI types, and pull once.
 
template<class TPrimaryPair >
void BorrowSetup (TPrimaryPair &primary)
 Attach, borrow ghost indexing from a primary pair, and create MPI types (no pull).
 
void CompressBoth ()
 Compress both father and son CSR arrays (no-op for non-CSR layouts).
 
void CopyFather (t_self &R)
 Copy only the father's data from another pair (shallow).
 
void SwapDataFatherSon (t_self &R)
 Swap both father and son data with another pair of the same type.
 
std::size_t hash ()
 Combined hash across ranks. Used for determinism / equality checks in tests.
 
void WriteSerialize (Serializer::SerializerBaseSSP serializerP, const std::string &name, bool includePIG=true, bool includeSon=true)
 Writes the ArrayPair (father, optional son, optional ghost mapping).
 
void WriteSerialize (Serializer::SerializerBaseSSP serializerP, const std::string &name, const std::vector< index > &origIndex, bool includePIG=true, bool includeSon=true)
 Writes the ArrayPair with an origIndex companion dataset for redistribution support.
 
void ReadSerialize (Serializer::SerializerBaseSSP serializerP, const std::string &name, bool includePIG=true, bool includeSon=true)
 Reads an ArrayPair written by WriteSerialize (same partition count).
 
void ReadSerializeRedistributed (Serializer::SerializerBaseSSP serializerP, const std::string &name, const std::vector< index > &newOrigIndex)
 Reads ArrayPair data from HDF5 with redistribution support.
 
template<DeviceBackend B>
auto deviceView ()
 Produce a mutable device view; both father and son must be allocated.
 
template<DeviceBackend B>
auto deviceView () const
 Produce a const device view.
 
void to_device (DeviceBackend backend)
 Mirror both father and son to the given device backend.
 
void to_host ()
 Bring both father and son mirrors back to host memory.
 

Additional Inherited Members

- Static Public Member Functions inherited from DNDS::ArrayPair< TArray >
static constexpr bool IsCSR ()
 Whether the underlying array uses CSR storage.
 
- Public Attributes inherited from DNDS::ArrayPair< TArray >
ssp< TArray > father
 Owned-side array (must be resized before ghost setup).
 
ssp< TArray > son
 Ghost-side array (sized automatically by createMPITypes / BorrowAndPull).
 
TTrans trans
 Ghost-communication engine bound to father and son.
 

Detailed Description

template<int nVarsFixed>
class DNDS::Euler::ArrayRECV< nVarsFixed >

MPI-parallel distributed array of per-cell reconstruction coefficient matrices.

Wraps CFV::tURec<nVarsFixed> (which is ArrayDof<DynamicSize, nVarsFixed>), adding element-wise arithmetic, norms, dot products, and MPI-collective reductions.

Each cell stores a matrix of shape (nRecBases x nVars), where nRecBases is the number of polynomial reconstruction basis functions (determined at runtime by the reconstruction order) and nVars is the number of conservative variables. These coefficients define the high-order polynomial representation of the solution within each cell, as used by the Compact Finite Volume variational reconstruction scheme.

Template Parameters
nVarsFixedCompile-time number of conservative variables (matrix columns), or Eigen::Dynamic for runtime-sized.
Todo:
Add more arithmetic operators (see existing TODO in source).
See also
ArrayDOFV for per-cell DOF vectors.
ArrayGRADV for per-cell gradient matrices.
Todo:
://TODO add operators

Definition at line 400 of file Euler.hpp.

Member Typedef Documentation

◆ t_base

template<int nVarsFixed>
using DNDS::Euler::ArrayRECV< nVarsFixed >::t_base = CFV::tURec<nVarsFixed>

Base distributed reconstruction array type.

Definition at line 404 of file Euler.hpp.

◆ t_self

template<int nVarsFixed>
using DNDS::Euler::ArrayRECV< nVarsFixed >::t_self = ArrayRECV<nVarsFixed>

Self type alias.

Definition at line 403 of file Euler.hpp.

Member Function Documentation

◆ addTo() [1/2]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::addTo ( const t_self R,
const Eigen::Array< real, 1, nVarsFixed > &  r 
)
inline

Column-wise scaled addition: this[i] += R[i] .* r (per-variable scaling).

For each cell, adds R's reconstruction matrix with each column scaled by the corresponding element of r: this[i].col(j) += r(j) * R[i].col(j).

Parameters
RSource reconstruction array to add.
rPer-variable (column-wise) scaling factors (1 x nVarsFixed).
Note
Only operates on host memory. Asserts if device storage is active.
OpenMP parallelized when DNDS_DIST_MT_USE_OMP is defined.

Definition at line 537 of file Euler.hpp.

Here is the call graph for this function:

◆ addTo() [2/2]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::addTo ( const t_self R,
real  r 
)
inline

Uniform scaled addition: this[i] += r * R[i] for every cell (axpy-style).

Parameters
RSource reconstruction array to add.
rUniform scalar multiplier applied to R before addition.

Definition at line 553 of file Euler.hpp.

Here is the call graph for this function:

◆ dot()

template<int nVarsFixed>
real DNDS::Euler::ArrayRECV< nVarsFixed >::dot ( const t_self R)
inline

Compute the global dot product <this, R> with MPI reduction.

Sums the element-wise product of all matrix entries across locally-owned cells, then performs MPI_Allreduce(SUM).

Parameters
RThe other ArrayRECV operand.
Returns
Global dot product (same value on all ranks).

Definition at line 576 of file Euler.hpp.

Here is the call graph for this function:

◆ dotV()

template<int nVarsFixed>
auto DNDS::Euler::ArrayRECV< nVarsFixed >::dotV ( const t_self R)
inline

Compute a per-variable (column-wise) dot product with MPI reduction.

Returns a row vector where each component j contains \(\sum_i \sum_k \text{this}[i](k,j) \cdot R[i](k,j)\) summed over all locally-owned cells and reconstruction bases, then reduced across MPI ranks via MPI_Allreduce(SUM).

Useful for monitoring per-variable convergence of reconstruction coefficients.

Parameters
RThe other ArrayRECV operand.
Returns
Row vector of per-variable dot products (1 x nVarsFixed, same on all ranks).
Note
Only operates on host memory. Asserts if device storage is active.
Uses OpenMP custom reduction (EigenVecSum) when OMP is enabled.
Only iterates over father (locally-owned) cells, not ghost cells.

Definition at line 598 of file Euler.hpp.

Here is the call graph for this function:

◆ norm2()

template<int nVarsFixed>
real DNDS::Euler::ArrayRECV< nVarsFixed >::norm2 ( )
inline

Compute the global L2 norm of all reconstruction coefficients with MPI reduction.

Returns
Global Frobenius-like L2 norm (same value on all ranks).

Definition at line 562 of file Euler.hpp.

Here is the call graph for this function:

◆ operator*=() [1/4]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator*= ( const ArrayDOFV< 1 > &  R)
inline

Component-wise multiplication by a scalar-per-cell ArrayDOFV<1>.

Each cell's reconstruction matrix is scaled by the single scalar stored in the corresponding cell of R.

Parameters
RScalar-per-cell array (ArrayDOFV<1>).

Definition at line 490 of file Euler.hpp.

Here is the call graph for this function:

◆ operator*=() [2/4]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator*= ( const Eigen::Array< real, 1, nVarsFixed > &  R)
inline

Column-wise scaling by a per-variable multiplier row-vector.

Each column (variable) of every cell's reconstruction matrix is multiplied by the corresponding element of R: this[i].col(j) *= R(j). Useful for applying per-variable scaling (e.g. non-dimensionalization).

Parameters
RRow array of per-variable multipliers (1 x nVarsFixed).
Note
Only operates on host memory. Asserts if device storage is active.
OpenMP parallelized when DNDS_DIST_MT_USE_OMP is defined.

Definition at line 506 of file Euler.hpp.

Here is the call graph for this function:

◆ operator*=() [3/4]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator*= ( const std::vector< real > &  R)
inline

Per-cell scalar multiplication from a vector of cell-wise weights.

Multiplies each cell's reconstruction matrix by the corresponding scalar in R: this[i] *= R[i]. Only operates on father (locally-owned) cells.

Parameters
RVector of per-cell scalar multipliers. Must have size >= number of locally-owned cells.
Note
Only operates on host memory. Asserts if device storage is active.
OpenMP parallelized when DNDS_DIST_MT_USE_OMP is defined.

Definition at line 471 of file Euler.hpp.

Here is the call graph for this function:

◆ operator*=() [4/4]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator*= ( real  R)
inline

Uniform scalar multiplication: this[i] *= R for every cell.

Parameters
RScalar multiplier applied to all entries of all cells.

Definition at line 455 of file Euler.hpp.

Here is the call graph for this function:

◆ operator+=()

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator+= ( const t_self R)
inline

Element-wise addition: this[i] += R[i] for every cell.

Parameters
RSource array with the same distribution layout.

Definition at line 439 of file Euler.hpp.

Here is the call graph for this function:

◆ operator-=()

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator-= ( const t_self R)
inline

Element-wise subtraction: this[i] -= R[i] for every cell.

Parameters
RSource array with the same distribution layout.

Definition at line 447 of file Euler.hpp.

Here is the call graph for this function:

◆ operator=()

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::operator= ( const t_self R)
inline

Deep copy assignment from another ArrayRECV.

Parameters
RSource array to copy from. Must have the same distribution layout.

Definition at line 520 of file Euler.hpp.

Here is the call graph for this function:

◆ setConstant() [1/2]

template<int nVarsFixed>
template<class TR >
void DNDS::Euler::ArrayRECV< nVarsFixed >::setConstant ( const TR R)
inline

Set all cells' reconstruction matrices to copies of a given matrix.

Template Parameters
TRMatrix type compatible with the per-cell storage (must be assignable to each cell's matrix block).
Parameters
RReference matrix; each cell's coefficient matrix is set to this value.
Note
Only operates on host memory. Asserts if device storage is active.
OpenMP parallelized when DNDS_DIST_MT_USE_OMP is defined.

Definition at line 425 of file Euler.hpp.

Here is the call graph for this function:

◆ setConstant() [2/2]

template<int nVarsFixed>
void DNDS::Euler::ArrayRECV< nVarsFixed >::setConstant ( real  R)
inline

Set all reconstruction coefficients to a uniform scalar value.

Parameters
RScalar value to fill every matrix entry with.

Definition at line 410 of file Euler.hpp.

Here is the call graph for this function:

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