Block-Structured AMR Software Framework
AMReX_AmrParticleDataAdaptor.H
Go to the documentation of this file.
1 #ifndef AMReX_AmrParticleDataAdaptor_h
2 #define AMReX_AmrParticleDataAdaptor_h
3 
4 // AMReX includes
5 #include <AMReX_Config.H>
6 #ifdef AMREX_PARTICLES
7 
8 #include <AMReX_AmrDataAdaptor.H>
9 #include <AMReX_Particles.H>
10 
11 #include <AMReX_AmrMesh.H>
12 #include <AMReX_MultiFab.H>
14 // sensei includes
15 #include "DataAdaptor.h"
16 
17 namespace amrex
18 {
19 template<typename ParticleType, int NArrayReal, int NArrayInt>
20 class AmrParticleDataAdaptor : public sensei::DataAdaptor
21 {
22 public:
23  static AmrParticleDataAdaptor* New();
24  senseiTypeMacro(AmrParticleDataAdaptor, sensei::DataAdaptor);
25 
26  int SetDataSource(
27  Amr *amr,
29  const std::map<std::string, std::vector<int>> & rStructs = {},
30  const std::map<std::string, int> & iStructs = {},
31  const std::map<std::string, std::vector<int>> & rArrays = {},
32  const std::map<std::string, int> & iArrays = {}
33  );
34 
35  // SENSEI API
36 #if SENSEI_VERSION_MAJOR >= 3
37  int GetMeshMetadata(unsigned int id, sensei::MeshMetadataPtr &metadata) override;
38 #else
39  int GetMeshName(unsigned int id, std::string &meshName) override;
40  int GetMeshHasGhostNodes(const std::string &meshName, int &nLayers) override;
41  int GetMeshHasGhostCells(const std::string &meshName, int &nLayers) override;
42  int GetNumberOfArrays(const std::string &meshName, int association, unsigned int &numberOfArrays) override;
43  int GetArrayName(const std::string &meshName, int association, unsigned int index, std::string &arrayName) override;
44 #endif
45  int GetNumberOfMeshes(unsigned int &numMeshes) override;
46  int GetMesh(const std::string &meshName, bool structureOnly, svtkDataObject *&mesh) override;
47  int AddGhostNodesArray(svtkDataObject* mesh, const std::string &meshName) override;
48  int AddGhostCellsArray(svtkDataObject* mesh, const std::string &meshName) override;
49  int AddArray(svtkDataObject* mesh, const std::string &meshName, int association, const std::string &arrayName) override;
50  int ReleaseData() override;
51 
52 protected:
53  AmrParticleDataAdaptor()
54  {
55  m_meshAdaptor = AmrDataAdaptor::New();
56  m_particleAdaptor = ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::New();
57  }
58 
59  ~AmrParticleDataAdaptor()
60  {
61  m_meshAdaptor->Delete();
62  m_particleAdaptor->Delete();
63  }
64 
65 private:
66  ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>* m_particleAdaptor;
67  AmrDataAdaptor* m_meshAdaptor;
68 
69  const std::string m_meshName = "mesh";
70  const std::string m_particlesName = "particles";
71 };
72 }
73 
75 #endif // AMREX_PARTICLES
76 #endif // AMReX_AmrParticleDataAdaptor_h
static AmrDataAdaptor * New()
A distributed container for Particles sorted onto the levels, grids, and tiles of a block-structured ...
Definition: AMReX_ParticleContainer.H:145
Definition: AMReX_Amr.cpp:49