24#ifdef MAIA_EXTRA_DEBUG
25#define LPTCOLLECTOR_SANITY_CHECKS_ACCESSORS
28#ifdef LPTCOLLECTOR_SOA_MEMORY_LAYOUT
29#error Missing implementation for structure-of-arrays memory layout.
33#if defined(MAIA_ASSERT_ACCESSORS) || defined(LPTCOLLECTOR_SANITY_CHECKS_ACCESSORS)
34#define ENSURE_VALID_ID_ACCESSOR(id) \
36 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
38#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
40 MAIA_CONTAINER_ENSURE( \
41 (id) >= 0 && (id) < maxNoSets(), \
42 "set id = " + std::to_string(id) + "is out-of-bounds [0, " + std::to_string(maxNoSets()) + ")", AT_); \
44#define ENSURE_VALID_DIM_ID_ACCESSOR(dim) \
46 MAIA_CONTAINER_ENSURE(dim >= 0 && dim < nDim, \
47 "dim = " + std::to_string(dim) + " is out-of-bounds [0, " + std::to_string(nDim) + ")", \
50#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
52 MAIA_CONTAINER_ENSURE(p != LptCell::NumProperties, "Invalid property", AT_); \
55#define ENSURE_VALID_ID_ACCESSOR(id) \
58#define ENSURE_VALID_SET_ID_ACCESSOR(id) \
61#define ENSURE_VALID_DIM_ID_ACCESSOR(id) \
64#define ENSURE_VALID_PROPERTY_ACCESSOR(dim) \
85 static constexpr MInt value() {
return std::numeric_limits<MInt>::min(); }
92#ifdef MAIA_PGI_COMPILER
93 return std::numeric_limits<MFloat>::quiet_NaN();
95 return std::numeric_limits<MFloat>::signaling_NaN();
185 template <
class Functor,
class T>
224 m_massCoupling = mass;
225 m_momentumCoupling = momentum;
226 m_heatCoupling = heat;
233 resetStorage(1, m_properties);
234 resetStorage(1, m_noParticles);
235 resetStorage(1, m_noEllipsoids);
236 resetStorage(1, m_volumeFraction);
237 resetStorage(1, m_bndryCellId);
239 resetStorage(noVars(), m_variables);
241 resetStorage(noSpecies(), m_species);
243 if(hasMassCoupling()) {
244 resetStorage(1, m_massFlux);
246 if(hasHeatCoupling()) resetStorage(1, m_heatFlux);
247 if(hasMomentumCoupling()) {
248 resetStorage(nDim, m_momentumFlux);
249 resetStorage(1, m_workFlux);
252 resetStorage(nDim * nDim, m_velocitySlopes);
259 ENSURE_VALID_ID_ACCESSOR(
id);
260 ENSURE_VALID_PROPERTY_ACCESSOR(p);
266 ENSURE_VALID_ID_ACCESSOR(
id);
267 ENSURE_VALID_PROPERTY_ACCESSOR(p);
273 ENSURE_VALID_ID_ACCESSOR(
id);
274 m_properties.at(
id).reset();
279 ENSURE_VALID_ID_ACCESSOR(
id);
280 return m_properties[
id];
286 ENSURE_VALID_ID_ACCESSOR(
id);
287 return m_volumeFraction[
id];
291 ENSURE_VALID_ID_ACCESSOR(
id);
292 return m_volumeFraction[
id];
297 ENSURE_VALID_ID_ACCESSOR(
id);
298 return m_noParticles[
id];
302 ENSURE_VALID_ID_ACCESSOR(
id);
303 return m_noParticles[
id];
309 ENSURE_VALID_ID_ACCESSOR(
id);
310 return m_noEllipsoids[
id];
314 ENSURE_VALID_ID_ACCESSOR(
id);
315 return m_noEllipsoids[
id];
321 ENSURE_VALID_ID_ACCESSOR(
id);
322 return m_bndryCellId[
id];
326 ENSURE_VALID_ID_ACCESSOR(
id);
327 return m_bndryCellId[
id];
333 ENSURE_VALID_ID_ACCESSOR(
id);
334 return m_variables[
id * noVars() + var];
338 ENSURE_VALID_ID_ACCESSOR(
id);
339 return m_variables[
id * noVars() + var];
345 ENSURE_VALID_ID_ACCESSOR(
id);
346 return m_species[
id];
350 ENSURE_VALID_ID_ACCESSOR(
id);
351 return m_species[
id];
357 ENSURE_VALID_ID_ACCESSOR(
id);
358 return m_massFlux[
id];
362 ENSURE_VALID_ID_ACCESSOR(
id);
363 return m_massFlux[
id];
368 ENSURE_VALID_ID_ACCESSOR(
id);
369 ENSURE_VALID_DIM_ID_ACCESSOR(dim);
370 return m_momentumFlux[
id * nDim + dim];
374 ENSURE_VALID_ID_ACCESSOR(
id);
375 ENSURE_VALID_DIM_ID_ACCESSOR(dim);
376 return m_momentumFlux[
id * nDim + dim];
381 ENSURE_VALID_ID_ACCESSOR(
id);
382 return m_workFlux[
id];
386 ENSURE_VALID_ID_ACCESSOR(
id);
387 return m_workFlux[
id];
393 ENSURE_VALID_ID_ACCESSOR(
id);
394 return m_heatFlux[
id];
398 ENSURE_VALID_ID_ACCESSOR(
id);
399 return m_heatFlux[
id];
404 ENSURE_VALID_ID_ACCESSOR(
id);
405 ENSURE_VALID_DIM_ID_ACCESSOR(dir);
406 return m_velocitySlopes[
id * nDim * nDim + varId * nDim + dir];
411 ENSURE_VALID_ID_ACCESSOR(
id);
412 ENSURE_VALID_DIM_ID_ACCESSOR(dir);
413 return m_velocitySlopes[
id * nDim * nDim + varId * nDim + dir];
420 fill_invalid(m_properties, begin, end, 1,
false);
421 fill_invalid(m_volumeFraction, begin, end);
422 fill_invalid(m_noParticles, begin, end);
423 fill_invalid(m_noEllipsoids, begin, end);
424 fill_invalid(m_bndryCellId, begin, end);
426 fill_invalid(m_variables, begin, end, noVars());
427 fill_invalid(m_species, begin, end, noSpecies());
429 if(hasMassCoupling()) {
430 fill_invalid(m_massFlux, begin, end);
432 if(hasHeatCoupling()) fill_invalid(m_heatFlux, begin, end);
433 if(hasMomentumCoupling()) {
434 fill_invalid(m_workFlux, begin, end);
435 fill_invalid(m_momentumFlux, begin, end, nDim);
438 fill_invalid(m_velocitySlopes, begin, end, nDim * nDim);
444template <
class Functor,
class T>
446 const MInt destination) {
447 copyData(source.m_properties, m_properties, c, begin, end, destination);
448 copyData(source.m_volumeFraction, m_volumeFraction, c, begin, end, destination);
449 copyData(source.m_noParticles, m_noParticles, c, begin, end, destination);
450 copyData(source.m_noEllipsoids, m_noEllipsoids, c, begin, end, destination);
451 copyData(source.m_bndryCellId, m_bndryCellId, c, begin, end, destination);
453 copyData(source.m_variables, m_variables, c, begin, end, destination, noVars());
454 copyData(source.m_species, m_species, c, begin, end, destination, noSpecies());
456 if(hasMassCoupling()) {
457 copyData(source.m_massFlux, m_massFlux, c, begin, end, destination);
459 if(hasHeatCoupling()) copyData(source.m_heatFlux, m_heatFlux, c, begin, end, destination);
460 if(hasMomentumCoupling()) {
461 copyData(source.m_workFlux, m_workFlux, c, begin, end, destination);
462 copyData(source.m_momentumFlux, m_momentumFlux, c, begin, end, destination, nDim);
465 copyData(source.m_velocitySlopes, m_velocitySlopes, c, begin, end, destination, nDim * nDim);
475#undef LPTCOLLECTOR_SANITY_CHECKS_ACCESSORS
476#undef ENSURE_VALID_ID_ACCESSOR
477#undef ENSURE_VALID_ID_ACCESSOR
478#undef ENSURE_VALID_SET_ID_ACCESSOR
479#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 LPT cell collector.
Storage< MFloat > m_momentumFlux
Storage< MFloat > m_massFlux
MFloat & momentumFlux(const MInt id, const MInt dim)
Accessor for momentumFlux.
Storage< MInt > m_noEllipsoids
Storage< MFloat > m_workFlux
MInt noEllipsoids(const MInt id) const
void setLptCollectorSlopes()
Storage< BitsetType > m_properties
constexpr MBool hasHeatCoupling() const
Storage< MFloat > m_volumeFraction
Storage< MFloat > m_variables
static constexpr MInt m_noVariables
MFloat & velocitySlope(const MInt id, const MInt varId, const MInt dim)
BitsetType & properties(const MInt id)
Accessor for properties.
constexpr MBool hasMassCoupling() const
MInt bndryCellId(const MInt id) const
constexpr LptCells()=default
Default c'tor does nothing.
void reset()
Reset tree, re-create data structures with given capacity, and set size to zero.
Storage< MInt > m_bndryCellId
Storage< MFloat > m_species
Storage< MFloat > m_heatFlux
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 MBool hasMomentumCoupling() const
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
MFloat fluidSpecies(const MInt id) const
MFloat volumeFraction(const MInt id) const
MFloat & heatFlux(const MInt id)
Accessor for heatFlux.
constexpr MInt noVars() const
MInt noParticles(const MInt id) const
MFloat & massFlux(const MInt id)
Accessor for massFlux.
typename Base::template Storage< T > Storage
constexpr MBool hasSlopes() const
BitsetType::reference hasProperty(const MInt id, const LptCell p)
Accessor for properties.
maia::lpt::cell::BitsetType BitsetType
typename maia::lpt::collector::Invalid< T > Invalid
Storage< MInt > m_noParticles
MFloat & workFlux(const MInt id)
Accessor for workFlux.
MFloat fluidVariable(const MInt id, const MInt var) const
void setLptCollectorCoupling(const MBool mass, const MBool momentum, const MBool heat)
Set the lpt-collector type.
Storage< MFloat > m_velocitySlopes
void resetProperties(const MInt id)
Reset all properties.
void setLptCollectorNoSpecies(const MInt noSpecies)
constexpr MInt noSpecies() const
LptCell
Lpt cell Property Labels.
constexpr std::underlying_type< LptCell >::type p(const LptCell property)
Converts property name to underlying integer value.
std::bitset< p(LptCell::NumProperties)> BitsetType
maia::lpt::cell::BitsetType BitsetType
Underlying bitset type for property storage.
Namespace for auxiliary functions/classes.
static constexpr MFloat value()
static constexpr MInt value()