Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
progress.h
Go to the documentation of this file.
1
/** @file progress.h
2
*/
3
static
int
_ilast
= -1;
4
static
double
_tlast
= -1;
5
static
timer
_progresst
;
6
static
int
_progressn
= 0;
7
8
static
void
last_events
()
9
{
10
disable_fpe
(
FE_DIVBYZERO
|
FE_INVALID
);
11
t
= 0.,
iter
= 0;
12
// look for events happening at specific times
13
while
(
events
(
false
) &&
tnext
<
HUGE
)
14
t
=
tnext
,
iter
=
inext
;
15
if
(
t
> 0.)
16
_ilast
= 0,
_tlast
=
t
;
17
else
{
18
// look for condition on maximum time
19
double
tmin
= 0.,
tmax
=
HUGE
;
20
while
((
tmax
-
tmin
)/(
tmax
+
tmin
) > 0.01 &&
tmax
-
tmin
> 1
e
-30) {
21
t
= (
tmin
+
tmax
)/2.;
22
if
(
events
(
false
))
23
tmin
=
t
;
24
else
25
tmax
=
t
;
26
}
27
if
(
t < HUGE/2. && t >
1
e
-30)
28
_ilast
= 0,
_tlast
=
t
;
29
else
{
30
// look for condition on maximum number of iterations
31
_tlast
=
t
= 0.;
32
iter
= 0;
33
while
(
events
(
false
) &&
iter
< 1<<16)
34
iter
=
inext
;
35
_ilast
=
iter
< 1<<16 ?
iter
: 0;
36
}
37
}
38
enable_fpe
(
FE_DIVBYZERO
|
FE_INVALID
);
39
#if 0
40
fprintf
(
stderr
,
"_tlast: %g _ilast: %d\n"
,
_tlast
,
_ilast
);
41
exit
(1);
42
#endif
43
}
44
45
/** @brief Event: _progress (i += 5) */
46
void
event__progress
(
void
)
47
{
48
static
FILE
*
fp
=
fopen
(
"progress"
,
"w"
);
49
if
(
i
== 0) {
50
_progresst
=
timer_start
();
51
_progressn
++;
52
}
53
double
peri
=
_ilast
?
i
/(
double
)
_ilast
: 1.,
54
pert
=
_tlast
?
t
/
_tlast
: 1.,
per
=
min
(
peri
,
pert
);
55
if
(
per
> 0.01 &&
per
< 1.) {
56
fprintf
(
fp
,
"%2.0f%% done"
,
floor
(
per
*100.));
57
double
rem
=
per
?
timer_elapsed
(
_progresst
)*(1. -
per
)/
per
: 0.;
58
if
(
rem
> 0.) {
59
double
min
=
floor
(
rem
/60.);
60
fprintf
(
fp
,
", %02.0f:%02.0f remaining"
,
min
,
rem
- 60.*
min
);
61
}
62
if
(
_progressn
> 1)
63
fprintf
(
fp
,
" (run #%d)"
,
_progressn
);
64
}
65
fputc
(
'\r'
,
fp
);
66
fflush
(
fp
);
67
}
min
int min
Definition
balance.h:192
x
int x
Definition
common.h:76
HUGE
#define HUGE
Definition
common.h:6
timer_elapsed
double timer_elapsed(timer t)
Definition
common.h:379
timer_start
timer timer_start(void)
Definition
common.h:368
enable_fpe
if __APPLE__ include< stdint.h > include fp_osx h endif if _GPU define enable_fpe(flags) @else @ define enable_fpe(flags) feenableexcept(flags) @endif @ define disable_fpe(flags) fedisableexcept(flags) static void set_fpe(void)
Definition
config.h:603
i
scalar int i
Definition
embed.h:74
t
double t
Definition
events.h:24
inext
int inext
Definition
events.h:23
iter
int iter
Definition
events.h:23
tnext
double tnext
Definition
events.h:24
fp
FILE * fp
Definition
mtrace.h:7
event__progress
void event__progress(void)
Event: _progress (i += 5)
Definition
progress.h:46
_tlast
static double _tlast
Definition
progress.h:4
last_events
static void last_events()
Definition
progress.h:8
_ilast
static int _ilast
Definition
progress.h:3
_progressn
static int _progressn
Definition
progress.h:6
_progresst
static timer _progresst
Definition
progress.h:5
events
int events
Definition
qcc.c:60
timer
Definition
common.h:362
fflush
src vof fflush(ferr)
grid
progress.h
Generated by
1.9.8