aboutsummaryrefslogtreecommitdiff
path: root/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.H
blob: 6b82514567da964330b4db7cccce506ac1e4cad9 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* Copyright 2023 The WarpX Community
 *
 * This file is part of WarpX.
 *
 * Authors: Juliette Pech, Axel Huebl
 * License: BSD-3-Clause-LBNL
 */

#ifndef WARPX_DIAGNOSTICS_REDUCEDDIAGS_PARTICLEHISTOGRAM2D_H_
#define WARPX_DIAGNOSTICS_REDUCEDDIAGS_PARTICLEHISTOGRAM2D_H_

#include "ReducedDiags.H"

#include <AMReX_Parser.H>
#include <AMReX_REAL.H>
#include <AMReX_TableData.H>

#include <memory>
#include <string>

/**
 * Reduced diagnostics that computes a histogram over particles
 * for a quantity specified by the user in the input file using the parser.
 */
class ParticleHistogram2D : public ReducedDiags
{
public:

    /**
     * constructor
     * @param[in] rd_name reduced diags names
     */
    ParticleHistogram2D(std::string rd_name);

    /// File type
    std::string m_openpmd_backend {"default"};

    /// number of bins on the abscissa and ordinate
    int m_bin_num_abs;
    int m_bin_num_ord;

    /// output data
    amrex::TableData<amrex::Real,2> m_h_data_2D;

    /// selected species index
    int m_selected_species_id = -1;

    /// max and min bin values
    amrex::Real m_bin_max_abs;
    amrex::Real m_bin_min_abs;
    amrex::Real m_bin_max_ord;
    amrex::Real m_bin_min_ord;

    /// bin sizes
    amrex::Real m_bin_size_abs;
    amrex::Real m_bin_size_ord;

    /// functions
    std::string function_string_abs;
    std::string function_string_ord;
    std::string filter_string;
    std::string value_string;

/// Parser to read expression for particle quantity from the input file.
    /// 7 elements are t, x, y, z, ux, uy, uz, w
    static constexpr int m_nvars = 8;
    std::unique_ptr<amrex::Parser> m_parser_abs;
    std::unique_ptr<amrex::Parser> m_parser_ord;

    /// Optional parser to filter particles before doing the histogram
    std::unique_ptr<amrex::Parser> m_parser_filter;

    /// Whether the filter is activated
    bool m_do_parser_filter = false;

    /// Optional parser to filter particles before doing the histogram
    std::unique_ptr<amrex::Parser> m_parser_value;

    /// Whether the filter is activated
    bool m_do_parser_value;

    /**
     * This function computes a histogram of user defined quantity.
     *
     * @param[in] step current time step
     */
    void ComputeDiags(int step) override final;

    /**
     * write to file function
     *
     * @param[in] step current time step
     */
    void WriteToFile (int step) const override final;

};

#endif