31#ifdef MAIA_EXTRA_DEBUG
32#define FCCOLLECTOR_SANITY_CHECKS_ACCESSORS
36#if defined(FCCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
37#define ENSURE_VALID_ID_ACCESSOR(id) \
39 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
41#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
43 MAIA_CONTAINER_ENSURE( \
44 id >= 0 && id < noVariables(), \
45 "variable id = " + std::to_string(id) + " is out-of-bounds [0, " + std::to_string(noVariables()) + ")", AT_); \
47#define ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(id) \
49 MAIA_CONTAINER_ENSURE(id >= 0 && id < noDistributions(), \
50 "distribution id = " + std::to_string(id) + " is out-of-bounds [0, " \
51 + std::to_string(noDistributions()), \
55#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
57 MAIA_CONTAINER_ENSURE(p != FcCell::NumProperties, "Invalid property", AT_); \
60#define ENSURE_VALID_ID_ACCESSOR(id) \
63#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
66#define ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(id) \
69#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
90 static constexpr MInt value() {
return std::numeric_limits<MInt>::min(); }
97#ifdef MAIA_PGI_COMPILER
98 return std::numeric_limits<MFloat>::quiet_NaN();
100 return std::numeric_limits<MFloat>::signaling_NaN();
221 template <
class Functor,
class T>
268 resetStorage(1, m_alpha);
269 resetStorage(1, m_poissonRatio);
270 resetStorage(1, m_invJacobian);
271 resetStorage(1, m_pRfnmnt);
272 resetStorage(1, m_maxSubCellLvl);
273 resetStorage(1, m_noNodesPerCell);
274 resetStorage(1, m_bndId);
275 resetStorage(noNodes(), m_nodeIdsLoc);
276 resetStorage(noNodes(), m_nodeIdsGlob);
277 resetStorage(nDim, m_elementDisplacements);
278 resetStorage(noStrains(), m_elementStrains);
279 resetStorage(maxPRfnmnt() + 2, m_nodePosition);
280 resetStorage(noStresses(), m_elementStresses);
282 resetStorage(noNodes(), m_deltaGamma);
283 resetStorage(noNodes(), m_epsilonBarP);
284 resetStorage(noStrains() * noNodes(), m_nodalStrains);
285 resetStorage(noStresses() * noNodes(), m_nodalStresses);
288 resetStorage(1, m_properties);
296#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
297#error Missing implementation for structure-of-arrays memory layout.
299 ENSURE_VALID_ID_ACCESSOR(
id);
306#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
307#error Missing implementation for structure-of-arrays memory layout.
309 ENSURE_VALID_ID_ACCESSOR(
id);
317#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
318#error Missing implementation for structure-of-arrays memory layout.
320 ENSURE_VALID_ID_ACCESSOR(
id);
321 return m_poissonRatio[
id];
327#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
328#error Missing implementation for structure-of-arrays memory layout.
330 ENSURE_VALID_ID_ACCESSOR(
id);
331 return m_poissonRatio[
id];
338#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
339#error Missing implementation for structure-of-arrays memory layout.
341 ENSURE_VALID_ID_ACCESSOR(
id);
342 return m_invJacobian[
id];
348#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
349#error Missing implementation for structure-of-arrays memory layout.
351 ENSURE_VALID_ID_ACCESSOR(
id);
352 return m_invJacobian[
id];
359#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
360#error Missing implementation for structure-of-arrays memory layout.
362 ENSURE_VALID_ID_ACCESSOR(
id);
363 return m_pRfnmnt[
id];
369#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
370#error Missing implementation for structure-of-arrays memory layout.
372 ENSURE_VALID_ID_ACCESSOR(
id);
373 return m_pRfnmnt[
id];
380#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
381#error Missing implementation for structure-of-arrays memory layout.
383 ENSURE_VALID_ID_ACCESSOR(
id);
384 return m_maxSubCellLvl[
id];
390#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
391#error Missing implementation for structure-of-arrays memory layout.
393 ENSURE_VALID_ID_ACCESSOR(
id);
394 return m_maxSubCellLvl[
id];
401#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
402#error Missing implementation for structure-of-arrays memory layout.
404 ENSURE_VALID_ID_ACCESSOR(
id);
405 return m_noNodesPerCell[
id];
411#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
412#error Missing implementation for structure-of-arrays memory layout.
414 ENSURE_VALID_ID_ACCESSOR(
id);
415 return m_noNodesPerCell[
id];
422#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
423#error Missing implementation for structure-of-arrays memory layout.
425 ENSURE_VALID_ID_ACCESSOR(
id);
432#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
433#error Missing implementation for structure-of-arrays memory layout.
435 ENSURE_VALID_ID_ACCESSOR(
id);
443#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
444#error Missing implementation for structure-of-arrays memory layout.
446 ENSURE_VALID_ID_ACCESSOR(
id);
447 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
448 return m_nodeIdsLoc[
id * noNodes() + eid];
454#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
455#error Missing implementation for structure-of-arrays memory layout.
457 ENSURE_VALID_ID_ACCESSOR(
id);
458 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
459 return m_nodeIdsLoc[
id * noNodes() + eid];
466#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
467#error Missing implementation for structure-of-arrays memory layout.
469 ENSURE_VALID_ID_ACCESSOR(
id);
470 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
471 return m_nodeIdsGlob[
id * noNodes() + eid];
477#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
478#error Missing implementation for structure-of-arrays memory layout.
480 ENSURE_VALID_ID_ACCESSOR(
id);
481 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
482 return m_nodeIdsGlob[
id * noNodes() + eid];
489#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
490#error Missing implementation for structure-of-arrays memory layout.
492 ENSURE_VALID_ID_ACCESSOR(
id);
493 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
494 return m_elementDisplacements[
id * nDim + eid];
500#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
501#error Missing implementation for structure-of-arrays memory layout.
503 ENSURE_VALID_ID_ACCESSOR(
id);
504 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
505 return m_elementDisplacements[
id * nDim + eid];
512#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
513#error Missing implementation for structure-of-arrays memory layout.
515 ENSURE_VALID_ID_ACCESSOR(
id);
516 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
517 return m_elementStrains[
id * noStrains() + eid];
523#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
524#error Missing implementation for structure-of-arrays memory layout.
526 ENSURE_VALID_ID_ACCESSOR(
id);
527 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
528 return m_elementStrains[
id * noStrains() + eid];
535#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
536#error Missing implementation for structure-of-arrays memory layout.
538 ENSURE_VALID_ID_ACCESSOR(
id);
539 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(nid * noStrains() + eid);
540 return m_nodalStrains[
id * noStrains() * noNodes() + nid * noStrains() + eid];
546#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
547#error Missing implementation for structure-of-arrays memory layout.
549 ENSURE_VALID_ID_ACCESSOR(
id);
550 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(nid * noStrains() + eid);
551 return m_nodalStrains[
id * noStrains() * noNodes() + nid * noStrains() + eid];
558#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
559#error Missing implementation for structure-of-arrays memory layout.
561 ENSURE_VALID_ID_ACCESSOR(
id);
562 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
563 return m_elementStresses[
id * noStresses() + eid];
569#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
570#error Missing implementation for structure-of-arrays memory layout.
572 ENSURE_VALID_ID_ACCESSOR(
id);
573 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
574 return m_elementStresses[
id * noStresses() + eid];
581#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
582#error Missing implementation for structure-of-arrays memory layout.
584 ENSURE_VALID_ID_ACCESSOR(
id);
585 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(nid * noStresses() + eid);
586 return m_nodalStresses[
id * noStresses() * noNodes() + nid * noStresses() + eid];
592#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
593#error Missing implementation for structure-of-arrays memory layout.
595 ENSURE_VALID_ID_ACCESSOR(
id);
596 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(nid * noStresses() + eid);
597 return m_nodalStresses[
id * noStresses() * noNodes() + nid * noStresses() + eid];
604#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
605#error Missing implementation for structure-of-arrays memory layout.
607 ENSURE_VALID_ID_ACCESSOR(
id);
608 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
609 return m_nodePosition[
id * (maxPRfnmnt() + 2) + eid];
615#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
616#error Missing implementation for structure-of-arrays memory layout.
618 ENSURE_VALID_ID_ACCESSOR(
id);
619 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
620 return m_nodePosition[
id * (maxPRfnmnt() + 2) + eid];
627#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
628#error Missing implementation for structure-of-arrays memory layout.
630 ENSURE_VALID_ID_ACCESSOR(
id);
631 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
632 return m_deltaGamma[
id * noNodes() + eid];
638#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
639#error Missing implementation for structure-of-arrays memory layout.
641 ENSURE_VALID_ID_ACCESSOR(
id);
642 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
643 return m_deltaGamma[
id * noNodes() + eid];
650#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
651#error Missing implementation for structure-of-arrays memory layout.
653 ENSURE_VALID_ID_ACCESSOR(
id);
654 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
655 return m_epsilonBarP[
id * noNodes() + eid];
661#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
662#error Missing implementation for structure-of-arrays memory layout.
664 ENSURE_VALID_ID_ACCESSOR(
id);
665 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
666 return m_epsilonBarP[
id * noNodes() + eid];
672 ENSURE_VALID_ID_ACCESSOR(
id);
673 ENSURE_VALID_PROPERTY_ACCESSOR(p);
679 ENSURE_VALID_ID_ACCESSOR(
id);
680 ENSURE_VALID_PROPERTY_ACCESSOR(p);
686 ENSURE_VALID_ID_ACCESSOR(
id);
687 m_properties[
id].reset();
693 ENSURE_VALID_ID_ACCESSOR(
id);
694 return m_properties[
id];
700 m_isThermal = isThermal_;
701 m_noVariables = isThermal() ? 1 + 1 : 1;
707 m_isPlastic = isPlastic_;
713 m_maxPRfnmnt = maxPRfnmnt_;
714 m_numberOfNodes = (m_maxPRfnmnt + 2) * (m_maxPRfnmnt + 2);
715 if(nDim == 3) m_numberOfNodes *= (m_maxPRfnmnt + 2);
717 if(maxPRfnmnt_ > 0) m_isPRefined =
true;
724#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
725#error Missing implementation for structure-of-arrays memory layout.
728 fill_invalid(m_alpha, begin, end, 1, 1.);
729 fill_invalid(m_poissonRatio, begin, end, 1, 0.);
730 fill_invalid(m_invJacobian, begin, end, 1, 0.);
731 fill_invalid(m_pRfnmnt, begin, end, 1, 0);
732 fill_invalid(m_maxSubCellLvl, begin, end, 1, 0);
733 fill_invalid(m_noNodesPerCell, begin, end, 1, -1);
734 fill_invalid(m_bndId, begin, end, 1, -1);
735 fill_invalid(m_nodeIdsLoc, begin, end, noNodes(), -1);
736 fill_invalid(m_nodeIdsGlob, begin, end, noNodes(), -1);
737 fill_invalid(m_elementDisplacements, begin, end, nDim, 0.);
738 fill_invalid(m_elementStrains, begin, end, noStrains(), 0.);
739 fill_invalid(m_nodePosition, begin, end, maxPRfnmnt() + 2, 0.);
740 fill_invalid(m_elementStresses, begin, end, noStresses(), 0.);
743 fill_invalid(m_deltaGamma, begin, end, noNodes(), 0.);
744 fill_invalid(m_epsilonBarP, begin, end, noNodes(), 0.);
745 fill_invalid(m_nodalStrains, begin, end, noStrains() * noNodes(), 0.);
746 fill_invalid(m_nodalStresses, begin, end, noStresses() * noNodes(), 0.);
750 fill_invalid(m_properties, begin, end);
756template <
class Functor,
class T>
758 const MInt destination) {
760#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
761#error Missing implementation for structure-of-arrays memory layout.
764 copyData(source.m_alpha, m_alpha, c, begin, end, destination);
765 copyData(source.m_poissonRatio, m_poissonRatio, c, begin, end, destination);
766 copyData(source.m_invJacobian, m_invJacobian, c, begin, end, destination);
767 copyData(source.m_pRfnmnt, m_pRfnmnt, c, begin, end, destination);
768 copyData(source.m_maxSubCellLvl, m_maxSubCellLvl, c, begin, end, destination);
769 copyData(source.m_noNodesPerCell, m_noNodesPerCell, c, begin, end, destination);
770 copyData(source.m_bndId, m_bndId, c, begin, end, destination);
771 copyData(source.m_nodeIdsLoc, m_nodeIdsLoc, c, begin, end, destination, noNodes());
772 copyData(source.m_nodeIdsGlob, m_nodeIdsGlob, c, begin, end, destination, noNodes());
773 copyData(source.m_elementDisplacements, m_elementDisplacements, c, begin, end, destination, nDim);
774 copyData(source.m_elementStrains, m_elementStrains, c, begin, end, destination, noStrains());
775 copyData(source.m_nodePosition, m_nodePosition, c, begin, end, destination, maxPRfnmnt() + 2);
776 copyData(source.m_elementStresses, m_elementStresses, c, begin, end, destination, noStresses());
779 copyData(source.m_deltaGamma, m_deltaGamma, c, begin, end, destination);
780 copyData(source.m_epsilonBarP, m_epsilonBarP, c, begin, end, destination);
781 copyData(source.m_nodalStrains, m_nodalStrains, c, begin, end, destination);
782 copyData(source.m_nodalStresses, m_nodalStresses, c, begin, end, destination);
787 copyData(source.m_properties, m_properties, c, begin, end, destination);
796#undef FCCOLLECTOR_SANITY_CHECKS_ACCESSORS
797#undef ENSURE_VALID_ID_ACCESSOR
798#undef ENSURE_VALID_VARIABLE_ID_ACCESSOR
799#undef ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR
800#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 FC cell collector.
MBool m_isPRefined
Use p-refinement.
constexpr MInt noStrains() const
Return number of strains.
MInt & pRfnmnt(const MInt id)
Accessor for pRfnmnt.
constexpr MInt noVariables() const
Return number of variables.
Storage< MInt > m_maxSubCellLvl
MFloat & nodePosition(const MInt id, const MInt eid)
Accessor for the node position.
MFloat & elementDisplacements(const MInt id, const MInt eid)
Accessor for element displacements.
Storage< MFloat > m_elementDisplacements
constexpr FcCellCollector()=default
Default c'tor does nothing.
MInt & maxSubCellLvl(const MInt id)
Accessor for maxSubCellLvl.
Storage< MFloat > m_elementStresses
Storage< MFloat > m_invJacobian
static constexpr MInt noProperties()
Return number of properties defined for each node.
constexpr MInt noStresses() const
Return number of stresses.
typename maia::fc::collector::Invalid< T > Invalid
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.
BitsetType::reference hasProperty(const MInt id, const FcCell p)
Accessor for properties.
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
MInt & nodeIdsGlob(const MInt id, const MInt eid)
Accessor for global nodeIds.
Storage< MFloat > m_alpha
typename Base::template Storage< T > Storage
Storage< MFloat > m_nodalStrains
Storage< MInt > m_nodeIdsLoc
MFloat & deltaGamma(const MInt id, const MInt eid)
Accessor for delta gamma, a factor in plasticity models.
MFloat & elementStresses(const MInt id, const MInt eid)
Accessor for element stresses, i.e., cell based stresses.
Storage< MFloat > m_deltaGamma
constexpr MInt noNodes() const
Storage< MFloat > m_nodalStresses
void setPlasticity(const MBool isPlastic_)
Allow setting whether to support plastic computations.
MFloat & nodalStrains(const MInt id, const MInt nid, const MInt eid)
Accessor for nodal strains, i.e., node based strains.
Storage< MInt > m_pRfnmnt
constexpr MBool isThermal() const
Return if simulation is thermal.
void setMaxPRfnmnt(const MInt maxPRfnmnt_)
Sets the number of strains.
maia::fc::cell::BitsetType BitsetType
constexpr MBool isPlastic() const
Return if simulation is plastic.
constexpr MBool isPRefined() const
Return if simulation is p-refined.
MFloat & epsilonBarP(const MInt id, const MInt eid)
Accessor for epsilon bar, a factor in plasticity models.
BitsetType & allProperties(const MInt id)
Accessor for properties.
Storage< BitsetType > m_properties
Storage< MFloat > m_elementStrains
MBool m_isThermal
Use thermal model.
void resetProperties(const MInt id)
Reset all properties.
Storage< MFloat > m_epsilonBarP
MFloat & elementStrains(const MInt id, const MInt eid)
Accessor for element strains, i.e., cell based strains.
MBool m_isPlastic
Use plastic model.
MFloat & alpha(const MInt id)
Accessor for alpha.
constexpr MInt maxPRfnmnt() const
Return max pRfnmnt.
Storage< MFloat > m_poissonRatio
MInt m_noVariables
Number of variables.
MFloat & poissonRatio(const MInt id)
Accessor for poissonRatio.
MInt & nodeIdsLoc(const MInt id, const MInt eid)
Accessor for local nodeIds.
Storage< MInt > m_noNodesPerCell
Storage< MFloat > m_nodePosition
void reset()
Reset tree, re-create data structures with given capacity, and set size to zero.
void setThermal(const MBool isThermal_)
Allow setting whether to support thermal computations.
MInt & noNodesPerCell(const MInt id)
Accessor for number of elements.
Storage< MInt > m_nodeIdsGlob
MFloat & nodalStresses(const MInt id, const MInt nid, const MInt eid)
Accessor for nodal stresses, i.e., node based stresses.
MFloat & invJacobian(const MInt id)
Accessor for inverse jacobian.
MInt & bndId(const MInt id)
Accessor for bndId.
FcCell
FC cell Property Labels.
std::bitset< p(FcCell::NumProperties)> BitsetType
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.
maia::fc::cell::BitsetType BitsetType
Underlying bitset type for property storage.
Namespace for auxiliary functions/classes.
static constexpr MFloat value()
static constexpr MInt value()