MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvcartesiancellcollector.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef FVCELLCOLLECTOR_H_
8#define FVCELLCOLLECTOR_H_
9
10#include <algorithm>
11#include <bitset>
12#include <type_traits>
13#include <vector>
15#include "INCLUDE/maiamacro.h"
16#include "INCLUDE/maiatypes.h"
17#include "IO/context.h"
18#include "MEMORY/container.h"
19#include "UTIL/functions.h"
20#include "compiler_config.h"
22#include "property.h"
23
24// The following macro enables the "Structure-of-Arrays" memory layout for multi-dimensional node
25// variables. This might be beneficial for GPU computations. Default is "Array-of-Structures".
26// Examples (for nodes nN with four children cM each)
27// Array-of-Structures (AOS): n0c0, n0c1, n0c2, n0c3, n1c0, n1c1, n1c2, n1c3, n2c0, n2c1, ...
28// Structure-of-Arrays (SOA): n0c0, n1c0, n2c0, n3c0, ..., n0c1, n1c1, n2c1, n3c1, ..., n0c2, ...
29// #define FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
30
31// Sanity-checking macros for accessors
32#if defined(FVCELLCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
33#define ENSURE_VALID_ID_ACCESSOR(id) \
34 do { \
35 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
36 } while(false)
37#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
38 do { \
39 MAIA_CONTAINER_ENSURE( \
40 id >= 0 && id < noCVariables(), \
41 "variable id = " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(noCVariables()) + ")", AT_); \
42 } while(false)
43#define ENSURE_VALID_PVARIABLE_ID_ACCESSOR(id) \
44 do { \
45 MAIA_CONTAINER_ENSURE(id >= 0 && id < noPVariables(), \
46 "primitive variable id = " + std::to_string(id) + " out-of-bounds [0, " \
47 + std::to_string(noPVariables()) + ")", \
48 AT_); \
49 } while(false)
50#define ENSURE_VALID_FVARIABLE_ID_ACCESSOR(id) \
51 do { \
52 MAIA_CONTAINER_ENSURE(id >= 0 && id < noFVariables(), \
53 "flux variable id = " + std::to_string(id) + " out-of-bounds [0, " \
54 + std::to_string(noFVariables()) + ")", \
55 AT_); \
56 } while(false)
57#define ENSURE_VALID_AVARIABLE_ID_ACCESSOR(id) \
58 do { \
59 MAIA_CONTAINER_ENSURE(id >= 0 && id < noAVariables(), \
60 "additional variable id = " + std::to_string(id) + " out-of-bounds [0, " \
61 + std::to_string(noAVariables()) + ")", \
62 AT_); \
63 } while(false)
64#define ENSURE_VALID_DIRECTION_ID_ACCESSOR(id) \
65 do { \
66 MAIA_CONTAINER_ENSURE(id >= 0 && id < nDim, \
67 "direction id = " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nDim) + ")", \
68 AT_); \
69 } while(false)
70#define ENSURE_VALID_RECNGHBR_ID_ACCESSOR(id) \
71 do { \
72 MAIA_CONTAINER_ENSURE(id >= 0 && id < noRecNghbrs(), \
73 "reconstruction neighbor id = " + std::to_string(id) + " out-of-bounds [0, " \
74 + std::to_string(noRecNghbrs()) + ")", \
75 AT_); \
76 } while(false)
77#define ENSURE_VALID_REACTION_ID_ACCESSOR(id) \
78 do { \
79 MAIA_CONTAINER_ENSURE(id >= 0 && id < noReactionRates(), \
80 "reaction rate id = " + std::to_string(id) + " out-of-bounds [0, " \
81 + std::to_string(noReactionRates()) + ")", \
82 AT_); \
83 } while(false)
84#define ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(id) \
85 do { \
86 MAIA_CONTAINER_ENSURE(id >= 0 && id < noImplicitCoefficients(), \
87 "implict coefficient id = " + std::to_string(id) + " out-of-bounds [0, " \
88 + std::to_string(noImplicitCoefficients()) + ")", \
89 AT_); \
90 } while(false)
91#define ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir) \
92 do { \
93 MAIA_CONTAINER_ENSURE(dir >= 0 && dir < nDim, \
94 "coordinate direction dir = " + std::to_string(dir) + " out-of-bounds [0, " \
95 + std::to_string(nDim) + ")", \
96 AT_); \
97 } while(false)
98#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
99 do { \
100 MAIA_CONTAINER_ENSURE(p != FvCell::NumProperties, "Invalid property", AT_); \
101 } while(false)
102#else
103#define ENSURE_VALID_ID_ACCESSOR(id) \
104 do { \
105 } while(false)
106#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
107 do { \
108 } while(false)
109#define ENSURE_VALID_PVARIABLE_ID_ACCESSOR(id) \
110 do { \
111 } while(false)
112#define ENSURE_VALID_FVARIABLE_ID_ACCESSOR(id) \
113 do { \
114 } while(false)
115#define ENSURE_VALID_AVARIABLE_ID_ACCESSOR(id) \
116 do { \
117 } while(false)
118#define ENSURE_VALID_DIRECTION_ID_ACCESSOR(id) \
119 do { \
120 } while(false)
121#define ENSURE_VALID_RECNGHBR_ID_ACCESSOR(id) \
122 do { \
123 } while(false)
124#define ENSURE_VALID_REACTION_ID_ACCESSOR(id) \
125 do { \
126 } while(false)
127#define ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(id) \
128 do { \
129 } while(false)
130#define ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir) \
131 do { \
132 } while(false)
133#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
134 do { \
135 } while(false)
136#endif
137
138
140namespace maia {
141namespace fv {
142namespace collector {
143
146
147// Type traits for invalid values. These values are used to initialize/erase nodes
148template <class T>
149struct Invalid {};
150
151// Invalid value for ids is 'INT_MIN'
152template <>
153struct Invalid<MInt> {
154 static constexpr MInt value() { return std::numeric_limits<MInt>::min(); }
155};
156
157// Invalid value for floats is 'NaN'
158template <>
160 static constexpr MFloat value() {
161#ifdef MAIA_PGI_COMPILER
162 return std::numeric_limits<MFloat>::quiet_NaN();
163#else
164 return std::numeric_limits<MFloat>::signaling_NaN();
165#endif
166 }
167};
168
169// Invalid value for BitsetProperties is '0'
170template <>
172 static constexpr BitsetType value() { return BitsetType(0); }
173};
174
175// Invalid value for ... is ...
176template <>
177struct Invalid<M16X2bit<false>> {
178 static constexpr M16X2bit<false>::type value() { return M16X2bit<false>::type{}; }
179};
180
181
183template <MInt nDim>
184class FvCellCollector : public maia::container::Container<FvCellCollector<nDim>, Invalid> {
185 // Necessary for CRTP
187
188 // Make base class functions known to use without this pointer
190 using Base::resetStorage;
192 template <class T>
193 using Storage = typename Base::template Storage<T>;
195
196
197 public:
198 void setFvCollectorType(const MInt mode);
199 void setFvTimeStepType(const MInt mode);
200 // accessors to specify FvCell collector type
202 constexpr MBool hasCellCenterGamma() const { return m_hasCellCenterGamma; }
203 constexpr MBool hasReactionRates() const { return m_hasReactionRates; }
205 constexpr MBool hasPsi() const { return m_hasPsi; }
206 constexpr MBool isEEGas() const { return m_isEEGas; }
207 constexpr MBool hasLocalTS() const { return m_hasLocalTS; }
208 constexpr MBool hasDualTS() const { return m_hasDualTS; }
209
210 // Types
211 template <class T>
213
214 // Constructors
216 constexpr FvCellCollector() = default;
217
218 // Ensure that base class method is found when called from outside
219 using Base::copyData;
220 using Base::fill_invalid;
221 using Base::reset;
222 using Base::resize;
223
224 // Accessors
225 MFloat& oldVariable(const MInt id, const MInt varId);
226 MFloat oldVariable(const MInt id, const MInt varId) const;
227
228 MFloat& variable(const MInt id, const MInt dim);
229 MFloat variable(const MInt id, const MInt dim) const;
230
231 MFloat& pvariable(const MInt id, const MInt dim);
232 MFloat pvariable(const MInt id, const MInt dim) const;
233
234 MFloat& avariable(const MInt id, const MInt dim);
235 MFloat avariable(const MInt id, const MInt dim) const;
236
237 MFloat& rightHandSide(const MInt id, const MInt varId);
238 MFloat rightHandSide(const MInt id, const MInt varId) const;
239
240 MFloat& slope(const MInt id, const MInt dimVar, const MInt dimDir);
241 MFloat slope(const MInt id, const MInt dimVar, const MInt dimDir) const;
242
243 MInt& bndryCellId(const MInt id);
244 MInt bndryCellId(const MInt id) const;
245
246 MInt& noRcnstrctnNghbrIds(const MInt id);
247 MInt noRcnstrctnNghbrIds(const MInt id) const;
248
249 MInt& rcnstrctnNghbrId(const MInt id, const MInt dimRecNghbr);
250 MInt rcnstrctnNghbrId(const MInt id, const MInt dimRecNghbr) const;
251
252 MInt& reconstructionData(const MInt id);
253 MInt reconstructionData(const MInt id) const;
254
255 void nghbrInterface(const MInt id, const MInt dir, const MInt state);
256 MInt nghbrInterface(const MInt id, const MInt dir) const;
257
258 MFloat& reactionRate(const MInt id, const MInt dimReaction);
259 MFloat reactionRate(const MInt id, const MInt dimReaction) const;
260
261 MFloat& reactionRateBackup(const MInt id, const MInt dimReaction);
262 MFloat reactionRateBackup(const MInt id, const MInt dimReaction) const;
263
264 MFloat& psi(const MInt id);
265 MFloat psi(const MInt id) const;
266
267 MFloat& implicitCoefficient(const MInt id, const MInt dimCoefficient);
268 MFloat implicitCoefficient(const MInt id, const MInt dimCoefficient) const;
269
270 MFloat& speciesReactionRate(const MInt id, const MInt speciesIndex);
271 MFloat speciesReactionRate(const MInt id, const MInt speciesIndex) const;
272
274 MFloat cellCenterMeanMolarWeight(const MInt id) const;
275
276 MFloat& cellCenterGamma(const MInt id);
277 MFloat cellCenterGamma(const MInt id) const;
278
279 MFloat& dt1Variable(const MInt id, const MInt dim);
280 MFloat dt1Variable(const MInt id, const MInt dim) const;
281
282 MFloat& dt2Variable(const MInt id, const MInt dim);
283 MFloat dt2Variable(const MInt id, const MInt dim) const;
284
285 MFloat& localTimeStep(const MInt id);
286 MFloat localTimeStep(const MInt id) const;
287
289 const MFloat& fluidFraction(const MInt id) const;
290
291 MFloat& spongeFactor(const MInt id);
292 MFloat spongeFactor(const MInt id) const;
293
294 MFloat& spongeFactorStart(const MInt id);
295 MFloat spongeFactorStart(const MInt id) const;
296
297 MInt& spongeBndryId(const MInt id, const MInt dimDir);
298 MInt spongeBndryId(const MInt id, const MInt dimDir) const;
299
300 MFloat& coordinate(const MInt id, const MInt dim);
301 MFloat coordinate(const MInt id, const MInt dim) const;
302
303 MInt& level(const MInt cellId);
304 MInt level(const MInt cellId) const;
305
306 MFloat& cellVolume(const MInt cellId);
307 MFloat cellVolume(const MInt cellId) const;
308
309 MFloat& FcellVolume(const MInt cellId);
310 MFloat FcellVolume(const MInt cellId) const;
311
312 // Multilevel-related accessors
313 MFloat& tau(const MInt id, const MInt varId);
314 MFloat tau(const MInt id, const MInt varId) const;
315
316 MFloat& restrictedRHS(const MInt id, const MInt varId);
317 MFloat restrictedRHS(const MInt id, const MInt varId) const;
318
319 MFloat& restrictedVar(const MInt id, const MInt varId);
320 MFloat restrictedVar(const MInt id, const MInt varId) const;
321
322 MFloat& storedSlope(const MInt id, const MInt dimVar, const MInt dimDir);
323 MFloat storedSlope(const MInt id, const MInt dimVar, const MInt dimDir) const;
324
325 // Property-related accessors
326 BitsetType::reference hasProperty(const MInt id, const FvCell p);
327 MBool hasProperty(const MInt id, const FvCell p) const;
328 void resetProperties(const MInt id);
329 BitsetType& properties(const MInt id);
330
331 // Allow setting number of species and rans variables
332 void setNoCVariables(const MInt noCVariables_, const MInt noSpecies_);
333
334 // Allow setting number of PVs
335 void setNoPVariables(const MInt noPVariables_);
336
337 // Allow setting number of FVs
338 void setNoFVariables(const MInt noFVariables_);
339
340 // Allow setting number of AVs
341 void setNoAVariables(const MInt noAVariables_);
342
344 constexpr MInt noSpecies() const { return m_noSpecies; }
345
347 MInt isMultilevel(const MBool isMultilevel_);
348
350 constexpr MInt isMultilevel() const { return m_isMultilevel; }
351
353 constexpr MInt noCVariables() const { return m_noCVariables; }
354
356 constexpr MInt noPVariables() const { return m_noPVariables; }
357
359 constexpr MInt noFVariables() const { return m_noFVariables; }
360
362 constexpr MInt noAVariables() const { return m_noAVariables; }
363
365 constexpr MInt noRecNghbrs() const { return m_noRecNghbrs; }
366
368 constexpr MInt noReactionRates() const { return m_noReactionRates; }
369
372
374 static constexpr MInt noProperties() { return maia::fv::cell::p(FvCell::NumProperties); }
375
376 private:
377 // Bools for fv-collector type
386
387
388 // Methods required by base class for CRTP
389 void reset();
390 void resize() override;
391 void invalidate(const MInt begin, const MInt end);
392 template <class Functor, class T>
393 void rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end, const MInt destination);
394
400
403
406
408 MInt m_noRecNghbrs = IPOW3[nDim] + nDim;
409
412
415
416 // Data containers
447
448 // Multilevel-related data
453};
454
455
457template <MInt nDim>
459 resetStorage(noCVariables(), m_oldVariables);
460 resetStorage(noCVariables(), m_variables);
461 resetStorage(noFVariables(), m_rightHandSide);
462 resetStorage(noPVariables() * nDim, m_slopes);
463 resetStorage(noPVariables(), m_pvariables);
464 resetStorage(1, m_bndryCellIds);
465 resetStorage(1, m_noRcnstrctnNghbrIds);
466 resetStorage(noRecNghbrs(), m_rcnstrctnNghbrIds);
467 resetStorage(1, m_reconstructionData);
468 resetStorage(1, m_nghbrInterface);
469 if(hasReactionRates()) resetStorage(noReactionRates(), m_reactionRates);
470 if(hasReactionRates()) resetStorage(noSpecies(), m_speciesReactionRates);
471 if(hasReactionRatesBackup()) resetStorage(noReactionRates(), m_reactionRatesBackup);
472 if(hasPsi()) resetStorage(1, m_psi);
473 if(hasCellCenterMeanMolarWeight()) resetStorage(1, m_cellCenterMeanMolarWeight);
474 if(hasCellCenterGamma()) resetStorage(1, m_cellCenterGamma);
475 if(isEEGas()) resetStorage(noImplicitCoefficients(), m_implicitCoefficients);
476 resetStorage(noAVariables(), m_avariables);
477 if(hasDualTS()) {
478 resetStorage(noCVariables(), m_dt1Variables);
479 resetStorage(noCVariables(), m_dt2Variables);
480 resetStorage(1, m_localTimeStep_);
481 } else if(hasLocalTS()) {
482 resetStorage(1, m_localTimeStep_);
483 }
484 resetStorage(1, m_spongeFactor);
485 resetStorage(1, m_spongeFactorStart);
486 resetStorage(nDim, m_spongeBndryIds);
487 resetStorage(nDim, m_coordinates);
488 resetStorage(1, m_levels);
489 resetStorage(1, m_properties);
490 resetStorage(1, m_cellVolumes);
491 resetStorage(1, m_FcellVolumes);
492
493 // Initialize multilevel storage only if using more than one grid level
494 if(isMultilevel()) {
495 resetStorage(noCVariables(), m_tau);
496 resetStorage(noCVariables(), m_restrictedRHS);
497 resetStorage(noCVariables(), m_restrictedVars);
498 resetStorage(noCVariables() * nDim, m_storedSlopes);
499 }
500}
501
503template <MInt nDim>
505 resizeStorage(noCVariables(), m_oldVariables);
506 resizeStorage(noCVariables(), m_variables);
507 resizeStorage(noFVariables(), m_rightHandSide);
508 resizeStorage(noPVariables() * nDim, m_slopes);
509 resizeStorage(noPVariables(), m_pvariables);
510 resizeStorage(1, m_bndryCellIds);
511 resizeStorage(1, m_noRcnstrctnNghbrIds);
512 resizeStorage(noRecNghbrs(), m_rcnstrctnNghbrIds);
513 resizeStorage(1, m_reconstructionData);
514 if(hasReactionRates()) resizeStorage(noReactionRates(), m_reactionRates);
515 if(hasReactionRates()) resizeStorage(noSpecies(), m_speciesReactionRates);
516 if(hasReactionRatesBackup()) resizeStorage(noReactionRates(), m_reactionRatesBackup);
517 if(hasPsi()) resizeStorage(1, m_psi);
518 if(hasCellCenterMeanMolarWeight()) resizeStorage(1, m_cellCenterMeanMolarWeight);
519 if(hasCellCenterGamma()) resizeStorage(1, m_cellCenterGamma);
520 if(isEEGas()) resizeStorage(noImplicitCoefficients(), m_implicitCoefficients);
521 resizeStorage(noAVariables(), m_avariables);
522
523 if(hasDualTS()) {
524 resizeStorage(noCVariables(), m_dt1Variables);
525 resizeStorage(noCVariables(), m_dt2Variables);
526 resizeStorage(1, m_localTimeStep_);
527 } else if(hasLocalTS()) {
528 resizeStorage(1, m_localTimeStep_);
529 }
530
531 resizeStorage(1, m_spongeFactor);
532 resizeStorage(1, m_spongeFactorStart);
533 resizeStorage(nDim, m_spongeBndryIds);
534 resizeStorage(nDim, m_coordinates);
535 resizeStorage(1, m_levels);
536 resizeStorage(1, m_properties);
537 resizeStorage(1, m_cellVolumes);
538 resizeStorage(1, m_FcellVolumes);
539
540 // Initialize multilevel storage only if using more than one grid level
541 if(isMultilevel()) {
542 resizeStorage(noCVariables(), m_tau);
543 resizeStorage(noCVariables(), m_restrictedRHS);
544 resizeStorage(noCVariables(), m_restrictedVars);
545 resizeStorage(noCVariables() * nDim, m_storedSlopes);
546 }
547}
548
549
551template <MInt nDim>
553 ASSERT(mode >= 0, "");
554 switch(mode) {
555 case 0: {
556 m_hasCellCenterMeanMolarWeight = false;
557 m_hasCellCenterGamma = false;
558 m_hasReactionRates = false;
559 m_hasReactionRatesBackup = false;
560 m_hasPsi = false;
561 m_isEEGas = false;
562 break;
563 }
564 case 1: // detailedChemistry:
565 {
566 m_hasCellCenterMeanMolarWeight = true;
567 m_hasCellCenterGamma = true;
568 m_hasReactionRates = true;
569 m_hasReactionRatesBackup = false;
570 m_hasPsi = false;
571 m_isEEGas = false;
572 break;
573 }
574 case 2: { // combustion without detailedChemisty
575 m_hasCellCenterMeanMolarWeight = false;
576 m_hasCellCenterGamma = false;
577 m_hasReactionRates = true;
578 m_hasReactionRatesBackup = true;
579 m_hasPsi = true;
580 m_isEEGas = false;
581 break;
582 }
583 case 3: { // EEGas
584 m_hasCellCenterMeanMolarWeight = false;
585 m_hasCellCenterGamma = false;
586 m_hasReactionRates = false;
587 m_hasReactionRatesBackup = false;
588 m_hasPsi = false;
589 m_isEEGas = true;
590 break;
591 }
592 default: {
593 mTerm(1, AT_, "Unknown fvCollector Type!");
594 }
595 }
596}
597template <MInt nDim>
599 ASSERT(mode >= 0, "");
600 switch(mode) {
601 case 0: {
602 // default: global single time-step
603 break;
604 }
605 case 1: {
606 // local time-step with standart RK
607 m_hasLocalTS = true;
608 break;
609 }
610 case 2: {
611 // dual time-stepping with local TS
612 m_hasDualTS = true;
613 break;
614 }
615 default: {
616 mTerm(1, AT_, "Unknown fvTimeStepType!");
617 }
618 }
619}
620
622template <MInt nDim>
624// Prevent accidental compilation without support for SoA layout
625#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
626#error Missing implementation for structure-of-arrays memory layout.
627#endif
628 ENSURE_VALID_ID_ACCESSOR(id);
629 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
630 return m_oldVariables[id * noCVariables() + varId];
631}
633template <MInt nDim>
635// Prevent accidental compilation without support for SoA layout
636#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
637#error Missing implementation for structure-of-arrays memory layout.
638#endif
639 ENSURE_VALID_ID_ACCESSOR(id);
640 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
641 return m_oldVariables[id * noCVariables() + varId];
642}
643
645template <MInt nDim>
647// Prevent accidental compilation without support for SoA layout
648#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
649#error Missing implementation for structure-of-arrays memory layout.
650#endif
651 ENSURE_VALID_ID_ACCESSOR(id);
652 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
653 return m_variables[id * noCVariables() + varId];
654}
656template <MInt nDim>
657MFloat FvCellCollector<nDim>::variable(const MInt id, const MInt varId) const {
658// Prevent accidental compilation without support for SoA layout
659#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
660#error Missing implementation for structure-of-arrays memory layout.
661#endif
662 ENSURE_VALID_ID_ACCESSOR(id);
663 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
664 return m_variables[id * noCVariables() + varId];
665}
666
668template <MInt nDim>
670// Prevent accidental compilation without support for SoA layout
671#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
672#error Missing implementation for structure-of-arrays memory layout.
673#endif
674 ENSURE_VALID_ID_ACCESSOR(id);
675 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(varId);
676 return m_pvariables[id * noPVariables() + varId];
677}
679template <MInt nDim>
680MFloat FvCellCollector<nDim>::pvariable(const MInt id, const MInt varId) const {
681// Prevent accidental compilation without support for SoA layout
682#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
683#error Missing implementation for structure-of-arrays memory layout.
684#endif
685 ENSURE_VALID_ID_ACCESSOR(id);
686 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(varId);
687 return m_pvariables[id * noPVariables() + varId];
688}
689
691template <MInt nDim>
693// Prevent accidental compilation without support for SoA layout
694#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
695#error Missing implementation for structure-of-arrays memory layout.
696#endif
697 ENSURE_VALID_ID_ACCESSOR(id);
698 ENSURE_VALID_AVARIABLE_ID_ACCESSOR(varId);
699 return m_avariables[id * noAVariables() + varId];
700}
702template <MInt nDim>
703MFloat FvCellCollector<nDim>::avariable(const MInt id, const MInt varId) const {
704// Prevent accidental compilation without support for SoA layout
705#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
706#error Missing implementation for structure-of-arrays memory layout.
707#endif
708 ENSURE_VALID_ID_ACCESSOR(id);
709 ENSURE_VALID_AVARIABLE_ID_ACCESSOR(varId);
710 return m_avariables[id * noAVariables() + varId];
711}
712
714template <MInt nDim>
716// Prevent accidental compilation without support for SoA layout
717#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
718#error Missing implementation for structure-of-arrays memory layout.
719#endif
720 ENSURE_VALID_ID_ACCESSOR(id);
721 ENSURE_VALID_FVARIABLE_ID_ACCESSOR(varId);
722 return m_rightHandSide[id * noFVariables() + varId];
723}
725template <MInt nDim>
727// Prevent accidental compilation without support for SoA layout
728#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
729#error Missing implementation for structure-of-arrays memory layout.
730#endif
731 ENSURE_VALID_ID_ACCESSOR(id);
732 ENSURE_VALID_FVARIABLE_ID_ACCESSOR(varId);
733 return m_rightHandSide[id * noFVariables() + varId];
734}
735
737template <MInt nDim>
738MFloat& FvCellCollector<nDim>::slope(const MInt id, const MInt dimVar, const MInt dimDir) {
739// Prevent accidental compilation without support for SoA layout
740#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
741#error Missing implementation for structure-of-arrays memory layout.
742#endif
743 ENSURE_VALID_ID_ACCESSOR(id);
744 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(dimVar);
745 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
746 return m_slopes[id * noPVariables() * nDim + dimVar * nDim + dimDir];
747}
749template <MInt nDim>
750MFloat FvCellCollector<nDim>::slope(const MInt id, const MInt dimVar, const MInt dimDir) const {
751// Prevent accidental compilation without support for SoA layout
752#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
753#error Missing implementation for structure-of-arrays memory layout.
754#endif
755 ENSURE_VALID_ID_ACCESSOR(id);
756 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(dimVar);
757 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
758 return m_slopes[id * noPVariables() * nDim + dimVar * nDim + dimDir];
759}
760
762template <MInt nDim>
764// Prevent accidental compilation without support for SoA layout
765#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
766#error Missing implementation for structure-of-arrays memory layout.
767#endif
768 ENSURE_VALID_ID_ACCESSOR(id);
769 return m_bndryCellIds[id];
770}
772template <MInt nDim>
774// Prevent accidental compilation without support for SoA layout
775#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
776#error Missing implementation for structure-of-arrays memory layout.
777#endif
778 ENSURE_VALID_ID_ACCESSOR(id);
779 return m_bndryCellIds[id];
780}
781
783template <MInt nDim>
785// Prevent accidental compilation without support for SoA layout
786#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
787#error Missing implementation for structure-of-arrays memory layout.
788#endif
789 ENSURE_VALID_ID_ACCESSOR(id);
790 return m_noRcnstrctnNghbrIds[id];
791}
793template <MInt nDim>
795// Prevent accidental compilation without support for SoA layout
796#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
797#error Missing implementation for structure-of-arrays memory layout.
798#endif
799 ENSURE_VALID_ID_ACCESSOR(id);
800 return m_noRcnstrctnNghbrIds[id];
801}
802
804template <MInt nDim>
806// Prevent accidental compilation without support for SoA layout
807#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
808#error Missing implementation for structure-of-arrays memory layout.
809#endif
810 ENSURE_VALID_ID_ACCESSOR(id);
811 ENSURE_VALID_RECNGHBR_ID_ACCESSOR(dimRecNghbr);
812 return m_rcnstrctnNghbrIds[id * noRecNghbrs() + dimRecNghbr];
813}
815template <MInt nDim>
816MInt FvCellCollector<nDim>::rcnstrctnNghbrId(const MInt id, const MInt dimRecNghbr) const {
817// Prevent accidental compilation without support for SoA layout
818#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
819#error Missing implementation for structure-of-arrays memory layout.
820#endif
821 ENSURE_VALID_ID_ACCESSOR(id);
822 ENSURE_VALID_RECNGHBR_ID_ACCESSOR(dimRecNghbr);
823 return m_rcnstrctnNghbrIds[id * noRecNghbrs() + dimRecNghbr];
824}
825
827template <MInt nDim>
829// Prevent accidental compilation without support for SoA layout
830#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
831#error Missing implementation for structure-of-arrays memory layout.
832#endif
833 ENSURE_VALID_ID_ACCESSOR(id);
834 return m_reconstructionData[id];
835}
837template <MInt nDim>
839// Prevent accidental compilation without support for SoA layout
840#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
841#error Missing implementation for structure-of-arrays memory layout.
842#endif
843 ENSURE_VALID_ID_ACCESSOR(id);
844 return m_reconstructionData[id];
845}
846
848template <MInt nDim>
849void FvCellCollector<nDim>::nghbrInterface(const MInt id, const MInt dir, const MInt state) {
850// Prevent accidental compilation without support for SoA layout
851#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
852#error Missing implementation for structure-of-arrays memory layout.
853#endif
854 ENSURE_VALID_ID_ACCESSOR(id);
855 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dir / 2);
856 m_nghbrInterface[id].set(dir, state);
857}
859template <MInt nDim>
861// Prevent accidental compilation without support for SoA layout
862#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
863#error Missing implementation for structure-of-arrays memory layout.
864#endif
865 ENSURE_VALID_ID_ACCESSOR(id);
866 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dir / 2);
867 return m_nghbrInterface[id].get(dir);
868}
869
871template <MInt nDim>
873// Prevent accidental compilation without support for SoA layout
874#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
875#error Missing implementation for structure-of-arrays memory layout.
876#endif
877 ENSURE_VALID_ID_ACCESSOR(id);
878 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
879 return m_reactionRates[id * noReactionRates() + dimReaction];
880}
882template <MInt nDim>
883MFloat FvCellCollector<nDim>::reactionRate(const MInt id, const MInt dimReaction) const {
884// Prevent accidental compilation without support for SoA layout
885#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
886#error Missing implementation for structure-of-arrays memory layout.
887#endif
888 ENSURE_VALID_ID_ACCESSOR(id);
889 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
890 return m_reactionRates[id * noReactionRates() + dimReaction];
891}
892
894template <MInt nDim>
896// Prevent accidental compilation without support for SoA layout
897#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
898#error Missing implementation for structure-of-arrays memory layout.
899#endif
900 ENSURE_VALID_ID_ACCESSOR(id);
901 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
902 return m_reactionRatesBackup[id * noReactionRates() + dimReaction];
903}
905template <MInt nDim>
906MFloat FvCellCollector<nDim>::reactionRateBackup(const MInt id, const MInt dimReaction) const {
907// Prevent accidental compilation without support for SoA layout
908#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
909#error Missing implementation for structure-of-arrays memory layout.
910#endif
911 ENSURE_VALID_ID_ACCESSOR(id);
912 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
913 return m_reactionRatesBackup[id * noReactionRates() + dimReaction];
914}
915
917template <MInt nDim>
919// Prevent accidental compilation without support for SoA layout
920#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
921#error Missing implementation for structure-of-arrays memory layout.
922#endif
923 ENSURE_VALID_ID_ACCESSOR(id);
924 return m_psi[id];
925}
927template <MInt nDim>
929// Prevent accidental compilation without support for SoA layout
930#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
931#error Missing implementation for structure-of-arrays memory layout.
932#endif
933 ENSURE_VALID_ID_ACCESSOR(id);
934 return m_psi[id];
935}
936
938template <MInt nDim>
940// Prevent accidental compilation without support for SoA layout
941#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
942#error Missing implementation for structure-of-arrays memory layout.
943#endif
944 ENSURE_VALID_ID_ACCESSOR(id);
945 ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(dimCoefficient);
946 return m_implicitCoefficients[id * noImplicitCoefficients() + dimCoefficient];
947}
949template <MInt nDim>
950MFloat FvCellCollector<nDim>::implicitCoefficient(const MInt id, const MInt dimCoefficient) const {
951// Prevent accidental compilation without support for SoA layout
952#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
953#error Missing implementation for structure-of-arrays memory layout.
954#endif
955 ENSURE_VALID_ID_ACCESSOR(id);
956 ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(dimCoefficient);
957 return m_implicitCoefficients[id * noImplicitCoefficients() + dimCoefficient];
958}
959
961template <MInt nDim>
963// Prevent accidental compilation without support for SoA layout
964#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
965#error Missing implementation for structure-of-arrays memory layout.
966#endif
967 ENSURE_VALID_ID_ACCESSOR(id);
968 ENSURE_VALID_REACTION_ID_ACCESSOR(speciesIndex);
969 return m_speciesReactionRates[id * noSpecies() + speciesIndex];
970}
971
973template <MInt nDim>
974MFloat FvCellCollector<nDim>::speciesReactionRate(const MInt id, const MInt speciesIndex) const {
975// Prevent accidental compilation without support for SoA layout
976#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
977#error Missing implementation for structure-of-arrays memory layout.
978#endif
979 ENSURE_VALID_ID_ACCESSOR(id);
980 ENSURE_VALID_REACTION_ID_ACCESSOR(speciesIndex);
981 return m_speciesReactionRates[id * noSpecies() + speciesIndex];
982}
983
985template <MInt nDim>
987// Prevent accidental compilation without support for SoA layout
988#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
989#error Missing implementation for structure-of-arrays memory layout.
990#endif
991 ENSURE_VALID_ID_ACCESSOR(id);
992 return m_cellCenterMeanMolarWeight[id];
993}
994
996template <MInt nDim>
998// Prevent accidental compilation without support for SoA layout
999#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1000#error Missing implementation for structure-of-arrays memory layout.
1001#endif
1002 ENSURE_VALID_ID_ACCESSOR(id);
1003 return m_cellCenterMeanMolarWeight[id];
1004}
1005
1007template <MInt nDim>
1009// Prevent accidental compilation without support for SoA layout
1010#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1011#error Missing implementation for structure-of-arrays memory layout.
1012#endif
1013 ENSURE_VALID_ID_ACCESSOR(id);
1014 return m_cellCenterGamma[id];
1015}
1016
1018template <MInt nDim>
1020// Prevent accidental compilation without support for SoA layout
1021#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1022#error Missing implementation for structure-of-arrays memory layout.
1023#endif
1024 ENSURE_VALID_ID_ACCESSOR(id);
1025 return m_cellCenterGamma[id];
1026}
1027
1029template <MInt nDim>
1031// Prevent accidental compilation without support for SoA layout
1032#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1033#error Missing implementation for structure-of-arrays memory layout.
1034#endif
1035 ENSURE_VALID_ID_ACCESSOR(id);
1036 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1037 return m_dt1Variables[id * noCVariables() + varId];
1038}
1040template <MInt nDim>
1042// Prevent accidental compilation without support for SoA layout
1043#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1044#error Missing implementation for structure-of-arrays memory layout.
1045#endif
1046 ENSURE_VALID_ID_ACCESSOR(id);
1047 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1048 return m_dt1Variables[id * noCVariables() + varId];
1049}
1050
1052template <MInt nDim>
1054// Prevent accidental compilation without support for SoA layout
1055#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1056#error Missing implementation for structure-of-arrays memory layout.
1057#endif
1058 ENSURE_VALID_ID_ACCESSOR(id);
1059 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1060 return m_dt2Variables[id * noCVariables() + varId];
1061}
1063template <MInt nDim>
1065// Prevent accidental compilation without support for SoA layout
1066#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1067#error Missing implementation for structure-of-arrays memory layout.
1068#endif
1069 ENSURE_VALID_ID_ACCESSOR(id);
1070 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1071 return m_dt2Variables[id * noCVariables() + varId];
1072}
1073
1075template <MInt nDim>
1077#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1078#error Missing implementation for structure-of-arrays memory layout.
1079#endif
1080 ENSURE_VALID_ID_ACCESSOR(id);
1081 return m_localTimeStep_[id];
1082}
1083
1085template <MInt nDim>
1087#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1088#error Missing implementation for structure-of-arrays memory layout.
1089#endif
1090 ENSURE_VALID_ID_ACCESSOR(id);
1091 return m_localTimeStep_[id];
1092}
1093
1095template <MInt nDim>
1097// Prevent accidental compilation without support for SoA layout
1098#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1099#error Missing implementation for structure-of-arrays memory layout.
1100#endif
1101 ENSURE_VALID_ID_ACCESSOR(id);
1102 return m_spongeFactor[id];
1103}
1105template <MInt nDim>
1107// Prevent accidental compilation without support for SoA layout
1108#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1109#error Missing implementation for structure-of-arrays memory layout.
1110#endif
1111 ENSURE_VALID_ID_ACCESSOR(id);
1112 return m_spongeFactor[id];
1113}
1114
1116template <MInt nDim>
1118// Prevent accidental compilation without support for SoA layout
1119#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1120#error Missing implementation for structure-of-arrays memory layout.
1121#endif
1122 ENSURE_VALID_ID_ACCESSOR(id);
1123 return m_spongeFactorStart[id];
1124}
1126template <MInt nDim>
1128// Prevent accidental compilation without support for SoA layout
1129#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1130#error Missing implementation for structure-of-arrays memory layout.
1131#endif
1132 ENSURE_VALID_ID_ACCESSOR(id);
1133 return m_spongeFactorStart[id];
1134}
1135
1137template <MInt nDim>
1139// Prevent accidental compilation without support for SoA layout
1140#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1141#error Missing implementation for structure-of-arrays memory layout.
1142#endif
1143 ENSURE_VALID_ID_ACCESSOR(id);
1144 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1145 return m_spongeBndryIds[id * nDim + dimDir];
1146}
1148template <MInt nDim>
1150// Prevent accidental compilation without support for SoA layout
1151#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1152#error Missing implementation for structure-of-arrays memory layout.
1153#endif
1154 ENSURE_VALID_ID_ACCESSOR(id);
1155 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1156 return m_spongeBndryIds[id * nDim + dimDir];
1157}
1158
1160template <MInt nDim>
1162// Prevent accidental compilation without support for SoA layout
1163#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1164#error Missing implementation for structure-of-arrays memory layout.
1165#endif
1166 ENSURE_VALID_ID_ACCESSOR(id);
1167 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
1168 return m_coordinates[id * nDim + dir];
1169}
1171template <MInt nDim>
1173// Prevent accidental compilation without support for SoA layout
1174#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1175#error Missing implementation for structure-of-arrays memory layout.
1176#endif
1177 ENSURE_VALID_ID_ACCESSOR(id);
1178 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
1179 return m_coordinates[id * nDim + dir];
1180}
1181
1183template <MInt nDim>
1185 ENSURE_VALID_ID_ACCESSOR(id);
1186 return m_levels[id];
1187}
1189template <MInt nDim>
1191 ENSURE_VALID_ID_ACCESSOR(id);
1192 return m_levels[id];
1193}
1194
1196template <MInt nDim>
1198 ENSURE_VALID_ID_ACCESSOR(id);
1199 return m_cellVolumes[id];
1200}
1202template <MInt nDim>
1204 ENSURE_VALID_ID_ACCESSOR(id);
1205 return m_cellVolumes[id];
1206}
1207
1209template <MInt nDim>
1211 ENSURE_VALID_ID_ACCESSOR(id);
1212 return m_FcellVolumes[id];
1213}
1215template <MInt nDim>
1217 ENSURE_VALID_ID_ACCESSOR(id);
1218 return m_FcellVolumes[id];
1219}
1220
1222template <MInt nDim>
1224 ENSURE_VALID_ID_ACCESSOR(id);
1225 ENSURE_VALID_PROPERTY_ACCESSOR(p);
1226 return m_properties[id][maia::fv::cell::p(p)];
1227}
1229template <MInt nDim>
1231 ENSURE_VALID_ID_ACCESSOR(id);
1232 ENSURE_VALID_PROPERTY_ACCESSOR(p);
1233 return m_properties[id][maia::fv::cell::p(p)];
1234}
1236template <MInt nDim>
1238 ENSURE_VALID_ID_ACCESSOR(id);
1239 m_properties[id].reset();
1240}
1242template <MInt nDim>
1244 ENSURE_VALID_ID_ACCESSOR(id);
1245 return m_properties[id];
1246}
1247
1249template <MInt nDim>
1251// Prevent accidental compilation without support for SoA layout
1252#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1253#error Missing implementation for structure-of-arrays memory layout.
1254#endif
1255 ENSURE_VALID_ID_ACCESSOR(id);
1256 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1257 return m_tau[id * noCVariables() + varId];
1258}
1260template <MInt nDim>
1261MFloat FvCellCollector<nDim>::tau(const MInt id, const MInt varId) const {
1262// Prevent accidental compilation without support for SoA layout
1263#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1264#error Missing implementation for structure-of-arrays memory layout.
1265#endif
1266 ENSURE_VALID_ID_ACCESSOR(id);
1267 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1268 return m_tau[id * noCVariables() + varId];
1269}
1270
1272template <MInt nDim>
1274// Prevent accidental compilation without support for SoA layout
1275#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1276#error Missing implementation for structure-of-arrays memory layout.
1277#endif
1278 ENSURE_VALID_ID_ACCESSOR(id);
1279 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1280 return m_restrictedRHS[id * noCVariables() + varId];
1281}
1283template <MInt nDim>
1285// Prevent accidental compilation without support for SoA layout
1286#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1287#error Missing implementation for structure-of-arrays memory layout.
1288#endif
1289 ENSURE_VALID_ID_ACCESSOR(id);
1290 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1291 return m_restrictedRHS[id * noCVariables() + varId];
1292}
1293
1295template <MInt nDim>
1297// Prevent accidental compilation without support for SoA layout
1298#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1299#error Missing implementation for structure-of-arrays memory layout.
1300#endif
1301 ENSURE_VALID_ID_ACCESSOR(id);
1302 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1303 return m_restrictedVars[id * noCVariables() + varId];
1304}
1306template <MInt nDim>
1308// Prevent accidental compilation without support for SoA layout
1309#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1310#error Missing implementation for structure-of-arrays memory layout.
1311#endif
1312 ENSURE_VALID_ID_ACCESSOR(id);
1313 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1314 return m_restrictedVars[id * noCVariables() + varId];
1315}
1316
1318template <MInt nDim>
1319MFloat& FvCellCollector<nDim>::storedSlope(const MInt id, const MInt dimVar, const MInt dimDir) {
1320// Prevent accidental compilation without support for SoA layout
1321#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1322#error Missing implementation for structure-of-arrays memory layout.
1323#endif
1324 ENSURE_VALID_ID_ACCESSOR(id);
1325 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(dimVar);
1326 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1327 return m_storedSlopes[id * noPVariables() * nDim + dimVar * nDim + dimDir];
1328}
1330template <MInt nDim>
1331MFloat FvCellCollector<nDim>::storedSlope(const MInt id, const MInt dimVar, const MInt dimDir) const {
1332// Prevent accidental compilation without support for SoA layout
1333#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1334#error Missing implementation for structure-of-arrays memory layout.
1335#endif
1336 ENSURE_VALID_ID_ACCESSOR(id);
1337 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(dimVar);
1338 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1339 return m_storedSlopes[id * noPVariables() * nDim + dimVar * nDim + dimDir];
1340}
1341
1343template <MInt nDim>
1344void FvCellCollector<nDim>::setNoCVariables(const MInt noCVariables_, const MInt noSpecies_) {
1345 m_noSpecies = noSpecies_;
1346 m_noCVariables = noCVariables_;
1347 return;
1348}
1349
1351template <MInt nDim>
1353 m_noPVariables = noPVariables_;
1354 return;
1355}
1356
1358template <MInt nDim>
1360 m_noFVariables = noFVariables_;
1361 return;
1362}
1363
1365template <MInt nDim>
1367 m_noAVariables = noAVariables_;
1368 return;
1369}
1370
1372template <MInt nDim>
1374 const MInt oldIsMultilevel = m_isMultilevel;
1375 m_isMultilevel = isMultilevel_;
1376 return oldIsMultilevel;
1377}
1378
1380template <MInt nDim>
1381void FvCellCollector<nDim>::invalidate(const MInt begin, const MInt end) {
1382// Prevent accidental compilation without support for SoA layout
1383#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1384#error Missing implementation for structure-of-arrays memory layout.
1385#endif
1386
1387 // oldVariables
1388 fill_invalid(m_oldVariables, begin, end, noCVariables());
1389 // variables
1390 fill_invalid(m_variables, begin, end, noCVariables());
1391 // pvariables
1392 fill_invalid(m_pvariables, begin, end, noPVariables());
1393 // right hand side
1394 fill_invalid(m_rightHandSide, begin, end, noFVariables());
1395 // slopes
1396 fill_invalid(m_slopes, begin, end, noPVariables() * nDim);
1397 // bndry cell ids, -1 as "invalid" value
1398 // mapping -1: internal, -2: ghost cell
1399 fill_invalid(m_bndryCellIds, begin, end, 1, -1);
1400 // noRcnstrctnNghbrIds
1401 fill_invalid(m_noRcnstrctnNghbrIds, begin, end);
1402 // rcnstrctnNghbrId
1403 fill_invalid(m_rcnstrctnNghbrIds, begin, end, noRecNghbrs());
1404 // m_reconstructionData
1405 fill_invalid(m_reconstructionData, begin, end);
1406 // nghbrInterface
1407 fill_invalid(m_nghbrInterface, begin, end);
1408
1409 // reactionRates
1410 if(hasReactionRates()) fill_invalid(m_reactionRates, begin, end, noReactionRates());
1411 if(hasReactionRatesBackup()) fill_invalid(m_reactionRatesBackup, begin, end, noReactionRates());
1412 // psi
1413 if(hasPsi()) fill_invalid(m_psi, begin, end);
1414 // speciesReactionRates
1415 if(hasReactionRates()) fill_invalid(m_speciesReactionRates, begin, end, noSpecies());
1416 if(hasCellCenterMeanMolarWeight()) fill_invalid(m_cellCenterMeanMolarWeight, begin, end);
1417 if(hasCellCenterGamma()) fill_invalid(m_cellCenterGamma, begin, end);
1418
1419 // implicit coefficients
1420 if(isEEGas()) fill_invalid(m_implicitCoefficients, begin, end, noImplicitCoefficients());
1421 // additional variables
1422 fill_invalid(m_avariables, begin, end, noAVariables());
1423
1424 if(hasDualTS()) {
1425 // dt1Variables
1426 fill_invalid(m_dt1Variables, begin, end, noCVariables());
1427 // dt2Variables
1428 fill_invalid(m_dt2Variables, begin, end, noCVariables());
1429 fill_invalid(m_localTimeStep_, begin, end);
1430 } else if(hasLocalTS()) {
1431 fill_invalid(m_localTimeStep_, begin, end);
1432 }
1433
1434 // spongeFactor
1435 fill_invalid(m_spongeFactor, begin, end);
1436 // spongeFactorStart
1437 fill_invalid(m_spongeFactorStart, begin, end);
1438 // spongeBndryIds
1439 fill_invalid(m_spongeBndryIds, begin, end, nDim);
1440
1441 // Properties
1442 fill_invalid(m_properties, begin, end);
1443 // Coordinates
1444 fill_invalid(m_coordinates, begin * nDim, end * nDim);
1445
1446 // Level
1447 fill_invalid(m_levels, begin, end);
1448
1449 // Cell volume
1450 fill_invalid(m_cellVolumes, begin, end);
1451 // Inverse cell volume
1452 fill_invalid(m_FcellVolumes, begin, end);
1453
1454 // Multilevel-related data
1455 if(isMultilevel()) {
1456 // Coarse grid correction
1457 fill_invalid(m_tau, begin, end, noCVariables());
1458 // Restricted RHS
1459 fill_invalid(m_restrictedRHS, begin, end, noCVariables());
1460 // Variables after restriction
1461 fill_invalid(m_restrictedVars, begin, end, noCVariables());
1462 // Temporarily stored slopes
1463 fill_invalid(m_storedSlopes, begin, end, noPVariables() * nDim);
1464 }
1465}
1466
1467
1469template <MInt nDim>
1470template <class Functor, class T>
1471void FvCellCollector<nDim>::rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end,
1472 const MInt destination) {
1473// Prevent accidental compilation without support for SoA layout
1474#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1475#error Missing implementation for structure-of-arrays memory layout.
1476#endif
1477
1478 // oldVariables
1479 copyData(source.m_oldVariables, m_oldVariables, c, begin, end, destination, noCVariables());
1480 // variables
1481 copyData(source.m_variables, m_variables, c, begin, end, destination, noCVariables());
1482 // pvariables
1483 copyData(source.m_pvariables, m_pvariables, c, begin, end, destination, noPVariables());
1484 // right hand side
1485 copyData(source.m_rightHandSide, m_rightHandSide, c, begin, end, destination, noFVariables());
1486 // slopes
1487 copyData(source.m_slopes, m_slopes, c, begin, end, destination, noPVariables() * nDim);
1488 // bndryCellIds
1489 copyData(source.m_bndryCellIds, m_bndryCellIds, c, begin, end, destination);
1490 // noRcnstrctnNghbrIds
1491 copyData(source.m_noRcnstrctnNghbrIds, m_noRcnstrctnNghbrIds, c, begin, end, destination);
1492 // rcnstrctnNghbrId
1493 copyData(source.m_rcnstrctnNghbrIds, m_rcnstrctnNghbrIds, c, begin, end, destination, noRecNghbrs());
1494 // reconstructionData
1495 copyData(source.m_reconstructionData, m_reconstructionData, c, begin, end, destination);
1496 // nghbrInterface
1497 copyData(source.m_nghbrInterface, m_nghbrInterface, c, begin, end, destination);
1498 // reactionRate
1499 if(hasReactionRates())
1500 copyData(source.m_reactionRates, m_reactionRates, c, begin, end, destination, noReactionRates());
1501 if(hasReactionRatesBackup())
1502 copyData(source.m_reactionRatesBackup, m_reactionRatesBackup, c, begin, end, destination, noReactionRates());
1503 // psi
1504 if(hasPsi()) copyData(source.m_psi, m_psi, c, begin, end, destination);
1505 // speciesReactionRate
1506 if(hasReactionRates())
1507 copyData(source.m_speciesReactionRates, m_speciesReactionRates, c, begin, end, destination, noSpecies());
1508 if(hasCellCenterMeanMolarWeight())
1509 copyData(source.m_cellCenterMeanMolarWeight, m_cellCenterMeanMolarWeight, c, begin, end, destination);
1510 if(hasCellCenterGamma()) copyData(source.m_cellCenterGamma, m_cellCenterGamma, c, begin, end, destination);
1511
1512 // implicit coefficient
1513 if(isEEGas())
1514 copyData(source.m_implicitCoefficients, m_implicitCoefficients, c, begin, end, destination,
1515 noImplicitCoefficients());
1516
1517 // additional variables
1518 copyData(source.m_avariables, m_avariables, c, begin, end, destination, noAVariables());
1519
1520 if(hasDualTS()) {
1521 // dt1Variables
1522 copyData(source.m_dt1Variables, m_dt1Variables, c, begin, end, destination, noCVariables());
1523 // dt2Variables
1524 copyData(source.m_dt2Variables, m_dt2Variables, c, begin, end, destination, noCVariables());
1525 copyData(source.m_localTimeStep_, m_localTimeStep_, c, begin, end, destination);
1526 } else if(hasLocalTS()) {
1527 copyData(source.m_localTimeStep_, m_localTimeStep_, c, begin, end, destination);
1528 }
1529
1530 // spongeFactor
1531 copyData(source.m_spongeFactor, m_spongeFactor, c, begin, end, destination);
1532 // spongeFactorStart
1533 copyData(source.m_spongeFactorStart, m_spongeFactorStart, c, begin, end, destination);
1534 // spongeBbndryIds
1535 copyData(source.m_spongeBndryIds, m_spongeBndryIds, c, begin, end, destination, nDim);
1536 // Coordinates
1537 copyData(source.m_coordinates, m_coordinates, c, begin, end, destination, nDim);
1538
1539 // Properties
1540 copyData(source.m_properties, m_properties, c, begin, end, destination);
1541
1542 // Level
1543 copyData(source.m_levels, m_levels, c, begin, end, destination);
1544
1545 // Cell volume
1546 copyData(source.m_cellVolumes, m_cellVolumes, c, begin, end, destination);
1547
1548 // Inverse cell volume
1549 copyData(source.m_FcellVolumes, m_FcellVolumes, c, begin, end, destination);
1550
1551 // Multilevel-related data
1552 if(isMultilevel()) {
1553 // Coarse grid correction
1554 copyData(source.m_tau, m_tau, c, begin, end, destination, noCVariables());
1555 // Restricted RHS
1556 copyData(source.m_restrictedRHS, m_restrictedRHS, c, begin, end, destination, noCVariables());
1557 // Variables after restriction
1558 copyData(source.m_restrictedVars, m_restrictedVars, c, begin, end, destination, noCVariables());
1559 // Temporarly stored slopes
1560 copyData(source.m_storedSlopes, m_storedSlopes, c, begin, end, destination, noPVariables() * nDim);
1561 }
1562}
1563
1564} // namespace collector
1565} // namespace fv
1566} // namespace maia
1567
1568
1569// Undefine macros that should not be used outside this file
1570#undef FVCELLCOLLECTOR_SANITY_CHECKS_ACCESSORS
1571#undef ENSURE_VALID_ID_ACCESSOR
1572#undef ENSURE_VALID_VARIABLE_ID_ACCESSOR
1573#undef ENSURE_VALID_PVARIABLE_ID_ACCESSOR
1574#undef ENSURE_VALID_FVARIABLE_ID_ACCESSOR
1575#undef ENSURE_VALID_AVARIABLE_ID_ACCESSOR
1576#undef ENSURE_VALID_DIRECTION_ID_ACCESSOR
1577#undef ENSURE_VALID_RECNGHBR_ID_ACCESSOR
1578#undef ENSURE_VALID_REACTION_ID_ACCESSOR
1579#undef ENSURE_VALID_COORDINATE_DIR_ACCESSOR
1580#undef ENSURE_VALID_PROPERTY_ACCESSOR
1581#undef ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR
1582
1583#endif // ifndef FVCELLCOLLECTOR_H_
T type
Definition: maiatypes.h:82
void copyData(const Container_ &source, Container_ &target, Functor &&f, const MInt begin, const MInt end, const MInt dest, const MInt solverSize=1)
Copy [begin, end) range with given solver size from source to dest position of target.
Definition: container.h:138
void fill_invalid(Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=Invalid< T >::value())
Definition: container.h:131
void resetStorage(const MInt n, Storage< T > &c)
Create new container with given size and replace original one.
Definition: container.h:420
void resizeStorage(const MInt n, Storage< T > &c)
Resize container with given size.
Definition: container.h:436
void reset(const MInt capacity)
Reset tree, re-create data structures with given capacity, and set size to zero.
Definition: container.h:187
Class that represents FV cell collector.
MFloat & pvariable(const MInt id, const MInt dim)
Accessor for pvariable.
MFloat & implicitCoefficient(const MInt id, const MInt dimCoefficient)
Accessor for implicit coefficient.
MFloat & dt1Variable(const MInt id, const MInt dim)
Accessor for dt1Variable.
const MFloat & fluidFraction(const MInt id) const
MInt & rcnstrctnNghbrId(const MInt id, const MInt dimRecNghbr)
Accessor for rcnstrctnNghbrId.
constexpr MBool hasCellCenterMeanMolarWeight() const
void setNoAVariables(const MInt noAVariables_)
Update number of additional variables.
static constexpr MInt noProperties()
Return number of properties defined for each node.
MFloat & cellCenterMeanMolarWeight(const MInt id)
Accessor for species reaction rates.
MFloat & psi(const MInt id)
Accessor for psi.
BitsetType::reference hasProperty(const MInt id, const FvCell p)
Accessor for properties.
typename Base::template Storage< T > Storage
MFloat & slope(const MInt id, const MInt dimVar, const MInt dimDir)
Accessor for slopes.
typename maia::fv::collector::Invalid< T > Invalid
MFloat & restrictedVar(const MInt id, const MInt varId)
Accessor for variables after restriction during multigrid computations.
MFloat & variable(const MInt id, const MInt dim)
Accessor for variables.
constexpr MInt isMultilevel() const
Return whether multilevel is active or not.
constexpr MInt noImplicitCoefficients() const
Return max number of implicit coefficients.
MFloat & cellVolume(const MInt cellId)
Accessor for cell volume.
MFloat & reactionRate(const MInt id, const MInt dimReaction)
Accessor for reaction rates.
constexpr MInt noCVariables() const
Return number of conservative variables.
MFloat & localTimeStep(const MInt id)
Accessor for local timestep.
void setNoFVariables(const MInt noFVariables_)
Update number of flux variables.
constexpr MInt noPVariables() const
Return number of primitive variables.
MFloat & coordinate(const MInt id, const MInt dim)
Accessor for coordinates.
constexpr MInt noAVariables() const
Return number of additional variables.
MFloat & restrictedRHS(const MInt id, const MInt varId)
Accessor for restricted RHS for multilevel computation.
MFloat & rightHandSide(const MInt id, const MInt varId)
Accessor for right hand side.
MInt & reconstructionData(const MInt id)
Accessor for reconstructionData.
MFloat & avariable(const MInt id, const MInt dim)
Accessor for additional variables.
MFloat & storedSlope(const MInt id, const MInt dimVar, const MInt dimDir)
Accessor for stored slopes.
MInt m_noImplicitCoefficients
Max number of implicit coefficients.
MInt & level(const MInt cellId)
Accessor for level.
MFloat & fluidFraction(const MInt id)
MInt & bndryCellId(const MInt id)
Accessor for bndryCellIds.
Storage< M16X2bit< false > > m_nghbrInterface
MInt m_noRecNghbrs
Max number of reconstruction neighbors.
MBool m_isMultilevel
Is multilevel computation activated.
constexpr FvCellCollector()=default
Default c'tor does nothing.
BitsetType & properties(const MInt id)
Accessor for properties.
MFloat & oldVariable(const MInt id, const MInt varId)
Accessor for oldVariables.
MFloat & speciesReactionRate(const MInt id, const MInt speciesIndex)
Accessor for species reaction rates.
MFloat & dt2Variable(const MInt id, const MInt dim)
Accessor for dt2Variable.
constexpr MInt noReactionRates() const
Return max number of reaction rates.
MFloat & FcellVolume(const MInt cellId)
Accessor for inverse cell volume.
void nghbrInterface(const MInt id, const MInt dir, const MInt state)
Accessor for nghbrInterface.
MFloat & spongeFactorStart(const MInt id)
Accessor for spongeFactorStart.
MFloat & reactionRateBackup(const MInt id, const MInt dimReaction)
Accessor for reaction rates backup.
MFloat & tau(const MInt id, const MInt varId)
Accessor for coarse cell correction (tau).
MInt m_noReactionRates
Max number of reaction rates.
void setFvCollectorType(const MInt mode)
Set the fv-collector type.
void rawCopyGeneric(Functor &&c, const T &source, const MInt begin, const MInt end, const MInt destination)
Helper function for rawCopy(). Destination may refer to beginning or end of target range.
constexpr MInt noRecNghbrs() const
Return max number of reconstruction nghbrs.
void reset()
Reset tree, re-create data structures with given capacity, and set size to zero.
MInt & noRcnstrctnNghbrIds(const MInt id)
Accessor for noRcnstrctnNghbrIds.
constexpr MInt noFVariables() const
Return number of flux variables.
void setNoCVariables(const MInt noCVariables_, const MInt noSpecies_)
Set number of species and update number of variables.
MFloat & cellCenterGamma(const MInt id)
Accessor for species reaction rates.
Storage< MFloat > m_localTimeStep_
Storage of cell-local time-steps for dual time stepping:
MFloat & spongeFactor(const MInt id)
Accessor for spongeFactor.
void setNoPVariables(const MInt noPVariables_)
Update number of primitive variables.
void resetProperties(const MInt id)
Reset all properties.
MInt & spongeBndryId(const MInt id, const MInt dimDir)
Accessor for spongeBndryId.
constexpr MInt noSpecies() const
Return number of species.
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
FvCell
FV cell Property Labels.
constexpr bool isEEGas
Checks if the SysEqn is SysEqnEEGas.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
MInt id
Definition: maiatypes.h:71
constexpr std::underlying_type< FvCell >::type p(const FvCell property)
Converts property name to underlying integer value.
std::bitset< p(FvCell::NumProperties)> BitsetType
maia::fv::cell::BitsetType BitsetType
Underlying bitset type for property storage.
Namespace for auxiliary functions/classes.