MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fccellcollector.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 FCCOLLECTOR_H_
8#define FCCOLLECTOR_H_
9
10#include <algorithm>
11#include <bitset>
12#include <type_traits>
13#include <vector>
15#include "INCLUDE/maiamacro.h"
16#include "INCLUDE/maiatypes.h"
17#include "MEMORY/container.h"
18#include "UTIL/functions.h"
19#include "compiler_config.h"
20#include "fccellproperties.h"
21
22// The following macro enables the "Structure-of-Arrays" memory layout for multi-dimensional node
23// variables. This might be beneficial for GPU computations. Default is "Array-of-Structures".
24// Examples (for nodes nN with four children cM each)
25// Array-of-Structures (AOS): n0c0, n0c1, n0c2, n0c3, n1c0, n1c1, n1c2, n1c3, n2c0, n2c1, ...
26// Structure-of-Arrays (SOA): n0c0, n1c0, n2c0, n3c0, ..., n0c1, n1c1, n2c1, n3c1, ..., n0c2, ...
27// #define FCCOLLECTOR_SOA_MEMORY_LAYOUT
28
29// The macro 'FCCOLLECTOR_SANITY_CHECKS_ACCESSORS' enables (potentially very expensive) sanity
30// checks for all accessors. It is enabled for build type "extra_debug".
31#ifdef MAIA_EXTRA_DEBUG
32#define FCCOLLECTOR_SANITY_CHECKS_ACCESSORS
33#endif
34
35// Sanity-checking macros for accessors
36#if defined(FCCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
37#define ENSURE_VALID_ID_ACCESSOR(id) \
38 do { \
39 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
40 } while(false)
41#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
42 do { \
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_); \
46 } while(false)
47#define ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(id) \
48 do { \
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()), \
52 AT_); \
53 } while(false)
54
55#define ENSURE_VALID_PROPERTY_ACCESSOR(p) \
56 do { \
57 MAIA_CONTAINER_ENSURE(p != FcCell::NumProperties, "Invalid property", AT_); \
58 } while(false)
59#else
60#define ENSURE_VALID_ID_ACCESSOR(id) \
61 do { \
62 } while(false)
63#define ENSURE_VALID_VARIABLE_ID_ACCESSOR(id) \
64 do { \
65 } while(false)
66#define ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(id) \
67 do { \
68 } while(false)
69#define ENSURE_VALID_PROPERTY_ACCESSOR(dir) \
70 do { \
71 } while(false)
72#endif
73
74
75// Namespace for auxiliary functions/classes
76namespace maia {
77namespace fc {
78namespace collector {
79
82
83// Type traits for invalid values. These values are used to initialize/erase nodes
84template <class T>
85struct Invalid {};
86
87// Invalid value for ids is 'INT_MIN'
88template <>
89struct Invalid<MInt> {
90 static constexpr MInt value() { return std::numeric_limits<MInt>::min(); }
91};
92
93// Invalid value for floats is 'NaN'
94template <>
95struct Invalid<MFloat> {
96 static constexpr MFloat value() {
97#ifdef MAIA_PGI_COMPILER
98 return std::numeric_limits<MFloat>::quiet_NaN();
99#else
100 return std::numeric_limits<MFloat>::signaling_NaN();
101#endif
102 }
103};
104
105// Invalid value for BitsetProperties is '0'
106template <>
108 static constexpr BitsetType value() { return BitsetType(0); }
109};
110
112template <MInt nDim>
113class FcCellCollector : public maia::container::Container<FcCellCollector<nDim>, Invalid> {
114 // Necessary for CRTP
116
117 // Make base class functions known to use without this pointer
119 using Base::resetStorage;
120 template <class T>
121 using Storage = typename Base::template Storage<T>;
123
124
125 public:
126 // Types
127 template <class T>
129
130 // Constructors
132 constexpr FcCellCollector() = default;
133
134 // Ensure that base class method is found when called from outside
135 using Base::copyData;
136 using Base::fill_invalid;
137 using Base::reset;
138
139 // Accessors
140 MFloat& alpha(const MInt id);
141 MFloat alpha(const MInt id) const;
142 MFloat& poissonRatio(const MInt id);
143 MFloat poissonRatio(const MInt id) const;
144 MFloat& invJacobian(const MInt id);
145 MFloat invJacobian(const MInt id) const;
146 MInt& pRfnmnt(const MInt id);
147 MInt pRfnmnt(const MInt id) const;
148 MInt& maxSubCellLvl(const MInt id);
149 MInt maxSubCellLvl(const MInt id) const;
150 MInt& noNodesPerCell(const MInt id);
151 MInt noNodesPerCell(const MInt id) const;
152 MInt& bndId(const MInt id);
153 MInt bndId(const MInt id) const;
154 MInt& nodeIdsLoc(const MInt id, const MInt eid);
155 MInt nodeIdsLoc(const MInt id, const MInt eid) const;
156 MInt& nodeIdsGlob(const MInt id, const MInt eid);
157 MInt nodeIdsGlob(const MInt id, const MInt eid) const;
158 MFloat& elementDisplacements(const MInt id, const MInt eid);
159 MFloat elementDisplacements(const MInt id, const MInt eid) const;
160 MFloat& elementStrains(const MInt id, const MInt eid);
161 MFloat elementStrains(const MInt id, const MInt eid) const;
162 MFloat& nodalStrains(const MInt id, const MInt nid, const MInt eid);
163 MFloat nodalStrains(const MInt id, const MInt nid, const MInt eid) const;
164 MFloat& elementStresses(const MInt id, const MInt eid);
165 MFloat elementStresses(const MInt id, const MInt eid) const;
166 MFloat& nodalStresses(const MInt id, const MInt nid, const MInt eid);
167 MFloat nodalStresses(const MInt id, const MInt nid, const MInt eid) const;
168 MFloat& nodePosition(const MInt id, const MInt eid);
169 MFloat nodePosition(const MInt id, const MInt eid) const;
170 MFloat& deltaGamma(const MInt id, const MInt eid);
171 MFloat deltaGamma(const MInt id, const MInt eid) const;
172 MFloat& epsilonBarP(const MInt id, const MInt eid);
173 MFloat epsilonBarP(const MInt id, const MInt eid) const;
174
175
176 // Property-related accessors
177 BitsetType::reference hasProperty(const MInt id, const FcCell p);
178 MBool hasProperty(const MInt id, const FcCell p) const;
179 void resetProperties(const MInt id);
180 BitsetType& allProperties(const MInt id);
181
183 void setThermal(const MBool isThermal_);
184
186 void setPlasticity(const MBool isPlastic_);
187
189 void setMaxPRfnmnt(const MInt maxPRfnmnt_);
190
192 constexpr MBool isThermal() const { return m_isThermal; }
193
195 constexpr MBool isPlastic() const { return m_isPlastic; }
196
198 constexpr MBool isPRefined() const { return m_isPRefined; }
199
201 constexpr MInt noVariables() const { return m_noVariables; }
202
204 constexpr MInt noStrains() const { return m_noStrainsPerCell; }
205
207 constexpr MInt noStresses() const { return m_noStressesPerCell; }
208
209 constexpr MInt noNodes() const { return m_numberOfNodes; }
210
212 constexpr MInt maxPRfnmnt() const { return m_maxPRfnmnt; }
213
215 static constexpr MInt noProperties() { return maia::fc::cell::p(FcCell::NumProperties); }
216
217 private:
218 // Methods required by base class for CRTP
219 void reset();
220 void invalidate(const MInt begin, const MInt end);
221 template <class Functor, class T>
222 void rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end, const MInt destination);
223
226
227 MInt m_noStrainsPerCell = (nDim == 2) ? (nDim + 1) : (nDim * 2);
228
230
232
234
237
240
243
244 // Data containers
263};
264
266template <MInt nDim>
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);
281 if(isPlastic()) {
282 resetStorage(noNodes(), m_deltaGamma);
283 resetStorage(noNodes(), m_epsilonBarP);
284 resetStorage(noStrains() * noNodes(), m_nodalStrains);
285 resetStorage(noStresses() * noNodes(), m_nodalStresses);
286 }
287
288 resetStorage(1, m_properties);
289}
290
291
293template <MInt nDim>
295// Prevent accidental compilation without support for SoA layout
296#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
297#error Missing implementation for structure-of-arrays memory layout.
298#endif
299 ENSURE_VALID_ID_ACCESSOR(id);
300 return m_alpha[id];
301}
303template <MInt nDim>
305// Prevent accidental compilation without support for SoA layout
306#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
307#error Missing implementation for structure-of-arrays memory layout.
308#endif
309 ENSURE_VALID_ID_ACCESSOR(id);
310 return m_alpha[id];
311}
312
314template <MInt nDim>
316// Prevent accidental compilation without support for SoA layout
317#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
318#error Missing implementation for structure-of-arrays memory layout.
319#endif
320 ENSURE_VALID_ID_ACCESSOR(id);
321 return m_poissonRatio[id];
322}
324template <MInt nDim>
326// Prevent accidental compilation without support for SoA layout
327#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
328#error Missing implementation for structure-of-arrays memory layout.
329#endif
330 ENSURE_VALID_ID_ACCESSOR(id);
331 return m_poissonRatio[id];
332}
333
335template <MInt nDim>
337// Prevent accidental compilation without support for SoA layout
338#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
339#error Missing implementation for structure-of-arrays memory layout.
340#endif
341 ENSURE_VALID_ID_ACCESSOR(id);
342 return m_invJacobian[id];
343}
345template <MInt nDim>
347// Prevent accidental compilation without support for SoA layout
348#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
349#error Missing implementation for structure-of-arrays memory layout.
350#endif
351 ENSURE_VALID_ID_ACCESSOR(id);
352 return m_invJacobian[id];
353}
354
356template <MInt nDim>
358// Prevent accidental compilation without support for SoA layout
359#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
360#error Missing implementation for structure-of-arrays memory layout.
361#endif
362 ENSURE_VALID_ID_ACCESSOR(id);
363 return m_pRfnmnt[id];
364}
366template <MInt nDim>
368// Prevent accidental compilation without support for SoA layout
369#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
370#error Missing implementation for structure-of-arrays memory layout.
371#endif
372 ENSURE_VALID_ID_ACCESSOR(id);
373 return m_pRfnmnt[id];
374}
375
377template <MInt nDim>
379// Prevent accidental compilation without support for SoA layout
380#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
381#error Missing implementation for structure-of-arrays memory layout.
382#endif
383 ENSURE_VALID_ID_ACCESSOR(id);
384 return m_maxSubCellLvl[id];
385}
387template <MInt nDim>
389// Prevent accidental compilation without support for SoA layout
390#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
391#error Missing implementation for structure-of-arrays memory layout.
392#endif
393 ENSURE_VALID_ID_ACCESSOR(id);
394 return m_maxSubCellLvl[id];
395}
396
398template <MInt nDim>
400 // Prevent accidental compilation without support for SoA layout
401#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
402#error Missing implementation for structure-of-arrays memory layout.
403#endif
404 ENSURE_VALID_ID_ACCESSOR(id);
405 return m_noNodesPerCell[id];
406}
408template <MInt nDim>
410 // Prevent accidental compilation without support for SoA layout
411#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
412#error Missing implementation for structure-of-arrays memory layout.
413#endif
414 ENSURE_VALID_ID_ACCESSOR(id);
415 return m_noNodesPerCell[id];
416}
417
419template <MInt nDim>
421 // Prevent accidental compilation without support for SoA layout
422#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
423#error Missing implementation for structure-of-arrays memory layout.
424#endif
425 ENSURE_VALID_ID_ACCESSOR(id);
426 return m_bndId[id];
427}
429template <MInt nDim>
431 // Prevent accidental compilation without support for SoA layout
432#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
433#error Missing implementation for structure-of-arrays memory layout.
434#endif
435 ENSURE_VALID_ID_ACCESSOR(id);
436 return m_bndId[id];
437}
438
440template <MInt nDim>
442 // Prevent accidental compilation without support for SoA layout
443#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
444#error Missing implementation for structure-of-arrays memory layout.
445#endif
446 ENSURE_VALID_ID_ACCESSOR(id);
447 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
448 return m_nodeIdsLoc[id * noNodes() + eid];
449}
451template <MInt nDim>
453 // Prevent accidental compilation without support for SoA layout
454#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
455#error Missing implementation for structure-of-arrays memory layout.
456#endif
457 ENSURE_VALID_ID_ACCESSOR(id);
458 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
459 return m_nodeIdsLoc[id * noNodes() + eid];
460}
461
463template <MInt nDim>
465 // Prevent accidental compilation without support for SoA layout
466#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
467#error Missing implementation for structure-of-arrays memory layout.
468#endif
469 ENSURE_VALID_ID_ACCESSOR(id);
470 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
471 return m_nodeIdsGlob[id * noNodes() + eid];
472}
474template <MInt nDim>
476 // Prevent accidental compilation without support for SoA layout
477#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
478#error Missing implementation for structure-of-arrays memory layout.
479#endif
480 ENSURE_VALID_ID_ACCESSOR(id);
481 ENSURE_VALID_VARIABLE_ID_ACCESSOR(eid);
482 return m_nodeIdsGlob[id * noNodes() + eid];
483}
484
486template <MInt nDim>
488 // Prevent accidental compilation without support for SoA layout
489#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
490#error Missing implementation for structure-of-arrays memory layout.
491#endif
492 ENSURE_VALID_ID_ACCESSOR(id);
493 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
494 return m_elementDisplacements[id * nDim + eid];
495}
497template <MInt nDim>
499 // Prevent accidental compilation without support for SoA layout
500#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
501#error Missing implementation for structure-of-arrays memory layout.
502#endif
503 ENSURE_VALID_ID_ACCESSOR(id);
504 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
505 return m_elementDisplacements[id * nDim + eid];
506}
507
509template <MInt nDim>
511 // Prevent accidental compilation without support for SoA layout
512#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
513#error Missing implementation for structure-of-arrays memory layout.
514#endif
515 ENSURE_VALID_ID_ACCESSOR(id);
516 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
517 return m_elementStrains[id * noStrains() + eid];
518}
520template <MInt nDim>
522 // Prevent accidental compilation without support for SoA layout
523#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
524#error Missing implementation for structure-of-arrays memory layout.
525#endif
526 ENSURE_VALID_ID_ACCESSOR(id);
527 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
528 return m_elementStrains[id * noStrains() + eid];
529}
530
532template <MInt nDim>
533MFloat& FcCellCollector<nDim>::nodalStrains(const MInt id, const MInt nid, const MInt eid) {
534 // Prevent accidental compilation without support for SoA layout
535#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
536#error Missing implementation for structure-of-arrays memory layout.
537#endif
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];
541}
543template <MInt nDim>
544MFloat FcCellCollector<nDim>::nodalStrains(const MInt id, const MInt nid, const MInt eid) const {
545 // Prevent accidental compilation without support for SoA layout
546#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
547#error Missing implementation for structure-of-arrays memory layout.
548#endif
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];
552}
553
555template <MInt nDim>
557 // Prevent accidental compilation without support for SoA layout
558#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
559#error Missing implementation for structure-of-arrays memory layout.
560#endif
561 ENSURE_VALID_ID_ACCESSOR(id);
562 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
563 return m_elementStresses[id * noStresses() + eid];
564}
566template <MInt nDim>
568 // Prevent accidental compilation without support for SoA layout
569#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
570#error Missing implementation for structure-of-arrays memory layout.
571#endif
572 ENSURE_VALID_ID_ACCESSOR(id);
573 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
574 return m_elementStresses[id * noStresses() + eid];
575}
576
578template <MInt nDim>
579MFloat& FcCellCollector<nDim>::nodalStresses(const MInt id, const MInt nid, const MInt eid) {
580 // Prevent accidental compilation without support for SoA layout
581#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
582#error Missing implementation for structure-of-arrays memory layout.
583#endif
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];
587}
589template <MInt nDim>
590MFloat FcCellCollector<nDim>::nodalStresses(const MInt id, const MInt nid, const MInt eid) const {
591 // Prevent accidental compilation without support for SoA layout
592#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
593#error Missing implementation for structure-of-arrays memory layout.
594#endif
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];
598}
599
601template <MInt nDim>
603 // Prevent accidental compilation without support for SoA layout
604#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
605#error Missing implementation for structure-of-arrays memory layout.
606#endif
607 ENSURE_VALID_ID_ACCESSOR(id);
608 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
609 return m_nodePosition[id * (maxPRfnmnt() + 2) + eid];
610}
612template <MInt nDim>
614 // Prevent accidental compilation without support for SoA layout
615#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
616#error Missing implementation for structure-of-arrays memory layout.
617#endif
618 ENSURE_VALID_ID_ACCESSOR(id);
619 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
620 return m_nodePosition[id * (maxPRfnmnt() + 2) + eid];
621}
622
624template <MInt nDim>
626 // Prevent accidental compilation without support for SoA layout
627#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
628#error Missing implementation for structure-of-arrays memory layout.
629#endif
630 ENSURE_VALID_ID_ACCESSOR(id);
631 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
632 return m_deltaGamma[id * noNodes() + eid];
633}
635template <MInt nDim>
637 // Prevent accidental compilation without support for SoA layout
638#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
639#error Missing implementation for structure-of-arrays memory layout.
640#endif
641 ENSURE_VALID_ID_ACCESSOR(id);
642 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
643 return m_deltaGamma[id * noNodes() + eid];
644}
645
647template <MInt nDim>
649 // Prevent accidental compilation without support for SoA layout
650#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
651#error Missing implementation for structure-of-arrays memory layout.
652#endif
653 ENSURE_VALID_ID_ACCESSOR(id);
654 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
655 return m_epsilonBarP[id * noNodes() + eid];
656}
658template <MInt nDim>
660 // Prevent accidental compilation without support for SoA layout
661#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
662#error Missing implementation for structure-of-arrays memory layout.
663#endif
664 ENSURE_VALID_ID_ACCESSOR(id);
665 ENSURE_VALID_DISTRIBUTION_ID_ACCESSOR(eid);
666 return m_epsilonBarP[id * noNodes() + eid];
667}
668
670template <MInt nDim>
672 ENSURE_VALID_ID_ACCESSOR(id);
673 ENSURE_VALID_PROPERTY_ACCESSOR(p);
674 return m_properties[id][maia::fc::cell::p(p)];
675}
677template <MInt nDim>
679 ENSURE_VALID_ID_ACCESSOR(id);
680 ENSURE_VALID_PROPERTY_ACCESSOR(p);
681 return m_properties[id][maia::fc::cell::p(p)];
682}
684template <MInt nDim>
686 ENSURE_VALID_ID_ACCESSOR(id);
687 m_properties[id].reset();
688}
689
691template <MInt nDim>
693 ENSURE_VALID_ID_ACCESSOR(id);
694 return m_properties[id];
695}
696
698template <MInt nDim>
700 m_isThermal = isThermal_;
701 m_noVariables = isThermal() ? 1 + 1 : 1;
702}
703
705template <MInt nDim>
707 m_isPlastic = isPlastic_;
708}
709
711template <MInt nDim>
713 m_maxPRfnmnt = maxPRfnmnt_;
714 m_numberOfNodes = (m_maxPRfnmnt + 2) * (m_maxPRfnmnt + 2);
715 if(nDim == 3) m_numberOfNodes *= (m_maxPRfnmnt + 2);
716
717 if(maxPRfnmnt_ > 0) m_isPRefined = true;
718}
719
721template <MInt nDim>
722void FcCellCollector<nDim>::invalidate(const MInt begin, const MInt end) {
723// Prevent accidental compilation without support for SoA layout
724#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
725#error Missing implementation for structure-of-arrays memory layout.
726#endif
727
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.);
741
742 if(isPlastic()) {
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.);
747 }
748
749 // Properties
750 fill_invalid(m_properties, begin, end);
751}
752
753
755template <MInt nDim>
756template <class Functor, class T>
757void FcCellCollector<nDim>::rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end,
758 const MInt destination) {
759// Prevent accidental compilation without support for SoA layout
760#ifdef FCCOLLECTOR_SOA_MEMORY_LAYOUT
761#error Missing implementation for structure-of-arrays memory layout.
762#endif
763
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());
777
778 if(isPlastic()) {
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);
783 }
784
785
786 // Properties
787 copyData(source.m_properties, m_properties, c, begin, end, destination);
788}
789
790} // namespace collector
791} // namespace fc
792} // namespace maia
793
794
795// Undefine macros that should not be used outside this file
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
801
802#endif // ifndef FCCOLLECTOR_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 FC cell collector.
constexpr MInt noStrains() const
Return number of strains.
MInt & pRfnmnt(const MInt id)
Accessor for pRfnmnt.
constexpr MInt noVariables() const
Return number of variables.
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.
constexpr FcCellCollector()=default
Default c'tor does nothing.
MInt & maxSubCellLvl(const MInt id)
Accessor for maxSubCellLvl.
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.
typename Base::template Storage< T > Storage
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.
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.
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.
MBool m_isThermal
Use thermal model.
void resetProperties(const MInt id)
Reset all properties.
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.
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.
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.
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.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
MInt id
Definition: maiatypes.h:71
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.