chombo-discharge
CD_EBAMRDataImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_EBAMRDataImplem_H
13 #define CD_EBAMRDataImplem_H
14 
15 // Chombo includes
16 #include <CH_Timer.H>
17 
18 // Our includes
19 #include <CD_EBAMRData.H>
20 #include <CD_NamespaceHeader.H>
21 
22 template <typename T>
24 {
25  CH_TIME("EBAMRData<T>::EBAMRData()");
26  m_reserved = false;
27 }
28 
29 template <typename T>
30 EBAMRData<T>::EBAMRData(const int a_size) noexcept : EBAMRData<T>()
31 {
32  CH_TIME("EBAMRData<T>::EBAMRData(int)");
33 
34  m_data.resize(a_size);
35 }
36 
37 template <typename T>
39 {
40  CH_TIME("EBAMRData<T>::~EBAMRData()");
41 }
42 
43 template <typename T>
44 RefCountedPtr<LevelData<T>>&
45 EBAMRData<T>::operator[](int a_level) noexcept
46 {
47  return m_data[a_level];
48 }
49 
50 template <typename T>
51 const RefCountedPtr<LevelData<T>>&
52 EBAMRData<T>::operator[](int a_level) const noexcept
53 {
54  return m_data[a_level];
55 }
56 
57 template <typename T>
58 void
59 EBAMRData<T>::resize(const int a_size) noexcept
60 {
61  m_data.resize(a_size);
62 }
63 
64 template <typename T>
65 int
66 EBAMRData<T>::size() const noexcept
67 {
68  return m_data.size();
69 }
70 
71 template <typename T>
72 void
74 {
75  for (int lvl = 0; lvl < m_data.size(); lvl++) {
76  m_data[lvl] = RefCountedPtr<LevelData<T>>(0);
77  }
78 
79  m_data.resize(0);
80 }
81 
82 template <typename T>
83 void
85 {
86  m_reserved = true;
87 }
88 
89 template <typename T>
90 void
92 {
93  m_reserved = false;
94 }
95 
96 template <typename T>
97 bool
98 EBAMRData<T>::isReserved() const noexcept
99 {
100  return m_reserved;
101 }
102 
103 template <typename T>
104 void
106 {
107  for (int lvl = 0; lvl < m_data.size(); lvl++) {
108  m_data[lvl]->exchange();
109  }
110 }
111 
112 template <typename T>
113 Vector<RefCountedPtr<LevelData<T>>>&
115 {
116  return m_data;
117 }
118 
119 template <typename T>
120 const Vector<RefCountedPtr<LevelData<T>>>&
121 EBAMRData<T>::getData() const noexcept
122 {
123  return m_data;
124 }
125 
126 template <typename T>
127 void
128 EBAMRData<T>::push_back(RefCountedPtr<LevelData<T>>& a_levelData) noexcept
129 {
130  m_data.push_back(a_levelData);
131 }
132 
133 template <typename T>
134 const std::string
135 EBAMRData<T>::getRealm() const noexcept
136 {
137  return m_realm;
138 }
139 
140 template <typename T>
141 void
142 EBAMRData<T>::setRealm(const std::string a_realm) noexcept
143 {
144  m_realm = a_realm;
145 }
146 
147 // Explicit templates
148 template class EBAMRData<MFCellFAB>;
149 template class EBAMRData<MFFluxFAB>;
150 template class EBAMRData<MFBaseIVFAB>;
151 template class EBAMRData<EBCellFAB>; // Cell-centered single-phase data
152 template class EBAMRData<EBFluxFAB>; // Face-centered single-phase data
153 template class EBAMRData<EBFaceFAB>;
154 template class EBAMRData<BaseIVFAB<Real>>;
155 template class EBAMRData<DomainFluxIFFAB>;
156 template class EBAMRData<BaseFab<bool>>;
157 template class EBAMRData<FArrayBox>;
158 
159 // Typedefs for simple typing.
160 typedef EBAMRData<MFCellFAB> MFAMRCellData; // Cell-centered multifluid data
161 typedef EBAMRData<MFFluxFAB> MFAMRFluxData; // Face-centered multifluid data
162 typedef EBAMRData<MFBaseIVFAB> MFAMRIVData; // Irregular face multifluid data
163 typedef EBAMRData<EBCellFAB> EBAMRCellData; // Cell-centered single-phase data
164 typedef EBAMRData<EBFluxFAB> EBAMRFluxData; // Face-centered data in all coordinate direction
165 typedef EBAMRData<EBFaceFAB> EBAMRFaceData; // Face-centered in a single coordinate direction
166 typedef EBAMRData<BaseIVFAB<Real>> EBAMRIVData; // Data on irregular data centroids
167 typedef EBAMRData<DomainFluxIFFAB> EBAMRIFData; // Data on domain phases
168 typedef EBAMRData<BaseFab<bool>> EBAMRBool; // For holding bool at every cell
169 typedef EBAMRData<FArrayBox> EBAMRFAB; // Just regular grid data.
170 
171 #include <CD_NamespaceFooter.H>
172 
173 #endif
Class for holding data across EBAMR hierarchies.
Default class for holding LevelData<T> data across an EBAMR realm.
Definition: CD_EBAMRData.H:40
EBAMRData() noexcept
Default constructor. Does nothing.
Definition: CD_EBAMRDataImplem.H:23
void reserve() noexcept
Reserve data.
Definition: CD_EBAMRDataImplem.H:84
void setRealm(const std::string a_realm) noexcept
Sets the realm for this object.
Definition: CD_EBAMRDataImplem.H:142
void push_back(RefCountedPtr< LevelData< T >> &a_levelData) noexcept
Push a LevelData<T> object to the back of the data vector.
Definition: CD_EBAMRDataImplem.H:128
Vector< RefCountedPtr< LevelData< T > > > & getData() noexcept
Get underlying data. Returns m_data.
Definition: CD_EBAMRDataImplem.H:114
void exchange() noexcept
Exchange on all AMR levels.
Definition: CD_EBAMRDataImplem.H:105
void resize(const int a_size) noexcept
Resize m_data to having size a_size.
Definition: CD_EBAMRDataImplem.H:59
virtual ~EBAMRData() noexcept
Destructor. Does nothing.
Definition: CD_EBAMRDataImplem.H:38
int size() const noexcept
Get size of m_data.
Definition: CD_EBAMRDataImplem.H:66
bool isReserved() const noexcept
Check if data is reserved.
Definition: CD_EBAMRDataImplem.H:98
void clear() noexcept
Delete all data.
Definition: CD_EBAMRDataImplem.H:73
void release() noexcept
Release data.
Definition: CD_EBAMRDataImplem.H:91
const std::string getRealm() const noexcept
Returns the string identifier for whatever realm this data is supposed to be allocated over.
Definition: CD_EBAMRDataImplem.H:135
RefCountedPtr< LevelData< T > > & operator[](int a_level) noexcept
Indexing operators. Returns m_data[a_level].
Definition: CD_EBAMRDataImplem.H:45