14#include "arcane/utils/ArcanePrecomp.h"
16#include "arcane/utils/CheckedConvert.h"
17#include "arcane/utils/ITraceMng.h"
19#include "arcane/ISubDomain.h"
20#include "arcane/ICaseFunction.h"
21#include "arcane/CommonVariables.h"
23#include "arcane/OutputChecker.h"
34OutputChecker(ISubDomain* sd,
const String& name)
37, m_out_type(OutTypeNone)
39, m_next_global_time(0)
42, m_step_global_time(0)
47assignGlobalTime(VariableScalarReal* variable,
const CaseOptionReal* option)
49 m_next_global_time = variable;
50 m_step_global_time = option;
54assignCPUTime(VariableScalarInteger* variable,
const CaseOptionInteger* option)
56 m_next_cpu_time = variable;
57 m_step_cpu_time = option;
61assignIteration(VariableScalarInteger* variable,
const CaseOptionInteger* option)
63 m_next_iteration = variable;
64 m_step_iteration = option;
92 if (m_out_type==OutTypeNone)
95 ITraceMng* trace = m_sub_domain->traceMng();
100 case OutTypeGlobalTime:
102 Real
next_time = (*m_next_global_time)();
104 <<
" Current time: " <<
current_time <<
" step=" << m_step_global_time;
121 if (!math::isZero(
to_add)){
138 case OutTypeIteration:
157 <<
"Next output at iteration " << (*m_next_iteration)()
182 <<
"Next output at cpu time " << (*m_next_cpu_time)()
213_recomputeTypeGlobalTime()
215 Real
current_time = m_sub_domain->commonVariables().globalTime();
218 Real
old_next = (*m_next_global_time)();
221 if (!math::isZero(
step)){
223 next =
step*(index+1.0);
224 *m_next_global_time = next;
227 ITraceMng* tm = m_sub_domain->traceMng();
228 tm->info(4) <<
"Recompute OutputChecker for Global Time: old=" << old_next
236_recomputeTypeCPUTime()
238 Real current_time = m_sub_domain->commonVariables().globalTime();
239 Integer step = m_step_cpu_time->valueAtParameter(current_time);
241 Integer old_next = (*m_next_cpu_time)();
243 double current_value = math::floor(m_sub_domain->commonVariables().globalCPUTime());
246 current_value /= 60.0;
249 Integer index = CheckedConvert::toInteger(current_value / step);
250 next = step*(index+1);
251 *m_next_cpu_time = next;
254 ITraceMng* tm = m_sub_domain->traceMng();
255 tm->info(4) <<
"Recompute OutputChecker for CPU Time: old=" << old_next <<
" new=" << next;
262_recomputeTypeIteration()
264 Real current_time = m_sub_domain->commonVariables().globalTime();
265 Integer step = m_step_iteration->valueAtParameter(current_time);
267 Integer old_next = (*m_next_iteration)();
269 Integer current_value = m_sub_domain->commonVariables().globalIteration();
271 if (old_next<=current_value){
272 *m_next_iteration = current_value;
275 Integer index = current_value / step;
276 next = step*(index+1);
277 *m_next_iteration = next;
281 ITraceMng* tm = m_sub_domain->traceMng();
282 tm->info(4) <<
"Recompute OutputChecker for CPU Time: old=" << old_next <<
" new=" << next;
298initialize(
bool recompute_next_value)
300 ITraceMng* trace = m_sub_domain->traceMng();
301 m_out_type = OutTypeNone;
303 ICaseFunction* func = 0;
306 if (m_step_global_time && m_next_global_time && m_step_global_time->isPresent()){
307 m_out_type = OutTypeGlobalTime;
308 func = m_step_global_time->function();
310 trace->info() <<
"Output in real time controlled by function '" << func->name() <<
"'.";
312 trace->info() <<
"Output in real time every " << (*m_step_global_time)() <<
" seconds.";
313 if (recompute_next_value)
314 _recomputeTypeGlobalTime();
316 else if (m_step_iteration && m_next_iteration && m_step_iteration->value()!=0){
317 m_out_type = OutTypeIteration;
318 func = m_step_iteration->function();
320 trace->info() <<
"Output in iterations controlled by function '" << func->name() <<
"'.";
322 trace->info() <<
"Output every " << (*m_step_iteration)() <<
" iterations.";
323 if (recompute_next_value)
324 _recomputeTypeIteration();
326 else if (m_step_cpu_time && m_next_cpu_time && m_step_cpu_time->isPresent()){
327 m_out_type = OutTypeCPUTime;
328 func = m_step_cpu_time->function();
330 trace->info() <<
"Output in CPU time controlled by function '" << func->name() <<
"'.";
332 trace->info() <<
"Output in CPU time every " << (*m_step_cpu_time)() <<
" minutes.";
333 if (recompute_next_value)
334 _recomputeTypeCPUTime();
337 trace->info() <<
"No output required.";
344nextGlobalTime()
const
347 if (m_next_global_time)
348 v = (*m_next_global_time)();
359 if (m_next_iteration)
360 v = (*m_next_iteration)();
372 v= (*m_next_cpu_time)();
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Interface du gestionnaire de traces.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Flot pour un message de debug.
Chaîne de caractères unicode.
Int32 Integer
Type représentant un entier.