13#include "arcane/PreciseOutputChecker.h"
27 m_output_period_physical_time = output_period;
36 m_table_values_physical_time = output_table;
42void PreciseOutputChecker::
43initializeOutputIteration(Integer output_period)
45 m_output_period_iteration = output_period;
51void PreciseOutputChecker::
52initializeOutputIteration(ICaseFunction* output_table)
54 m_table_values_iteration = output_table;
61checkIfOutput(Real old_time, Real current_time, Integer current_iteration)
63 bool output_requested =
false;
66 if (m_table_values_physical_time !=
nullptr) {
67 m_table_values_physical_time->
value(current_time, m_output_period_physical_time);
70 if (!output_requested) {
71 output_requested = _checkTime(old_time, current_time, m_output_period_physical_time);
74 if (!output_requested) {
75 output_requested = _checkTimeInterval(old_time, current_time, m_output_period_physical_time);
79 if (!output_requested) {
81 if (m_table_values_iteration !=
nullptr) {
82 m_table_values_iteration->
value(current_iteration, m_output_period_iteration);
84 if (m_output_period_iteration > 0) {
86 if (current_iteration % m_output_period_iteration == 0) {
87 output_requested =
true;
91 return output_requested;
97bool PreciseOutputChecker::
98_checkTimeInterval(Real old_time, Real current_time, Real output_period)
100 bool output_requested =
false;
101 if (output_period > 0) {
102 Integer number_of_previous_outputs = (int)floor(old_time / output_period);
103 Integer number_of_current_outputs = (int)floor(current_time / output_period);
105 if (number_of_previous_outputs != number_of_current_outputs) {
109 Integer number_of_previous_outputs_ceil = (int)ceil(old_time / output_period);
110 Real old_time_reconstruct = number_of_previous_outputs_ceil * output_period;
111 if ((old_time_reconstruct - old_time) > 1e-7 * old_time) {
112 output_requested =
true;
116 return output_requested;
122bool PreciseOutputChecker::
123_checkOldTime(Real old_time, Real output_period, Integer current_number_of_outputs)
125 bool output_requested =
true;
126 Integer prev_number_of_outputs_round = (int)
floor(old_time / output_period);
127 if (prev_number_of_outputs_round == current_number_of_outputs) {
129 Real prev_output_time_round = current_number_of_outputs * output_period;
131 bool old_time_output_requested = _compareTime(old_time, prev_output_time_round);
133 if (old_time_output_requested) {
134 output_requested =
false;
139 if (output_requested) {
140 Integer prev_number_of_outputs_ceil = (int)ceil(old_time / output_period);
141 if (prev_number_of_outputs_ceil == current_number_of_outputs) {
143 Real prev_output_time_ceil = prev_number_of_outputs_ceil * output_period;
145 bool old_time_output_requested = _compareTime(old_time, prev_output_time_ceil);
147 if (old_time_output_requested) {
148 output_requested =
false;
152 return output_requested;
158bool PreciseOutputChecker::
159_checkTime(Real old_time, Real current_time, Real output_period)
161 bool output_requested =
false;
163 if (output_period > 0) {
167 Integer number_of_outputs_round = (int)
floor(current_time / output_period);
168 Integer number_of_outputs_ceil = (int)ceil(current_time / output_period);
170 Real next_output_time_round = number_of_outputs_round * output_period;
171 Real next_output_time_ceil = number_of_outputs_ceil * output_period;
173 output_requested = _compareTime(current_time, next_output_time_round);
184 if (output_requested) {
185 output_requested = _checkOldTime(old_time, output_period, number_of_outputs_round);
188 if (!output_requested) {
189 output_requested = _compareTime(current_time, next_output_time_ceil);
191 if (output_requested) {
192 output_requested = _checkOldTime(old_time, output_period, number_of_outputs_ceil);
197 return output_requested;
203bool PreciseOutputChecker::
204_compareTime(Real current_time, Real compar_time)
206 bool output_requested =
false;
207 if (compar_time > 0.0) {
211 if (((math::abs(current_time - compar_time))) < 1.0e-7 * compar_time) {
212 output_requested =
true;
215 return output_requested;
virtual void value(Real param, Real &v) const =0
Valeur v de l'option pour le paramètre param.
bool checkIfOutput(double old_time, double current_time, Integer current_iteration)
Indique s'il faut ou non faire une sortie.
void initializeOutputPhysicalTime(double output_period)
__host__ __device__ double floor(double v)
Arondir v à l'entier immédiatement inférieur.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
double Real
Type représentant un réel.
Int32 Integer
Type représentant un entier.