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