388 #include <rheolef/iofem.h>
394 cerr <<
"branch: usage: branch "
395 <<
"-|file[.branch[.gz]]"
399 <<
"[-index int|-extract int] "
400 <<
"[-[catch]mark string] "
402 <<
"[-proj [string]] "
404 <<
"[-if {branch,vtk}] "
405 <<
"[-paraview|-gnuplot] "
407 <<
"[-[no]verbose|-[no]clean|-[no]execute] "
408 <<
"[-color|-gray|-black-and-white|-bw] "
409 <<
"[-[no]elevation] "
412 <<
"[-[no]showlabel] "
413 <<
"[-label string] "
416 <<
"[-normal x [y [z]]] "
417 <<
"[-origin x [y [z]]] "
419 <<
"[-iso[value] float|-noiso[value]] "
421 <<
"[-n-iso-negative int] "
422 <<
"[-topography filename] "
425 <<
"[-subdivide int] "
441 struct reuse_proj_form_type {
442 vector<form_basic<Float,sequential>>
m,
p;
444 reuse_proj_form_type() :
m(),
p(), done() {}
445 size_t size()
const {
return m.size(); }
446 void resize(
size_t n) {
m.resize(
n);
p.resize(
n); done.resize(
n,
false); }
454 string use_proj_approx,
455 reuse_proj_form_type reuse)
458 size_t k = Uh.degree();
460 std::string approx = (do_lumped_mass || use_proj_approx ==
"") ?
"P1" : use_proj_approx;
465 fopt.
lump = do_lumped_mass;
466 if (!reuse.done[extract_id] || !(reuse.m[extract_id].get_geo() == uh.
get_geo())) {
467 switch (Uh.valued_tag()) {
469 reuse.m[extract_id] =
integrate(v*vt, fopt);
482 error_macro (
"proj: unexpected valued field: " << Uh.valued());
484 reuse.done[extract_id] =
true;
488 vh.
set_u() = sm.
solve((reuse.p[extract_id]*uh).u());
497 string use_proj_approx,
499 const Float& scale_value,
500 reuse_proj_form_type reuse)
503 in >>
event.header();
504 out <<
event.header();
505 if (reuse.size() == 0) reuse.resize(event.size());
508 check_macro (in.
good(),
"extract: index="<<extract_id<<
" not found");
513 event.set_parameter (
t);
514 for (
size_t i = 0; in && i <
event.size(); i++) {
515 in >>
catchmark (event[i].first) >>
event[i].second;
519 uh =
proj (extract_id, uh, do_lumped_mass, use_proj_approx, reuse);
521 if (scale_value !=
Float(1)) {
525 out <<
event.finalize();
534 string use_proj_approx,
537 const Float& scale_value,
538 const std::pair<Float,Float>& u_range,
540 reuse_proj_form_type reuse)
542 if (extract_id != numeric_limits<size_type>::max()) {
543 extract (in,
out, do_proj, do_lumped_mass, use_proj_approx, extract_id, scale_value, reuse);
548 if (u_range.first != std::numeric_limits<Float>::max() ||
549 u_range.second != -std::numeric_limits<Float>::max()) {
552 in >>
event.header();
553 if (reuse.size() == 0) reuse.resize(event.size());
555 in.
is() >> noverbose;
556 out << setprecision(numeric_limits<Float>::digits10)
557 <<
"# i " <<
event.parameter_name() << endl;
560 out <<
n <<
" " << param << endl;
566 while (in >> event) {
567 for (
size_t i = 0; i <
event.size(); i++) {
568 uh =
event[i].second;
575 if (uh.
get_geo().map_dimension() == 3) {
577 if (!def_plane_cut_opt)
dout.
os() << cut;
579 if (!def_fill_opt)
dout.
os() << nofill;
582 if (!def_plane_cut_opt)
dout.
os() << nocut;
584 if (!def_fill_opt)
dout.
os() << fill;
586 out <<
event.header();
589 uh =
proj (i, uh, do_lumped_mass, use_proj_approx, reuse);
591 if (scale_value !=
Float(1)) {
594 event[i].second = uh;
599 out <<
event.finalize();
603 if (input_format ==
"vtk") in.
is() >>
vtk;
604 else if (input_format ==
"branch") in.
is() >>
rheo;
606 std::cerr <<
"branch: invalid input format \""<<input_format<<
"\"" << std::endl;
613 if (argc <= 1)
usage();
616 bool on_stdin =
false;
617 bool do_proj =
false;
618 string use_proj_approx =
"";
619 bool do_lumped_mass =
false;
620 reuse_proj_form_type reuse;
622 bool def_fill_opt =
false;
623 int digits10 = numeric_limits<Float>::digits10;
625 size_type extract_id = numeric_limits<size_type>::max();
626 Float scale_value = 1;
627 string file_name,
name, input_format =
"branch";
628 std::pair<Float,Float> u_range;
629 u_range.first = std::numeric_limits<Float>::max();
630 u_range.second = -std::numeric_limits<Float>::max();
633 cout << setnormal(
point(-0.015940197423022637, -0.9771157601293953, -0.21211011624358989));
634 cout << setorigin(
point(std::numeric_limits<Float>::max()));
636 for (
int i = 1; i < argc; i++) {
638 if (strcmp (argv[i],
"-ndigit") == 0) { digits10 = atoi(argv[++i]); }
639 else if (strcmp (argv[i],
"-toc") == 0) { render =
toc_render; }
640 else if (strcmp (argv[i],
"-index") == 0 || strcmp (argv[i],
"-extract") == 0)
646 else if (strcmp (argv[i],
"-skipvtk") == 0) {
dout.
os() << skipvtk; }
647 else if (strcmp (argv[i],
"-proj") == 0) { do_proj =
true;
648 if (i+1 < argc && argv[i+1][0] !=
'-') {
649 use_proj_approx = argv[++i];
652 else if (strcmp (argv[i],
"-lumped-proj") == 0){ do_proj = do_lumped_mass =
true; use_proj_approx =
"P1"; }
653 else if (strcmp (argv[i],
"-elevation") == 0) {
dout.
os() << elevation; }
654 else if (strcmp (argv[i],
"-noelevation") == 0) {
dout.
os() << noelevation; }
655 else if (strcmp (argv[i],
"-color") == 0) {
dout.
os() << color; }
656 else if (strcmp (argv[i],
"-gray") == 0) {
dout.
os() <<
gray; }
657 else if (strcmp (argv[i],
"-black-and-white") == 0) {
dout.
os() << black_and_white; }
658 else if (strcmp (argv[i],
"-bw") == 0) {
dout.
os() << black_and_white; }
659 else if (strcmp (argv[i],
"-showlabel") == 0) {
dout.
os() << showlabel; }
660 else if (strcmp (argv[i],
"-noshowlabel") == 0) {
dout.
os() << noshowlabel; }
661 else if (strcmp (argv[i],
"-fill") == 0) {
dout.
os() << fill; def_fill_opt =
true; }
662 else if (strcmp (argv[i],
"-nofill") == 0) {
dout.
os() << nofill; def_fill_opt =
true; }
663 else if (strcmp (argv[i],
"-stereo") == 0) {
dout.
os() << stereo;
669 else if (strcmp (argv[i],
"-nostereo") == 0) {
dout.
os() << nostereo; }
670 else if (strcmp (argv[i],
"-volume") == 0) {
dout.
os() <<
paraview << volume;
672 else if (strcmp (argv[i],
"-novolume") == 0) {
dout.
os() << novolume; }
673 else if (strcmp (argv[i],
"-cut") == 0) { do_cut =
true; }
674 else if (strcmp (argv[i],
"-nocut") == 0) { do_cut =
false; }
675 else if (strcmp (argv[i],
"-umin") == 0) {
677 u_range.first =
to_float (argv[++i]);
678 }
else if (strcmp (argv[i],
"-umax") == 0) {
680 u_range.second =
to_float (argv[++i]);
681 }
else if (strcmp (argv[i],
"-scale") == 0) {
684 dout.
os() << setvectorscale (scale_value);
685 }
else if (strcmp (argv[i],
"-noisovalue") == 0) {
687 }
else if (strcmp (argv[i],
"-isovalue") == 0 || strcmp (argv[i],
"-iso") == 0) {
690 if (i+1 < argc &&
is_float(argv[i+1])) {
692 dout.
os() << setisovalue(iso_value);
694 }
else if (strcmp (argv[i],
"-n-iso") == 0) {
696 if (i+1 == argc || !isdigit(argv[i+1][0]))
usage();
697 size_t idx = atoi (argv[++i]);
698 dout.
os() << setn_isovalue(idx);
700 }
else if (strcmp (argv[i],
"-n-iso-negative") == 0) {
702 if (i+1 == argc || !isdigit(argv[i+1][0]))
usage();
703 size_t idx = atoi (argv[++i]);
704 dout.
os() << setn_isovalue_negative(idx);
706 }
else if (strcmp (argv[i],
"-subdivide") == 0) {
707 if (i == argc-1) { cerr <<
"branch -subdivide: option argument missing" << endl;
usage(); }
708 size_t nsub = atoi(argv[++i]);
709 dout.
os() << setsubdivide (nsub);
710 }
else if (strcmp (argv[i],
"-topography") == 0) {
712 if (i+1 == argc)
usage();
716 dout.
os() << settopography(z);
718 else if (strcmp (argv[i],
"-I") == 0) {
719 if (i+1 == argc) { cerr <<
"geo -I: option argument missing" << endl;
usage(); }
723 else if (strcmp (argv[i],
"-noclean") == 0) clog << noclean;
724 else if (strcmp (argv[i],
"-clean") == 0) clog <<
clean;
725 else if (strcmp (argv[i],
"-noexecute") == 0) clog << noexecute;
726 else if (strcmp (argv[i],
"-execute") == 0) clog << execute;
727 else if (strcmp (argv[i],
"-verbose") == 0) clog <<
verbose;
728 else if (strcmp (argv[i],
"-noverbose") == 0) clog << noverbose;
729 else if ((strcmp(argv[i],
"-origin") == 0) || (strcmp (argv[i],
"-normal") == 0)) {
733 if (i+1 == argc || !
is_float(argv[i+1])) {
738 if (i+1 < argc &&
is_float(argv[i+1])) {
740 if (i+1 < argc &&
is_float(argv[i+1])) {
744 if (strcmp (argv[io],
"-origin") == 0) {
745 cout << setorigin(x);
747 cout << setnormal(x);
749 }
else if (strcmp (argv[i],
"-image-format") == 0) {
751 cerr <<
"field -image-format: option argument missing" << endl;
754 string format = argv[++i];
755 dout.
os() << setimage_format(format);
757 else if (strcmp (argv[i],
"-resolution") == 0) {
758 if (i == argc-1 || !isdigit(argv[i+1][0])) { std::cerr <<
"geo -resolution: option argument missing" << std::endl;
usage(); }
759 size_t nx = atoi(argv[++i]);
760 size_t ny = (i < argc-1 && isdigit(argv[i+1][0])) ? atoi(argv[++i]) :
nx;
763 else if (argv [i][0] ==
'-' && argv [i][1] ==
'I') {
767 else if (strcmp (argv[i],
"-name") == 0) {
768 if (i+1 == argc) { std::cerr <<
"field -name: option argument missing" << std::endl;
usage(); }
771 else if (strcmp (argv[i],
"-label") == 0) {
772 if (i+1 == argc) { std::cerr <<
"field -label: option argument missing" << std::endl;
usage(); }
773 string label = argv[++i];
774 dout.
os() << setlabel(label);
776 else if (strcmp (argv[i],
"-catchmark") == 0 || strcmp (argv[i],
"-mark") == 0) {
777 if (i+1 == argc) { std::cerr <<
"field -mark: option argument missing" << std::endl;
usage(); }
778 string mark = argv[++i];
779 dout.
os() << setmark(mark);
781 else if (strcmp (argv[i],
"-if") == 0 ||
782 strcmp (argv[i],
"-input-format") == 0) {
783 if (i == argc-1) { std::cerr <<
"branch "<<argv[i]<<
": option argument missing" << std::endl;
usage(); }
784 input_format = argv[++i];
786 else if (strcmp (argv [i],
"-") == 0) {
789 dout.
os() << setbasename(
"output") << reader_on_stdin;
790 file_name =
"output";
792 else if (argv [i][0] ==
'-') {
793 cerr <<
"branch: invalid option `" << argv[i] <<
"'" << endl;
804 if (!on_stdin && file_name ==
"") {
805 cerr <<
"branch: no input specified" << endl;
810 << setprecision(digits10);
814 put(
din,
dout, do_proj, do_lumped_mass, use_proj_approx, def_fill_opt, extract_id, scale_value, u_range, render, reuse);
817 check_macro(in.
good(),
"\"" << file_name <<
"[.branch[.gz]]\" not found.");
819 put(in,
dout, do_proj, do_lumped_mass, use_proj_approx, def_fill_opt, extract_id, scale_value, u_range, render, reuse);
int main(int argc, char **argv)
void set_input_format(idiststream &in, std::string input_format)
field::size_type size_type
void extract(idiststream &in, odiststream &out, bool do_proj, bool do_lumped_mass, string use_proj_approx, size_type extract_id, const Float &scale_value, reuse_proj_form_type reuse)
see the Float page for the full documentation
see the point page for the full documentation
void set_range(const std::pair< T, T > &u_range)
const std::string & parameter_name() const
see the catchmark page for the full documentation
see the environment page for the full documentation
const space_type & get_space() const
const geo_type & get_geo() const
const std::string & valued() const
idiststream: see the diststream page for the full documentation
see the integrate_option page for the full documentation
odiststream: see the diststream page for the full documentation
vec< T, M > solve(const vec< T, M > &b) const
point_basic< Float > point
idiststream din(cin)
see the diststream page for the full documentation
rheolef::space_base_rep< T, M > t
double Float
see the Float page for the full documentation
odiststream dout(cout)
see the diststream page for the full documentation
#define error_macro(message)
#define warning_macro(message)
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format format format format paraview
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format format gnuplot
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format vtk
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color rheo
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin gray
This file is part of Rheolef.
void put(std::ostream &out, std::string name, const tiny_matrix< T > &a)
string delete_suffix(const string &name, const string &suffix)
delete_suffix: see the rheostream page for the full documentation
void prepend_dir_to_rheo_path(const string &dir)
prepend_dir_to_rheo_path: see the rheostream page for the full documentation
field_basic< T, M > proj(const field_basic< T, M > &uh, const std::string &approx="P1")
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
dot(x,y): see the expression page for the full documentation
string get_basename(const string &name)
get_basename: see the rheostream page for the full documentation
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&! is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const integrate_option &iopt, Result dummy=Result())
see the integrate page for the full documentation
bool is_float(const string &s)
is_float: see the rheostream page for the full documentation
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
void append_dir_to_rheo_path(const string &dir)
append_dir_to_rheo_path: see the rheostream page for the full documentation
string get_dirname(const string &name)
get_dirname: see the rheostream page for the full documentation
Float to_float(const string &s)
to_float: see the rheostream page for the full documentation
rheolef - reference manual