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
101
102
103
104
105
106
107
108
109
110
111
112
|
#include "MultiDiagnostics.H"
#include "Diagnostics/BTDiagnostics.H"
#include "Diagnostics/FullDiagnostics.H"
#include "Diagnostics/BoundaryScrapingDiagnostics.H"
#include "Utils/TextMsg.H"
#include <ablastr/warn_manager/WarnManager.H>
#include <AMReX_ParmParse.H>
#include <AMReX.H>
#include <AMReX_REAL.H>
#include <algorithm>
using namespace amrex;
MultiDiagnostics::MultiDiagnostics ()
{
ReadParameters();
/** Resize alldiags and initialize each element to a pointer to a
* diagnostics. Calls the corresponding diagnostics constructor.
*/
alldiags.resize( ndiags );
for (int i=0; i<ndiags; i++){
if ( diags_types[i] == DiagTypes::Full ){
alldiags[i] = std::make_unique<FullDiagnostics>(i, diags_names[i]);
} else if ( diags_types[i] == DiagTypes::BackTransformed ){
alldiags[i] = std::make_unique<BTDiagnostics>(i, diags_names[i]);
} else if ( diags_types[i] == DiagTypes::BoundaryScraping ){
alldiags[i] = std::make_unique<BoundaryScrapingDiagnostics>(i, diags_names[i]);
} else {
amrex::Abort(Utils::TextMsg::Err("Unknown diagnostic type"));
}
}
}
void
MultiDiagnostics::InitData ()
{
for( auto& diag : alldiags ){
diag->InitData();
}
}
void
MultiDiagnostics::InitializeFieldFunctors ( int lev )
{
for( auto& diag : alldiags ){
// Initialize functors to store pointers to fields.
diag->InitializeFieldFunctors( lev );
}
}
void
MultiDiagnostics::ReadParameters ()
{
ParmParse pp_diagnostics("diagnostics");
int enable_diags = 1;
pp_diagnostics.query("enable", enable_diags);
if (enable_diags == 1) {
pp_diagnostics.queryarr("diags_names", diags_names);
ndiags = static_cast<int>(diags_names.size());
}
diags_types.resize( ndiags );
for (int i=0; i<ndiags; i++){
ParmParse pp_diag_name(diags_names[i]);
std::string diag_type_str;
pp_diag_name.get("diag_type", diag_type_str);
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
diag_type_str == "Full" || diag_type_str == "BackTransformed" || diag_type_str == "BoundaryScraping",
"<diag>.diag_type must be Full or BackTransformed or BoundaryScraping");
if (diag_type_str == "Full") diags_types[i] = DiagTypes::Full;
if (diag_type_str == "BackTransformed") diags_types[i] = DiagTypes::BackTransformed;
if (diag_type_str == "BoundaryScraping") diags_types[i] = DiagTypes::BoundaryScraping;
}
}
void
MultiDiagnostics::FilterComputePackFlush (int step, bool force_flush, bool BackTransform)
{
int i = 0;
for (auto& diag : alldiags){
if (BackTransform == true) {
if (diags_types[i] == DiagTypes::BackTransformed)
diag->FilterComputePackFlush (step, force_flush);
} else {
if (diags_types[i] != DiagTypes::BackTransformed)
diag->FilterComputePackFlush (step, force_flush);
}
++i;
}
}
void
MultiDiagnostics::FilterComputePackFlushLastTimestep (int step)
{
for (auto& diag : alldiags){
if (diag->DoDumpLastTimestep()){
constexpr bool force_flush = true;
diag->FilterComputePackFlush (step, force_flush);
}
}
}
void
MultiDiagnostics::NewIteration ()
{
for( auto& diag : alldiags ){
diag->NewIteration();
}
}
|