aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/ParticleBoundaryBuffer.H
blob: 592dc574f21a1a39f1f52436409f78823fc19a7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Copyright 2021 Andrew Myers
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */
#ifndef PARTICLEBOUNDARYBUFFER_H_
#define PARTICLEBOUNDARYBUFFER_H_

#include "Particles/ParticleBuffer.H"
#include "Particles/MultiParticleContainer_fwd.H"

#include <vector>

/**
 *  This stores particles that have left / been absorbed by domain and embedded boundaries.
 */
class ParticleBoundaryBuffer
{
public:
    ParticleBoundaryBuffer ();

    int numSpecies() const { return getSpeciesNames().size(); }

    const std::vector<std::string>& getSpeciesNames() const {
        static bool initialized = false;
        if (!initialized)
        {
            amrex::ParmParse pp_particles("particles");
            pp_particles.queryarr("species_names", m_species_names);
            initialized = true;
        }
        return m_species_names;
    }

    void gatherParticles (MultiParticleContainer& mypc,
                          const amrex::Vector<const amrex::MultiFab*>& distance_to_eb);

    void clearParticles ();

    void printNumParticles () const;

    int getNumParticlesInContainer(const std::string species_name, int boundary);

    ParticleBuffer::BufferType<amrex::PinnedArenaAllocator>& getParticleBuffer(const std::string species_name, int boundary);

    constexpr int numBoundaries () const {
        return AMREX_SPACEDIM*2
#ifdef AMREX_USE_EB
            + 1
#endif
            ;
    }

private:
    // over boundary, then number of species
    std::vector<std::vector<ParticleBuffer::BufferType<amrex::PinnedArenaAllocator> > > m_particle_containers;

    // over boundary, then number of species
    std::vector<std::vector<int> > m_do_boundary_buffer;

    mutable std::vector<std::string> m_species_names;
};

#endif /*PARTICLEBOUNDARYBUFFER_H_*/