Chi-Tech
doc_PostProcessors.h
Go to the documentation of this file.
1
/**\defgroup doc_PostProcessors H Post-Processors
2
*
3
* # 1 What is a Post-Processor?
4
* A post-processor, implemented via `chi::PostProcessor`, computes simple
5
* quantities derived from simulation entities (i.e., meshers, solvers, etc.).
6
* The most common form of a post-processor is a `SCALAR` which computes a single
7
* value, however, there is a also a `VECTOR` type and an `ARBITRARY` type.
8
*
9
* # 2 How are post-processors created
10
* Below is an example of the simplest (and first created) post-processors called
11
* the `chi::SolverInfoPostProcessor`. This post-processor obtains information
12
* from a solver, where each solver can override the virtual method
13
* `chi_physics::Solver::GetInfo` to provide any piece(s) of information. In this
14
* case the `prk::TransientSolver` is a mesh-less solver that computes the
15
* time-dependent neutron population of a Point-Reactor model.
16
\code
17
-- Example Point-Reactor Kinetics solver
18
phys0 = prk.TransientSolver.Create({ initial_source = 0.0 })
19
20
pp0 = chi.SolverInfoPostProcessor.Create
21
({
22
name = "neutron_population",
23
solver = phys0,
24
info = {name = "neutron_population"},
25
print_on = { "ProgramExecuted" }
26
})
27
\endcode
28
Post-processors have a few standard parameters.The `name` parameter is always
29
required among all post-processors. Additionally we have the following:
30
- `execute_on` controlling the events on which to execute the post-processor
31
(more on this later).
32
- `print_on` controlling the events on which to print the post-processor.
33
- `initial_value` can be used to set an initial value for the post-processor.
34
- other commands to control various behaviors see \ref chi__PostProcessor.
35
*
36
* # 3 How are post-processors executed?
37
Post-processors are executed using the event system (see \ref doc_EventSystem).
38
Each post-processor can be subscribed to objects deriving from
39
`chi::EventPublisher` that call the Post-Processors at different stages
40
(Subscriber design pattern).
41
One example is the physics solver-system which has a wrapper to call the post
42
processors on calls to `Initialize`, `Execute`, `Step` and `Advance`
43
44
## 3.1 Default `execute_on` events
45
By default a post-processor subscribes to the following events for execution:
46
- `SolverInitialized`
47
- `SolverAdvanced`
48
- `SolverExecuted`
49
- `ProgramExecuted`
50
51
This behavior can be customized by using the `execute_on` parameter. For example:
52
\code
53
pp0 = chi.SolverInfoPostProcessor.Create
54
({
55
name = "neutron_population",
56
solver = phys0,
57
info = {name = "neutron_population"},
58
execute_on = {"ProgramExecuted"},
59
print_on = { "ProgramExecuted" }
60
})
61
\endcode
62
63
## 3.2 Post-Processor output controls
64
Post-Processors are printed to console or file using the
65
`chi::PostProcessorPrinter` singleton. It has the options described in
66
\ref chi__PostProcessorPrinterOptions which can be set using
67
\ref chi__PostProcessorPrinterSetOptions.
68
69
### 3.2.1 Printing to console output
70
The following example shows the printing of a simple post processor.
71
\code
72
-- Example Point-Reactor Kinetics solver
73
phys0 = prk.TransientSolver.Create({ initial_source = 0.0 })
74
75
pp0 = chi.SolverInfoPostProcessor.Create
76
({
77
name = "neutron_population",
78
solver = phys0,
79
info = {name = "neutron_population"},
80
print_on = { "ProgramExecuted" }
81
})
82
83
chiSolverInitialize(phys0)
84
85
for t=1,20 do
86
chiSolverStep(phys0)
87
time = chiPRKGetParam(phys0, "time_next")
88
print(t, time,
89
chiPRKGetParam(phys0, "population_next"),
90
chiPRKGetParam(phys0, "period"))
91
92
chiSolverAdvance(phys0)
93
if (time > 0.1) then
94
prk.SetParam(phys0, "rho", 0.8)
95
end
96
end
97
\endcode
98
for which the last portion of the output would be:
99
\verbatim
100
[0] Final program time 00:00:00
101
[0] 2023-09-04 08:32:02 ChiTech finished execution of scratch/RPK/rpk1.lua
102
[0]
103
[0] SCALAR post-processors history at event "ProgramExecuted"
104
[0] *----------*--------------------*
105
[0] | Time | neutron_population |
106
[0] *----------*--------------------*
107
[0] | 0.060000 | 1.000000 |
108
[0] | 0.070000 | 1.000000 |
109
[0] | 0.080000 | 1.000000 |
110
[0] | 0.090000 | 1.000000 |
111
[0] | 0.100000 | 1.000000 |
112
[0] | 0.110000 | 1.000000 |
113
[0] | 0.120000 | 3.285132 |
114
[0] | 0.130000 | 4.316595 |
115
[0] | 0.140000 | 4.807549 |
116
[0] | 0.150000 | 5.065645 |
117
[0] | 0.160000 | 5.223603 |
118
[0] | 0.170000 | 5.338682 |
119
[0] | 0.180000 | 5.435592 |
120
[0] | 0.190000 | 5.524998 |
121
[0] | 0.200000 | 5.611508 |
122
[0] | Latest | 5.611508 |
123
[0] *----------*--------------------*
124
[0]
125
[0] SCALAR post-processors latest values at event "ProgramExecuted"
126
[0] *------------------------------*-----------------*
127
[0] | Post-Processor Name | Value |
128
[0] *------------------------------*-----------------*
129
[0] | neutron_population(latest) | 5.611508 |
130
[0] *------------------------------*-----------------*
131
\endverbatim
132
133
Here we can see that the `chi::PostProcessorPrinter` printed both the time
134
history of the post-processor as well its latest value.
135
136
The time history can be suppressed by adding the following to the input
137
\code
138
chi.PostProcessorPrinterSetOptions
139
({
140
print_scalar_time_history = false
141
})
142
\endcode
143
which results in only the latest value being printed
144
\verbatim
145
[0] Final program time 00:00:00
146
[0] 2023-09-04 08:34:41 ChiTech finished execution of scratch/RPK/rpk1.lua
147
[0]
148
[0] SCALAR post-processors latest values at event "ProgramExecuted"
149
[0] *------------------------------*-----------------*
150
[0] | Post-Processor Name | Value |
151
[0] *------------------------------*-----------------*
152
[0] | neutron_population(latest) | 5.611508 |
153
[0] *------------------------------*-----------------*
154
\endverbatim
155
156
### 3.2.2 Exporting to CSV
157
The time history of a post-processor can also be exported to a
158
Comma Separated Value file (CSV-file) by setting the `csv_filename` option in
159
\ref chi__PostProcessorPrinterSetOptions. Example:
160
\code
161
chi.PostProcessorPrinterSetOptions
162
({
163
csv_filename = "rpk1.csv"
164
})
165
\endcode
166
167
### 3.2.3 Manual printing of post-processors
168
Post-processors can be printing manually whenever needed by using either a list
169
of post-processor names or handles. For example:
170
\code
171
chi.PrintPostProcessors({"test_arb", "period(s)6"}) --using names
172
chi.PrintPostProcessors({pp0, pp1}) --using handles
173
\endcode
174
175
### 3.2.4 Controlling numeric formats
176
Each post-processor has the options `print_numeric_format` and `print_precision`
177
that controls how numbers are printed. For more about this see
178
\ref chi__PostProcessor.
179
*
180
* */
framework
post_processors
doc
doc_PostProcessors.h
Generated by
1.9.3