7#ifndef FVCELLCOLLECTOR_H_
8#define FVCELLCOLLECTOR_H_
32#if defined(FVCELLCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
33#define ENSURE_VALID_ID_ACCESSOR(id) \
35 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
37#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
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_); \
43#define ENSURE_VALID_PVARIABLE_ID_ACCESSOR(id) \
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()) + ")", \
50#define ENSURE_VALID_FVARIABLE_ID_ACCESSOR(id) \
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()) + ")", \
57#define ENSURE_VALID_AVARIABLE_ID_ACCESSOR(id) \
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()) + ")", \
64#define ENSURE_VALID_DIRECTION_ID_ACCESSOR(id) \
66 MAIA_CONTAINER_ENSURE(id >= 0 && id < nDim, \
67 "direction id = " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nDim) + ")", \
70#define ENSURE_VALID_RECNGHBR_ID_ACCESSOR(id) \
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()) + ")", \
77#define ENSURE_VALID_REACTION_ID_ACCESSOR(id) \
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()) + ")", \
84#define ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(id) \
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()) + ")", \
91#define ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir) \
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) + ")", \
98#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
100 MAIA_CONTAINER_ENSURE(p != FvCell::NumProperties, "Invalid property", AT_); \
103#define ENSURE_VALID_ID_ACCESSOR(id) \
106#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
109#define ENSURE_VALID_PVARIABLE_ID_ACCESSOR(id) \
112#define ENSURE_VALID_FVARIABLE_ID_ACCESSOR(id) \
115#define ENSURE_VALID_AVARIABLE_ID_ACCESSOR(id) \
118#define ENSURE_VALID_DIRECTION_ID_ACCESSOR(id) \
121#define ENSURE_VALID_RECNGHBR_ID_ACCESSOR(id) \
124#define ENSURE_VALID_REACTION_ID_ACCESSOR(id) \
127#define ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(id) \
130#define ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir) \
133#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
154 static constexpr MInt value() {
return std::numeric_limits<MInt>::min(); }
161#ifdef MAIA_PGI_COMPILER
162 return std::numeric_limits<MFloat>::quiet_NaN();
164 return std::numeric_limits<MFloat>::signaling_NaN();
392 template <
class Functor,
class T>
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);
478 resetStorage(noCVariables(), m_dt1Variables);
479 resetStorage(noCVariables(), m_dt2Variables);
480 resetStorage(1, m_localTimeStep_);
481 }
else if(hasLocalTS()) {
482 resetStorage(1, m_localTimeStep_);
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);
495 resetStorage(noCVariables(), m_tau);
496 resetStorage(noCVariables(), m_restrictedRHS);
497 resetStorage(noCVariables(), m_restrictedVars);
498 resetStorage(noCVariables() * nDim, m_storedSlopes);
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);
524 resizeStorage(noCVariables(), m_dt1Variables);
525 resizeStorage(noCVariables(), m_dt2Variables);
526 resizeStorage(1, m_localTimeStep_);
527 }
else if(hasLocalTS()) {
528 resizeStorage(1, m_localTimeStep_);
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);
542 resizeStorage(noCVariables(), m_tau);
543 resizeStorage(noCVariables(), m_restrictedRHS);
544 resizeStorage(noCVariables(), m_restrictedVars);
545 resizeStorage(noCVariables() * nDim, m_storedSlopes);
553 ASSERT(mode >= 0,
"");
556 m_hasCellCenterMeanMolarWeight =
false;
557 m_hasCellCenterGamma =
false;
558 m_hasReactionRates =
false;
559 m_hasReactionRatesBackup =
false;
566 m_hasCellCenterMeanMolarWeight =
true;
567 m_hasCellCenterGamma =
true;
568 m_hasReactionRates =
true;
569 m_hasReactionRatesBackup =
false;
575 m_hasCellCenterMeanMolarWeight =
false;
576 m_hasCellCenterGamma =
false;
577 m_hasReactionRates =
true;
578 m_hasReactionRatesBackup =
true;
584 m_hasCellCenterMeanMolarWeight =
false;
585 m_hasCellCenterGamma =
false;
586 m_hasReactionRates =
false;
587 m_hasReactionRatesBackup =
false;
593 mTerm(1, AT_,
"Unknown fvCollector Type!");
599 ASSERT(mode >= 0,
"");
616 mTerm(1, AT_,
"Unknown fvTimeStepType!");
625#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
626#error Missing implementation for structure-of-arrays memory layout.
628 ENSURE_VALID_ID_ACCESSOR(
id);
629 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
630 return m_oldVariables[
id * noCVariables() + varId];
636#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
637#error Missing implementation for structure-of-arrays memory layout.
639 ENSURE_VALID_ID_ACCESSOR(
id);
640 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
641 return m_oldVariables[
id * noCVariables() + varId];
648#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
649#error Missing implementation for structure-of-arrays memory layout.
651 ENSURE_VALID_ID_ACCESSOR(
id);
652 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
653 return m_variables[
id * noCVariables() + varId];
659#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
660#error Missing implementation for structure-of-arrays memory layout.
662 ENSURE_VALID_ID_ACCESSOR(
id);
663 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
664 return m_variables[
id * noCVariables() + varId];
671#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
672#error Missing implementation for structure-of-arrays memory layout.
674 ENSURE_VALID_ID_ACCESSOR(
id);
675 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(varId);
676 return m_pvariables[
id * noPVariables() + varId];
682#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
683#error Missing implementation for structure-of-arrays memory layout.
685 ENSURE_VALID_ID_ACCESSOR(
id);
686 ENSURE_VALID_PVARIABLE_ID_ACCESSOR(varId);
687 return m_pvariables[
id * noPVariables() + varId];
694#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
695#error Missing implementation for structure-of-arrays memory layout.
697 ENSURE_VALID_ID_ACCESSOR(
id);
698 ENSURE_VALID_AVARIABLE_ID_ACCESSOR(varId);
699 return m_avariables[
id * noAVariables() + varId];
705#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
706#error Missing implementation for structure-of-arrays memory layout.
708 ENSURE_VALID_ID_ACCESSOR(
id);
709 ENSURE_VALID_AVARIABLE_ID_ACCESSOR(varId);
710 return m_avariables[
id * noAVariables() + varId];
717#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
718#error Missing implementation for structure-of-arrays memory layout.
720 ENSURE_VALID_ID_ACCESSOR(
id);
721 ENSURE_VALID_FVARIABLE_ID_ACCESSOR(varId);
722 return m_rightHandSide[
id * noFVariables() + varId];
728#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
729#error Missing implementation for structure-of-arrays memory layout.
731 ENSURE_VALID_ID_ACCESSOR(
id);
732 ENSURE_VALID_FVARIABLE_ID_ACCESSOR(varId);
733 return m_rightHandSide[
id * noFVariables() + varId];
740#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
741#error Missing implementation for structure-of-arrays memory layout.
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];
752#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
753#error Missing implementation for structure-of-arrays memory layout.
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];
765#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
766#error Missing implementation for structure-of-arrays memory layout.
768 ENSURE_VALID_ID_ACCESSOR(
id);
769 return m_bndryCellIds[
id];
775#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
776#error Missing implementation for structure-of-arrays memory layout.
778 ENSURE_VALID_ID_ACCESSOR(
id);
779 return m_bndryCellIds[
id];
786#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
787#error Missing implementation for structure-of-arrays memory layout.
789 ENSURE_VALID_ID_ACCESSOR(
id);
790 return m_noRcnstrctnNghbrIds[
id];
796#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
797#error Missing implementation for structure-of-arrays memory layout.
799 ENSURE_VALID_ID_ACCESSOR(
id);
800 return m_noRcnstrctnNghbrIds[
id];
807#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
808#error Missing implementation for structure-of-arrays memory layout.
810 ENSURE_VALID_ID_ACCESSOR(
id);
811 ENSURE_VALID_RECNGHBR_ID_ACCESSOR(dimRecNghbr);
812 return m_rcnstrctnNghbrIds[
id * noRecNghbrs() + dimRecNghbr];
818#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
819#error Missing implementation for structure-of-arrays memory layout.
821 ENSURE_VALID_ID_ACCESSOR(
id);
822 ENSURE_VALID_RECNGHBR_ID_ACCESSOR(dimRecNghbr);
823 return m_rcnstrctnNghbrIds[
id * noRecNghbrs() + dimRecNghbr];
830#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
831#error Missing implementation for structure-of-arrays memory layout.
833 ENSURE_VALID_ID_ACCESSOR(
id);
834 return m_reconstructionData[
id];
840#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
841#error Missing implementation for structure-of-arrays memory layout.
843 ENSURE_VALID_ID_ACCESSOR(
id);
844 return m_reconstructionData[
id];
851#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
852#error Missing implementation for structure-of-arrays memory layout.
854 ENSURE_VALID_ID_ACCESSOR(
id);
855 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dir / 2);
856 m_nghbrInterface[
id].set(dir, state);
862#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
863#error Missing implementation for structure-of-arrays memory layout.
865 ENSURE_VALID_ID_ACCESSOR(
id);
866 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dir / 2);
867 return m_nghbrInterface[
id].get(dir);
874#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
875#error Missing implementation for structure-of-arrays memory layout.
877 ENSURE_VALID_ID_ACCESSOR(
id);
878 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
879 return m_reactionRates[
id * noReactionRates() + dimReaction];
885#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
886#error Missing implementation for structure-of-arrays memory layout.
888 ENSURE_VALID_ID_ACCESSOR(
id);
889 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
890 return m_reactionRates[
id * noReactionRates() + dimReaction];
897#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
898#error Missing implementation for structure-of-arrays memory layout.
900 ENSURE_VALID_ID_ACCESSOR(
id);
901 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
902 return m_reactionRatesBackup[
id * noReactionRates() + dimReaction];
908#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
909#error Missing implementation for structure-of-arrays memory layout.
911 ENSURE_VALID_ID_ACCESSOR(
id);
912 ENSURE_VALID_REACTION_ID_ACCESSOR(dimReaction);
913 return m_reactionRatesBackup[
id * noReactionRates() + dimReaction];
920#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
921#error Missing implementation for structure-of-arrays memory layout.
923 ENSURE_VALID_ID_ACCESSOR(
id);
930#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
931#error Missing implementation for structure-of-arrays memory layout.
933 ENSURE_VALID_ID_ACCESSOR(
id);
941#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
942#error Missing implementation for structure-of-arrays memory layout.
944 ENSURE_VALID_ID_ACCESSOR(
id);
945 ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(dimCoefficient);
946 return m_implicitCoefficients[
id * noImplicitCoefficients() + dimCoefficient];
952#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
953#error Missing implementation for structure-of-arrays memory layout.
955 ENSURE_VALID_ID_ACCESSOR(
id);
956 ENSURE_VALID_IMPLICIT_COEFFICIENT_ID_ACCESSOR(dimCoefficient);
957 return m_implicitCoefficients[
id * noImplicitCoefficients() + dimCoefficient];
964#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
965#error Missing implementation for structure-of-arrays memory layout.
967 ENSURE_VALID_ID_ACCESSOR(
id);
968 ENSURE_VALID_REACTION_ID_ACCESSOR(speciesIndex);
969 return m_speciesReactionRates[
id * noSpecies() + speciesIndex];
976#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
977#error Missing implementation for structure-of-arrays memory layout.
979 ENSURE_VALID_ID_ACCESSOR(
id);
980 ENSURE_VALID_REACTION_ID_ACCESSOR(speciesIndex);
981 return m_speciesReactionRates[
id * noSpecies() + speciesIndex];
988#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
989#error Missing implementation for structure-of-arrays memory layout.
991 ENSURE_VALID_ID_ACCESSOR(
id);
992 return m_cellCenterMeanMolarWeight[
id];
999#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1000#error Missing implementation for structure-of-arrays memory layout.
1002 ENSURE_VALID_ID_ACCESSOR(
id);
1003 return m_cellCenterMeanMolarWeight[
id];
1010#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1011#error Missing implementation for structure-of-arrays memory layout.
1013 ENSURE_VALID_ID_ACCESSOR(
id);
1014 return m_cellCenterGamma[
id];
1021#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1022#error Missing implementation for structure-of-arrays memory layout.
1024 ENSURE_VALID_ID_ACCESSOR(
id);
1025 return m_cellCenterGamma[
id];
1032#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1033#error Missing implementation for structure-of-arrays memory layout.
1035 ENSURE_VALID_ID_ACCESSOR(
id);
1036 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1037 return m_dt1Variables[
id * noCVariables() + varId];
1043#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1044#error Missing implementation for structure-of-arrays memory layout.
1046 ENSURE_VALID_ID_ACCESSOR(
id);
1047 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1048 return m_dt1Variables[
id * noCVariables() + varId];
1055#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1056#error Missing implementation for structure-of-arrays memory layout.
1058 ENSURE_VALID_ID_ACCESSOR(
id);
1059 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1060 return m_dt2Variables[
id * noCVariables() + varId];
1066#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1067#error Missing implementation for structure-of-arrays memory layout.
1069 ENSURE_VALID_ID_ACCESSOR(
id);
1070 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1071 return m_dt2Variables[
id * noCVariables() + varId];
1077#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1078#error Missing implementation for structure-of-arrays memory layout.
1080 ENSURE_VALID_ID_ACCESSOR(
id);
1081 return m_localTimeStep_[
id];
1087#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1088#error Missing implementation for structure-of-arrays memory layout.
1090 ENSURE_VALID_ID_ACCESSOR(
id);
1091 return m_localTimeStep_[
id];
1098#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1099#error Missing implementation for structure-of-arrays memory layout.
1101 ENSURE_VALID_ID_ACCESSOR(
id);
1102 return m_spongeFactor[
id];
1108#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1109#error Missing implementation for structure-of-arrays memory layout.
1111 ENSURE_VALID_ID_ACCESSOR(
id);
1112 return m_spongeFactor[
id];
1119#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1120#error Missing implementation for structure-of-arrays memory layout.
1122 ENSURE_VALID_ID_ACCESSOR(
id);
1123 return m_spongeFactorStart[
id];
1129#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1130#error Missing implementation for structure-of-arrays memory layout.
1132 ENSURE_VALID_ID_ACCESSOR(
id);
1133 return m_spongeFactorStart[
id];
1140#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1141#error Missing implementation for structure-of-arrays memory layout.
1143 ENSURE_VALID_ID_ACCESSOR(
id);
1144 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1145 return m_spongeBndryIds[
id * nDim + dimDir];
1151#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1152#error Missing implementation for structure-of-arrays memory layout.
1154 ENSURE_VALID_ID_ACCESSOR(
id);
1155 ENSURE_VALID_DIRECTION_ID_ACCESSOR(dimDir);
1156 return m_spongeBndryIds[
id * nDim + dimDir];
1163#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1164#error Missing implementation for structure-of-arrays memory layout.
1166 ENSURE_VALID_ID_ACCESSOR(
id);
1167 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
1168 return m_coordinates[
id * nDim + dir];
1174#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1175#error Missing implementation for structure-of-arrays memory layout.
1177 ENSURE_VALID_ID_ACCESSOR(
id);
1178 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
1179 return m_coordinates[
id * nDim + dir];
1185 ENSURE_VALID_ID_ACCESSOR(
id);
1186 return m_levels[
id];
1191 ENSURE_VALID_ID_ACCESSOR(
id);
1192 return m_levels[
id];
1198 ENSURE_VALID_ID_ACCESSOR(
id);
1199 return m_cellVolumes[
id];
1204 ENSURE_VALID_ID_ACCESSOR(
id);
1205 return m_cellVolumes[
id];
1211 ENSURE_VALID_ID_ACCESSOR(
id);
1212 return m_FcellVolumes[
id];
1217 ENSURE_VALID_ID_ACCESSOR(
id);
1218 return m_FcellVolumes[
id];
1224 ENSURE_VALID_ID_ACCESSOR(
id);
1225 ENSURE_VALID_PROPERTY_ACCESSOR(p);
1231 ENSURE_VALID_ID_ACCESSOR(
id);
1232 ENSURE_VALID_PROPERTY_ACCESSOR(p);
1238 ENSURE_VALID_ID_ACCESSOR(
id);
1239 m_properties[
id].reset();
1244 ENSURE_VALID_ID_ACCESSOR(
id);
1245 return m_properties[
id];
1252#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1253#error Missing implementation for structure-of-arrays memory layout.
1255 ENSURE_VALID_ID_ACCESSOR(
id);
1256 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1257 return m_tau[
id * noCVariables() + varId];
1263#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1264#error Missing implementation for structure-of-arrays memory layout.
1266 ENSURE_VALID_ID_ACCESSOR(
id);
1267 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1268 return m_tau[
id * noCVariables() + varId];
1275#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1276#error Missing implementation for structure-of-arrays memory layout.
1278 ENSURE_VALID_ID_ACCESSOR(
id);
1279 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1280 return m_restrictedRHS[
id * noCVariables() + varId];
1286#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1287#error Missing implementation for structure-of-arrays memory layout.
1289 ENSURE_VALID_ID_ACCESSOR(
id);
1290 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1291 return m_restrictedRHS[
id * noCVariables() + varId];
1298#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1299#error Missing implementation for structure-of-arrays memory layout.
1301 ENSURE_VALID_ID_ACCESSOR(
id);
1302 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1303 return m_restrictedVars[
id * noCVariables() + varId];
1309#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1310#error Missing implementation for structure-of-arrays memory layout.
1312 ENSURE_VALID_ID_ACCESSOR(
id);
1313 ENSURE_VALID_VARIABLE_ID_ACCESSOR(varId);
1314 return m_restrictedVars[
id * noCVariables() + varId];
1321#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1322#error Missing implementation for structure-of-arrays memory layout.
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];
1333#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1334#error Missing implementation for structure-of-arrays memory layout.
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];
1345 m_noSpecies = noSpecies_;
1346 m_noCVariables = noCVariables_;
1353 m_noPVariables = noPVariables_;
1360 m_noFVariables = noFVariables_;
1367 m_noAVariables = noAVariables_;
1374 const MInt oldIsMultilevel = m_isMultilevel;
1375 m_isMultilevel = isMultilevel_;
1376 return oldIsMultilevel;
1383#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1384#error Missing implementation for structure-of-arrays memory layout.
1388 fill_invalid(m_oldVariables, begin, end, noCVariables());
1390 fill_invalid(m_variables, begin, end, noCVariables());
1392 fill_invalid(m_pvariables, begin, end, noPVariables());
1394 fill_invalid(m_rightHandSide, begin, end, noFVariables());
1396 fill_invalid(m_slopes, begin, end, noPVariables() * nDim);
1399 fill_invalid(m_bndryCellIds, begin, end, 1, -1);
1401 fill_invalid(m_noRcnstrctnNghbrIds, begin, end);
1403 fill_invalid(m_rcnstrctnNghbrIds, begin, end, noRecNghbrs());
1405 fill_invalid(m_reconstructionData, begin, end);
1407 fill_invalid(m_nghbrInterface, begin, end);
1410 if(hasReactionRates()) fill_invalid(m_reactionRates, begin, end, noReactionRates());
1411 if(hasReactionRatesBackup()) fill_invalid(m_reactionRatesBackup, begin, end, noReactionRates());
1413 if(hasPsi()) fill_invalid(m_psi, begin, end);
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);
1420 if(
isEEGas()) fill_invalid(m_implicitCoefficients, begin, end, noImplicitCoefficients());
1422 fill_invalid(m_avariables, begin, end, noAVariables());
1426 fill_invalid(m_dt1Variables, begin, end, noCVariables());
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);
1435 fill_invalid(m_spongeFactor, begin, end);
1437 fill_invalid(m_spongeFactorStart, begin, end);
1439 fill_invalid(m_spongeBndryIds, begin, end, nDim);
1442 fill_invalid(m_properties, begin, end);
1444 fill_invalid(m_coordinates, begin * nDim, end * nDim);
1447 fill_invalid(m_levels, begin, end);
1450 fill_invalid(m_cellVolumes, begin, end);
1452 fill_invalid(m_FcellVolumes, begin, end);
1455 if(isMultilevel()) {
1457 fill_invalid(m_tau, begin, end, noCVariables());
1459 fill_invalid(m_restrictedRHS, begin, end, noCVariables());
1461 fill_invalid(m_restrictedVars, begin, end, noCVariables());
1463 fill_invalid(m_storedSlopes, begin, end, noPVariables() * nDim);
1470template <
class Functor,
class T>
1472 const MInt destination) {
1474#ifdef FVCELLCOLLECTOR_SOA_MEMORY_LAYOUT
1475#error Missing implementation for structure-of-arrays memory layout.
1479 copyData(source.m_oldVariables, m_oldVariables, c, begin, end, destination, noCVariables());
1481 copyData(source.m_variables, m_variables, c, begin, end, destination, noCVariables());
1483 copyData(source.m_pvariables, m_pvariables, c, begin, end, destination, noPVariables());
1485 copyData(source.m_rightHandSide, m_rightHandSide, c, begin, end, destination, noFVariables());
1487 copyData(source.m_slopes, m_slopes, c, begin, end, destination, noPVariables() * nDim);
1489 copyData(source.m_bndryCellIds, m_bndryCellIds, c, begin, end, destination);
1491 copyData(source.m_noRcnstrctnNghbrIds, m_noRcnstrctnNghbrIds, c, begin, end, destination);
1493 copyData(source.m_rcnstrctnNghbrIds, m_rcnstrctnNghbrIds, c, begin, end, destination, noRecNghbrs());
1495 copyData(source.m_reconstructionData, m_reconstructionData, c, begin, end, destination);
1497 copyData(source.m_nghbrInterface, m_nghbrInterface, c, begin, end, destination);
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());
1504 if(hasPsi()) copyData(source.m_psi, m_psi, c, begin, end, destination);
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);
1514 copyData(source.m_implicitCoefficients, m_implicitCoefficients, c, begin, end, destination,
1515 noImplicitCoefficients());
1518 copyData(source.m_avariables, m_avariables, c, begin, end, destination, noAVariables());
1522 copyData(source.m_dt1Variables, m_dt1Variables, c, begin, end, destination, noCVariables());
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);
1531 copyData(source.m_spongeFactor, m_spongeFactor, c, begin, end, destination);
1533 copyData(source.m_spongeFactorStart, m_spongeFactorStart, c, begin, end, destination);
1535 copyData(source.m_spongeBndryIds, m_spongeBndryIds, c, begin, end, destination, nDim);
1537 copyData(source.m_coordinates, m_coordinates, c, begin, end, destination, nDim);
1540 copyData(source.m_properties, m_properties, c, begin, end, destination);
1543 copyData(source.m_levels, m_levels, c, begin, end, destination);
1546 copyData(source.m_cellVolumes, m_cellVolumes, c, begin, end, destination);
1549 copyData(source.m_FcellVolumes, m_FcellVolumes, c, begin, end, destination);
1552 if(isMultilevel()) {
1554 copyData(source.m_tau, m_tau, c, begin, end, destination, noCVariables());
1556 copyData(source.m_restrictedRHS, m_restrictedRHS, c, begin, end, destination, noCVariables());
1558 copyData(source.m_restrictedVars, m_restrictedVars, c, begin, end, destination, noCVariables());
1560 copyData(source.m_storedSlopes, m_storedSlopes, c, begin, end, destination, noPVariables() * nDim);
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
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.
void fill_invalid(Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=Invalid< T >::value())
void resetStorage(const MInt n, Storage< T > &c)
Create new container with given size and replace original one.
void resizeStorage(const MInt n, Storage< T > &c)
Resize container with given size.
void reset(const MInt capacity)
Reset tree, re-create data structures with given capacity, and set size to zero.
Class that represents FV cell collector.
Storage< MFloat > m_spongeFactor
Storage< MFloat > m_reactionRatesBackup
MFloat & pvariable(const MInt id, const MInt dim)
Accessor for pvariable.
MFloat & implicitCoefficient(const MInt id, const MInt dimCoefficient)
Accessor for implicit coefficient.
constexpr MBool hasLocalTS() const
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.
Storage< MFloat > m_cellVolumes
static constexpr MInt noProperties()
Return number of properties defined for each node.
MFloat & cellCenterMeanMolarWeight(const MInt id)
Accessor for species reaction rates.
constexpr MBool isEEGas() const
Storage< BitsetType > m_properties
MFloat & psi(const MInt id)
Accessor for psi.
constexpr MBool hasReactionRates() const
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.
Storage< MInt > m_noRcnstrctnNghbrIds
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.
Storage< MFloat > m_implicitCoefficients
void resize() override
TODO doc.
constexpr MBool hasReactionRatesBackup() const
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.
Storage< MFloat > m_avariables
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.
Storage< MFloat > m_cellCenterMeanMolarWeight
MFloat & storedSlope(const MInt id, const MInt dimVar, const MInt dimDir)
Accessor for stored slopes.
MInt m_noImplicitCoefficients
Max number of implicit coefficients.
Storage< MFloat > m_variables
Storage< MFloat > m_dt1Variables
Storage< MFloat > m_restrictedRHS
MInt & level(const MInt cellId)
Accessor for level.
constexpr MBool hasDualTS() const
MFloat & fluidFraction(const MInt id)
Storage< MFloat > m_coordinates
MInt & bndryCellId(const MInt id)
Accessor for bndryCellIds.
Storage< M16X2bit< false > > m_nghbrInterface
Storage< MFloat > m_restrictedVars
MInt m_noRecNghbrs
Max number of reconstruction neighbors.
MBool m_hasReactionRatesBackup
Storage< MFloat > m_dt2Variables
Storage< MFloat > m_speciesReactionRates
MBool m_isMultilevel
Is multilevel computation activated.
Storage< MFloat > m_reactionRates
Storage< MInt > m_spongeBndryIds
MInt m_noSpecies
Number of species.
constexpr FvCellCollector()=default
Default c'tor does nothing.
BitsetType & properties(const MInt id)
Accessor for properties.
Storage< MInt > m_bndryCellIds
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.
maia::fv::cell::BitsetType BitsetType
Storage< MFloat > m_slopes
Storage< MFloat > m_spongeFactorStart
constexpr MInt noReactionRates() const
Return max number of reaction rates.
Storage< MFloat > m_oldVariables
MFloat & FcellVolume(const MInt cellId)
Accessor for inverse cell volume.
void nghbrInterface(const MInt id, const MInt dir, const MInt state)
Accessor for nghbrInterface.
MBool m_hasCellCenterMeanMolarWeight
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.
Storage< MFloat > m_rightHandSide
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.
Storage< MFloat > m_storedSlopes
Storage< MFloat > m_FcellVolumes
Storage< MFloat > m_pvariables
Storage< MInt > m_reconstructionData
MBool m_hasCellCenterGamma
void setFvTimeStepType(const MInt mode)
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.
constexpr MBool hasPsi() const
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.
Storage< MInt > m_rcnstrctnNghbrIds
Storage< MFloat > m_cellCenterGamma
constexpr MBool hasCellCenterGamma() const
MInt m_noCVariables
Number of variables.
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)
FvCell
FV cell Property Labels.
constexpr bool isEEGas
Checks if the SysEqn is SysEqnEEGas.
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.
static constexpr BitsetType value()
static constexpr MFloat value()
static constexpr MInt value()