Peano
Loading...
Searching...
No Matches
GlobalState.template.cpp
Go to the documentation of this file.
1/* Template in python/swift2/output/GlobalState.template.cpp */
2
3#include <algorithm>
4
5#include "GlobalState.h"
6#include "Constants.h"
7
8#include "peano4/grid/grid.h"
10
11
13
14
15{% for PARTICLE in PARTICLE_SPECIES -%}
16#include "globaldata/{{ PARTICLE }}.h"
17#include "vertexdata/{{ PARTICLE }}Set.h"
18{% endfor %}
19
20
21{% for item in NAMESPACE -%}
22 namespace {{ item }} {
23{%- endfor %}
24
25
26tarch::logging::Log _log( "{{NAMESPACE | join("::")}}::GlobalState" );
27
28{% if LOAD_BALANCER!="" -%}
29{{LOAD_BALANCER}} loadBalancer({{LOAD_BALANCER_ARGUMENTS}});
30{% else -%}
32{% endif -%}
33
34
35bool rerunPreviousGridSweep() {
36 bool result = false;
37 {% for PARTICLE in PARTICLE_SPECIES -%}
38 result |= vertexdata::{{PARTICLE}}Set::getNumberOfDropsIntoHorizontalTreeDecomposition()>0;
39
40 result |= globaldata::{{PARTICLE}}::getSpecies().rerunPreviousGridSweep();
41 {%- endfor %}
42 return result;
43}
44
45
46double getMinTimeStamp() {
47 double result = std::numeric_limits<double>::max();
48 {% for PARTICLE in PARTICLE_SPECIES -%}
49 result = std::min( result, globaldata::{{PARTICLE}}::getSpecies().getMinTimeStamp() );
50 {%- endfor %}
51 return result;
52}
53
54
55double getMaxTimeStamp() {
56 double result = 0.0;
57 {% for PARTICLE in PARTICLE_SPECIES -%}
58 result = std::max( result, globaldata::{{PARTICLE}}::getSpecies().getMaxTimeStamp() );
59 {%- endfor %}
60 return result;
61}
62
63
64double getMinSearchRadius() {
65 double result = std::numeric_limits<double>::max();
66 {% for PARTICLE in PARTICLE_SPECIES -%}
67 result = std::min( result, globaldata::{{PARTICLE}}::getSpecies().getMinSearchRadius() );
68 {%- endfor %}
69 return result;
70}
71
72
73double getMaxSearchRadius() {
74 double result = 0.0;
75 {% for PARTICLE in PARTICLE_SPECIES -%}
76 result = std::max( result, globaldata::{{PARTICLE}}::getSpecies().getMaxSearchRadius() );
77 {%- endfor %}
78 return result;
79}
80
81
82double getMinTimeStepSize() {
83 double result = std::numeric_limits<double>::max();
84 {% for PARTICLE in PARTICLE_SPECIES -%}
85 result = std::min( result, globaldata::{{PARTICLE}}::getSpecies().getMinTimeStepSize() );
86 {%- endfor %}
87 return result;
88}
89
90
91double getMaxTimeStepSize() {
92 double result = 0.0;
93 {% for PARTICLE in PARTICLE_SPECIES -%}
94 result = std::max( result, globaldata::{{PARTICLE}}::getSpecies().getMaxTimeStepSize() );
95 {%- endfor %}
96 return result;
97}
98
99
100void startGridConstructionStep() {
101 logTraceIn( "GridConstructionStep()" );
102}
103
104
105void startIntermediateStep() {
106 logTraceIn( "IntermediateStep()" );
107
108 {% for PARTICLE in PARTICLE_SPECIES -%}
109 vertexdata::{{PARTICLE}}Set::clearReassignmentStatistics();
110 {%- endfor %}
111}
112
113
114void startInitialConditionStep() {
115 if (not ::swift2::commandlinesettings::enableDynamicLoadBalancing() ) {
116 loadBalancer.enable(false);
117 }
118 logTraceIn( "InitialConditionStep()" );
119}
120
121
122void startInitialisationStep() {
123 if (not ::swift2::commandlinesettings::enableDynamicLoadBalancing() ) {
124 loadBalancer.enable(false);
125 }
126 logTraceIn( "InitialisationStep()" );
127}
128
129
130void startTimeStep() {
131 logTraceIn( "startTimeStep()" );
132 {% for PARTICLE in PARTICLE_SPECIES -%}
133 globaldata::{{PARTICLE}}::getSpecies().startTimeStep();
134
135 vertexdata::{{PARTICLE}}Set::clearReassignmentStatistics();
136 vertexdata::{{PARTICLE}}Set::clearParticleStateStatistics();
137 {%- endfor %}
138 logTraceOut( "startTimeStep()" );
139}
140
141
142void startPlotStep() {
143 logTraceIn( "PlotStep()" );
144}
145
146
147void startCleanupStep() {
148 logTraceIn( "CleanupStep()" );
149}
150
151
152void finishTimeStep() {
153 logTraceIn( "finishTimeStep()" );
154
155 {% for PARTICLE in PARTICLE_SPECIES -%}
156 globaldata::{{PARTICLE}}::getSpecies().finishTimeStep();
157 vertexdata::{{PARTICLE}}Set::reduceParticleStateStatistics();
158 logInfo("finishTimeStep()", vertexdata::{{PARTICLE}}Set::printParticleStateStatistics() );
159 {%- endfor %}
160
161 loadBalancer.finishStep();
162
163 logInfo("finishTimeStep()", "min mesh size=" << ::peano4::parallel::SpacetreeSet::getInstance().getGridStatistics().getMinH()(0) );
164 logInfo("finishTimeStep()",
165 "#local cells=(" << ::peano4::parallel::SpacetreeSet::getInstance().getGridStatistics().getNumberOfLocalUnrefinedCells() <<
166 "/" << ::peano4::parallel::SpacetreeSet::getInstance().getGridStatistics().getNumberOfLocalRefinedCells() <<
167 ")\t(unrefined/refined)"
168 );
169 logInfo("finishTimeStep()",
170 "#remote cells=(" << ::peano4::parallel::SpacetreeSet::getInstance().getGridStatistics().getNumberOfRemoteUnrefinedCells() <<
171 "/" << ::peano4::parallel::SpacetreeSet::getInstance().getGridStatistics().getNumberOfRemoteRefinedCells() <<
172 ")\t(unrefined/refined)"
173 );
174
175 #ifdef UseSmartMPI
176 smartmpi::tick();
177 #endif
178 logTraceOut( "finishTimeStep()" );
179}
180
181
182void finishGridConstructionStep() {
183 loadBalancer.finishStep();
184 logTraceOut( "GridConstructionStep()" );
185}
186
187
188void finishInitialisationStep() {
189 {% for PARTICLE in PARTICLE_SPECIES -%}
190 vertexdata::{{PARTICLE}}Set::reduceReassignmentStatistics();
191 vertexdata::{{PARTICLE}}Set::reduceParticleStateStatistics();
192 {%- endfor %}
193
194 loadBalancer.finishStep();
195 logTraceOut( "InitialisationStep()" );
196}
197
198
199void finishInitialConditionStep() {
200 {% for PARTICLE in PARTICLE_SPECIES -%}
201 vertexdata::{{PARTICLE}}Set::clearReassignmentStatistics();
202 vertexdata::{{PARTICLE}}Set::clearParticleStateStatistics();
203 {%- endfor %}
204
205 loadBalancer.finishStep();
206 logTraceOut( "InitialConditionStep()" );
207}
208
209
210void finishPlotStep() {
211 logTraceOut( "PlotStep()" );
212}
213
214
215void finishCleanupStep() {
216 logTraceOut( "CleanupStep()" );
217}
218
219
220void finishIntermediateStep() {
221 {% for PARTICLE in PARTICLE_SPECIES -%}
222 vertexdata::{{PARTICLE}}Set::reduceReassignmentStatistics();
223 if (vertexdata::{{PARTICLE}}Set::registeredAnyResorting()) {
224 logInfo( "finishIntermediateStep()", vertexdata::{{PARTICLE}}Set::printReassignmentStatistics() );
225 }
226 {%- endfor %}
227 logTraceOut( "IntermediateStep()" );
228}
229
230{% for item in NAMESPACE -%}
231 }
232
233{%- endfor %}
234
#define logTraceOut(methodName)
Definition Log.h:379
#define logTraceIn(methodName)
Definition Log.h:369
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:411
static SpacetreeSet & getInstance()
Log Device.
Definition Log.h:516
virtual void finishStep() override
Finish a mesh sweep.
virtual void enable(bool value) override
You cannot enable the no load balancing.
tarch::logging::Log _log("exahype2::fv")