MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
Collector< T > Class Template Reference

#include <collector.h>

Inheritance diagram for Collector< T >:
[legend]

Public Member Functions

 Collector (MLong maxSize, MInt dimension, MFloat dummy, MInt maxNoSets)
 
 Collector (MLong maxSize, MInt dimension, MInt distributions, MInt distributions1)
 
 Collector (MLong maxSize, MInt dimension, MInt distributions, MInt distributions1, MInt maxNoSurfaces, MInt dummy1)
 
 Collector (MLong maxSize, MInt dimension, MInt distributions, MInt dummy, MInt dummy2)
 
 Collector (MLong maxSize, MInt dimension, MInt distributions)
 
 Collector (MLong maxSize, MInt dimension)
 
 Collector (MLong maxSize=1052000)
 
 ~Collector ()
 
MInt size ()
 
MInt maxSize ()
 
void append ()
 
MLong memoryUseage ()
 
T * operator[] (MInt index)
 
MInt setSize (MInt inputSize)
 
MInt resetSize (MInt inputSize)
 
char * getRawPointer ()
 

Public Attributes

T * a
 
MLong m_rawMemoryCounter
 

Private Member Functions

void init (const MLong maxSize_)
 
void allocMemory ()
 Allocates collector memory. More...
 
void allocMemoryAndInitElements ()
 Allocates collector memory and initializes elements. More...
 

Private Attributes

MLong m_maxSize
 
MInt m_size
 
char * m_rawMemory = nullptr
 
MLong m_usedMemory
 
MInt m_distribution
 
MInt m_staticElementSize
 

Detailed Description

template<typename T>
class Collector< T >

Definition at line 14 of file collector.h.

Constructor & Destructor Documentation

◆ Collector() [1/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize,
MInt  dimension,
MFloat  dummy,
MInt  maxNoSets 
)

Definition at line 146 of file collector.h.

146 {
147 init(inputMaxSize);
148 T::init(dimension, flameSpeed, inputMaxSize, maxNoSets);
150}
void allocMemoryAndInitElements()
Allocates collector memory and initializes elements.
Definition: collector.h:79
void init(const MLong maxSize_)
Definition: collector.h:59

◆ Collector() [2/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize,
MInt  dimension,
MInt  distributions,
MInt  distributions1 
)

Definition at line 122 of file collector.h.

122 {
123 init(inputMaxSize);
124 T::init(dimension, distributions, distributions1, inputMaxSize + 1);
126}

◆ Collector() [3/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize,
MInt  dimension,
MInt  distributions,
MInt  distributions1,
MInt  maxNoSurfaces,
MInt  dummy1 
)

Definition at line 138 of file collector.h.

139 {
140 init(inputMaxSize);
141 T::init(dimension, distributions, distributions1, inputMaxSize + 1, maxNoSurfaces);
143}

◆ Collector() [4/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize,
MInt  dimension,
MInt  distributions,
MInt  dummy,
MInt  dummy2 
)

Definition at line 130 of file collector.h.

130 {
131 init(inputMaxSize);
132 T::init(dimension, distributions, distributions1, inputMaxSize + 1, dummy2);
134}

◆ Collector() [5/7]

template<typename T >
Collector< T >::Collector ( MLong  inputMaxSize,
MInt  dimension,
MInt  dummy 
)

Overloading for LB cells, which require the distributions as parameter.

Also used for:

  • DG: m_elements

Definition at line 113 of file collector.h.

113 {
114 init(inputMaxSize);
115 T::init(dimension, dummy, inputMaxSize);
117}

◆ Collector() [6/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize,
MInt  dimension 
)

◆ Collector() [7/7]

template<typename T >
Collector< T >::Collector ( MLong  maxSize = 1052000)

Definition at line 97 of file collector.h.

97 {
98 init(inputMaxSize);
100 for(MInt i = 0; i < (inputMaxSize + 1); i++) {
101 a[i].allocateElements((void*)(m_rawMemory + m_rawMemoryCounter));
103 }
104}
void allocMemory()
Allocates collector memory.
Definition: collector.h:66
char * m_rawMemory
Definition: collector.h:55
MInt m_staticElementSize
Definition: collector.h:58
MLong m_rawMemoryCounter
Definition: collector.h:38
int32_t MInt
Definition: maiatypes.h:62
Definition: contexttypes.h:19

◆ ~Collector()

template<typename T >
Collector< T >::~Collector ( )
inline

Definition at line 25 of file collector.h.

25 {
26 delete[] a;
27 delete[] m_rawMemory;
28 };

Member Function Documentation

◆ allocMemory()

template<typename T >
void Collector< T >::allocMemory ( )
inlineprivate

Definition at line 66 of file collector.h.

66 {
67 m_staticElementSize = T::staticElementSize();
68 // An extra element is allocated in m_rawMemory to ensure that all element
69 // variables are inside memory even when the all need to be realigned.
71 a = new T[m_maxSize + 1];
72 if(m_usedMemory > 0) {
73 m_rawMemory = new char[m_usedMemory];
74 } else {
75 m_rawMemory = nullptr;
76 }
77 }
MLong m_maxSize
Definition: collector.h:53
MLong m_usedMemory
Definition: collector.h:56

◆ allocMemoryAndInitElements()

template<typename T >
void Collector< T >::allocMemoryAndInitElements ( )
inlineprivate

Definition at line 79 of file collector.h.

79 {
81 for(MInt i = 0; i < m_maxSize + 1; i++) {
82 a[i].allocateElements((void*)(m_rawMemory + m_rawMemoryCounter), (void*)m_rawMemory, i);
84 }
85 }

◆ append()

template<typename T >
void Collector< T >::append

Definition at line 153 of file collector.h.

153 {
154 if(m_size < m_maxSize) {
155 m_size++;
156 } else {
157 std::stringstream errorMessage;
158 errorMessage << " Error in collector, maxSize reached ( " << m_maxSize << " elements ).";
159 mTerm(1, AT_, errorMessage.str());
160 }
161}
MInt m_size
Definition: collector.h:54
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

◆ getRawPointer()

template<typename T >
char * Collector< T >::getRawPointer

Definition at line 164 of file collector.h.

164 {
165 return m_rawMemory;
166}

◆ init()

template<typename T >
void Collector< T >::init ( const MLong  maxSize_)
inlineprivate

Definition at line 59 of file collector.h.

59 {
60 m_size = 0;
62 m_maxSize = maxSize_;
63 }

◆ maxSize()

template<typename T >
MInt Collector< T >::maxSize ( )
inline

Definition at line 31 of file collector.h.

31{ return (MInt)m_maxSize; };

◆ memoryUseage()

template<typename T >
MLong Collector< T >::memoryUseage ( )
inline

Definition at line 34 of file collector.h.

34{ return (MLong)(m_usedMemory + (m_maxSize + 1) * sizeof(T)); };
int64_t MLong
Definition: maiatypes.h:64

◆ operator[]()

template<typename T >
T * Collector< T >::operator[] ( MInt  index)

Definition at line 170 of file collector.h.

170 {
171 return &a[index];
172}
IdType index(const FloatType *const x, const IdType level)
Return Hilbert index for given location and level in 2D or 3D.
Definition: hilbert.h:165

◆ resetSize()

template<typename T >
MInt Collector< T >::resetSize ( MInt  inputSize)
inline

Definition at line 45 of file collector.h.

45 {
46 m_size = inputSize;
47 return (MInt)inputSize;
48 }

◆ setSize()

template<typename T >
MInt Collector< T >::setSize ( MInt  inputSize)
inline

Definition at line 40 of file collector.h.

40 {
41 if(inputSize < m_size) m_size = inputSize;
42 return (MInt)inputSize;
43 }

◆ size()

template<typename T >
MInt Collector< T >::size ( )
inline

Definition at line 29 of file collector.h.

29{ return (MInt)m_size; };

Member Data Documentation

◆ a

template<typename T >
T* Collector< T >::a

Definition at line 37 of file collector.h.

◆ m_distribution

template<typename T >
MInt Collector< T >::m_distribution
private

Definition at line 57 of file collector.h.

◆ m_maxSize

template<typename T >
MLong Collector< T >::m_maxSize
private

Definition at line 53 of file collector.h.

◆ m_rawMemory

template<typename T >
char* Collector< T >::m_rawMemory = nullptr
private

Definition at line 55 of file collector.h.

◆ m_rawMemoryCounter

template<typename T >
MLong Collector< T >::m_rawMemoryCounter

Definition at line 38 of file collector.h.

◆ m_size

template<typename T >
MInt Collector< T >::m_size
private

Definition at line 54 of file collector.h.

◆ m_staticElementSize

template<typename T >
MInt Collector< T >::m_staticElementSize
private

Definition at line 58 of file collector.h.

◆ m_usedMemory

template<typename T >
MLong Collector< T >::m_usedMemory
private

Definition at line 56 of file collector.h.


The documentation for this class was generated from the following files: