MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lscartesiancellcollector.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 LSCOLLECTOR_H_
8#define LSCOLLECTOR_H_
9
10#include <algorithm>
11#include <bitset>
12#include <type_traits>
13#include <vector>
14#include "INCLUDE/maiamacro.h"
15#include "INCLUDE/maiatypes.h"
16#include "MEMORY/container.h"
17#include "UTIL/functions.h"
18#include "compiler_config.h"
20
21// The following macro enables the "Structure-of-Arrays" memory layout for multi-dimensional node
22// variables. This might be beneficial for GPU computations. Default is "Array-of-Structures".
23// Examples (for nodes nN with four children cM each)
24// Array-of-Structures (AOS): n0c0, n0c1, n0c2, n0c3, n1c0, n1c1, n1c2, n1c3, n2c0, n2c1, ...
25// Structure-of-Arrays (SOA): n0c0, n1c0, n2c0, n3c0, ..., n0c1, n1c1, n2c1, n3c1, ..., n0c2, ...
26// #define LSCOLLECTOR_SOA_MEMORY_LAYOUT
27
28// The macro 'LSCOLLECTOR_SANITY_CHECKS_ACCESSORS' enables (potentially very expensive) sanity checks
29// for all accessors. It is enabled for build type "extra_debug".
30#ifdef MAIA_EXTRA_DEBUG
31#define LSCOLLECTOR_SANITY_CHECKS_ACCESSORS
32#endif
33
34#ifdef LSCOLLECTOR_SOA_MEMORY_LAYOUT
35#error Missing implementation for structure-of-arrays memory layout.
36#endif
37
38// Sanity-checking macros for accessors
39#if defined(MAIA_ASSERT_ACCESSORS) || defined(LSCOLLECTOR_SANITY_CHECKS_ACCESSORS)
40#define ENSURE_VALID_ID_ACCESSOR(id) \
41 do { \
42 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
43 } while(false)
44#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
45 do { \
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_); \
49 } while(false)
50
51#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
52 do { \
53 MAIA_CONTAINER_ENSURE(p != LsCell::NumProperties, "Invalid property", AT_); \
54 } while(false)
55#else
56#define ENSURE_VALID_ID_ACCESSOR(id) \
57 do { \
58 } while(false)
59#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
60 do { \
61 } while(false)
62#define ENSURE_VALID_BODY_ID_ACCESSOR(id) \
63 do { \
64 } while(false)
65#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
66 do { \
67 } while(false)
68#endif
69
70
71// Namespace for auxiliary functions/classes
72namespace maia {
73namespace ls {
74namespace collector {
75
79
80
81// Type traits for invalid values. These values are used to initialize/erase nodes
82template <class T>
83struct Invalid {};
84
85// Invalid value for ids is 'INT_MIN'
86template <>
87struct Invalid<MInt> {
88 static constexpr MInt value() { return std::numeric_limits<MInt>::min(); }
89};
90
91// Invalid value for ids is 'LONG_INT_MIN'
92template <>
93struct Invalid<MLong> {
94 static constexpr MLong value() { return std::numeric_limits<MLong>::min(); }
95};
96
97// Invalid value for floats is 'NaN'
98template <>
99struct Invalid<MFloat> {
100 static constexpr MFloat value() {
101#ifdef MAIA_PGI_COMPILER
102 return std::numeric_limits<MFloat>::quiet_NaN();
103#else
104 return std::numeric_limits<MFloat>::signaling_NaN();
105#endif
106 }
107};
108
109// Invalid value for BitsetProperties is '0'
110template <>
112 static constexpr BitsetType value() { return BitsetType(0); }
113};
114/* // Invalid value for BitsetProperties is '0' */
115/* template <> */
116/* struct Invalid<BitsetTypeSet> { */
117/* static constexpr BitsetTypeSet value() { return BitsetTypeSet(0); } */
118/* }; */
119// NOTE: additional declaration only necessary if:
120// NumProperties != NumSetProperties is lscellproperties.h
121// Invalid value for BitsetProperties is '0'
122// template <> struct Invalid<BitsetTypeSet> {
123// static constexpr BitsetTypeSet value() { return BitsetTypeSet(0); }
124//};
125
126
128template <MInt nDim>
129class GCells : public maia::container::Container<GCells<nDim>, Invalid> {
130 // Necessary for CRTP
131 friend class maia::container::Container<GCells<nDim>, Invalid>;
132
133 // Make base class functions known to use without this pointer
135 using Base::resetStorage;
137 template <class T>
138 using Storage = typename Base::template Storage<T>;
139
140
141 public:
144
145
146 // Types
147 template <class T>
149
150 // Constructors
152 constexpr GCells() = default;
153
154 // Ensure that base class method is found when called from outside
155 using Base::copyData;
156 using Base::fill_invalid;
157 using Base::reset;
158
162
163 // accessors to specify GCell collector type
164 constexpr MBool hasBodyId() const { return m_hasBodyId; }
165 constexpr MBool hasOldG() const { return m_hasOldG; }
166 constexpr MBool hasRotatingLs() const { return m_hasRotatingLs; }
167 constexpr MBool hasReconstructOldG() const { return m_hasReconstructOldG; }
168 constexpr MBool hasFSRhs() const { return m_hasFSRhs; }
169 constexpr MBool hasReinit() const { return m_hasReinit; }
171
172 constexpr MBool hasFExt() const { return m_hasFExt; }
173 constexpr MBool hasCurvature() const { return m_hasCurvature; }
174 constexpr MBool hasNormalVector() const { return m_hasNormal; }
175 constexpr MBool hasGapClosing() const { return m_hasGapClosing; }
176
178 // ls-value
179 MFloat& gFunction(const MInt id, const MInt set) {
180 ENSURE_VALID_ID_ACCESSOR(id);
181 ENSURE_VALID_SET_ID_ACCESSOR(set);
182 return m_gFunction.at(m_maxNoSets * id + set);
183 }
184 MFloat gFunction(const MInt id, const MInt set) const { return const_cast<self&>(*this).gFunction(id, set); }
185 // old ls-value (for semi-Lagrange levelset!)
186 MFloat& oldGFunction(const MInt id, const MInt set) {
187 ENSURE_VALID_ID_ACCESSOR(id);
188 ENSURE_VALID_SET_ID_ACCESSOR(set);
189 return m_oldGFunction.at(m_maxNoSets * id + set);
190 }
191 MFloat oldGFunction(const MInt id, const MInt set) const { return const_cast<self&>(*this).oldGFunction(id, set); }
192
193 // ls-function slope
194 MFloat& levelSetFunctionSlope(const MInt id, const MInt dim, const MInt set) {
195 ENSURE_VALID_ID_ACCESSOR(id);
196 ENSURE_VALID_SET_ID_ACCESSOR(set);
197 return m_levelSetFunctionSlope.at((id * m_maxNoSets + set) * nDim + dim);
198 }
199 MFloat levelSetFunctionSlope(const MInt id, const MInt dim, const MInt set) const {
200 return const_cast<self&>(*this).levelSetFunctionSlope(id, dim, set);
201 }
202 // ls-rhs
203 MFloat& levelSetRHS(const MInt id, const MInt set) {
204 ENSURE_VALID_ID_ACCESSOR(id);
205 ENSURE_VALID_SET_ID_ACCESSOR(set);
206 return m_levelSetRHS.at(m_maxNoSets * id + set);
207 }
208 MFloat levelSetRHS(const MInt id, const MInt set) const { return const_cast<self&>(*this).levelSetRHS(id, set); }
209
210 // corrected burning velocity
211 MFloat& correctedBurningVelocity(const MInt id, const MInt set) {
212 ENSURE_VALID_ID_ACCESSOR(id);
213 ENSURE_VALID_SET_ID_ACCESSOR(set);
214 return m_correctedBurningVelocity.at(m_maxNoSets * id + set);
215 }
216 MFloat correctedBurningVelocity(const MInt id, const MInt set) const {
217 return const_cast<self&>(*this).correctedBurningVelocity(id, set);
218 }
219
220 // Containing Cell
221 MLong& containingCell(const MInt id, const MInt body) {
222 ENSURE_VALID_ID_ACCESSOR(id);
223 ENSURE_VALID_BODY_ID_ACCESSOR(body);
224 return m_containingCell.at(m_maxBodies * id + body);
225 }
226 MLong containingCell(const MInt id, const MInt body) const {
227 return const_cast<self&>(*this).containingCell(id, body);
228 }
229
230 // Containg Domain
231 MInt& containingDomain(const MInt id, const MInt body) {
232 ENSURE_VALID_ID_ACCESSOR(id);
233 ENSURE_VALID_BODY_ID_ACCESSOR(body);
234 return m_containingDomain.at(m_maxBodies * id + body);
235 }
236 MInt containingDomain(const MInt id, const MInt body) const {
237 return const_cast<self&>(*this).containingDomain(id, body);
238 }
239
240 // curvature
241 MFloat& curvature(const MInt id, const MInt set) {
242 ENSURE_VALID_ID_ACCESSOR(id);
243 ENSURE_VALID_SET_ID_ACCESSOR(set);
244 return m_curvature.at(m_maxNoSets * id + set);
245 }
246 MFloat curvature(const MInt id, const MInt set) const { return const_cast<self&>(*this).curvature(id, set); }
247 // extension-velocity
248 MFloat& fExt(const MInt id, const MInt dim, const MInt set) {
249 ENSURE_VALID_ID_ACCESSOR(id);
250 ENSURE_VALID_SET_ID_ACCESSOR(set);
251 return m_fExt.at((id * m_maxNoSets + set) * nDim + dim);
252 }
253 MFloat fExt(const MInt id, const MInt dim, const MInt set) const {
254 return const_cast<self&>(*this).fExt(id, dim, set);
255 }
256 // normal vector
257 MFloat& normalVector(const MInt id, const MInt dim, const MInt set) {
258 ENSURE_VALID_ID_ACCESSOR(id);
259 ENSURE_VALID_SET_ID_ACCESSOR(set);
260 return m_normalVector.at((id * m_maxNoSets + set) * nDim + dim);
261 }
262 MFloat normalVector(const MInt id, const MInt dim, const MInt set) const {
263 return const_cast<self&>(*this).normalVector(id, dim, set);
264 }
265 // bodyId
266 MInt& bodyId(const MInt id, const MInt set) {
267 ENSURE_VALID_ID_ACCESSOR(id);
268 ENSURE_VALID_SET_ID_ACCESSOR(set);
269 return m_bodyId.at(m_maxNoSets * id + set);
270 }
271 MInt bodyId(const MInt id, const MInt set) const {
272 ENSURE_VALID_ID_ACCESSOR(id);
273 ENSURE_VALID_SET_ID_ACCESSOR(set);
274 return m_bodyId.at(m_maxNoSets * id + set);
275 }
276
277 // secondBodyId
278 MInt& secondBodyId(const MInt id) {
279 ENSURE_VALID_ID_ACCESSOR(id);
280 return m_secondBodyId.at(id);
281 }
282 MInt secondBodyId(const MInt id) const {
283 ENSURE_VALID_ID_ACCESSOR(id);
284 return m_secondBodyId.at(id);
285 }
286
287 // gap width
288 MFloat& gapWidth(const MInt id) {
289 ENSURE_VALID_ID_ACCESSOR(id);
290 return m_gapWidth.at(id);
291 }
292 MFloat gapWidth(const MInt id) const {
293 ENSURE_VALID_ID_ACCESSOR(id);
294 return m_gapWidth.at(id);
295 }
296
297 // potentialGapCell
299 ENSURE_VALID_ID_ACCESSOR(id);
300 return m_potentialGapCell.at(id);
301 }
302 MInt potentialGapCell(const MInt id) const {
303 ENSURE_VALID_ID_ACCESSOR(id);
304 return m_potentialGapCell.at(id);
305 }
306 // potentialGapCellClose
308 ENSURE_VALID_ID_ACCESSOR(id);
309 return m_potentialGapCellClose.at(id);
310 }
312 ENSURE_VALID_ID_ACCESSOR(id);
313 return m_potentialGapCellClose.at(id);
314 }
315
317 MBool regridTrigger(const MInt id) const { return hasProperty(id, LsCell::RegridTrigger); }
318 BitsetType::reference regridTrigger(const MInt id) { return hasProperty(id, LsCell::RegridTrigger); }
319 MBool nearGap(const MInt id) const { return hasProperty(id, LsCell::NearGap); }
320 BitsetType::reference nearGap(const MInt id) { return hasProperty(id, LsCell::NearGap); }
321 MBool isBndryG(const MInt id) const { return hasProperty(id, LsCell::IsBndryG); }
322 BitsetType::reference isBndryG(const MInt id) { return hasProperty(id, LsCell::IsBndryG); }
323
324 MBool inBand(const MInt id, const MInt set) const { return hasSetProperty(id, set, LsSet::InBand); }
325 BitsetTypeSet::reference inBand(const MInt id, const MInt set) { return hasSetProperty(id, set, LsSet::InBand); }
326 MBool isGBndryCell(const MInt id, const MInt set) const { return hasSetProperty(id, set, LsSet::IsGBndryCell); }
327 BitsetTypeSet::reference isGBndryCell(const MInt id, const MInt set) {
328 return hasSetProperty(id, set, LsSet::IsGBndryCell);
329 }
330 MBool isGZero(const MInt id, const MInt set) const { return hasSetProperty(id, set, LsSet::IsGZero); }
331 BitsetTypeSet::reference isGZero(const MInt id, const MInt set) { return hasSetProperty(id, set, LsSet::IsGZero); }
332 MBool wasGZero(const MInt id, const MInt set) const { return hasSetProperty(id, set, LsSet::WasGZero); }
333 BitsetTypeSet::reference wasGZero(const MInt id, const MInt set) { return hasSetProperty(id, set, LsSet::WasGZero); }
334 MBool hasPositiveSign(const MInt id, const MInt set) const { return hasSetProperty(id, set, LsSet::HasPositiveSign); }
335 BitsetTypeSet::reference hasPositiveSign(const MInt id, const MInt set) {
336 return hasSetProperty(id, set, LsSet::HasPositiveSign);
337 }
338
339 // Property-related accessors
340 public:
341 BitsetType::reference hasProperty(const MInt id, const LsCell p);
342 MBool hasProperty(const MInt id, const LsCell p) const;
343 void resetProperties(const MInt id);
344
345 BitsetTypeSet::reference hasSetProperty(const MInt id, const MInt set, const LsSet p);
346 MBool hasSetProperty(const MInt id, const MInt set, const LsSet p) const;
347 void resetSetProperties(const MInt id, const MInt set);
348
349
350 public:
352 MInt maxNoSets() const { return m_maxNoSets; }
353 MInt maxBodies() const { return m_maxBodies; }
354
355 void setMaxNoSets(const MInt value) {
356 ASSERT(value >= 0, "setMaxNoSets size must be >= 0");
357 m_maxNoSets = value;
358 }
359
360 void setMaxBodiesToCompute(const MInt noBodies) {
361 ASSERT(noBodies >= 0, "setMaxBodiesToCompute size must be >= 0");
362 m_maxBodies = noBodies;
363 }
364
365 void setRotatingLs(const MBool rotatingLS) { m_hasRotatingLs = rotatingLS; }
366
367 void setGapClosing(const MBool gapClosing) { m_hasGapClosing = gapClosing; }
368
369 void setReconstructOldG(const MBool ReconstructOldG) { m_hasReconstructOldG = ReconstructOldG; }
370
371 void setReinit(const MBool Reinit) { m_hasReinit = Reinit; }
372
374 static constexpr MInt noProperties() { return maia::ls::cell::p(LsCell::NumProperties); }
375 static constexpr MInt noSetProperties() { return maia::ls::cell::setP(LsSet::NumSetProperties); }
376
377 private:
378 // Methods required by base class for CRTP
379 void reset();
380 void invalidate(const MInt begin, const MInt end);
381 template <class Functor, class T>
382 void rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end, const MInt destination);
383
384 public:
385 void setLsCollectorType(const MInt mode);
386
387 private:
391
395
398
401
403
407
409
410 // Data containers
412
413 Storage<MLong> m_containingCell; // Has to be MLong because containing cells are converted to globalIds during restart
414 // and load balance.
416
420
424
427
429
432
436};
437
439template <MInt nDim>
441 ASSERT(mode >= 0, "");
442 switch(mode) {
443 case 0: // combustion:
444 {
445 m_hasFExt = true;
446 m_hasNormal = true;
447 m_hasCurvature = true;
448 m_hasOldG = true;
449 m_hasFSRhs = true;
450 m_hasCorrectedBurningVelocity = true;
451 ASSERT(!m_hasBodyId, "");
452 break;
453 }
454 case 1: // semi-lagrange moving bndry without reinitialisation
455 {
456 m_hasBodyId = true;
457 m_hasOldG = true;
458 ASSERT(!m_hasFExt, "");
459 ASSERT(!m_hasNormal, "");
460 ASSERT(!m_hasCurvature, "");
461 ASSERT(!m_hasFSRhs, "");
462 ASSERT(!m_hasCorrectedBurningVelocity, "");
463 break;
464 }
465 case 2: // semi-lagrange moving bndry with reinitialisation
466 {
467 m_hasBodyId = true;
468 m_hasOldG = true;
469 m_hasNormal = true;
470 m_hasCurvature = true;
471 ASSERT(!m_hasFExt, "");
472 ASSERT(!m_hasFSRhs, "");
473 ASSERT(!m_hasCorrectedBurningVelocity, "");
474 break;
475 }
476 case 3: // moving bndry with flameExt-velocity
477 {
478 m_hasBodyId = true;
479 m_hasNormal = true;
480 m_hasCurvature = true;
481 m_hasFExt = true;
482 m_hasOldG = true;
483 m_hasFSRhs = true;
484 m_hasCorrectedBurningVelocity = true;
485 break;
486 }
487 default: {
488 mTerm(1, AT_, "Unknown lsCollector Type!");
489 }
490 }
491}
492
493
495template <MInt nDim>
497 // resetStorage(#of items per cell, Storage<> name);
498 resetStorage(m_maxNoSets, m_gFunction);
499
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);
503 if(hasBodyId()) {
504 resetStorage(m_maxNoSets, m_bodyId);
505 resetStorage(1, m_secondBodyId);
506 }
507 if(hasOldG()) resetStorage(m_maxNoSets, m_oldGFunction);
508
509 if(hasFSRhs() || hasReinit()) {
510 resetStorage(m_maxNoSets * nDim, m_levelSetFunctionSlope);
511 resetStorage(m_maxNoSets, m_levelSetRHS);
512 }
513
514 if(hasCorrectedBurningVelocity()) {
515 resetStorage(m_maxNoSets, m_correctedBurningVelocity);
516 }
517
518 if(hasRotatingLs()) resetStorage(m_maxBodies, m_containingCell);
519 if(hasRotatingLs() && !hasReconstructOldG()) resetStorage(m_maxBodies, m_containingDomain);
520
521 if(hasGapClosing()) {
522 resetStorage(1, m_gapWidth);
523 resetStorage(1, m_potentialGapCell);
524 resetStorage(1, m_potentialGapCellClose);
525 }
526
527 resetStorage(1, m_properties);
528 resetStorage(m_maxNoSets, m_setProperties);
529}
530
531template <MInt nDim>
533 ASSERT(hasFExt(), "Extension velocity not activated in cell collector!");
534 fill_invalid(m_fExt, 0, this->size(), m_maxNoSets * nDim, 0.0);
535}
536
537template <MInt nDim>
539 ASSERT(hasRotatingLs(), "non-rotating");
540 fill_invalid(m_containingCell, 0, this->size(), m_maxBodies, -1);
541}
542
543template <MInt nDim>
545 ASSERT(hasRotatingLs(), "non-rotating");
546 ASSERT(!hasReconstructOldG(), "ReconstructOldG");
547 fill_invalid(m_containingDomain, 0, this->size(), m_maxBodies, -1);
548}
549
551template <MInt nDim>
553 ENSURE_VALID_ID_ACCESSOR(id);
554 ENSURE_VALID_PROPERTY_ACCESSOR(p);
555 return m_properties.at(id)[maia::ls::cell::p(p)];
556}
558template <MInt nDim>
559MBool GCells<nDim>::hasProperty(const MInt id, const LsCell p) const {
560 ENSURE_VALID_ID_ACCESSOR(id);
561 ENSURE_VALID_PROPERTY_ACCESSOR(p);
562 return m_properties.at(id)[maia::ls::cell::p(p)];
563}
565template <MInt nDim>
567 ENSURE_VALID_ID_ACCESSOR(id);
568 m_properties.at(id).reset();
569}
570
572template <MInt nDim>
574 ENSURE_VALID_ID_ACCESSOR(id);
575 // ENSURE_VALID_PROPERTY_ACCESSOR(p);
576 return m_setProperties.at(m_maxNoSets * id + set)[maia::ls::cell::setP(p)];
577}
579template <MInt nDim>
580MBool GCells<nDim>::hasSetProperty(const MInt id, const MInt set, const LsSet p) const {
581 ENSURE_VALID_ID_ACCESSOR(id);
582 // ENSURE_VALID_PROPERTY_ACCESSOR(p);
583 return m_setProperties.at(m_maxNoSets * id + set)[maia::ls::cell::setP(p)];
584}
586template <MInt nDim>
587void GCells<nDim>::resetSetProperties(const MInt id, const MInt set) {
588 ENSURE_VALID_ID_ACCESSOR(id);
589 m_setProperties.at(m_maxNoSets * id + set).reset();
590}
591
593template <MInt nDim>
594void GCells<nDim>::invalidate(const MInt begin, const MInt end) {
595 fill_invalid(m_gFunction, begin, end, m_maxNoSets);
596
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);
600 if(hasBodyId()) {
601 fill_invalid(m_bodyId, begin, end, m_maxNoSets, -1);
602 fill_invalid(m_secondBodyId, begin, end, 1, -1);
603 }
604 if(hasOldG()) fill_invalid(m_oldGFunction, begin, end, m_maxNoSets, 0);
605
606 if(hasFSRhs() || hasReinit()) {
607 fill_invalid(m_levelSetFunctionSlope, begin, end, m_maxNoSets * nDim);
608 fill_invalid(m_levelSetRHS, begin, end, m_maxNoSets);
609 }
610
611 if(hasCorrectedBurningVelocity()) {
612 fill_invalid(m_correctedBurningVelocity, begin, end, m_maxNoSets);
613 }
614
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);
617
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);
622 }
623
624 fill_invalid(m_properties, begin, end, 1, false);
625 fill_invalid(m_setProperties, begin, end, m_maxNoSets, false);
626}
627
629template <MInt nDim>
630template <class Functor, class T>
631void GCells<nDim>::rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end,
632 const MInt destination) {
633 copyData(source.m_gFunction, m_gFunction, c, begin, end, destination, m_maxNoSets);
634
635 if(hasCurvature()) {
636 copyData(source.m_curvature, m_curvature, c, begin, end, destination, m_maxNoSets);
637 }
638 if(hasFExt()) {
639 copyData(source.m_fExt, m_fExt, c, begin, end, destination, m_maxNoSets * nDim);
640 }
641 if(hasNormalVector()) {
642 copyData(source.m_normalVector, m_normalVector, c, begin, end, destination, m_maxNoSets * nDim);
643 }
644 if(hasBodyId()) {
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);
647 }
648 if(hasOldG()) {
649 copyData(source.m_oldGFunction, m_oldGFunction, c, begin, end, destination, m_maxNoSets);
650 }
651
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);
655 }
656
657 if(hasCorrectedBurningVelocity()) {
658 copyData(source.m_correctedBurningVelocity, m_correctedBurningVelocity, c, begin, end, destination, m_maxNoSets);
659 }
660
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);
664
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);
669 }
670
671 copyData(source.m_properties, m_properties, c, begin, end, destination);
672 copyData(source.m_setProperties, m_setProperties, c, begin, end, destination, m_maxNoSets);
673}
674
675} // namespace collector
676} // namespace ls
677} // namespace maia
678
679
680// Undefine macros that should not be used outside this file
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
686
687#endif // ifndef LSCOLLECTOR_H_
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 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 LS cell collector.
maia::ls::cell::BitsetTypeSet BitsetTypeSet
MFloat levelSetRHS(const MInt id, const MInt set) const
MFloat gapWidth(const MInt id) const
MInt containingDomain(const MInt id, const MInt body) const
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)
MFloat & gFunction(const MInt id, const MInt set)
Accessors.
void setReinit(const MBool Reinit)
void setRotatingLs(const MBool rotatingLS)
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.
void reset()
Reset tree, re-create data structures with given capacity, and set size to zero.
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
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:
BitsetTypeSet::reference isGZero(const MInt id, const MInt set)
constexpr MBool hasNormalVector() const
void setMaxBodiesToCompute(const MInt noBodies)
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
MBool hasSetProperty(const MInt id, const MInt set, const LsSet p) const
Accessor for set properties (const version).
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)
Storage< BitsetTypeSet > m_setProperties
constexpr MBool hasCurvature() const
MBool nearGap(const MInt id) const
MBool hasPositiveSign(const MInt id, const MInt set) const
MLong & containingCell(const MInt id, const MInt body)
static constexpr MInt noProperties()
Return number of properties defined for each node.
MBool wasGZero(const MInt id, const MInt set) const
MInt & potentialGapCell(const MInt id)
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
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)
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)
constexpr MBool hasReconstructOldG() const
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
LsSet
LS set Property Labels.
LsCell
LS cell Property Labels.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
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.