Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_AmrParticleDataAdaptorI.H
Go to the documentation of this file.
2
3namespace amrex
4{
5//-----------------------------------------------------------------------------
6template <typename ParticleType, int NArrayReal, int NArrayInt>
7AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>*
8AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::New()
9{
10 auto result = new AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>;
11 result->InitializeObjectBase();
12 return result;
13}
14
15//-----------------------------------------------------------------------------
16template<typename ParticleType, int NArrayReal, int NArrayInt>
17int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::SetDataSource(
18 Amr *amr,
20 const std::map<std::string, std::vector<int>> & rStructs,
21 const std::map<std::string, int> & iStructs,
22 const std::map<std::string, std::vector<int>> & rArrays,
23 const std::map<std::string, int> & iArrays)
24{
25 int retMesh = this->m_meshAdaptor->SetDataSource(amr);
26 int retPtls = this->m_particleAdaptor->SetDataSource(particles, rStructs, iStructs, rArrays, iArrays);
27 return retMesh + retPtls;
28}
29
30// SENSEI API
31#if SENSEI_VERSION_MAJOR >= 3
32template<typename ParticleType, int NArrayReal, int NArrayInt>
33int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMeshMetadata(
34 unsigned int id,
35 sensei::MeshMetadataPtr &metadata)
36{
37 if(id == 0)
38 {
39 return this->m_meshAdaptor->GetMeshMetadata(0, metadata);
40 }
41 if(id == 1)
42 {
43 return this->m_particleAdaptor->GetMeshMetadata(1, metadata);
44 }
45 SENSEI_ERROR("unknown mesh ID in GetMeshMetadata");
46 return -1;
47}
48
49#else
50template<typename ParticleType, int NArrayReal, int NArrayInt>
51int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMeshName(
52 unsigned int id,
53 std::string &meshName)
54{
55 if(id == 0)
56 {
57 return this->m_meshAdaptor->GetMeshName(0, meshName);
58 }
59 if(id == 1)
60 {
61 return this->m_particleAdaptor->GetMeshName(1, meshName);
62 }
63 SENSEI_ERROR("unknown mesh ID in GetMeshName");
64 return -1;
65}
66
67template<typename ParticleType, int NArrayReal, int NArrayInt>
68int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMeshHasGhostNodes(
69 const std::string &meshName, int &nLayers)
70{
71 if(id == 0)
72 {
73 return this->m_meshAdaptor->GetMeshHasGhostNodes(meshName, nLayers);
74 }
75 if(id == 1)
76 {
77 return this->m_particleAdaptor->GetMeshHasGhostNodes(meshName, nLayers);
78 }
79 SENSEI_ERROR("unknown mesh ID in GetMeshHasGhostNodes");
80 return -1;
81}
82
83template<typename ParticleType, int NArrayReal, int NArrayInt>
84int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMeshHasGhostCells(
85 const std::string &meshName, int &nLayers)
86{
87 if(id == 0)
88 {
89 return this->m_meshAdaptor->GetMeshHasGhostCells(meshName, nLayers);
90 }
91 if(id == 1)
92 {
93 return this->m_particleAdaptor->GetMeshHasGhostCells(meshName, nLayers);
94 }
95 SENSEI_ERROR("unknown mesh ID in GetMeshHasGhostCells");
96 return -1;
97}
98
99template<typename ParticleType, int NArrayReal, int NArrayInt>
100int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetNumberOfArrays(
101 const std::string &meshName,
102 int association,
103 unsigned int &numberOfArrays)
104{
105 if(id == 0)
106 {
107 return this->m_meshAdaptor->GetNumberOfArrays(meshName, association, numberOfArrays);
108 }
109 if(id == 1)
110 {
111 return this->m_particleAdaptor->GetNumberOfArrays(meshName, association, numberOfArrays);
112 }
113 SENSEI_ERROR("unknown mesh ID in GetNumberOfArrays");
114 return -1;
115}
116
117template<typename ParticleType, int NArrayReal, int NArrayInt>
118int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetArrayName(
119 const std::string &meshName,
120 int association,
121 unsigned int index,
122 std::string &arrayName)
123{
124 if(id == 0)
125 {
126 return this->m_meshAdaptor->GetArrayName(meshName, association, index, arrayName);
127 }
128 if(id == 1)
129 {
130 return this->m_particleAdaptor->GetArrayName(meshName, association, index, arrayName);
131 }
132 SENSEI_ERROR("unknown mesh ID in GetArrayName");
133 return -1;
134}
135#endif
136
137template<typename ParticleType, int NArrayReal, int NArrayInt>
138int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetNumberOfMeshes(
139 unsigned int &numMeshes)
140{
141 numMeshes = 2;
142 return 0;
143}
144
145template<typename ParticleType, int NArrayReal, int NArrayInt>
146int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMesh(
147 const std::string &meshName,
148 bool structureOnly,
149 svtkDataObject *&mesh)
150{
151 if(meshName == m_meshName)
152 {
153 return this->m_meshAdaptor->GetMesh(meshName, structureOnly, mesh);
154 }
155 if(meshName == m_particlesName)
156 {
157 return this->m_particleAdaptor->GetMesh(meshName, structureOnly, mesh);
158 }
159 SENSEI_ERROR("unknown mesh name in GetMesh");
160 return -1;
161}
162
163template<typename ParticleType, int NArrayReal, int NArrayInt>
164int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddGhostNodesArray(
165 svtkDataObject* mesh,
166 const std::string &meshName)
167{
168 if(meshName == m_meshName)
169 {
170 return this->m_meshAdaptor->AddGhostNodesArray(mesh, meshName);
171 }
172 if(meshName == m_particlesName)
173 {
174 return this->m_particleAdaptor->AddGhostNodesArray(mesh, meshName);
175 }
176 SENSEI_ERROR("unknown mesh name in AddGhostNodesArray");
177 return -1;
178}
179
180template<typename ParticleType, int NArrayReal, int NArrayInt>
181int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddGhostCellsArray(
182 svtkDataObject* mesh,
183 const std::string &meshName)
184{
185 if(meshName == m_meshName)
186 {
187 return this->m_meshAdaptor->AddGhostCellsArray(mesh, meshName);
188 }
189 if(meshName == m_particlesName)
190 {
191 return this->m_particleAdaptor->AddGhostCellsArray(mesh, meshName);
192 }
193 SENSEI_ERROR("unknown mesh name in AddGhostCellsArray");
194 return -1;
195}
196
197template<typename ParticleType, int NArrayReal, int NArrayInt>
198int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddArray(
199 svtkDataObject* mesh,
200 const std::string &meshName,
201 int association,
202 const std::string &arrayName)
203{
204 if(meshName == m_meshName)
205 {
206 return this->m_meshAdaptor->AddArray(mesh, meshName, association, arrayName);
207 }
208 if(meshName == m_particlesName)
209 {
210 return this->m_particleAdaptor->AddArray(mesh, meshName, association, arrayName);
211 }
212 SENSEI_ERROR("unknown mesh name in AddArray");
213 return -1;
214}
215
216template<typename ParticleType, int NArrayReal, int NArrayInt>
217int AmrParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::ReleaseData()
218{
219 this->m_particleAdaptor->ReleaseData();
220 this->m_meshAdaptor->ReleaseData();
221 return 0;
222}
223
224} // end namespace amrex
A distributed container for Particles sorted onto the levels, grids, and tiles of a block-structured ...
Definition AMReX_ParticleContainer.H:146
Definition AMReX_Amr.cpp:49