DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::ArrayDof< n_m, n_n > Class Template Reference

Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations. More...

#include <ArrayDOF.hpp>

Inheritance diagram for DNDS::ArrayDof< n_m, n_n >:
[legend]
Collaboration diagram for DNDS::ArrayDof< n_m, n_n >:
[legend]

Public Types

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

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 n_m, int n_n>
class DNDS::ArrayDof< n_m, n_n >

Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.

ArrayDof<n_m, n_n> inherits everything from ArrayEigenMatrixPair<n_m, n_n> (father, son, transformer, typed row access as Eigen::Map<Matrix<real, n_m, n_n>>) and adds:

Host and CUDA backends are both supported – the methods dispatch based on father->device() at the call site.

CFV convenience aliases (in CFV/VRDefines.hpp):

  • tUDof<N> = ArrayDof<N, 1> (per-cell state vector).
  • tURec<N> = ArrayDof<DynamicSize, N> (reconstruction coefficients).
  • tUGrad<N,d>= ArrayDof<d, N> (gradients).
Template Parameters
n_mRow count per cell (1 for state vectors).
n_nColumn count per cell.
See also
ArrayEigenMatrixPair, docs/architecture/array_infrastructure.md, docs/guides/array_usage.md.

Definition at line 171 of file ArrayDOF.hpp.

Member Typedef Documentation

◆ t_base

template<int n_m, int n_n>
using DNDS::ArrayDof< n_m, n_n >::t_base = ArrayEigenMatrixPair<n_m, n_n>

Definition at line 174 of file ArrayDOF.hpp.

◆ t_deviceView

template<int n_m, int n_n>
template<DeviceBackend B>
using DNDS::ArrayDof< n_m, n_n >::t_deviceView = ArrayDofDeviceView<B, n_m, n_n>

Mutable device view alias.

Definition at line 179 of file ArrayDOF.hpp.

◆ t_deviceViewConst

template<int n_m, int n_n>
template<DeviceBackend B>
using DNDS::ArrayDof< n_m, n_n >::t_deviceViewConst = ArrayDofDeviceViewConst<B, n_m, n_n>

Const device view alias.

Definition at line 182 of file ArrayDOF.hpp.

◆ t_element_mat

template<int n_m, int n_n>
using DNDS::ArrayDof< n_m, n_n >::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.

Definition at line 208 of file ArrayDOF.hpp.

◆ t_ops

template<int n_m, int n_n>
template<DeviceBackend B>
using DNDS::ArrayDof< n_m, n_n >::t_ops = ArrayDofOp<B, n_m, n_n>

Static dispatcher alias selecting host / CUDA implementation.

Definition at line 205 of file ArrayDOF.hpp.

◆ t_self

template<int n_m, int n_n>
using DNDS::ArrayDof< n_m, n_n >::t_self = ArrayDof<n_m, n_n>

Definition at line 201 of file ArrayDOF.hpp.

Member Function Documentation

◆ addTo()

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::addTo ( const t_self R,
real  r 
)
inline

AXPY: this += r * R. One of the hot-path solver primitives.

Definition at line 295 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::clone ( const t_self R)
inline

Deep copy from another ArrayDof. Delegates to the base-class clone.

Definition at line 211 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ componentWiseNorm1() [1/2]

template<int n_m, int n_n>
t_element_mat DNDS::ArrayDof< n_m, n_n >::componentWiseNorm1 ( )
inline

Per-component global L1 norm, returned as an n_m x n_n matrix (collective).

Definition at line 331 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ componentWiseNorm1() [2/2]

template<int n_m, int n_n>
t_element_mat DNDS::ArrayDof< n_m, n_n >::componentWiseNorm1 ( const t_self R)
inline

Per-component global L1 distance between this and R (collective).

Definition at line 337 of file ArrayDOF.hpp.

Here is the call graph for this function:

◆ deviceView() [1/2]

template<int n_m, int n_n>
template<DeviceBackend B>
t_deviceView< B > DNDS::ArrayDof< n_m, n_n >::deviceView ( )
inline

Build a mutable device view (wraps the base-class implementation).

Definition at line 186 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ deviceView() [2/2]

template<int n_m, int n_n>
template<DeviceBackend B>
t_deviceViewConst< B > DNDS::ArrayDof< n_m, n_n >::deviceView ( ) const
inline

Build a const device view.

Definition at line 193 of file ArrayDOF.hpp.

◆ dot()

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::dot ( const t_self R)
inline

Global inner product: sum_i sum_j x_ij * R_ij (collective).

Definition at line 343 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max()

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::max ( )
inline

Global maximum across all entries (collective).

Definition at line 319 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ min()

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::min ( )
inline

Global minimum across all entries (collective).

Definition at line 313 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ norm2() [1/2]

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::norm2 ( )
inline

Global L2 norm (MPI-collective). sqrt(sum_i sum_j x_ij^2).

Definition at line 301 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm2() [2/2]

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::norm2 ( const t_self R)
inline

Global L2 distance between this and R (collective).

Definition at line 307 of file ArrayDOF.hpp.

Here is the call graph for this function:

◆ operator*=() [1/4]

template<int n_m, int n_n>
template<int n_m_T = n_m>
std::enable_if_t<!(n_m_T==1 &&n_n==1)> DNDS::ArrayDof< n_m, n_n >::operator*= ( const ArrayDof< 1, 1 > &  R)
inline

Scale each row by a corresponding scalar stored in R (a 1x1 ArrayDof).

Typical use: multiply state DOFs by per-cell values such as inverse mass. Only enabled for non-scalar DOF shapes.

Definition at line 265 of file ArrayDOF.hpp.

◆ operator*=() [2/4]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator*= ( const Eigen::Ref< const t_element_mat > &  R)
inline

In-place multiplication by a small fixed matrix (same applied to every row).

Definition at line 271 of file ArrayDOF.hpp.

◆ operator*=() [3/4]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator*= ( const t_self R)
inline

Element-wise multiply: this *= R (Hadamard).

Definition at line 277 of file ArrayDOF.hpp.

◆ operator*=() [4/4]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator*= ( real  R)
inline

Scalar multiply in place.

Definition at line 255 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ operator+=() [1/3]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator+= ( const Eigen::Ref< const t_element_mat > &  R)
inline

Add a per-row matrix R (same to every row).

Definition at line 243 of file ArrayDOF.hpp.

◆ operator+=() [2/3]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator+= ( const t_self R)
inline

In-place element-wise add: this += R.

Definition at line 231 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ operator+=() [3/3]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator+= ( real  R)
inline

Add the scalar R to every entry.

Definition at line 237 of file ArrayDOF.hpp.

◆ operator-=()

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator-= ( const t_self R)
inline

In-place element-wise subtract: this -= R.

Definition at line 249 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ operator/=()

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator/= ( const t_self R)
inline

Element-wise divide: this /= R.

Definition at line 283 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ operator=()

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::operator= ( const t_self R)
inline

Value-copy assignment from another ArrayDof of identical layout.

Definition at line 289 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ setConstant() [1/2]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::setConstant ( const Eigen::Ref< const t_element_mat > &  R)
inline

Set every row to the matrix R (must have shape n_m x n_n).

Definition at line 225 of file ArrayDOF.hpp.

Here is the call graph for this function:

◆ setConstant() [2/2]

template<int n_m, int n_n>
void DNDS::ArrayDof< n_m, n_n >::setConstant ( real  R)
inline

Set every entry of every (father+son) row to the scalar R.

Definition at line 219 of file ArrayDOF.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sum()

template<int n_m, int n_n>
real DNDS::ArrayDof< n_m, n_n >::sum ( )
inline

Global sum of all entries (collective).

Definition at line 325 of file ArrayDOF.hpp.

Here is the caller graph for this function:

◆ to_device()

template<int n_m, int n_n>
void DNDS::ArrayPair< TArray >::to_device ( DeviceBackend  backend)
inline

Mirror both father and son to the given device backend.

Definition at line 684 of file ArrayPair.hpp.

Here is the caller graph for this function:

◆ to_host()

template<int n_m, int n_n>
void DNDS::ArrayPair< TArray >::to_host ( )
inline

Bring both father and son mirrors back to host memory.

Definition at line 693 of file ArrayPair.hpp.

Here is the caller graph for this function:

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