Skip to content

Commit

Permalink
Removed catalyst-specific particle code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcombs committed Aug 9, 2023
1 parent 8b4be4e commit ca181e6
Showing 1 changed file with 14 additions and 35 deletions.
49 changes: 14 additions & 35 deletions Src/Extern/Conduit/AMReX_Conduit_Blueprint_ParticlesI.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ namespace amrex
// Note:
// This is a helper function, it's not part of the AMReX Blueprint Interface.
//---------------------------------------------------------------------------//
template <typename ParticleType, int NArrayReal, int NArrayInt>
template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void
ParticleTileToBlueprint(const ParticleTile<ParticleType,
ParticleTileToBlueprint(const ParticleTile<amrex::Particle<NStructReal,
NStructInt>,
NArrayReal,
NArrayInt> &ptile,
const Vector<std::string> &real_comp_names,
Expand All @@ -31,7 +32,7 @@ ParticleTileToBlueprint(const ParticleTile<ParticleType,
const std::string &topology_name)
{
int num_particles = ptile.GetArrayOfStructs().size();
int struct_size = ParticleType::is_soa_particle ? 0 : sizeof(ParticleType);
int struct_size = sizeof(Particle<NStructReal, NStructInt>);

// knowing the above, we can zero copy the x,y,z positions + id, cpu
// and any user fields in the AOS
Expand Down Expand Up @@ -67,47 +68,25 @@ ParticleTileToBlueprint(const ParticleTile<ParticleType,
char* pbuf = const_cast<char*>(pbuf_const);

ParticleReal* xp = reinterpret_cast<ParticleReal*>(pbuf); pbuf += sizeof(ParticleReal);
#ifdef AMREX_USE_CATALYST
n_coords["values/x"].set(xp,
num_particles,
0,
struct_size);
#else
n_coords["values/x"].set_external(xp,
num_particles,
0,
struct_size);
#endif //AMREX_USE_CATALYST
#if AMREX_SPACEDIM > 1
ParticleReal* yp = reinterpret_cast<ParticleReal*>(pbuf); pbuf += sizeof(ParticleReal);

#ifdef AMREX_USE_CATALYST
n_coords["values/y"].set(yp,
num_particles,
0,
struct_size);
#else
n_coords["values/y"].set_external(yp,
num_particles,
0,
struct_size);
#endif // AMREX_USE_CATALYST
#endif
#if AMREX_SPACEDIM > 2
ParticleReal* zp = reinterpret_cast<ParticleReal*>(pbuf); pbuf += sizeof(ParticleReal);

#ifdef AMREX_USE_CATALYST
n_coords["values/z"].set(zp,
num_particles,
0,
struct_size);
#else
n_coords["values/z"].set_external(zp,
num_particles,
0,
struct_size);
#endif // AMREX_USE_CATALYST
#endif

// fields
conduit::Node &n_fields = res["fields"];

Expand All @@ -118,7 +97,7 @@ ParticleTileToBlueprint(const ParticleTile<ParticleType,
int vname_real_idx = 0;
// struct real fields, the first set are always the particle positions
// which we wrap above
for (int i = 0; i < ParticleType::NReal; i++)
for (int i = 0; i < NStructReal; i++)
{
ParticleReal* val = reinterpret_cast<ParticleReal*>(pbuf); pbuf += sizeof(ParticleReal);
conduit::Node &n_f = n_fields[real_comp_names.at(vname_real_idx)];
Expand Down Expand Up @@ -164,7 +143,7 @@ ParticleTileToBlueprint(const ParticleTile<ParticleType,
// --------------------------------

int vname_int_idx = 0;
for (int i = 0; i < ParticleType::NInt; i++)
for (int i = 0; i < NStructInt; i++)
{
int* val = reinterpret_cast<int*>(pbuf); pbuf += sizeof(int);
conduit::Node &n_f = n_fields[int_comp_names.at(vname_int_idx)];
Expand Down Expand Up @@ -214,9 +193,10 @@ ParticleTileToBlueprint(const ParticleTile<ParticleType,
//---------------------------------------------------------------------------//
// Converts a AMReX Particle Container into a Conduit Mesh Blueprint Hierarchy.
//---------------------------------------------------------------------------//
template <typename ParticleType, int NArrayReal, int NArrayInt>
template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void
ParticleContainerToBlueprint(const ParticleContainer_impl<ParticleType,
ParticleContainerToBlueprint(const ParticleContainer<NStructReal,
NStructInt,
NArrayReal,
NArrayInt> &pc,
const Vector<std::string> &real_comp_names,
Expand All @@ -229,9 +209,8 @@ ParticleContainerToBlueprint(const ParticleContainer_impl<ParticleType,
// validate varnames, which are used to provide field names
// for user defined aos and soa values.

// Not sure what to do here
// BL_ASSERT(real_comp_names.size() == (NStructReal + NArrayReal) );
// BL_ASSERT(int_comp_names.size() == (NStructInt + NArrayInt) );
BL_ASSERT(real_comp_names.size() == (NStructReal + NArrayReal) );
BL_ASSERT(int_comp_names.size() == (NStructInt + NArrayInt) );

int num_levels = pc.maxLevel() + 1;
int num_domains = 0;
Expand All @@ -241,7 +220,7 @@ ParticleContainerToBlueprint(const ParticleContainer_impl<ParticleType,
int rank = ParallelDescriptor::MyProc();
int nprocs = ParallelDescriptor::NProcs();

using MyParConstIter = ParConstIter_impl<ParticleType, NArrayReal, NArrayInt>;
using MyParConstIter = ParConstIter<NStructReal, NStructInt, NArrayReal, NArrayInt>;

//
// blueprint expects unique ids for each domain published
Expand Down Expand Up @@ -341,4 +320,4 @@ ParticleContainerToBlueprint(const ParticleContainer_impl<ParticleType,



}
}

0 comments on commit ca181e6

Please sign in to comment.