Block-Structured AMR Software Framework
AMReX_ParticleDataAdaptor.H
Go to the documentation of this file.
1 #ifndef AMReX_ParticleDataAdaptor_h
2 #define AMReX_ParticleDataAdaptor_h
3 
4 #include <AMReX_Config.H>
5 #ifdef AMREX_PARTICLES
6 #include <AMReX_Particles.H>
7 #include <AMReX_AmrMesh.H>
8 #include <AMReX_MultiFab.H>
9 
10 #include <DataAdaptor.h>
11 class svtkPolyData;
12 
13 namespace amrex
14 {
15 
16 template<typename ParticleType, int NArrayReal, int NArrayInt>
17 class ParticleDataAdaptor : public sensei::DataAdaptor
18 {
19 public:
20  static constexpr int NStructReal = ParticleType::NReal;
21  static constexpr int NStructInt = ParticleType::NInt;
22 
23  static ParticleDataAdaptor* New();
24  senseiTypeMacro(ParticleDataAdaptor, sensei::DataAdaptor);
25 
26  // set the source of the simulation data
27  int SetDataSource(
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  // set the data array names maps internally
36  int SetArrayNames(
37  const std::map<std::string, std::vector<int>> & rStructs,
38  const std::map<std::string, int> & iStructs,
39  const std::map<std::string, std::vector<int>> & rArrays,
40  const std::map<std::string, int> & iArrays);
41 
42  // force mesh origin to 0,0,0. off by default
43  void SetPinMesh(int val);
44 
45  // get particle id numbers
46  int AddParticlesIDArray(svtkDataObject* mesh);
47 
48  // get particle cpu numbers (process each particle was generated on)
49  int AddParticlesCPUArray(svtkDataObject* mesh);
50 
51  // get particle integer arrays in Structs of Arrays format
52  int AddParticlesSOAIntArray(const std::string &arrayName, svtkDataObject* mesh);
53 
54  // get particle real arrays in Structs of Arrays format
55  int AddParticlesSOARealArray(const std::string &arrayName, svtkDataObject* mesh);
56 
57  // get particle integer arrays in Array Of Structs format
58  int AddParticlesAOSIntArray(const std::string &arrayName, svtkDataObject* mesh);
59 
60  // get particle real arrays in Array Of Structs format
61  int AddParticlesAOSRealArray(const std::string &arrayName, svtkDataObject* mesh);
62 
63  // SENSEI API
64 #if SENSEI_VERSION_MAJOR >= 3
65  int GetMeshMetadata(unsigned int id, sensei::MeshMetadataPtr &metadata) override;
66 #else
67  int GetMeshName(unsigned int id, std::string &meshName) override;
68  int GetMeshHasGhostNodes(const std::string &meshName, int &nLayers) override;
69  int GetMeshHasGhostCells(const std::string &meshName, int &nLayers) override;
70  int GetNumberOfArrays(const std::string &meshName, int association, unsigned int &numberOfArrays) override;
71  int GetArrayName(const std::string &meshName, int association, unsigned int index, std::string &arrayName) override;
72 #endif
73  int GetNumberOfMeshes(unsigned int &numMeshes) override;
74  int GetMesh(const std::string &meshName, bool structureOnly, svtkDataObject *&mesh) override;
75  int AddGhostNodesArray(svtkDataObject* mesh, const std::string &meshName) override;
76  int AddGhostCellsArray(svtkDataObject* mesh, const std::string &meshName) override;
77  int AddArray(svtkDataObject* mesh, const std::string &meshName, int association, const std::string &arrayName) override;
78  int ReleaseData() override;
79 
80 protected:
81  ParticleDataAdaptor() = default;
82  ~ParticleDataAdaptor() = default;
83 
84 private:
85  svtkPolyData* BuildParticles();
86 
87  const std::string m_particlesName = "particles";
88 
90 
91  using RealDataMapType = std::map<std::string, std::vector<int>>;
92  using IntDataMapType = std::map<std::string, int>;
93 
94  RealDataMapType m_realStructs;
95  IntDataMapType m_intStructs;
96  RealDataMapType m_realArrays;
97  IntDataMapType m_intArrays;
98 };
99 
100 }
101 
103 
104 #endif
105 #endif
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