-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathParticleDiag.cpp
100 lines (86 loc) · 3.97 KB
/
ParticleDiag.cpp
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
99
100
#include "ParticleDiag.H"
#include "Diagnostics/ParticleDiag/ParticleDiag.H"
#include "Particles/WarpXParticleContainer.H"
#include "Utils/Parser/ParserUtils.H"
#include "Utils/TextMsg.H"
#include "WarpX.H"
#include <ablastr/warn_manager/WarnManager.H>
#include <AMReX_ParmParse.H>
#include <map>
#include <vector>
using namespace amrex;
ParticleDiag::ParticleDiag (
const std::string& diag_name, const std::string& name,
WarpXParticleContainer* pc, PinnedMemoryParticleContainer* pinned_pc):
m_diag_name(diag_name), m_name(name), m_pc(pc), m_pinned_pc(pinned_pc)
{
//variable to set m_plot_flags size
const int plot_flag_size = pc->NumRealComps();
// By default output all attributes
m_plot_flags.resize(plot_flag_size, 1);
const ParmParse pp_diag_name_species_name(diag_name + "." + name);
amrex::Vector<std::string> variables;
const int variables_specified = pp_diag_name_species_name.queryarr("variables", variables);
if (variables_specified) {
// If only specific variables have been specified, fill m_plot_flags with zero and only set
// requested variables to one
std::fill(m_plot_flags.begin(), m_plot_flags.end(), 0);
bool contains_positions = false;
if (variables[0] != "none"){
for (auto& var : variables){
#ifdef WARPX_DIM_RZ
// we reconstruct to Cartesian x,y,z for RZ particle output
if (var == "y") { var = "theta"; }
#endif
if (var == "phi") {
m_plot_phi = true;
} else if (var == "Ex" || var == "Ey" || var == "Ez" ||
var == "Bx" || var == "By" || var == "Bz") {
m_plot_EM = true;
if (var == "Ex") {m_plot_EM_flags[0] = true;}
if (var == "Ey") {m_plot_EM_flags[1] = true;}
if (var == "Ez") {m_plot_EM_flags[2] = true;}
if (var == "Bx") {m_plot_EM_flags[3] = true;}
if (var == "By") {m_plot_EM_flags[4] = true;}
if (var == "Bz") {m_plot_EM_flags[5] = true;}
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(pc->HasRealComp(var),
"variables argument '" + var
+"' is not an existing attribute for this species");
m_plot_flags[pc->GetRealCompIndex(var)] = 1;
if (var == "x" || var == "y" || var == "z" || var == "theta") {
contains_positions = true;
}
}
}
}
if (!contains_positions) {
ablastr::warn_manager::WMRecordWarning(
"Diagnostics",
diag_name + "." + name + ".variables contains no particle positions!",
ablastr::warn_manager::WarnPriority::high
);
}
}
#ifdef WARPX_DIM_RZ
// Always write out theta, whether or not it's requested,
// to be consistent with always writing out r and z.
// TODO: openPMD does a reconstruction to Cartesian, so we can now skip force-writing this
m_plot_flags[pc->GetRealCompIndex("theta")] = 1;
#endif
// build filter functors
m_do_random_filter = utils::parser::queryWithParser(
pp_diag_name_species_name, "random_fraction", m_random_fraction);
m_do_uniform_filter = utils::parser::queryWithParser(
pp_diag_name_species_name, "uniform_stride",m_uniform_stride);
std::string buf;
m_do_parser_filter = pp_diag_name_species_name.query("plot_filter_function(t,x,y,z,ux,uy,uz)",
buf);
if (m_do_parser_filter) {
std::string function_string;
utils::parser::Store_parserString(
pp_diag_name_species_name,"plot_filter_function(t,x,y,z,ux,uy,uz)", function_string);
m_particle_filter_parser = std::make_unique<amrex::Parser>(
utils::parser::makeParser(function_string,{"t","x","y","z","ux","uy","uz"}));
}
}