DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Defines.hpp
Go to the documentation of this file.
1#pragma once
2/// @file Defines.hpp
3/// @brief Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
4
5#include "Macros.hpp"
6// #define NDEBUG
7#include "Errors.hpp"
8#include "EigenPCH.hpp"
9#include <cassert>
10#include <cstddef>
11#include <cstdint>
12#include <cstdio>
13#include <vector>
14#include <memory>
15#include <tuple>
16#include <iostream>
17#include <cmath>
18#include <iomanip>
19#include <string>
20#include <type_traits>
21#include <filesystem>
22#include <functional>
23#include <locale>
24#include <csignal>
25#include <cstdarg>
26#include <cstdlib> // must be included before fmt headers for malloc/free with libc++ _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
27
28#include <fmt/core.h>
29
30#if defined(linux) || defined(_UNIX) || defined(__linux__) || defined(__unix__) || defined(__APPLE__)
31# define DNDS_UNIX_LIKE
32#endif
33
34#ifdef DNDS_USE_OMP
35# include <omp.h>
36#endif
37
38#if defined(_WIN32) || defined(__WINDOWS_)
39// #include <Windows.h>
40// #include <process.h>
41#endif
42
43#define DNDS_FMT_ARG(V) fmt::arg(#V, V)
44
45/***************/ // DNDS_assertS
46
47extern "C" void DNDS_signal_handler(int signal);
48
49namespace DNDS
50{
51 /// @brief Install SEGV / ABRT handlers that print a backtrace via @ref DNDS_signal_handler.
52 /// @details Optional opt-in; not installed automatically so unit test drivers
53 /// keep full control of their own handlers. Typical drivers call this once
54 /// after `MPI_Init` in `main()`.
56 {
57 std::signal(SIGSEGV, DNDS_signal_handler);
58 std::signal(SIGABRT, DNDS_signal_handler);
59 // std::signal(SIGKILL, DNDS_signal_handler);
60 }
61}
62
63/***************/
64
65#ifdef DNDS_USE_CUDA
66# include <cuda_runtime.h>
67#endif
68
69#if defined(DNDS_USE_CUDA)
70# define DNDS_DEVICE_CALLABLE __host__ __device__
71# define DNDS_DEVICE __device__
72# define DNDS_HOST __host__
73# define DNDS_GLOBAL __global__
74# define DNDS_CONSTANT __constant__
75#else
76# define DNDS_DEVICE_CALLABLE
77# define DNDS_DEVICE
78# define DNDS_HOST
79# define DNDS_GLOBAL
80# define DNDS_CONSTANT
81#endif
82
83// NOLINTBEGIN(bugprone-macro-parentheses)
84// Rationale: T and T_Self are type names used in constructor / assignment
85// operator signatures; parenthesizing a type in a parameter list is not
86// valid C++.
87#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE(T, T_Self) \
88 DNDS_DEVICE_CALLABLE T() = default; \
89 DNDS_DEVICE_CALLABLE T(const T_Self &) = default; \
90 DNDS_DEVICE_CALLABLE T(T_Self &&) = default; \
91 DNDS_DEVICE_CALLABLE T &operator=(const T_Self &) = default; \
92 DNDS_DEVICE_CALLABLE T &operator=(T_Self &&) = default; \
93 DNDS_DEVICE_CALLABLE ~T() = default;
94
95#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE_NO_EMPTY_CTOR(T, T_Self) \
96 DNDS_DEVICE_CALLABLE T(const T_Self &) = default; \
97 DNDS_DEVICE_CALLABLE T(T_Self &&) = default; \
98 DNDS_DEVICE_CALLABLE T &operator=(const T_Self &) = default; \
99 DNDS_DEVICE_CALLABLE T &operator=(T_Self &&) = default; \
100 DNDS_DEVICE_CALLABLE ~T() = default;
101// NOLINTEND(bugprone-macro-parentheses)
102
103/***************/
104
105static_assert(sizeof(uint8_t) == 1, "bad uint8_t");
106
107namespace DNDS
108{
109 /// @brief Canonical floating-point scalar used throughout DNDSR (double precision).
110 using real = double;
111 /// @brief Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
112 using index = int64_t;
113 /// @brief Row-width / per-row element-count type (signed 32-bit).
114 using rowsize = int32_t;
115 /// @brief Integer type with the same width as #real (used for type-punning / packing).
116 using real_sized_index = int64_t;
117 /// @brief Integer type with half the width of #real.
118 using real_half_sized_index = int32_t;
119 static_assert(sizeof(real_sized_index) == sizeof(real) && sizeof(real_half_sized_index) == sizeof(real) / 2);
120
121#define DNDS_INDEX_MAX INT64_MAX
122#define DNDS_INDEX_MIN INT64_MIN
123#define DNDS_ROWSIZE_MAX INT32_MAX
124#define DNDS_ROWSIZE_MIN INT32_MIN
125
126 /// @brief Default column separator for CLI / log output (tab character).
127 static const char *outputDelim = "\t";
128
129 /// @brief Split a global range `[0, nGlobal)` evenly among `nRanks` workers.
130 /// @details Used by the @ref EvenSplit serialization-offset mode and by
131 /// redistribution routines to pick per-rank slabs without exchanging sizes.
132 /// The partition is dense and balanced to within one item.
133 /// @return `[start, end)` for the caller's `rank`.
134 inline std::pair<index, index> EvenSplitRange(int rank, int nRanks, index nGlobal)
135 {
136 index start = index(rank) * nGlobal / index(nRanks);
137 index end = index(rank + 1) * nGlobal / index(nRanks);
138 return {start, end};
139 }
140
141 /// @brief Shortened alias for `std::shared_ptr` used pervasively in DNDSR.
142 template <typename T>
143 using ssp = std::shared_ptr<T>;
144
145 /// @brief Type trait that detects whether a type is a std::shared_ptr wrapping.
146 template <typename T>
147 struct is_ssp : std::false_type
148 {
149 };
150
151 template <typename T>
152 struct is_ssp<ssp<T>> : std::true_type
153 {
154 };
155
156 template <typename T>
157 inline constexpr bool is_ssp_v = is_ssp<T>::value;
158
159 /// @brief Convenience `remove_cv` + `remove_reference` composition (C++17 port of C++20's `std::remove_cvref_t`).
160 template <typename T>
161 using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
162
163 /// @brief Vector of row widths (one `rowsize` per row).
164 using t_RowsizeVec = std::vector<rowsize>;
165 /// @brief Vector of index values (global offsets, local ids, etc.).
166 using t_IndexVec = std::vector<index>;
167 /// @brief Shared pointer alias to t_IndexVec (used by mapping tables shared
168 /// between arrays, see IndexMapping.hpp).
170
171 /// @brief Paired indices, typically `(start, size)` or `(first, last)`.
172 using t_indexerPair = std::tuple<index, index>;
173
174 /// @brief Minimum representable #index value (= @ref INT64_MIN).
175 DNDS_CONSTANT const index indexMin = INT64_MIN;
176
177 /// @brief Sentinel "not initialised" real value (NaN). Cheap to detect with
178 /// `std::isnan` or @ref IsUnInitReal; survives MPI transport unchanged.
180 /// @brief Sentinel "not initialised" index value (= @ref INT64_MIN).
181 DNDS_CONSTANT const index UnInitIndex = INT64_MIN;
182 static_assert(UnInitIndex < 0);
183 /// @brief Sentinel "not initialised" rowsize value (= @ref INT32_MIN).
185 static_assert(UnInitRowsize < 0);
186
187 /// @brief Whether `v` equals the NaN sentinel @ref UnInitReal (tested via `isnan`).
188 inline bool IsUnInitReal(real v)
189 {
190 // return (*(int64_t *)(&v)) == (*(int64_t *)(&UnInitReal));
191 return std::isnan(v);
192 }
193
194 /// @brief Catch-all upper bound ("practically infinity") for physical scalars.
196 /// @brief Loose upper bound (e.g., for non-dimensional limits).
198 /// @brief Catch-all lower bound ("effectively zero").
200 /// @brief Loose lower bound (for iterative-solver tolerances etc.).
202#define DNDS_E_PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
203 /// @brief π in double precision (matches @ref DNDS_E_PI macro).
205
206 /// @brief Row-major dynamic Eigen matrix used by quadrature / basis tables.
207 using tDiFj = Eigen::Matrix<real, -1, -1, Eigen::RowMajor>;
208
209 /// @brief Column-major dynamic Eigen matrix of reals (default layout).
210 using MatrixXR = Eigen::Matrix<real, Eigen::Dynamic, Eigen::Dynamic>;
211 /// @brief Dynamic Eigen vector of reals.
212 using VectorXR = Eigen::Vector<real, Eigen::Dynamic>;
213 /// @brief Dynamic row-vector of reals.
214 using RowVectorXR = Eigen::RowVector<real, Eigen::Dynamic>;
215
216/// @deprecated Use make_ssp<T>() or make_ssp<T>(ObjName{...}, ...) instead.
217#define DNDS_MAKE_SSP(ssp, ...) (ssp = std::make_shared<typename decltype(ssp)::element_type>(__VA_ARGS__))
218
219 /// @brief Mixin base class providing a runtime instance name for tracing/debugging.
220 ///
221 /// Array and its subclasses inherit this to carry a human-readable name
222 /// (e.g., "coords", "cell2node") that appears in assertion messages.
223 /// Zero overhead when no name is set (empty string).
224 /// NOT added to device-callable types (ArrayView, ArrayLayout).
226 {
227 std::string _objectName;
228
229 public:
230 ObjectNaming() = default;
231 ObjectNaming(const ObjectNaming &) = default;
235 ~ObjectNaming() = default;
236
237 void setObjectName(const std::string &name) { _objectName = name; }
238 [[nodiscard]] const std::string &getObjectName() const { return _objectName; }
239
240 /// Returns "name(sig)" if name is set, or just "sig" otherwise.
241 /// Callers pass the type signature (e.g., GetArrayName()) as `sig`.
242 [[nodiscard]] std::string getObjectIdentity(const std::string &sig) const
243 {
244 if (_objectName.empty())
245 return sig;
246 return fmt::format("{}({})", _objectName, sig);
247 }
248 };
249
250 /// @brief Tag type for naming objects created via make_ssp.
251 ///
252 /// Usage: `auto p = make_ssp<ParArray<index>>(ObjName{"cell2node"}, mpi);`
253 struct ObjName
254 {
255 std::string name;
256 };
257
258 /// @brief Type-safe replacement for DNDS_MAKE_SSP. Creates ssp<T> with forwarded args.
259 template <typename T, typename... Args>
260 ssp<T> make_ssp(Args &&...args)
261 {
262 return std::make_shared<T>(std::forward<Args>(args)...);
263 }
264
265 /// @brief Named variant of make_ssp. If T inherits ObjectNaming, sets the name.
266 ///
267 /// Usage: `auto p = make_ssp<ParArray<index>>(ObjName{"cell2node"}, mpi);`
268 template <typename T, typename... Args>
269 ssp<T> make_ssp(ObjName objName, Args &&...args)
270 {
271 auto p = std::make_shared<T>(std::forward<Args>(args)...);
272 if constexpr (std::is_base_of_v<ObjectNaming, T>)
273 p->setObjectName(objName.name);
274 return p;
275 }
276
277} // namespace DNDS
278
279namespace DNDS
280{
281 /// @brief Template parameter flag: "row width is set at runtime but uniform".
283 /// @brief Template parameter flag: "each row has an independent width".
285 static_assert(DynamicSize != NonUniformSize, "DynamicSize, NonUniformSize definition conflict");
286 /// @brief Alignment flag: no padding applied to rows (the only currently-supported value).
288
289 /// @brief Convert a #rowsize constant to the corresponding Eigen compile-time size.
290 /// Fixed >= 0 -> the value; DynamicSize / NonUniformSize -> Eigen::Dynamic.
292 {
293 return rs >= 0 ? static_cast<int>(rs) : (rs == DynamicSize || rs == NonUniformSize ? Eigen::Dynamic : INT_MIN);
294 }
295
296 /// @brief Encode a #rowsize constant as a short Python-binding snippet:
297 /// "<number>" for fixed, "D" for DynamicSize, "I" for NonUniformSize.
298 /// Used when generating pybind11 class names.
299 inline std::string RowSize_To_PySnippet(rowsize rs)
300 {
301 if (rs >= 0)
302 return fmt::format("{}", rs);
303 else if (rs == DynamicSize)
304 return "D";
305 else if (rs == NonUniformSize)
306 return "I";
307 else
308 {
309 return "Unknown";
310 }
311 }
312
313 /// @brief Encode an alignment value as a Python-binding snippet:
314 /// "N" for @ref NoAlign, the number otherwise.
315 inline std::string Align_To_PySnippet(rowsize al)
316 {
317 if (al == NoAlign)
318 return "N";
319 else if (al < 0)
320 return "Invalid";
321 else
322 return fmt::format("{}", al);
323 }
324}
325
326namespace DNDS
327{
328 /// @brief Shared output stream: where `DNDS::log()` writes progress / diagnostics.
329 /// @details Defaults to `std::cout` when #useCout is true; otherwise refers
330 /// to the file/stream installed via #setLogStream.
331 extern ssp<std::ostream> logStream;
332
333 /// @brief Whether `DNDS::log()` is currently routed to `std::cout`.
334 extern bool useCout;
335
336 /// @brief Return the current DNDSR log stream (either `std::cout` or the installed file).
337 std::ostream &log();
338
339 /// @brief Heuristic detection of whether `ostream` is attached to a terminal.
340 bool ostreamIsTTY(std::ostream &ostream);
341
342 /// @brief Convenience: #ostreamIsTTY applied to the current #log() stream.
343 bool logIsTTY();
344
345 /// @brief Redirect `log()` output to a user-supplied stream. Ownership is shared.
346 void setLogStream(ssp<std::ostream> nstream);
347
348 /// @brief Restore the default `std::cout` routing for `log()`.
349 void setLogStreamCout();
350
351 /// @brief Terminal width in columns (falls back to a fixed default when not a TTY).
352 int get_terminal_width();
353
354 /// @brief Render a textual progress bar to `os` for `progress` in `[0, 1]`.
355 void print_progress(std::ostream &os, double progress);
356}
357
358namespace DNDS
359{
360 /// @brief Read `OMP_NUM_THREADS` env var, returning 1 if unset / invalid.
361 extern int get_env_OMP_NUM_THREADS();
362 /// @brief Read the DNDSR-specific @ref DNDS_DIST_OMP_NUM_THREADS override,
363 /// falling back to #get_env_OMP_NUM_THREADS.
365}
366
367/*
368
369
370
371
372
373
374
375
376
377*/
378
379namespace DNDS
380{
381 /// @brief Overflow-detecting test for `value + increment` on signed integers.
382 /// @return `true` if the addition would overflow.
383 // Generic function to check for overflow in signed integer addition
384 template <typename T>
385 bool signedIntWillAddOverflow(T value, T increment)
386 {
387 static_assert(std::is_signed_v<T> && std::is_integral_v<T>, "T must be a signed integral type");
388 if (increment > 0 && value > std::numeric_limits<T>::max() - increment)
389 return true; // Overflow when adding a positive increment
390 if (increment < 0 && value < std::numeric_limits<T>::min() - increment)
391 return true; // Overflow when adding a negative increment
392 return false; // No overflow
393 }
394
395 /// @brief Add two signed integers, asserting on overflow instead of silently wrapping.
396 /// @throws Dies via @ref DNDS_assert_info if the result would overflow.
397 // Generic function to safely add with overflow check
398 template <typename T>
399 T signedIntSafeAdd(T value, T increment)
400 {
401 static_assert(std::is_signed_v<T> && std::is_integral_v<T>, "T must be a signed integral type");
402 if (signedIntWillAddOverflow<T>(value, increment))
403 {
404 DNDS_assert_info(false, fmt::format("doing [{} + {}] overflow detected", value, increment));
405 return 0;
406 }
407 return value + increment;
408 }
409
410 /// @brief Narrowing `size_t -> T` conversion with range check.
411 /// @tparam T Signed integral target type.
412 /// @throws Dies via @ref DNDS_assert_info if `v > std::numeric_limits<T>::max()`.
413 template <typename T>
415 {
416 static_assert(std::is_signed_v<T> && std::is_integral_v<T>, "T must be a signed integral type");
417 static_assert(std::is_unsigned_v<size_t>, "size_t should be unsigned");
418 if (v <= std::numeric_limits<T>::max())
419 return T(v);
420 else
421 {
422 DNDS_assert_info(false, fmt::format("[{}] from {} to size_t overflow detected", v, typeid(T).name()));
423 return v;
424 }
425 }
426
427 /// @brief Range-checked conversion from size_t to DNDS::index.
428 /// @throws std::runtime_error (via DNDS_assert_info) if value exceeds index max.
429 /// Use this for safe conversions from container sizes (e.g., std::vector::size())
430 /// to DNDS index types, avoiding sign comparison warnings and overflow bugs.
431 inline index size_to_index(size_t v)
432 {
433 return size_t_to_signed<index>(v);
434 }
435
436 /// @brief Range-checked conversion from size_t to DNDS::rowsize.
437 /// @throws std::runtime_error (via DNDS_assert_info) if value exceeds rowsize max.
438 inline rowsize size_to_rowsize(size_t v)
439 {
440 return size_t_to_signed<rowsize>(v);
441 }
442
443 /**
444 * @brief Build a prefix-sum table from a row-size vector.
445 *
446 * @details Resizes `rowstarts` to `rowsizes.size() + 1` and fills it so that
447 * `rowstarts[i] = sum_{k<i} rowsizes[k]`. Asserts on overflow.
448 * Used extensively by CSR @ref DNDS::Array "Array" / ghost-indexing to turn row-count vectors
449 * into offset vectors.
450 *
451 * @tparam TtRowsizeVec `std::vector`-like of row sizes (e.g. `rowsize`).
452 * @tparam TtIndexVec `std::vector`-like of offsets (e.g. `index`), must
453 * have a strictly wider range than the row-size type.
454 */
455 // Note that TtIndexVec being accumulated could overflow
456 template <class TtRowsizeVec, class TtIndexVec>
457 inline void AccumulateRowSize(const TtRowsizeVec &rowsizes, TtIndexVec &rowstarts)
458 {
459 static_assert(std::is_signed_v<typename TtIndexVec::value_type>, "row starts should be signed");
460 static_assert(std::numeric_limits<typename TtIndexVec::value_type>::max() >=
461 std::numeric_limits<typename TtRowsizeVec::value_type>::max(),
462 "row starts should have larger upper limit");
463 rowstarts.resize(rowsizes.size() + 1);
464 rowstarts[0] = 0;
465 for (typename TtIndexVec::size_type i = 1; i < rowstarts.size(); i++)
466 {
467 rowstarts[i] = signedIntSafeAdd<typename TtIndexVec::value_type>(rowstarts[i - 1], rowsizes[i - 1]);
468 }
469 }
470
471 /// @brief Whether all elements of `dat` are equal; if so, stores the value into `value`.
472 /// @return false if the vector is empty or contains at least two distinct values.
473 template <class T>
474 inline bool checkUniformVector(const std::vector<T> &dat, T &value)
475 {
476 if (dat.empty())
477 return false;
478 value = dat[0];
479 for (auto i = 1; i < dat.size(); i++)
480 if (dat[i] != value)
481 return false;
482 return true;
483 }
484
485 /// @brief Print a vector to `out` with #outputDelim between elements.
486 /// @tparam TP Optional cast type (e.g., promote `int8_t` to `int` to avoid
487 /// character printing).
488 template <class T, class TP = T>
489 inline void PrintVec(const std::vector<T> &dat, std::ostream &out)
490 {
491 for (auto i = 0; i < dat.size(); i++)
492 out << TP(dat[i]) << outputDelim;
493 }
494
495 /// @brief Integer ceiling division. `l` must be non-negative, `r` positive.
496 /// @bug The current expression has incorrect precedence; see #divide_ceil for
497 /// the corrected version. Do not use new code with `divCeil`.
498 /// \brief l must be non-negative, r must be positive. integers
499 template <class TL, class TR>
500 constexpr auto divCeil(TL l, TR r)
501 {
502 return l / r + (l % r) ? 1 : 0;
503 }
504}
505
506/*
507
508
509
510
511
512
513
514
515
516*/
517
518namespace DNDS
519{
520 /// @brief `a * a`, constexpr. Works for all arithmetic types.
521 template <typename T>
522 constexpr T sqr(const T &a)
523 {
524 static_assert(std::is_arithmetic_v<T>, "need arithmetic");
525 return a * a;
526 }
527
528 /// @brief `a * a * a`, constexpr.
529 template <typename T>
530 constexpr T cube(const T &a)
531 {
532 static_assert(std::is_arithmetic_v<T>, "need arithmetic");
533 return a * a * a;
534 }
535
536 /// @brief Signum function: +1, 0, or -1.
537 constexpr real sign(real a)
538 {
539 return a > 0 ? 1 : (a < 0 ? -1 : 0);
540 }
541
542 /// @brief Tolerant signum: returns 0 inside `[-tol, tol]`.
543 constexpr real signTol(real a, real tol)
544 {
545 return a > tol ? 1 : (a < -tol ? -1 : 0);
546 }
547
548 /// @brief "Signum, biased toward +1": treats 0 as positive.
549 constexpr real signP(real a)
550 {
551 return a >= 0 ? 1 : -1;
552 }
553
554 /// @brief "Signum, biased toward -1": treats 0 as negative.
555 constexpr real signM(real a)
556 {
557 return a <= 0 ? -1 : 1;
558 }
559
560 /// @brief Mathematical modulo that always returns a non-negative result.
561 /// Unlike `%` in C++ where `(-1) % 3 == -1`, `mod(-1, 3) == 2`.
562 template <typename T>
563 constexpr T mod(T a, T b)
564 {
565 static_assert(std::is_signed<T>::value && std::is_integral<T>::value, "not legal mod type");
566 T val = a % b;
567 if (val < 0)
568 val += b;
569 return val;
570 }
571
572 /// @brief Integer ceiling division `ceil(a / b)`. Correct for all signs.
573 template <typename T>
574 constexpr T divide_ceil(T a, T b)
575 {
576 static_assert(std::is_integral<T>::value, "not legal mod type");
577 return a / b + (a % b ? 1 : 0);
578 }
579 // const int a = divide_ceil(23, 11);
580
581 /**
582 * @brief Floating-point modulo matching Python's `%` (result has sign of `b`).
583 * @param b Must be positive.
584 */
586 {
587 return a - std::floor(a / b) * b;
588 }
589
590 /**
591 * @brief Walk two ordered ranges in lockstep, calling `F` on each match.
592 *
593 * @details Two-pointer algorithm. Requires both ranges to be sorted in
594 * ascending order; advances the smaller side at each step. Exits early
595 * (returning `true`) if `F(value, pos1, pos2)` returns `true`.
596 *
597 * @tparam tF Callable `bool(value, size_t pos1, size_t pos2)`.
598 * @return true if the functor short-circuited, false if ranges were walked to completion.
599 */
600 template <class tIt1, class tIt1end, class tIt2, class tIt2end, class tF>
601 bool iterateIdentical(tIt1 it1, tIt1end it1end, tIt2 it2, tIt2end it2end, tF F)
602 {
603 size_t it1Pos{0}, it2Pos{0};
604 while (it1 != it1end && it2 != it2end)
605 {
606 if ((*it1) < (*it2))
607 ++it1, ++it1Pos;
608 else if ((*it1) > (*it2))
609 ++it2, ++it2Pos;
610 else if ((*it1) == (*it2))
611 {
612 if (F(*it1, it1Pos, it2Pos))
613 return true;
614 ++it1, ++it1Pos;
615 ++it2, ++it2Pos;
616 }
617 }
618 return false;
619 }
620
621 ///@todo //TODO: overflow_assign_int64_to_32
622
623 /// @brief Narrow #index to `int32_t` with range check; dies on overflow.
624 inline int32_t checkedIndexTo32(index v)
625 {
626 DNDS_assert_info(!(v > static_cast<index>(INT32_MAX) || v < static_cast<index>(INT32_MIN)),
627 fmt::format("Index {} to int32 overflow", v));
628 return static_cast<int32_t>(v);
629 }
630
631 /// @brief Convert a `wstring` to `string` (UTF-8 on Windows, byte-cast elsewhere).
632 std::string getStringForceWString(const std::wstring &v);
633
634 /// @brief Portable conversion of a platform-native path string to `std::string`.
635 inline std::string getStringForcePath(const std::filesystem::path::string_type &v)
636 {
637#ifdef _WIN32
638 return getStringForceWString(v);
639#else
640 return std::string{v};
641#endif
642 }
643
644}
645
646namespace DNDS
647{
648#if EIGEN_MAJOR_VERSION >= 5
649 /// @brief Eigen "select every index" placeholder (compatibility wrapper across Eigen versions).
650 static const auto EigenAll = Eigen::placeholders::all;
651 /// @brief Eigen "last index" placeholder (compatibility wrapper across Eigen versions).
652 static const auto EigenLast = Eigen::placeholders::last;
653#else
654 static const auto EigenAll = Eigen::all;
655 static const auto EigenLast = Eigen::last;
656#endif
657
658}
659
660/*-----------------------------------------*/
661// some meta-programming utilities
662namespace DNDS::Meta
663{
664 template <typename T>
665 inline constexpr bool always_false = false;
666
667 /// @brief Type trait that detects whether a type is a std::array.
668 template <class T>
669 struct is_std_array : std::false_type
670 {
671 };
672
673 template <class T, size_t N>
674 struct is_std_array<std::array<T, N>> : std::true_type
675 {
676 };
677
678 /// @brief Type trait that detects whether a type is a std::vector.
679 template <class T>
680 struct is_std_vector : std::false_type
681 {
682 };
683
684 template <class T, class Allocator>
685 struct is_std_vector<std::vector<T, Allocator>> : std::true_type
686 {
687 };
688
689 template <typename Tp>
691
692 static_assert(is_std_array_v<std::array<real, 5>> && (!is_std_array_v<std::vector<real>>)); // basic test
693
694 /**
695 * @brief see if the Actual valid data is in the struct scope (memcpy copyable)
696 * @details
697 * generally a fixed size Eigen::Matrix, but it seems std::is_trivially_copyable_v<> does not distinguish that,
698 * see https://eigen.tuxfamily.org/dox/classEigen_1_1Matrix.html, ABI part
699 * ```
700 * static_assert(!is_fixed_data_real_eigen_matrix_v<std::array<real, 10>> &&
701 is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, 2, 2>> &&
702 !is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, 2>> &&
703 is_fixed_data_real_eigen_matrix_v<Eigen::Vector2d> &&
704 !is_fixed_data_real_eigen_matrix_v<Eigen::Vector2f> &&
705 is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, -1, Eigen::DontAlign, 2, 2>> &&
706 !is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, -1, Eigen::DontAlign, -1, 2>> &&
707 !is_fixed_data_real_eigen_matrix_v<Eigen::MatrixXd>,
708 "is_fixed_data_real_eigen_matrix_v bad");
709 * ```
710 *
711 * @tparam T
712 */
713
714 template <class T>
716 {
717 static constexpr bool value = false;
718 };
719
720 template <class T, int M, int N, int options, int max_m, int max_n>
721 struct is_fixed_data_real_eigen_matrix<Eigen::Matrix<T, M, N, options, max_m, max_n>>
722 {
723 static constexpr bool value = std::is_same_v<real, T> &&
724 ((M > 0 && N > 0) ||
725 (max_m > 0 && max_n > 0));
726 };
727
728 template <typename Tp>
730
731 static_assert(!is_fixed_data_real_eigen_matrix_v<std::array<real, 10>> &&
732 is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, 2, 2>> &&
733 !is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, 2>> &&
734 is_fixed_data_real_eigen_matrix_v<Eigen::Vector2d> &&
735 !is_fixed_data_real_eigen_matrix_v<Eigen::Vector2f> &&
736 is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, -1, Eigen::DontAlign, 2, 2>> &&
737 !is_fixed_data_real_eigen_matrix_v<Eigen::Matrix<real, -1, -1, Eigen::DontAlign, -1, 2>> &&
738 !is_fixed_data_real_eigen_matrix_v<Eigen::MatrixXd>,
739 "is_fixed_data_real_eigen_matrix_v bad");
740
741 template <typename T>
742 inline constexpr bool is_eigen_dense_v = std::is_base_of_v<Eigen::DenseBase<T>, T>;
743
744 /// @brief Type trait that detects whether a type is an Eigen::Matrix with `real` scalar type.
745 template <class T>
747 {
748 static constexpr bool value = false;
749 };
750
751 template <int M, int N, int options, int max_m, int max_n>
752 struct is_real_eigen_matrix<Eigen::Matrix<real, M, N, options, max_m, max_n>>
753 {
754 static constexpr bool value = true;
755 };
756
757 template <class T>
759
760 /// @brief Type trait that detects whether std::hash is specialized for a given type.
761 template <typename T, typename = void>
762 struct has_std_hash : std::false_type
763 {
764 };
765
766 template <typename T>
767 struct has_std_hash<T, std::void_t<decltype(std::hash<T>{}(std::declval<T>()))>> : std::true_type
768 {
769 };
770
771 static_assert(has_std_hash<double>::value);
772 static_assert(!has_std_hash<std::vector<std::string>>::value);
773}
774
775namespace DNDS
776{
777 inline std::vector<std::string> splitSString(const std::string &str, char delim) // TODO: make more C++
778 {
779 std::vector<std::string> ret;
780 size_t top = 0;
781 size_t bot = 0;
782 while (top < str.size() + 1)
783 {
784 if (str[top] != delim && top != str.size())
785 {
786 top++;
787 continue;
788 }
789 ret.push_back(str.substr(bot, top - bot));
790 bot = ++top;
791 }
792 return ret;
793 }
794
795 inline std::vector<std::string> splitSStringClean(const std::string &str, char delim)
796 {
797 std::vector<std::string> ret0 = splitSString(str, delim);
798 std::vector<std::string> ret;
799 for (auto &v : ret0)
800 if (!v.empty())
801 ret.push_back(v);
802 return ret;
803 }
804
805 inline bool sstringHasSuffix(const std::string &str, const std::string &suffix)
806 {
807 if (str.size() < suffix.size())
808 return false;
809 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
810 }
811
812 /// @brief Hash functor for std::vector<T>, combining element hashes via XOR.
813 template <typename T>
815 {
816 std::size_t operator()(const std::vector<T> &v) const noexcept
817 {
818 std::size_t r = 0;
819 if constexpr (Meta::has_std_hash<T>::value)
820 for (auto &i : v)
821 r = r ^ std::hash<T>{}(i);
822 else if constexpr (Meta::is_std_vector<T>::value)
823 for (auto &i : v)
825 else
826 {
827 for (size_t i = 0; i < v.size() * sizeof(T); i++)
828 r = r ^ std::hash<uint8_t>{}(((uint8_t *)(v.data()))[i]);
829 }
830 return r;
831 }
832
833 template <class TBegin, class TEnd>
834 std::size_t operator()(TBegin &&begin, TEnd &&end) const noexcept
835 {
836 std::size_t r = 0;
837 ptrdiff_t size = end - begin;
838 if constexpr (Meta::has_std_hash<T>::value)
839 for (ptrdiff_t i = 0; i < size; i++)
840 r = r ^ std::hash<T>{}(begin[i]);
841 else if constexpr (Meta::is_std_vector<T>::value)
842 for (ptrdiff_t i = 0; i < size; i++)
844 else
845 {
846 auto *start = reinterpret_cast<uint8_t *>(&(*begin));
847 for (size_t i = 0; i < size * sizeof(T); i++)
848 r = r ^ std::hash<uint8_t>{}(start[i]);
849 }
850 return r;
851 }
852 };
853
854 /// @brief Hash functor for std::array<T, s>, combining element hashes via XOR.
855 template <typename T, std::size_t s>
857 {
858 std::size_t operator()(const std::array<T, s> &v) const noexcept
859 {
860 std::size_t r = 0;
861 for (auto i : v)
862 {
863 r = r ^ std::hash<decltype(i)>()(i);
864 }
865 return r;
866 }
867 };
868
869}
870
872{
873 /// @brief ANSI escape: bright red foreground.
874 constexpr std::string_view Red = "\033[91m";
875 /// @brief ANSI escape: bright green foreground.
876 constexpr std::string_view Green = "\033[92m";
877 /// @brief ANSI escape: bright yellow foreground.
878 constexpr std::string_view Yellow = "\033[93m";
879 /// @brief ANSI escape: bright blue foreground.
880 constexpr std::string_view Blue = "\033[94m";
881 /// @brief ANSI escape: bright magenta foreground.
882 constexpr std::string_view Magenta = "\033[95m";
883 /// @brief ANSI escape: bright cyan foreground.
884 constexpr std::string_view Cyan = "\033[96m";
885 /// @brief ANSI escape: bright white foreground.
886 constexpr std::string_view White = "\033[97m";
887 /// @brief ANSI escape: reset all attributes.
888 constexpr std::string_view Reset = "\033[0m";
889 /// @brief ANSI escape: bold.
890 constexpr std::string_view Bold = "\033[1m";
891 /// @brief ANSI escape: underline.
892 constexpr std::string_view Underline = "\033[4m";
893 /// @brief ANSI escape: blinking text.
894 constexpr std::string_view Blink = "\033[5m";
895 /// @brief ANSI escape: reverse (swap fg/bg).
896 constexpr std::string_view Reverse = "\033[7m";
897 /// @brief ANSI escape: hidden text.
898 constexpr std::string_view Hidden = "\033[8m";
899
900}
901/*
902
903
904
905
906
907
908
909
910
911*/
912
913namespace DNDS
914{
915 /// @brief Trivially-copyable empty placeholder type that accepts any assignment.
916 struct Empty
917 {
919 template <class T>
920 DNDS_DEVICE_CALLABLE Empty &operator=(T v) { return *this; };
921 template <class T>
923 };
924
925 /// @brief Empty placeholder type without a default constructor; accepts any assignment.
936}
937/*
938
939
940
941
942
943
944
945
946
947*/
948
949namespace DNDS
950{
951 /// @brief Read/set the build version string accessible from code.
952 /// @details When `ver` is non-empty it replaces the stored value; always
953 /// returns the current value. Written into HDF5 attributes for traceability.
954 std::string GetSetVersionName(const std::string &ver = "");
955}
956
957/*
958
959
960
961
962
963
964
965
966
967
968
969*/
970
971#if defined(_MSC_VER)
972/// @brief `restrict`-pointer attribute (MSVC spelling).
973# define DNDS_RESTRICT __restrict
974/// @brief Force-inline attribute (MSVC spelling).
975# define DNDS_FORCEINLINE __forceinline
976#elif defined(__GNUC__) || defined(__clang__)
977/// @brief `restrict`-pointer attribute (GCC/Clang spelling).
978# define DNDS_RESTRICT __restrict__
979/// @brief Force-inline attribute (GCC/Clang spelling).
980# define DNDS_FORCEINLINE inline __attribute__((always_inline))
981#else
982# define DNDS_RESTRICT
983# define DNDS_FORCEINLINE
984#endif
void DNDS_signal_handler(int signal)
Definition Defines.cpp:27
#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE(T, T_Self)
Definition Defines.hpp:87
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
#define DNDS_E_PI
Definition Defines.hpp:202
void DNDS_signal_handler(int signal)
Definition Defines.cpp:27
#define DNDS_CONSTANT
Definition Defines.hpp:80
Pre-compiled-header style shim that includes the heavy Eigen headers under DNDSR's warning suppressio...
Assertion / error-handling macros and supporting helper functions.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Definition Errors.hpp:117
Project-wide preprocessor flags, branch-hint macros, and version/build metadata strings....
Mixin base class providing a runtime instance name for tracing/debugging.
Definition Defines.hpp:226
std::string getObjectIdentity(const std::string &sig) const
Definition Defines.hpp:242
ObjectNaming(ObjectNaming &&)=default
ObjectNaming & operator=(ObjectNaming &&)=default
ObjectNaming & operator=(const ObjectNaming &)=default
ObjectNaming()=default
const std::string & getObjectName() const
Definition Defines.hpp:238
~ObjectNaming()=default
ObjectNaming(const ObjectNaming &)=default
void setObjectName(const std::string &name)
Definition Defines.hpp:237
constexpr bool is_fixed_data_real_eigen_matrix_v
Definition Defines.hpp:729
constexpr bool is_std_array_v
Definition Defines.hpp:690
constexpr bool is_eigen_dense_v
Definition Defines.hpp:742
constexpr bool always_false
Definition Defines.hpp:665
constexpr bool is_real_eigen_matrix_v
Definition Defines.hpp:758
constexpr std::string_view Blue
ANSI escape: bright blue foreground.
Definition Defines.hpp:880
constexpr std::string_view Blink
ANSI escape: blinking text.
Definition Defines.hpp:894
constexpr std::string_view Cyan
ANSI escape: bright cyan foreground.
Definition Defines.hpp:884
constexpr std::string_view Magenta
ANSI escape: bright magenta foreground.
Definition Defines.hpp:882
constexpr std::string_view Reverse
ANSI escape: reverse (swap fg/bg).
Definition Defines.hpp:896
constexpr std::string_view White
ANSI escape: bright white foreground.
Definition Defines.hpp:886
constexpr std::string_view Reset
ANSI escape: reset all attributes.
Definition Defines.hpp:888
constexpr std::string_view Green
ANSI escape: bright green foreground.
Definition Defines.hpp:876
constexpr std::string_view Yellow
ANSI escape: bright yellow foreground.
Definition Defines.hpp:878
constexpr std::string_view Red
ANSI escape: bright red foreground.
Definition Defines.hpp:874
constexpr std::string_view Bold
ANSI escape: bold.
Definition Defines.hpp:890
constexpr std::string_view Underline
ANSI escape: underline.
Definition Defines.hpp:892
constexpr std::string_view Hidden
ANSI escape: hidden text.
Definition Defines.hpp:898
the host side operators are provided as implemented
constexpr T cube(const T &a)
a * a * a, constexpr.
Definition Defines.hpp:530
bool signedIntWillAddOverflow(T value, T increment)
Overflow-detecting test for value + increment on signed integers.
Definition Defines.hpp:385
std::vector< rowsize > t_RowsizeVec
Vector of row widths (one rowsize per row).
Definition Defines.hpp:164
int32_t real_half_sized_index
Integer type with half the width of real.
Definition Defines.hpp:118
ssp< std::ostream > logStream
Shared output stream: where DNDS::log() writes progress / diagnostics.
Definition Defines.cpp:46
void PrintVec(const std::vector< T > &dat, std::ostream &out)
Print a vector to out with outputDelim between elements.
Definition Defines.hpp:489
constexpr real signM(real a)
"Signum, biased toward -1": treats 0 as negative.
Definition Defines.hpp:555
int get_env_OMP_NUM_THREADS()
Read OMP_NUM_THREADS env var, returning 1 if unset / invalid.
Definition Defines.cpp:122
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
Definition Defines.hpp:181
rowsize size_to_rowsize(size_t v)
Range-checked conversion from size_t to DNDS::rowsize.
Definition Defines.hpp:438
bool sstringHasSuffix(const std::string &str, const std::string &suffix)
Definition Defines.hpp:805
int32_t checkedIndexTo32(index v)
Narrow index to int32_t with range check; dies on overflow.
Definition Defines.hpp:624
DNDS_CONSTANT const rowsize NoAlign
Alignment flag: no padding applied to rows (the only currently-supported value).
Definition Defines.hpp:287
DNDS_CONSTANT const real verySmallReal
Catch-all lower bound ("effectively zero").
Definition Defines.hpp:199
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:291
T size_t_to_signed(size_t v)
Narrowing size_t -> T conversion with range check.
Definition Defines.hpp:414
constexpr bool is_ssp_v
Definition Defines.hpp:157
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
Convenience remove_cv + remove_reference composition (C++17 port of C++20's std::remove_cvref_t).
Definition Defines.hpp:161
int64_t real_sized_index
Integer type with the same width as real (used for type-punning / packing).
Definition Defines.hpp:116
void RegisterSignalHandler()
Install SEGV / ABRT handlers that print a backtrace via DNDS_signal_handler.
Definition Defines.hpp:55
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
Definition Defines.hpp:114
DNDS_CONSTANT const real pi
π in double precision (matches DNDS_E_PI macro).
Definition Defines.hpp:204
constexpr real signTol(real a, real tol)
Tolerant signum: returns 0 inside [-tol, tol].
Definition Defines.hpp:543
DNDS_CONSTANT const rowsize DynamicSize
Template parameter flag: "row width is set at runtime but uniform".
Definition Defines.hpp:282
DNDS_CONSTANT const real UnInitReal
Sentinel "not initialised" real value (NaN). Cheap to detect with std::isnan or IsUnInitReal; survive...
Definition Defines.hpp:179
void AccumulateRowSize(const TtRowsizeVec &rowsizes, TtIndexVec &rowstarts)
Build a prefix-sum table from a row-size vector.
Definition Defines.hpp:457
constexpr T divide_ceil(T a, T b)
Integer ceiling division ceil(a / b). Correct for all signs.
Definition Defines.hpp:574
constexpr auto divCeil(TL l, TR r)
Integer ceiling division. l must be non-negative, r positive.
Definition Defines.hpp:500
constexpr real sign(real a)
Signum function: +1, 0, or -1.
Definition Defines.hpp:537
DNDS_CONSTANT const rowsize NonUniformSize
Template parameter flag: "each row has an independent width".
Definition Defines.hpp:284
std::pair< index, index > EvenSplitRange(int rank, int nRanks, index nGlobal)
Split a global range [0, nGlobal) evenly among nRanks workers.
Definition Defines.hpp:134
void setLogStream(ssp< std::ostream > nstream)
Redirect log() output to a user-supplied stream. Ownership is shared.
Definition Defines.cpp:54
std::string RowSize_To_PySnippet(rowsize rs)
Encode a rowsize constant as a short Python-binding snippet: "<number>" for fixed,...
Definition Defines.hpp:299
std::vector< index > t_IndexVec
Vector of index values (global offsets, local ids, etc.).
Definition Defines.hpp:166
bool checkUniformVector(const std::vector< T > &dat, T &value)
Whether all elements of dat are equal; if so, stores the value into value.
Definition Defines.hpp:474
std::tuple< index, index > t_indexerPair
Paired indices, typically (start, size) or (first, last).
Definition Defines.hpp:172
std::vector< std::string > splitSString(const std::string &str, char delim)
Definition Defines.hpp:777
bool logIsTTY()
Convenience: ostreamIsTTY applied to the current log() stream.
Definition Defines.cpp:52
T signedIntSafeAdd(T value, T increment)
Add two signed integers, asserting on overflow instead of silently wrapping.
Definition Defines.hpp:399
Eigen::Matrix< real, Eigen::Dynamic, Eigen::Dynamic > MatrixXR
Column-major dynamic Eigen matrix of reals (default layout).
Definition Defines.hpp:210
int get_terminal_width()
Terminal width in columns (falls back to a fixed default when not a TTY).
Definition Defines.cpp:58
index size_to_index(size_t v)
Range-checked conversion from size_t to DNDS::index.
Definition Defines.hpp:431
bool IsUnInitReal(real v)
Whether v equals the NaN sentinel UnInitReal (tested via isnan).
Definition Defines.hpp:188
DNDS_CONSTANT const real largeReal
Loose upper bound (e.g., for non-dimensional limits).
Definition Defines.hpp:197
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:112
constexpr T mod(T a, T b)
Mathematical modulo that always returns a non-negative result. Unlike % in C++ where (-1) % 3 == -1,...
Definition Defines.hpp:563
std::string getStringForcePath(const std::filesystem::path::string_type &v)
Portable conversion of a platform-native path string to std::string.
Definition Defines.hpp:635
std::string getStringForceWString(const std::wstring &v)
Convert a wstring to string (UTF-8 on Windows, byte-cast elsewhere).
Definition Defines.cpp:107
constexpr T sqr(const T &a)
a * a, constexpr. Works for all arithmetic types.
Definition Defines.hpp:522
Eigen::RowVector< real, Eigen::Dynamic > RowVectorXR
Dynamic row-vector of reals.
Definition Defines.hpp:214
Eigen::Matrix< real, -1, -1, Eigen::RowMajor > tDiFj
Row-major dynamic Eigen matrix used by quadrature / basis tables.
Definition Defines.hpp:207
int get_env_DNDS_DIST_OMP_NUM_THREADS()
Read the DNDSR-specific DNDS_DIST_OMP_NUM_THREADS override, falling back to get_env_OMP_NUM_THREADS.
Definition Defines.cpp:142
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
Definition Defines.hpp:143
DNDS_CONSTANT const index indexMin
Minimum representable index value (= INT64_MIN).
Definition Defines.hpp:175
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:110
constexpr real signP(real a)
"Signum, biased toward +1": treats 0 as positive.
Definition Defines.hpp:549
ssp< T > make_ssp(Args &&...args)
Type-safe replacement for DNDS_MAKE_SSP. Creates ssp<T> with forwarded args.
Definition Defines.hpp:260
bool ostreamIsTTY(std::ostream &ostream)
Heuristic detection of whether ostream is attached to a terminal.
Definition Defines.cpp:37
ssp< t_IndexVec > t_pIndexVec
Shared pointer alias to t_IndexVec (used by mapping tables shared between arrays, see IndexMapping....
Definition Defines.hpp:169
std::vector< std::string > splitSStringClean(const std::string &str, char delim)
Definition Defines.hpp:795
void print_progress(std::ostream &os, double progress)
Render a textual progress bar to os for progress in [0, 1].
Definition Defines.cpp:78
real float_mod(real a, real b)
Floating-point modulo matching Python's % (result has sign of b).
Definition Defines.hpp:585
std::string Align_To_PySnippet(rowsize al)
Encode an alignment value as a Python-binding snippet: "N" for NoAlign, the number otherwise.
Definition Defines.hpp:315
DNDS_CONSTANT const real smallReal
Loose lower bound (for iterative-solver tolerances etc.).
Definition Defines.hpp:201
Eigen::Vector< real, Eigen::Dynamic > VectorXR
Dynamic Eigen vector of reals.
Definition Defines.hpp:212
std::ostream & log()
Return the current DNDSR log stream (either std::cout or the installed file).
Definition Defines.cpp:50
bool iterateIdentical(tIt1 it1, tIt1end it1end, tIt2 it2, tIt2end it2end, tF F)
Walk two ordered ranges in lockstep, calling F on each match.
Definition Defines.hpp:601
DNDS_CONSTANT const real veryLargeReal
Catch-all upper bound ("practically infinity") for physical scalars.
Definition Defines.hpp:195
bool useCout
Whether DNDS::log() is currently routed to std::cout.
Definition Defines.cpp:48
void setLogStreamCout()
Restore the default std::cout routing for log().
Definition Defines.cpp:56
std::string GetSetVersionName(const std::string &ver)
Read/set the build version string accessible from code.
Definition Defines.cpp:175
DNDS_CONSTANT const rowsize UnInitRowsize
Sentinel "not initialised" rowsize value (= INT32_MIN).
Definition Defines.hpp:184
Empty placeholder type without a default constructor; accepts any assignment.
Definition Defines.hpp:927
DNDS_DEVICE_CALLABLE EmptyNoDefault(EmptyNoDefault &&v)=default
DNDS_DEVICE_CALLABLE EmptyNoDefault(const EmptyNoDefault &v)=default
DNDS_DEVICE_CALLABLE EmptyNoDefault & operator=(T v)
Definition Defines.hpp:932
DNDS_DEVICE_CALLABLE EmptyNoDefault(T v)
Definition Defines.hpp:934
DNDS_DEVICE_CALLABLE EmptyNoDefault & operator=(const EmptyNoDefault &)=default
Trivially-copyable empty placeholder type that accepts any assignment.
Definition Defines.hpp:917
DNDS_DEVICE_CALLABLE Empty & operator=(T v)
Definition Defines.hpp:920
DNDS_DEVICE_CALLABLE Empty(T v)
Definition Defines.hpp:922
Type trait that detects whether std::hash is specialized for a given type.
Definition Defines.hpp:763
see if the Actual valid data is in the struct scope (memcpy copyable)
Definition Defines.hpp:716
Type trait that detects whether a type is an Eigen::Matrix with real scalar type.
Definition Defines.hpp:747
static constexpr bool value
Definition Defines.hpp:748
Type trait that detects whether a type is a std::array.
Definition Defines.hpp:670
Type trait that detects whether a type is a std::vector.
Definition Defines.hpp:681
Tag type for naming objects created via make_ssp.
Definition Defines.hpp:254
std::string name
Definition Defines.hpp:255
Hash functor for std::array<T, s>, combining element hashes via XOR.
Definition Defines.hpp:857
std::size_t operator()(const std::array< T, s > &v) const noexcept
Definition Defines.hpp:858
Type trait that detects whether a type is a std::shared_ptr wrapping.
Definition Defines.hpp:148
Hash functor for std::vector<T>, combining element hashes via XOR.
Definition Defines.hpp:815
std::size_t operator()(const std::vector< T > &v) const noexcept
Definition Defines.hpp:816
std::size_t operator()(TBegin &&begin, TEnd &&end) const noexcept
Definition Defines.hpp:834
Eigen::Matrix< real, 5, 1 > v
constexpr DNDS::index N
tVec r(NCells)
tVec b(NCells)
const tPoint const tPoint const tPoint & p