DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
ArrayDOF.hpp
Go to the documentation of this file.
1#pragma once
2/// @file ArrayDOF.hpp
3/// @brief Degree-of-freedom array with vector-space operations (MPI-collective).
4/// @par Unit Test Coverage (test_ArrayDOF.cpp, MPI np=1,2,4)
5/// - setConstant (scalar and Eigen::Matrix)
6/// - operator+= (scalar, ArrayDof, Eigen::Matrix), operator-=, operator*= (scalar,
7/// ArrayDof element-wise, Eigen::Matrix), operator/=
8/// - addTo(other, scale)
9/// - norm2, norm2(other) (L2 distance), dot (MPI-collective)
10/// - min, max, sum (MPI-collective reductions)
11/// - componentWiseNorm1, componentWiseNorm1(other)
12/// - operator= (value copy), clone (deep copy)
13/// - Scalar-array multiply: ArrayDof<N,1> *= ArrayDof<1,1>
14/// - Mathematical identity: dot(x,x) == norm2(x)^2
15/// @par Not Yet Tested
16/// - Multi-column DOFs (n_n > 1, i.e. matrix-valued DOFs)
17/// - Ghost communication through ArrayDof (all tests use son->Resize(0))
18/// - ArrayDofOp<DeviceBackend::CUDA>
19/// - ArrayDofSinglePack::BuildResizeFatherSon
20
22
24
25#include "ArrayPair.hpp"
26#include "DNDS/Defines.hpp"
28
29namespace DNDS
30{
31 /// @brief Mutable device view of an ArrayDof father/son pair.
32 template <DeviceBackend B, int n_m, int n_n>
33 class ArrayDofDeviceView : public ArrayPairDeviceView<B, ArrayEigenMatrix<n_m, n_n>>
34 {
35 public:
37 using t_base::t_base;
38
40
41 DNDS_DEVICE_CALLABLE ArrayDofDeviceView(const t_base &base_view) : t_base(base_view) {}
43 };
44
45 /// @brief Const device view of an ArrayDof father/son pair.
46 template <DeviceBackend B, int n_m, int n_n>
58
59 template <int n_m, int n_n>
60 class ArrayDof;
61
62 template <DeviceBackend B, int n_m, int n_n>
64
65#define DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n)
66#define DNDS_ARRAY_DOF_OP_FUNC_LIST(B, n_m, n_n, spec) \
67 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) setConstant(t_self &self, real R); \
68 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) setConstant(t_self &self, const Eigen::Ref<const t_element_mat> &R); \
69 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_plus_assign(t_self &self, const t_self &R); \
70 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_plus_assign(t_self &self, real R); \
71 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_plus_assign(t_self &self, const Eigen::Ref<const t_element_mat> &R); \
72 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_minus_assign(t_self &self, const t_self &R); \
73 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_mult_assign(t_self &self, real R); \
74 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_mult_assign_scalar_arr(t_self &self, const ArrayDof<1, 1> &R); \
75 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_mult_assign(t_self &self, const Eigen::Ref<const t_element_mat> &R); \
76 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_mult_assign(t_self &self, const t_self &R); \
77 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_div_assign(t_self &self, const t_self &R); \
78 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) operator_assign(t_self &self, const t_self &R); \
79 spec void DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) addTo(t_self &self, const t_self &R, real r); \
80 spec real DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) norm2(t_self &self); \
81 spec real DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) norm2(t_self &self, const t_self &R); \
82 spec real DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) reduction(t_self &self, const std::string &op); \
83 spec ArrayDofOp<B, n_m, n_n>::t_element_mat DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) componentWiseNorm1(t_self &self); \
84 spec ArrayDofOp<B, n_m, n_n>::t_element_mat DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) componentWiseNorm1(t_self &self, const t_self &R); \
85 spec real DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) dot(t_self &self, const t_self &R);
86
87 /**
88 * @brief Host-side static dispatcher: implements every vector-space operation
89 * declared in @ref DNDS_ARRAY_DOF_OP_FUNC_LIST for CPU execution.
90 *
91 * @details Each member is a `static` free-function-style routine that takes
92 * the target @ref DNDS::ArrayDof "ArrayDof" by reference. Explicit instantiations for the
93 * supported `(n_m, n_n)` combinations live in `ArrayDOF_inst/<...>.cpp`.
94 * The host version uses OpenMP where profitable; the CUDA specialisation
95 * (below) is a parallel mirror that dispatches to kernels.
96 */
97 template <int n_m, int n_n>
98 class ArrayDofOp<DeviceBackend::Host, n_m, n_n>
99 {
100 public:
104 };
105
106#ifdef DNDS_USE_CUDA
107 /**
108 * @brief CUDA-side static dispatcher. Same interface as the host version;
109 * implemented in `ArrayDOF_inst/<...>.cu`.
110 */
111 template <int n_m, int n_n>
112 class ArrayDofOp<DeviceBackend::CUDA, n_m, n_n>
113 {
114 public:
115 using t_self = ArrayDof<n_m, n_n>;
116 using t_element_mat = Eigen::Matrix<real, RowSize_To_EigenSize(n_m), RowSize_To_EigenSize(n_n)>;
117 DNDS_ARRAY_DOF_OP_FUNC_LIST(DeviceBackend::CUDA, n_m, n_n, static)
118 };
119#endif
120
121#ifdef DNDS_USE_CUDA
122# define DNDS_ARRAY_OP_SWITCH_CUDA_CASE(expr) \
123 case DeviceBackend::CUDA: \
124 { \
125 return (t_ops<DeviceBackend::CUDA>::expr); \
126 }
127#else
128# define DNDS_ARRAY_OP_SWITCH_CUDA_CASE(expr)
129#endif
130
131#define DNDS_ARRAY_OP_SWITCHER(Backend, expr) \
132 switch (Backend) \
133 { \
134 case DeviceBackend::Host: \
135 case DeviceBackend::Unknown: \
136 { \
137 return (t_ops<DeviceBackend::Host>::expr); \
138 } \
139 DNDS_ARRAY_OP_SWITCH_CUDA_CASE(expr) \
140 default: \
141 DNDS_assert(false); \
142 return (t_ops<DeviceBackend::Host>::expr); \
143 }
144
145 /**
146 * @brief Primary solver state container: an @ref DNDS::ArrayEigenMatrix "ArrayEigenMatrix" pair with
147 * MPI-collective vector-space operations.
148 *
149 * @details `ArrayDof<n_m, n_n>` inherits everything from
150 * @ref ArrayEigenMatrixPair<n_m, n_n> (father, son, transformer, typed row
151 * access as `Eigen::Map<Matrix<real, n_m, n_n>>`) and adds:
152 * - entry-wise updates: `+= real`, `+= ArrayDof`, `*= real`, `*= matrix`, etc.;
153 * - AXPY: #addTo;
154 * - **MPI-collective** reductions: #norm2, #dot, #min, #max, #sum, #componentWiseNorm1.
155 *
156 * Host and CUDA backends are both supported -- the methods dispatch based
157 * on `father->device()` at the call site.
158 *
159 * CFV convenience aliases (in `CFV/VRDefines.hpp`):
160 * - `tUDof<N> = ArrayDof<N, 1>` (per-cell state vector).
161 * - `tURec<N> = ArrayDof<DynamicSize, N>` (reconstruction coefficients).
162 * - `tUGrad<N,d>= ArrayDof<d, N>` (gradients).
163 *
164 * @tparam n_m Row count per cell (1 for state vectors).
165 * @tparam n_n Column count per cell.
166 *
167 * @sa ArrayEigenMatrixPair, docs/architecture/array_infrastructure.md,
168 * docs/guides/array_usage.md.
169 */
170 template <int n_m, int n_n>
171 class ArrayDof : public ArrayEigenMatrixPair<n_m, n_n>
172 {
173 public:
175 using t_base::t_base;
176
177 /// @brief Mutable device view alias.
178 template <DeviceBackend B>
180 /// @brief Const device view alias.
181 template <DeviceBackend B>
183
184 /// @brief Build a mutable device view (wraps the base-class implementation).
185 template <DeviceBackend B>
187 {
188 return {t_base::template deviceView<B>()};
189 }
190
191 /// @brief Build a const device view.
192 template <DeviceBackend B>
194 {
195 return {t_base::template deviceView<B>()};
196 }
197
198 using t_base::to_device;
199 using t_base::to_host;
200
202
203 /// @brief Static dispatcher alias selecting host / CUDA implementation.
204 template <DeviceBackend B>
206
207 /// @brief Shape of one DOF row as an Eigen matrix.
209
210 /// @brief Deep copy from another ArrayDof. Delegates to the base-class clone.
211 void clone(const t_self &R)
212 {
213 // ! no using operator= here
214 this->t_base::clone(R);
215 // no extra data
216 }
217
218 /// @brief Set every entry of every (father+son) row to the scalar `R`.
220 {
221 DNDS_ARRAY_OP_SWITCHER(this->father->device(), setConstant(*this, R));
222 }
223
224 /// @brief Set every row to the matrix `R` (must have shape `n_m x n_n`).
225 void setConstant(const Eigen::Ref<const t_element_mat> &R)
226 {
227 DNDS_ARRAY_OP_SWITCHER(this->father->device(), setConstant(*this, R));
228 }
229
230 /// @brief In-place element-wise add: `this += R`.
231 void operator+=(const t_self &R)
232 {
233 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_plus_assign(*this, R));
234 }
235
236 /// @brief Add the scalar `R` to every entry.
238 {
239 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_plus_assign(*this, R));
240 }
241
242 /// @brief Add a per-row matrix `R` (same to every row).
243 void operator+=(const Eigen::Ref<const t_element_mat> &R)
244 {
245 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_plus_assign(*this, R));
246 }
247
248 /// @brief In-place element-wise subtract: `this -= R`.
249 void operator-=(const t_self &R)
250 {
251 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_minus_assign(*this, R));
252 }
253
254 /// @brief Scalar multiply in place.
256 {
257 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_mult_assign(*this, R));
258 }
259
260 /// @brief Scale each row by a corresponding scalar stored in `R` (a `1x1` ArrayDof).
261 /// @details Typical use: multiply state DOFs by per-cell values such as
262 /// inverse mass. Only enabled for non-scalar DOF shapes.
263 template <int n_m_T = n_m>
264 std::enable_if_t<!(n_m_T == 1 && n_n == 1)>
265 operator*=(const ArrayDof<1, 1> &R)
266 {
268 }
269
270 /// @brief In-place multiplication by a small fixed matrix (same applied to every row).
271 void operator*=(const Eigen::Ref<const t_element_mat> &R)
272 {
273 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_mult_assign(*this, R));
274 }
275
276 /// @brief Element-wise multiply: `this *= R` (Hadamard).
277 void operator*=(const t_self &R)
278 {
279 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_mult_assign(*this, R));
280 }
281
282 /// @brief Element-wise divide: `this /= R`.
283 void operator/=(const t_self &R)
284 {
285 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_div_assign(*this, R));
286 }
287
288 /// @brief Value-copy assignment from another ArrayDof of identical layout.
289 void operator=(const t_self &R)
290 {
291 DNDS_ARRAY_OP_SWITCHER(this->father->device(), operator_assign(*this, R));
292 }
293
294 /// @brief AXPY: `this += r * R`. One of the hot-path solver primitives.
295 void addTo(const t_self &R, real r)
296 {
297 DNDS_ARRAY_OP_SWITCHER(this->father->device(), addTo(*this, R, r));
298 }
299
300 /// @brief Global L2 norm (MPI-collective). `sqrt(sum_i sum_j x_ij^2)`.
302 {
303 DNDS_ARRAY_OP_SWITCHER(this->father->device(), norm2(*this));
304 }
305
306 /// @brief Global L2 distance between `this` and `R` (collective).
307 real norm2(const t_self &R)
308 {
309 DNDS_ARRAY_OP_SWITCHER(this->father->device(), norm2(*this, R));
310 }
311
312 /// @brief Global minimum across all entries (collective).
314 {
315 DNDS_ARRAY_OP_SWITCHER(this->father->device(), reduction(*this, "min"));
316 }
317
318 /// @brief Global maximum across all entries (collective).
320 {
321 DNDS_ARRAY_OP_SWITCHER(this->father->device(), reduction(*this, "max"));
322 }
323
324 /// @brief Global sum of all entries (collective).
326 {
327 DNDS_ARRAY_OP_SWITCHER(this->father->device(), reduction(*this, "sum"));
328 }
329
330 /// @brief Per-component global L1 norm, returned as an `n_m x n_n` matrix (collective).
335
336 /// @brief Per-component global L1 distance between `this` and `R` (collective).
338 {
339 DNDS_ARRAY_OP_SWITCHER(this->father->device(), componentWiseNorm1(*this, R));
340 }
341
342 /// @brief Global inner product: `sum_i sum_j x_ij * R_ij` (collective).
343 real dot(const t_self &R)
344 {
345 DNDS_ARRAY_OP_SWITCHER(this->father->device(), dot(*this, R));
346 }
347 };
348}
349//! the host side operators are provided as implemented
350#include "ArrayDOF_op.hxx"
351
352namespace DNDS
353{
354#undef DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE
355#define DNDS_ARRAY_DOF_OP_FUNC_LIST_SCOPE(B, n_m, n_n) ArrayDofOp<B, n_m, n_n>::
356
357#define DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(B, offset, exttmp) \
358 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 1, 1 + (offset), exttmp); \
359 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 2, 1 + (offset), exttmp); \
360 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 3, 1 + (offset), exttmp); \
361 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 4, 1 + (offset), exttmp); \
362 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 5, 1 + (offset), exttmp); \
363 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 6, 1 + (offset), exttmp); \
364 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 7, 1 + (offset), exttmp); \
365 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, 8, 1 + (offset), exttmp); \
366 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, DynamicSize, 1 + (offset), exttmp); \
367 DNDS_ARRAY_DOF_OP_FUNC_LIST(B, NonUniformSize, 1 + (offset), exttmp);
368
379
380#ifdef DNDS_USE_CUDA
381 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 0, extern template)
382 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 1, extern template)
383 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 2, extern template)
384 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 3, extern template)
385 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 4, extern template)
386 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 5, extern template)
387 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 6, extern template)
388 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, 7, extern template)
391#endif
392}
393
394namespace DNDS
395{
396 /*
397#define DNDS_ARRAYDOF_DEVICEVIEW(B, n_m, n_n) ArrayDof<n_m, n_n>::template t_deviceView<B>
398
399#define DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, n_m, n_n, ext) \
400 DNDS_DEVICE_STORAGE_BASE_DELETER_INST(DNDS_ARRAYDOF_DEVICEVIEW(B, n_m, n_n), ext) \
401 DNDS_DEVICE_STORAGE_INST(DNDS_ARRAYDOF_DEVICEVIEW(B, n_m, n_n), B, ext)
402
403#define DNDS_ARRAYDOF_INST_STORAGE(B, offset, ext) \
404 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 1, 1 + (offset), ext); \
405 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 2, 1 + (offset), ext); \
406 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 3, 1 + (offset), ext); \
407 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 4, 1 + (offset), ext); \
408 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 5, 1 + (offset), ext); \
409 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 6, 1 + (offset), ext); \
410 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 7, 1 + (offset), ext); \
411 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, 8, 1 + (offset), ext); \
412 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, DynamicSize, 1 + (offset), ext); \
413 DNDS_ARRAYDOF_DEVICEVIEW_INST_DELETER_AND_FACTORY(B, NonUniformSize, 1 + (offset), ext);
414
415 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 0, extern)
416 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 1, extern)
417 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 2, extern)
418 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 3, extern)
419 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 4, extern)
420 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 5, extern)
421 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 6, extern)
422 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, 7, extern)
423 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, DynamicSize - 1, extern)
424 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, NonUniformSize - 1, extern)
425
426#ifdef DNDS_USE_CUDA
427 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 0, extern)
428 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 1, extern)
429 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 2, extern)
430 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 3, extern)
431 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 4, extern)
432 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 5, extern)
433 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 6, extern)
434 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, 7, extern)
435 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, DynamicSize - 1, extern)
436 DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, NonUniformSize - 1, extern)
437#endif
438*/
439}
#define DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(B, offset, exttmp)
Definition ArrayDOF.hpp:357
#define DNDS_ARRAY_DOF_OP_FUNC_LIST(B, n_m, n_n, spec)
Definition ArrayDOF.hpp:66
#define DNDS_ARRAY_OP_SWITCHER(Backend, expr)
Definition ArrayDOF.hpp:131
Host-side implementations of #ArrayDofOp vector-space operations.
Eigen-matrix array: each row is an Eigen::Map<Matrix> over contiguous real storage.
Eigen-vector array: each row is an Eigen::Map over contiguous real storage.
Father-son array pairs with device views and ghost communication.
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE(T, T_Self)
Definition Defines.hpp:83
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
Device memory abstraction layer with backend-specific storage and factory creation.
Const device view of an ArrayDof father/son pair.
Definition ArrayDOF.hpp:48
DNDS_DEVICE_CALLABLE ArrayDofDeviceViewConst(t_base &&base_view)
Definition ArrayDOF.hpp:56
Mutable device view of an ArrayDof father/son pair.
Definition ArrayDOF.hpp:34
DNDS_DEVICE_CALLABLE ArrayDofDeviceView(t_base &&base_view)
Definition ArrayDOF.hpp:42
Eigen::Matrix< real, RowSize_To_EigenSize(n_m), RowSize_To_EigenSize(n_n)> t_element_mat
Definition ArrayDOF.hpp:102
Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.
Definition ArrayDOF.hpp:172
real norm2()
Global L2 norm (MPI-collective). sqrt(sum_i sum_j x_ij^2).
Definition ArrayDOF.hpp:301
t_element_mat componentWiseNorm1()
Per-component global L1 norm, returned as an n_m x n_n matrix (collective).
Definition ArrayDOF.hpp:331
void operator-=(const t_self &R)
In-place element-wise subtract: this -= R.
Definition ArrayDOF.hpp:249
real dot(const t_self &R)
Global inner product: sum_i sum_j x_ij * R_ij (collective).
Definition ArrayDOF.hpp:343
void operator+=(real R)
Add the scalar R to every entry.
Definition ArrayDOF.hpp:237
real max()
Global maximum across all entries (collective).
Definition ArrayDOF.hpp:319
void operator+=(const t_self &R)
In-place element-wise add: this += R.
Definition ArrayDOF.hpp:231
void clone(const t_self &R)
Deep copy from another ArrayDof. Delegates to the base-class clone.
Definition ArrayDOF.hpp:211
t_element_mat componentWiseNorm1(const t_self &R)
Per-component global L1 distance between this and R (collective).
Definition ArrayDOF.hpp:337
t_deviceView< B > deviceView()
Build a mutable device view (wraps the base-class implementation).
Definition ArrayDOF.hpp:186
t_deviceViewConst< B > deviceView() const
Build a const device view.
Definition ArrayDOF.hpp:193
real min()
Global minimum across all entries (collective).
Definition ArrayDOF.hpp:313
real norm2(const t_self &R)
Global L2 distance between this and R (collective).
Definition ArrayDOF.hpp:307
void operator/=(const t_self &R)
Element-wise divide: this /= R.
Definition ArrayDOF.hpp:283
void operator*=(real R)
Scalar multiply in place.
Definition ArrayDOF.hpp:255
void setConstant(real R)
Set every entry of every (father+son) row to the scalar R.
Definition ArrayDOF.hpp:219
void operator*=(const Eigen::Ref< const t_element_mat > &R)
In-place multiplication by a small fixed matrix (same applied to every row).
Definition ArrayDOF.hpp:271
void operator*=(const t_self &R)
Element-wise multiply: this *= R (Hadamard).
Definition ArrayDOF.hpp:277
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).
Definition ArrayDOF.hpp:225
void operator+=(const Eigen::Ref< const t_element_mat > &R)
Add a per-row matrix R (same to every row).
Definition ArrayDOF.hpp:243
void addTo(const t_self &R, real r)
AXPY: this += r * R. One of the hot-path solver primitives.
Definition ArrayDOF.hpp:295
real sum()
Global sum of all entries (collective).
Definition ArrayDOF.hpp:325
ArrayDofDeviceView< B, n_m, n_n > t_deviceView
Mutable device view alias.
Definition ArrayDOF.hpp:179
Eigen::Matrix< real, RowSize_To_EigenSize(n_m), RowSize_To_EigenSize(n_n)> t_element_mat
Shape of one DOF row as an Eigen matrix.
Definition ArrayDOF.hpp:208
void operator=(const t_self &R)
Value-copy assignment from another ArrayDof of identical layout.
Definition ArrayDOF.hpp:289
the host side operators are provided as implemented
DeviceBackend
Enumerates the backends a DeviceStorage / Array can live on.
@ Host
Plain CPU memory.
constexpr int RowSize_To_EigenSize(rowsize rs)
Convert a rowsize constant to the corresponding Eigen compile-time size. Fixed >= 0 -> the value; Dyn...
Definition Defines.hpp:286
DNDS_CONSTANT const rowsize DynamicSize
Template parameter flag: "row width is set at runtime but uniform".
Definition Defines.hpp:277
DNDS_CONSTANT const rowsize NonUniformSize
Template parameter flag: "each row has an independent width".
Definition Defines.hpp:279
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:105
Const device view of a father-son array pair.
Mutable device view onto an ArrayPair (for CUDA kernels).
Convenience bundle of a father, son, and attached ArrayTransformer.
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.
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
void clone(const t_self &R)
Deep-copy: allocate new father / son and copy their data; rebind trans.
tVec r(NCells)