384 #include <rheolef/iofem.h>
390 cerr <<
"branch: usage: branch "
391 <<
"-|file[.branch[.gz]]"
395 <<
"[-index int|-extract int] "
396 <<
"[-[catch]mark string] "
400 <<
"[-if {branch,vtk}] "
401 <<
"[-paraview|-gnuplot] "
403 <<
"[-[no]verbose|-[no]clean|-[no]execute] "
404 <<
"[-color|-gray|-black-and-white|-bw] "
405 <<
"[-[no]elevation] "
408 <<
"[-[no]showlabel] "
409 <<
"[-label string] "
412 <<
"[-normal x [y [z]]] "
413 <<
"[-origin x [y [z]]] "
415 <<
"[-iso[value] float|-noiso[value]] "
417 <<
"[-n-iso-negative int] "
418 <<
"[-topography filename] "
421 <<
"[-subdivide int] "
430 size_t k = Uh.degree();
432 std::string approx =
"P" +
itos(k);
437 fopt.
lump = do_lumped_mass;
439 switch (Uh.valued_tag()) {
454 error_macro (
"proj: unexpected valued field: " << Uh.valued());
466 out <<
event.header();
471 }
while (i <= extract_id);
477 event.set_parameter (t);
478 for (
size_t i = 0; in && i <
event.size(); i++) {
479 in >>
catchmark (event[i].first) >>
event[i].second;
482 if (do_proj && uh.
get_space().get_basis().have_compact_support_inside_element()) {
483 uh =
proj (uh, do_lumped_mass);
485 if (scale_value !=
Float(1)) {
489 out <<
event.finalize();
507 const Float& scale_value,
508 const std::pair<Float,Float>& u_range,
511 if (extract_id != numeric_limits<size_type>::max()) {
512 extract (in,
out, do_proj, do_lumped_mass, extract_id, scale_value);
517 if (u_range.first != std::numeric_limits<Float>::max() ||
518 u_range.second != -std::numeric_limits<Float>::max()) {
521 in >>
event.header();
523 in.is() >> noverbose;
524 out << setprecision(numeric_limits<Float>::digits10)
525 <<
"# i " <<
event.parameter_name() << endl;
528 out <<
n <<
" " << param << endl;
534 while (in >> event) {
535 for (
size_t i = 0; i <
event.size(); i++) {
536 uh =
event[i].second;
543 if (uh.
get_geo().map_dimension() == 3) {
545 if (!def_plane_cut_opt)
dout.
os() << cut;
547 if (!def_fill_opt)
dout.
os() << nofill;
550 if (!def_plane_cut_opt)
dout.
os() << nocut;
552 if (!def_fill_opt)
dout.
os() << fill;
554 out <<
event.header();
556 if (do_proj && uh.
get_space().get_basis().have_compact_support_inside_element()) {
557 uh =
proj (uh, do_lumped_mass);
559 if (scale_value !=
Float(1)) {
562 event[i].second = uh;
567 out <<
event.finalize();
571 if (input_format ==
"vtk") in.is() >>
vtk;
572 else if (input_format ==
"branch") in.is() >>
rheo;
574 std::cerr <<
"branch: invalid input format \""<<input_format<<
"\"" << std::endl;
581 if (argc <= 1)
usage();
584 bool on_stdin =
false;
585 bool do_proj =
false;
586 bool do_lumped_mass =
false;
588 bool def_fill_opt =
false;
589 int digits10 = numeric_limits<Float>::digits10;
591 size_type extract_id = numeric_limits<size_type>::max();
592 Float scale_value = 1;
593 string file_name,
name, input_format =
"branch";
594 std::pair<Float,Float> u_range;
595 u_range.first = std::numeric_limits<Float>::max();
596 u_range.second = -std::numeric_limits<Float>::max();
599 cout << setnormal(
point(-0.015940197423022637, -0.9771157601293953, -0.21211011624358989));
600 cout << setorigin(
point(std::numeric_limits<Float>::max()));
602 for (
int i = 1; i < argc; i++) {
604 if (strcmp (argv[i],
"-ndigit") == 0) { digits10 = atoi(argv[++i]); }
605 else if (strcmp (argv[i],
"-toc") == 0) { render =
toc_render; }
606 else if (strcmp (argv[i],
"-index") == 0 || strcmp (argv[i],
"-extract") == 0)
612 else if (strcmp (argv[i],
"-skipvtk") == 0) {
dout.
os() << skipvtk; }
613 else if (strcmp (argv[i],
"-proj") == 0) { do_proj =
true; }
614 else if (strcmp (argv[i],
"-lumped-proj") == 0){ do_proj = do_lumped_mass =
true; }
615 else if (strcmp (argv[i],
"-elevation") == 0) {
dout.
os() << elevation; }
616 else if (strcmp (argv[i],
"-noelevation") == 0) {
dout.
os() << noelevation; }
617 else if (strcmp (argv[i],
"-color") == 0) {
dout.
os() << color; }
618 else if (strcmp (argv[i],
"-gray") == 0) {
dout.
os() <<
gray; }
619 else if (strcmp (argv[i],
"-black-and-white") == 0) {
dout.
os() << black_and_white; }
620 else if (strcmp (argv[i],
"-bw") == 0) {
dout.
os() << black_and_white; }
621 else if (strcmp (argv[i],
"-showlabel") == 0) {
dout.
os() << showlabel; }
622 else if (strcmp (argv[i],
"-noshowlabel") == 0) {
dout.
os() << noshowlabel; }
623 else if (strcmp (argv[i],
"-fill") == 0) {
dout.
os() << fill; def_fill_opt =
true; }
624 else if (strcmp (argv[i],
"-nofill") == 0) {
dout.
os() << nofill; def_fill_opt =
true; }
625 else if (strcmp (argv[i],
"-stereo") == 0) {
dout.
os() << stereo;
631 else if (strcmp (argv[i],
"-nostereo") == 0) {
dout.
os() << nostereo; }
632 else if (strcmp (argv[i],
"-volume") == 0) {
dout.
os() <<
paraview << volume;
634 else if (strcmp (argv[i],
"-novolume") == 0) {
dout.
os() << novolume; }
635 else if (strcmp (argv[i],
"-cut") == 0) { do_cut =
true; }
636 else if (strcmp (argv[i],
"-nocut") == 0) { do_cut =
false; }
637 else if (strcmp (argv[i],
"-umin") == 0) {
639 u_range.first =
to_float (argv[++i]);
640 }
else if (strcmp (argv[i],
"-umax") == 0) {
642 u_range.second =
to_float (argv[++i]);
643 }
else if (strcmp (argv[i],
"-scale") == 0) {
646 dout.
os() << setvectorscale (scale_value);
647 }
else if (strcmp (argv[i],
"-noisovalue") == 0) {
649 }
else if (strcmp (argv[i],
"-isovalue") == 0 || strcmp (argv[i],
"-iso") == 0) {
652 if (i+1 < argc &&
is_float(argv[i+1])) {
654 dout.
os() << setisovalue(iso_value);
656 }
else if (strcmp (argv[i],
"-n-iso") == 0) {
658 if (i+1 == argc || !isdigit(argv[i+1][0]))
usage();
659 size_t idx = atoi (argv[++i]);
660 dout.
os() << setn_isovalue(idx);
662 }
else if (strcmp (argv[i],
"-n-iso-negative") == 0) {
664 if (i+1 == argc || !isdigit(argv[i+1][0]))
usage();
665 size_t idx = atoi (argv[++i]);
666 dout.
os() << setn_isovalue_negative(idx);
668 }
else if (strcmp (argv[i],
"-subdivide") == 0) {
669 if (i == argc-1) { cerr <<
"branch -subdivide: option argument missing" << endl;
usage(); }
670 size_t nsub = atoi(argv[++i]);
671 dout.
os() << setsubdivide (nsub);
672 }
else if (strcmp (argv[i],
"-topography") == 0) {
674 if (i+1 == argc)
usage();
675 idiststream zin (argv[++i]);
678 dout.
os() << settopography(z);
680 else if (strcmp (argv[i],
"-I") == 0) {
681 if (i+1 == argc) { cerr <<
"geo -I: option argument missing" << endl;
usage(); }
685 else if (strcmp (argv[i],
"-noclean") == 0) clog << noclean;
686 else if (strcmp (argv[i],
"-clean") == 0) clog <<
clean;
687 else if (strcmp (argv[i],
"-noexecute") == 0) clog << noexecute;
688 else if (strcmp (argv[i],
"-execute") == 0) clog << execute;
689 else if (strcmp (argv[i],
"-verbose") == 0) clog <<
verbose;
690 else if (strcmp (argv[i],
"-noverbose") == 0) clog << noverbose;
691 else if ((strcmp(argv[i],
"-origin") == 0) || (strcmp (argv[i],
"-normal") == 0)) {
695 if (i+1 == argc || !
is_float(argv[i+1])) {
700 if (i+1 < argc &&
is_float(argv[i+1])) {
702 if (i+1 < argc &&
is_float(argv[i+1])) {
706 if (strcmp (argv[io],
"-origin") == 0) {
707 cout << setorigin(x);
709 cout << setnormal(x);
712 }
else if (strcmp (argv[i],
"-image-format") == 0) {
714 cerr <<
"field -image-format: option argument missing" << endl;
717 string format = argv[++i];
718 dout.
os() << setimage_format(format);
720 else if (strcmp (argv[i],
"-resolution") == 0) {
721 if (i == argc-1 || !isdigit(argv[i+1][0])) { std::cerr <<
"geo -resolution: option argument missing" << std::endl;
usage(); }
722 size_t nx = atoi(argv[++i]);
723 size_t ny = (i < argc-1 && isdigit(argv[i+1][0])) ? atoi(argv[++i]) :
nx;
726 else if (argv [i][0] ==
'-' && argv [i][1] ==
'I') {
730 else if (strcmp (argv[i],
"-name") == 0) {
731 if (i+1 == argc) { std::cerr <<
"field -name: option argument missing" << std::endl;
usage(); }
734 else if (strcmp (argv[i],
"-label") == 0) {
735 if (i+1 == argc) { std::cerr <<
"field -label: option argument missing" << std::endl;
usage(); }
736 string label = argv[++i];
737 dout.
os() << setlabel(label);
739 else if (strcmp (argv[i],
"-catchmark") == 0 || strcmp (argv[i],
"-mark") == 0) {
740 if (i+1 == argc) { std::cerr <<
"field -mark: option argument missing" << std::endl;
usage(); }
741 string mark = argv[++i];
742 dout.
os() << setmark(mark);
744 else if (strcmp (argv[i],
"-if") == 0 ||
745 strcmp (argv[i],
"-input-format") == 0) {
746 if (i == argc-1) { std::cerr <<
"branch "<<argv[i]<<
": option argument missing" << std::endl;
usage(); }
747 input_format = argv[++i];
749 else if (strcmp (argv [i],
"-") == 0) {
752 dout.
os() << setbasename(
"output") << reader_on_stdin;
753 file_name =
"output";
755 else if (argv [i][0] ==
'-') {
756 cerr <<
"branch: invalid option `" << argv[i] <<
"'" << endl;
767 if (!on_stdin && file_name ==
"") {
768 cerr <<
"branch: no input specified" << endl;
773 << setprecision(digits10);
777 put(
din,
dout, do_proj, do_lumped_mass, def_fill_opt, extract_id, scale_value, u_range, render);
779 idiststream in (file_name,
"branch");
780 check_macro(in.good(),
"\"" << file_name <<
"[.branch[.gz]]\" not found.");
782 put(in,
dout, do_proj, do_lumped_mass, def_fill_opt, extract_id, scale_value, u_range, render);