30#ifdef MAIA_EXTRA_DEBUG
31#define LSCOLLECTOR_SANITY_CHECKS_ACCESSORS
34#ifdef LSCOLLECTOR_SOA_MEMORY_LAYOUT
35#error Missing implementation for structure-of-arrays memory layout.
39#if defined(MAIA_ASSERT_ACCESSORS) || defined(LSCOLLECTOR_SANITY_CHECKS_ACCESSORS)
40#define ENSURE_VALID_ID_ACCESSOR(id) \
42 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
44#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
46 MAIA_CONTAINER_ENSURE( \
47 (id) >= 0 && (id) < maxNoSets(), \
48 "set id = " + std::to_string(id) + "is out-of-bounds [0, " + std::to_string(maxNoSets()) + ")", AT_); \
51#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
53 MAIA_CONTAINER_ENSURE(p != LsCell::NumProperties, "Invalid property", AT_); \
56#define ENSURE_VALID_ID_ACCESSOR(id) \
59#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
62#define ENSURE_VALID_BODY_ID_ACCESSOR(id) \
65#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
88 static constexpr MInt value() {
return std::numeric_limits<MInt>::min(); }
94 static constexpr MLong value() {
return std::numeric_limits<MLong>::min(); }
101#ifdef MAIA_PGI_COMPILER
102 return std::numeric_limits<MFloat>::quiet_NaN();
104 return std::numeric_limits<MFloat>::signaling_NaN();
180 ENSURE_VALID_ID_ACCESSOR(
id);
181 ENSURE_VALID_SET_ID_ACCESSOR(set);
187 ENSURE_VALID_ID_ACCESSOR(
id);
188 ENSURE_VALID_SET_ID_ACCESSOR(set);
195 ENSURE_VALID_ID_ACCESSOR(
id);
196 ENSURE_VALID_SET_ID_ACCESSOR(set);
204 ENSURE_VALID_ID_ACCESSOR(
id);
205 ENSURE_VALID_SET_ID_ACCESSOR(set);
212 ENSURE_VALID_ID_ACCESSOR(
id);
213 ENSURE_VALID_SET_ID_ACCESSOR(set);
222 ENSURE_VALID_ID_ACCESSOR(
id);
223 ENSURE_VALID_BODY_ID_ACCESSOR(body);
232 ENSURE_VALID_ID_ACCESSOR(
id);
233 ENSURE_VALID_BODY_ID_ACCESSOR(body);
242 ENSURE_VALID_ID_ACCESSOR(
id);
243 ENSURE_VALID_SET_ID_ACCESSOR(set);
249 ENSURE_VALID_ID_ACCESSOR(
id);
250 ENSURE_VALID_SET_ID_ACCESSOR(set);
254 return const_cast<self&
>(*this).
fExt(
id, dim, set);
258 ENSURE_VALID_ID_ACCESSOR(
id);
259 ENSURE_VALID_SET_ID_ACCESSOR(set);
267 ENSURE_VALID_ID_ACCESSOR(
id);
268 ENSURE_VALID_SET_ID_ACCESSOR(set);
272 ENSURE_VALID_ID_ACCESSOR(
id);
273 ENSURE_VALID_SET_ID_ACCESSOR(set);
279 ENSURE_VALID_ID_ACCESSOR(
id);
283 ENSURE_VALID_ID_ACCESSOR(
id);
289 ENSURE_VALID_ID_ACCESSOR(
id);
293 ENSURE_VALID_ID_ACCESSOR(
id);
299 ENSURE_VALID_ID_ACCESSOR(
id);
303 ENSURE_VALID_ID_ACCESSOR(
id);
308 ENSURE_VALID_ID_ACCESSOR(
id);
312 ENSURE_VALID_ID_ACCESSOR(
id);
356 ASSERT(value >= 0,
"setMaxNoSets size must be >= 0");
361 ASSERT(noBodies >= 0,
"setMaxBodiesToCompute size must be >= 0");
381 template <
class Functor,
class T>
441 ASSERT(mode >= 0,
"");
447 m_hasCurvature =
true;
450 m_hasCorrectedBurningVelocity =
true;
451 ASSERT(!m_hasBodyId,
"");
458 ASSERT(!m_hasFExt,
"");
459 ASSERT(!m_hasNormal,
"");
460 ASSERT(!m_hasCurvature,
"");
461 ASSERT(!m_hasFSRhs,
"");
462 ASSERT(!m_hasCorrectedBurningVelocity,
"");
470 m_hasCurvature =
true;
471 ASSERT(!m_hasFExt,
"");
472 ASSERT(!m_hasFSRhs,
"");
473 ASSERT(!m_hasCorrectedBurningVelocity,
"");
480 m_hasCurvature =
true;
484 m_hasCorrectedBurningVelocity =
true;
488 mTerm(1, AT_,
"Unknown lsCollector Type!");
498 resetStorage(m_maxNoSets, m_gFunction);
500 if(hasCurvature()) resetStorage(m_maxNoSets, m_curvature);
501 if(hasFExt()) resetStorage(m_maxNoSets * nDim, m_fExt);
502 if(hasNormalVector()) resetStorage(m_maxNoSets * nDim, m_normalVector);
504 resetStorage(m_maxNoSets, m_bodyId);
505 resetStorage(1, m_secondBodyId);
507 if(hasOldG()) resetStorage(m_maxNoSets, m_oldGFunction);
509 if(hasFSRhs() || hasReinit()) {
510 resetStorage(m_maxNoSets * nDim, m_levelSetFunctionSlope);
511 resetStorage(m_maxNoSets, m_levelSetRHS);
514 if(hasCorrectedBurningVelocity()) {
515 resetStorage(m_maxNoSets, m_correctedBurningVelocity);
518 if(hasRotatingLs()) resetStorage(m_maxBodies, m_containingCell);
519 if(hasRotatingLs() && !hasReconstructOldG()) resetStorage(m_maxBodies, m_containingDomain);
521 if(hasGapClosing()) {
522 resetStorage(1, m_gapWidth);
523 resetStorage(1, m_potentialGapCell);
524 resetStorage(1, m_potentialGapCellClose);
527 resetStorage(1, m_properties);
528 resetStorage(m_maxNoSets, m_setProperties);
533 ASSERT(hasFExt(),
"Extension velocity not activated in cell collector!");
534 fill_invalid(m_fExt, 0, this->size(), m_maxNoSets * nDim, 0.0);
539 ASSERT(hasRotatingLs(),
"non-rotating");
540 fill_invalid(m_containingCell, 0, this->size(), m_maxBodies, -1);
545 ASSERT(hasRotatingLs(),
"non-rotating");
546 ASSERT(!hasReconstructOldG(),
"ReconstructOldG");
547 fill_invalid(m_containingDomain, 0, this->size(), m_maxBodies, -1);
553 ENSURE_VALID_ID_ACCESSOR(
id);
554 ENSURE_VALID_PROPERTY_ACCESSOR(p);
560 ENSURE_VALID_ID_ACCESSOR(
id);
561 ENSURE_VALID_PROPERTY_ACCESSOR(p);
567 ENSURE_VALID_ID_ACCESSOR(
id);
568 m_properties.at(
id).reset();
574 ENSURE_VALID_ID_ACCESSOR(
id);
581 ENSURE_VALID_ID_ACCESSOR(
id);
588 ENSURE_VALID_ID_ACCESSOR(
id);
589 m_setProperties.at(m_maxNoSets *
id + set).reset();
595 fill_invalid(m_gFunction, begin, end, m_maxNoSets);
597 if(hasCurvature()) fill_invalid(m_curvature, begin, end, m_maxNoSets, 0);
598 if(hasFExt()) fill_invalid(m_fExt, begin, end, m_maxNoSets * nDim);
599 if(hasNormalVector()) fill_invalid(m_normalVector, begin, end, m_maxNoSets * nDim);
601 fill_invalid(m_bodyId, begin, end, m_maxNoSets, -1);
602 fill_invalid(m_secondBodyId, begin, end, 1, -1);
604 if(hasOldG()) fill_invalid(m_oldGFunction, begin, end, m_maxNoSets, 0);
606 if(hasFSRhs() || hasReinit()) {
607 fill_invalid(m_levelSetFunctionSlope, begin, end, m_maxNoSets * nDim);
608 fill_invalid(m_levelSetRHS, begin, end, m_maxNoSets);
611 if(hasCorrectedBurningVelocity()) {
612 fill_invalid(m_correctedBurningVelocity, begin, end, m_maxNoSets);
615 if(hasRotatingLs()) fill_invalid(m_containingCell, begin, end, m_maxBodies, -1);
616 if(hasRotatingLs() && !hasReconstructOldG()) fill_invalid(m_containingDomain, begin, end, m_maxBodies, -1);
618 if(hasGapClosing()) {
619 fill_invalid(m_gapWidth, begin, end, 1);
620 fill_invalid(m_potentialGapCell, begin, end, 1, 0);
621 fill_invalid(m_potentialGapCellClose, begin, end, 1, 0);
624 fill_invalid(m_properties, begin, end, 1,
false);
625 fill_invalid(m_setProperties, begin, end, m_maxNoSets,
false);
630template <
class Functor,
class T>
632 const MInt destination) {
633 copyData(source.m_gFunction, m_gFunction, c, begin, end, destination, m_maxNoSets);
636 copyData(source.m_curvature, m_curvature, c, begin, end, destination, m_maxNoSets);
639 copyData(source.m_fExt, m_fExt, c, begin, end, destination, m_maxNoSets * nDim);
641 if(hasNormalVector()) {
642 copyData(source.m_normalVector, m_normalVector, c, begin, end, destination, m_maxNoSets * nDim);
645 copyData(source.m_bodyId, m_bodyId, c, begin, end, destination, m_maxNoSets);
646 copyData(source.m_secondBodyId, m_secondBodyId, c, begin, end, destination, 1);
649 copyData(source.m_oldGFunction, m_oldGFunction, c, begin, end, destination, m_maxNoSets);
652 if(hasFSRhs() || hasReinit()) {
653 copyData(source.m_levelSetFunctionSlope, m_levelSetFunctionSlope, c, begin, end, destination, m_maxNoSets * nDim);
654 copyData(source.m_levelSetRHS, m_levelSetRHS, c, begin, end, destination, m_maxNoSets);
657 if(hasCorrectedBurningVelocity()) {
658 copyData(source.m_correctedBurningVelocity, m_correctedBurningVelocity, c, begin, end, destination, m_maxNoSets);
661 if(hasRotatingLs()) copyData(source.m_containingCell, m_containingCell, c, begin, end, destination, m_maxBodies);
662 if(hasRotatingLs() && !hasReconstructOldG())
663 copyData(source.m_containingDomain, m_containingDomain, c, begin, end, destination, m_maxBodies);
665 if(hasGapClosing()) {
666 copyData(source.m_gapWidth, m_gapWidth, c, begin, end, destination, 1);
667 copyData(source.m_potentialGapCell, m_potentialGapCell, c, begin, end, destination, 1);
668 copyData(source.m_potentialGapCellClose, m_potentialGapCellClose, c, begin, end, destination, 1);
671 copyData(source.m_properties, m_properties, c, begin, end, destination);
672 copyData(source.m_setProperties, m_setProperties, c, begin, end, destination, m_maxNoSets);
681#undef LSCOLLECTOR_SANITY_CHECKS_ACCESSORS
682#undef ENSURE_VALID_ID_ACCESSOR
683#undef ENSURE_VALID_SET_ID_ACCESSOR
684#undef ENSURE_VALID_BODY_ID_ACCESSOR
685#undef ENSURE_VALID_PROPERTY_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 reset(const MInt capacity)
Reset tree, re-create data structures with given capacity, and set size to zero.
Class that represents LS cell collector.
Storage< MInt > m_containingDomain
maia::ls::cell::BitsetTypeSet BitsetTypeSet
Storage< MLong > m_containingCell
MFloat levelSetRHS(const MInt id, const MInt set) const
Storage< MInt > m_potentialGapCell
MFloat gapWidth(const MInt id) const
MInt containingDomain(const MInt id, const MInt body) const
Storage< MFloat > m_levelSetRHS
MBool m_hasBodyId
Bools for ls-collector types.
BitsetTypeSet::reference inBand(const MInt id, const MInt set)
MLong containingCell(const MInt id, const MInt body) const
void resetProperties(const MInt id)
Reset all properties.
MFloat fExt(const MInt id, const MInt dim, const MInt set) const
BitsetType::reference nearGap(const MInt id)
MFloat & oldGFunction(const MInt id, const MInt set)
void setReconstructOldG(const MBool ReconstructOldG)
MInt & bodyId(const MInt id, const MInt set)
MFloat & correctedBurningVelocity(const MInt id, const MInt set)
MFloat & curvature(const MInt id, const MInt set)
MInt & containingDomain(const MInt id, const MInt body)
Storage< MFloat > m_levelSetFunctionSlope
MFloat & gFunction(const MInt id, const MInt set)
Accessors.
void setReinit(const MBool Reinit)
void setRotatingLs(const MBool rotatingLS)
Storage< MFloat > m_curvature
MBool inBand(const MInt id, const MInt set) const
MFloat & normalVector(const MInt id, const MInt dim, const MInt set)
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
MInt & secondBodyId(const MInt id)
void reset()
Reset tree, re-create data structures with given capacity, and set size to zero.
void setMaxNoSets(const MInt value)
MFloat gFunction(const MInt id, const MInt set) const
BitsetTypeSet::reference hasSetProperty(const MInt id, const MInt set, const LsSet p)
Accessor for set properties.
constexpr MBool hasGapClosing() const
constexpr GCells()=default
Default c'tor does nothing.
constexpr MBool hasCorrectedBurningVelocity() const
MFloat normalVector(const MInt id, const MInt dim, const MInt set) const
Storage< MFloat > m_correctedBurningVelocity
typename Base::template Storage< T > Storage
MInt & potentialGapCellClose(const MInt id)
MFloat & fExt(const MInt id, const MInt dim, const MInt set)
BitsetTypeSet::reference hasPositiveSign(const MInt id, const MInt set)
MBool regridTrigger(const MInt id) const
properties:
constexpr MBool hasFExt() const
BitsetTypeSet::reference isGZero(const MInt id, const MInt set)
constexpr MBool hasNormalVector() const
void setMaxBodiesToCompute(const MInt noBodies)
Storage< MInt > m_potentialGapCellClose
MInt potentialGapCellClose(const MInt id) const
BitsetTypeSet::reference isGBndryCell(const MInt id, const MInt set)
MFloat & levelSetRHS(const MInt id, const MInt set)
MFloat curvature(const MInt id, const MInt set) const
constexpr MBool hasReinit() const
MBool hasSetProperty(const MInt id, const MInt set, const LsSet p) const
Accessor for set properties (const version).
MBool m_hasCorrectedBurningVelocity
Storage< BitsetType > m_properties
MBool hasProperty(const MInt id, const LsCell p) const
Accessor for properties (const version).
typename maia::ls::collector::Invalid< T > Invalid
MFloat oldGFunction(const MInt id, const MInt set) const
maia::ls::cell::BitsetType BitsetType
MFloat correctedBurningVelocity(const MInt id, const MInt set) const
MInt m_maxNoSets
Maximum number of sets.
BitsetType::reference hasProperty(const MInt id, const LsCell p)
Accessor for properties.
BitsetType::reference regridTrigger(const MInt id)
constexpr MBool hasOldG() const
Storage< BitsetTypeSet > m_setProperties
constexpr MBool hasCurvature() const
MBool nearGap(const MInt id) const
MBool hasPositiveSign(const MInt id, const MInt set) const
Storage< MFloat > m_gapWidth
MLong & containingCell(const MInt id, const MInt body)
void fillContainingDomain()
static constexpr MInt noProperties()
Return number of properties defined for each node.
MBool wasGZero(const MInt id, const MInt set) const
MBool m_hasReconstructOldG
MInt & potentialGapCell(const MInt id)
Storage< MFloat > m_gFunction
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.
MBool isGBndryCell(const MInt id, const MInt set) const
MFloat levelSetFunctionSlope(const MInt id, const MInt dim, const MInt set) const
constexpr MBool hasFSRhs() const
Storage< MFloat > m_normalVector
constexpr MBool hasBodyId() const
void fillContainingCell()
MInt bodyId(const MInt id, const MInt set) const
MInt potentialGapCell(const MInt id) const
void setLsCollectorType(const MInt mode)
Set the ls-collector type.
MBool isBndryG(const MInt id) const
MInt secondBodyId(const MInt id) const
void setGapClosing(const MBool gapClosing)
MFloat & gapWidth(const MInt id)
BitsetTypeSet::reference wasGZero(const MInt id, const MInt set)
MBool isGZero(const MInt id, const MInt set) const
MInt maxNoSets() const
Return number of level set functions.
void resetSetProperties(const MInt id, const MInt set)
Reset all set properties.
constexpr MBool hasRotatingLs() const
static constexpr MInt noSetProperties()
BitsetType::reference isBndryG(const MInt id)
MFloat & levelSetFunctionSlope(const MInt id, const MInt dim, const MInt set)
Storage< MFloat > m_oldGFunction
constexpr MBool hasReconstructOldG() const
Storage< MInt > m_secondBodyId
void resetExtensionVelocity()
void mTerm(const MInt errorCode, const MString &location, const MString &message)
LsSet
LS set Property Labels.
LsCell
LS cell Property Labels.
std::bitset< p(LsCell::NumProperties)> BitsetType
constexpr std::underlying_type< LsSet >::type setP(const LsSet property)
Converts property name to underlying integer value.
constexpr std::underlying_type< LsCell >::type p(const LsCell property)
Converts property name to underlying integer value.
std::bitset< setP(LsSet::NumSetProperties)> BitsetTypeSet
maia::ls::cell::BitsetTypeSet BitsetTypeSet
maia::ls::cell::BitsetType BitsetType
Underlying bitset type for property storage.
Namespace for auxiliary functions/classes.
static constexpr MFloat value()
static constexpr MInt value()
static constexpr MLong value()