aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Resampling/LevelingThinning.H
blob: ecfd727c4c4389020f29f9acdd0d739c0e156040 (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
/* Copyright 2019-2020 Neil Zaim
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */
#ifndef WARPX_LEVELING_THINNING_H_
#define WARPX_LEVELING_THINNING_H_

#include "Resampling.H"

/**
 * \brief This class implements the leveling thinning algorithm as defined in Muraviev, A., et al.
 * arXiv:2006.08593 (2020).
 * The main steps of the algorithm are the following: for every cell we calculate a level weight,
 * defined by the average weight of the species particles in that cell multiplied by the target
 * ratio. Then, particles with a weight lower than the level weight are either removed, with a
 * probability 1 - particle_weight/level_weight, or have their weight set to the level weight.
 */
class LevelingThinning: public ResamplingAlgorithm {
public:

    /**
     * \brief Default constructor of the LevelingThinning class.
     */
    LevelingThinning () = default;

    /**
     * \brief Constructor of the LevelingThinning class
     *
     * @param[in] species_name the name of the resampled species
     */
    LevelingThinning (const std::string species_name);

    /**
     * \brief A method that performs leveling thinning for the considered species.
     *
     * @param[in] pti WarpX particle iterator of the particles to resample.
     * @param[in] lev the index of the refinement level.
     * @param[in] pc a pointer to the particle container.
     */
    void operator() (WarpXParIter& pti, const int lev, WarpXParticleContainer * const pc) const override final;

private:
    amrex::Real m_target_ratio = amrex::Real(1.5);
    int m_min_ppc = 1;
};


#endif //WARPX_LEVELING_THINNING_H_