3
/// This file is part of Rheolef.
5
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7
/// Rheolef is free software; you can redistribute it and/or modify
8
/// it under the terms of the GNU General Public License as published by
9
/// the Free Software Foundation; either version 2 of the License, or
10
/// (at your option) any later version.
12
/// Rheolef is distributed in the hope that it will be useful,
13
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
/// GNU General Public License for more details.
17
/// You should have received a copy of the GNU General Public License
18
/// along with Rheolef; if not, write to the Free Software
19
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/// =========================================================================
23
// TODO: filter options
32
// -select u <==> -mask-all -unmask u
36
// -norm {-l2|-linf|-h1}
37
// -> normes in direct via gnuplot via branch (geo with dim=0)
39
// Q. how to combine and synchronize images u(t) and |u(t)| ?
40
// -> field n(t,x), mesh with dim=0, one point p0, value n(t,p0) = |u(t)|
43
// sqrt(|u^{n+1}-u^n|/(t^{n+1}-t^n)) : mesure a(u,u), l'energie (norme l2 pour u)
46
// -height : with -topography, interprets scalar as height
47
// -yield value : mask all scalars lesser than
51
// transparency : of the height
52
// edit color map for height : can put uniform color
56
NAME: @code{branch} -- handle a family of fields
59
@cindex continuation methods
60
@cindex time-dependent problems
62
@cindex RHEOPATH environment variable
63
@fiindex @file{.branch} family of fields
67
branch [@var{options}] @var{filename}
71
Generates vtk file colection for visualization with paraview:
73
branch output.branch -paraview
76
Read and output a branch of finite element fields from file,
77
in field text file format.
78
INPUT FILE SPECIFICATION:
82
add @var{dir} to the RHEOPATH search path.
83
See also @ref{geo class} for RHEOPATH mechanism.
86
specifies the name of the file containing
90
read field on standard input instead on a file.
92
@itemx -ndigit @var{int}
93
Number of digits used to print floating point values
94
when using the @samp{-geo} option.
95
Default depends upon the machine precision associated to the
100
OUTPUT AND RENDER SPECIFICATION:
103
@itemx -extract @var{int}
104
Extract the i-th record in the file. The output
105
is a field or multi-field file format.
108
Output on stdout in @file{.branch} format.
117
Generate a collection of @code{vtk} files
118
for using @code{paraview}.
121
Generate a single @code{vtk} file
122
with numbered fields.
125
Run 1d animation using @code{gnuplot}.
128
This driver is unsupported for animations.
135
@itemx -umin @var{float}
136
@itemx -umax @var{float}
137
set the solution range for the @code{gnuplot} driver.
138
By default this range is computed from the first field
139
of the branch, and this could be problematic when this
140
field is initialy zero.
143
@itemx -topography @var{filename}[.field[.gz]]
144
performs a tridimensionnal elevation view based
145
on the topographic data.
151
performs a @code{P1} projection on the fly.
152
This option is useful when rendering @code{P0} data
153
while @code{vtk} render requieres @code{P1} description.
157
For two dimensional field, represent values as elevation in the third dimension.
161
Prevent from the elevation representation.
163
@itemx -scale @var{float}
164
applies a multiplicative factor to the field.
165
This is useful e.g. in conjonction with the @code{elevation} option.
166
The default value is 1.
169
print messages related to graphic files created and
170
command system calls (this is the default).
173
does not print previous messages.
176
clear temporary graphic files (this is the default).
179
does not clear temporary graphic files.
182
execute graphic command (this is the default).
185
does not execute graphic command. Generates only
186
graphic files. This is usefull in conjuction with the
187
@code{-noclean} command.
195
@fiindex @file{.field} field
197
The @file{.branch} file format bases on the @file{.field} one:
203
1 1 11 <version> <nfield=1> <nvalue=N>
204
time u <key> <field name>
206
#time 3.14 #<key> <key value 1>
212
#time 6.28 #<key> <key value N>
217
The key name is here @code{time}, but could be any string (without spaces).
218
The previous example contains one @code{field} at each time step.
219
Labels appears all along the file to facilitate direct jumps and field and step skips.
221
The format supports several fields, such as (t,u(t),p(t)), where u could
222
be a multi-component (e.g. a vector) field:
246
// -------------------------------------------------------------
248
// -------------------------------------------------------------
250
#include <rheolef/iofem.h>
251
using namespace rheolef;
256
cerr << "branch: usage: branch"
260
<< " [-[no]elevation]"
264
<< " [-topography filename]"
266
<< " [-paraview|-vtk|-gnuplot|-plotmtv]"
267
<< " [-[no]verbose|-[no]clean|-[no]execute]"
272
typedef field::size_type size_type;
275
extract (idiststream& in, odiststream& out, bool do_proj, size_type extract_id,const Float& scale_value)
277
branch_basic<Float,sequential> event;
278
in >> event.header();
279
out << event.header();
282
in >> catchmark (event.parameter_name());
284
} while (i <= extract_id);
290
event.set_parameter (t);
291
for (size_t i = 0; in && i < event.size(); i++) {
292
in >> catchmark (event[i].first) >> event[i].second;
294
field_basic<Float,sequential> u = event[0].second;
296
fatal_macro ("-proj: not yet -- sorry");
298
space_basic<Float,sequential> V = u.get_space();
299
space_basic<Float,sequential> V1 (u.get_geo(), "P1");
300
field_basic<Float,sequential> one (V1, 1);
301
form_basic<Float,sequential> proj (V, V1, "mass");
302
form_diag_basic<Float,sequential> m (V1, "mass");
303
field_basic<Float,sequential> u1(V1);
304
u1.u = (1./m.uu)*(proj.uu*u.u);
308
if (scale_value != Float(1)) {
312
out << event.finalize();
319
size_type extract_id,
320
const Float& scale_value,
321
const std::pair<Float,Float>& u_range)
323
if (extract_id != numeric_limits<size_type>::max()) {
324
extract (in, out, do_proj, extract_id, scale_value);
328
field_basic<Float,sequential> u;
329
branch_basic<Float,sequential> event;
330
event.set_range (u_range);
332
in >> event.header();
333
out << event.header();
334
while (in >> event) {
335
for (size_t i = 0; i < event.size(); i++) {
338
fatal_macro ("-proj: not yet -- sorry");
340
space_basic<Float,sequential> V = u.get_space();
341
size_t n_comp = u.n_component();
342
space_basic<Float,sequential> V_new_i (u.get_geo(), "P1");
343
space_basic<Float,sequential> V_new = pow(V_new_i, n_comp);
344
field_basic<Float,sequential> u_new(V_new);
345
field_basic<Float,sequential> one (V_new_i, 1);
346
for (size_t i = 0; i < n_comp; i++) {
347
space_basic<Float,sequential> Vi = V[i];
348
form_basic<Float,sequential> proj (Vi, V_new_i, "mass");
349
form_diag_basic<Float,sequential> m (V_new_i, "mass");
350
field_basic<Float,sequential> u_new_i(V_new_i);
351
u_new_i.u = (1./m.uu)*(proj.uu*u[i].u);
357
if (scale_value != Float(1)) {
365
out << event.finalize();
367
int main(int argc, char**argv)
369
environment distributed(argc, argv);
370
if (argc <= 1) usage();
372
dout.os() << elevation;
373
bool on_stdin = false;
374
bool do_proj = false;
375
int digits10 = numeric_limits<Float>::digits10;
376
typedef enum { text_render, paraview_render, vtk_render, plotmtv_render, gnuplot_render } render_type;
377
render_type render = text_render;
378
size_type extract_id = numeric_limits<size_type>::max();
379
Float scale_value = 1;
381
std::pair<Float,Float> u_range;
382
u_range.first = std::numeric_limits<Float>::min();
383
u_range.second = std::numeric_limits<Float>::max();
385
for (int i = 1; i < argc; i++) {
387
if (strcmp (argv[i], "-ndigit") == 0) { digits10 = atoi(argv[++i]); }
388
else if (strcmp (argv[i], "-extract") == 0) { extract_id = atoi(argv[++i]); }
389
else if (strcmp (argv[i], "-branch") == 0) { render = text_render; }
390
else if (strcmp (argv[i], "-paraview") == 0) { render = paraview_render; dout.os() << paraview; }
391
else if (strcmp (argv[i], "-vtk") == 0) { render = vtk_render; dout.os() << vtk; }
392
else if (strcmp (argv[i], "-plotmtv") == 0) { render = plotmtv_render; dout.os() << plotmtv; }
393
else if (strcmp (argv[i], "-gnuplot") == 0) { render = gnuplot_render; dout.os() << gnuplot; }
394
else if (strcmp (argv[i], "-proj") == 0) { do_proj = true; }
395
else if (strcmp (argv[i], "-elevation") == 0) { dout.os() << elevation; }
396
else if (strcmp (argv[i], "-noelevation") == 0) { dout.os() << noelevation; }
397
else if (strcmp (argv[i], "-umin") == 0) {
398
if (i+1 == argc || !is_float(argv[i+1])) usage();
399
u_range.first = to_float (argv[++i]);
400
} else if (strcmp (argv[i], "-umax") == 0) {
401
if (i+1 == argc || !is_float(argv[i+1])) usage();
402
u_range.second = to_float (argv[++i]);
403
} else if (strcmp (argv[i], "-scale") == 0) {
404
if (i+1 == argc || !is_float(argv[i+1])) usage();
405
scale_value = to_float (argv[++i]);
406
} else if (strcmp (argv[i], "-topography") == 0) {
408
if (i+1 == argc) usage();
409
idiststream zin (argv[++i]);
410
field_basic<Float,sequential> z;
412
dout.os() << settopography(z);
414
else if (strcmp (argv[i], "-noclean") == 0) clog << noclean;
415
else if (strcmp (argv[i], "-clean") == 0) clog << clean;
416
else if (strcmp (argv[i], "-noexecute") == 0) clog << noexecute;
417
else if (strcmp (argv[i], "-execute") == 0) clog << execute;
418
else if (strcmp (argv[i], "-verbose") == 0) clog << verbose;
419
else if (strcmp (argv[i], "-noverbose") == 0) clog << noverbose;
421
else if (argv [i][0] == '-' && argv [i][1] == 'I') {
423
append_dir_to_rheo_path (argv[i]+2);
425
else if (strcmp (argv [i], "-") == 0) {
428
dout.os() << setbasename("output") << reader_on_stdin;
429
file_name = "output";
434
string dir_name = get_dirname(argv[i]);
435
prepend_dir_to_rheo_path (dir_name);
436
file_name = get_basename(delete_suffix (delete_suffix (argv[i], "gz"), "branch"));
439
if (!on_stdin && file_name == "") {
440
cerr << "branch: no input specified" << endl;
443
dout.os() << setbasename(file_name)
444
<< setprecision(digits10);
447
put(din,dout, do_proj, extract_id, scale_value, u_range);
449
idiststream in (file_name, "branch");
450
check_macro(in.good(), "\"" << file_name << "[.branch[.gz]]\" not found.");
451
put(in, dout, do_proj, extract_id, scale_value, u_range);