Block-Structured AMR Software Framework
AMReX_AmrMeshParticleDataAdaptor.H
Go to the documentation of this file.
1 #ifndef AMReX_AmrMeshParticleDataAdaptor_h
2 #define AMReX_AmrMeshParticleDataAdaptor_h
3 
4 // AMReX includes
5 #include <AMReX_Config.H>
6 #ifdef AMREX_PARTICLES
7 
8 #include <AMReX_Particles.H>
9 
10 #include <AMReX_AmrMesh.H>
11 #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 AmrMeshParticleDataAdaptor : public sensei::DataAdaptor
21 {
22 public:
23  static AmrMeshParticleDataAdaptor* New();
24  senseiTypeMacro(AmrMeshParticleDataAdaptor, sensei::DataAdaptor);
25 
26  int SetDataSource(
27  AmrMesh *mesh,
28  const std::vector<amrex::Vector<amrex::MultiFab>*> &mesh_states,
29  const std::vector<std::vector<std::string>> &mesh_names,
31  const std::map<std::string, std::vector<int>> & rStructs = {},
32  const std::map<std::string, int> & iStructs = {},
33  const std::map<std::string, std::vector<int>> & rArrays = {},
34  const std::map<std::string, int> & iArrays = {}
35  );
36 
37  // SENSEI API
38 #if SENSEI_VERSION_MAJOR >= 3
39  int GetMeshMetadata(unsigned int id, sensei::MeshMetadataPtr &metadata) override;
40 #else
41  int GetMeshName(unsigned int id, std::string &meshName) override;
42  int GetMeshHasGhostNodes(const std::string &meshName, int &nLayers) override;
43  int GetMeshHasGhostCells(const std::string &meshName, int &nLayers) override;
44  int GetNumberOfArrays(const std::string &meshName, int association, unsigned int &numberOfArrays) override;
45  int GetArrayName(const std::string &meshName, int association, unsigned int index, std::string &arrayName) override;
46 #endif
47  int GetNumberOfMeshes(unsigned int &numMeshes) override;
48  int GetMesh(const std::string &meshName, bool structureOnly, svtkDataObject *&mesh) override;
49  int AddGhostNodesArray(svtkDataObject* mesh, const std::string &meshName) override;
50  int AddGhostCellsArray(svtkDataObject* mesh, const std::string &meshName) override;
51  int AddArray(svtkDataObject* mesh, const std::string &meshName, int association, const std::string &arrayName) override;
52  int ReleaseData() override;
53 
54 protected:
55  AmrMeshParticleDataAdaptor()
56  {
57  m_meshAdaptor = AmrMeshDataAdaptor::New();
58  m_particleAdaptor = ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::New();
59  }
60 
61  ~AmrMeshParticleDataAdaptor()
62  {
63  m_meshAdaptor->Delete();
64  m_particleAdaptor->Delete();
65  }
66 
67 private:
68  ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>* m_particleAdaptor;
69  AmrMeshDataAdaptor* m_meshAdaptor;
70 
71  const std::string m_meshName = "mesh";
72  const std::string m_particlesName = "particles";
73 };
74 }
75 
77 #endif // AMREX_PARTICLES
78 #endif // AMReX_AmrMeshParticleDataAdaptor_h
static AmrMeshDataAdaptor * 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