436 # include "rheolef/iofem.h"
440 <<
"geo: usage:" << std::endl
442 <<
"{-|file[.geo[.gz]]}"
446 <<
"[-subdivide int] "
447 <<
"[-if {geo,bamg,vtk}] "
448 <<
"[-geo|-gmsh|-gnuplot|-paraview] "
450 <<
"[-[no]full|-[no]fill|-[no]lattice] "
451 <<
"[-[no]stereo|-[no]full|-[no]cut|-[no]shrink|-[no]showlabel] "
452 <<
"[-image-format string] "
453 <<
"[-resolution int [int]] "
454 <<
"[-add-boundary] "
456 <<
"[-size] [-n-vertex] "
457 <<
"[-hmin] [-hmax] "
458 <<
"[-[min|max]-element-measure] "
459 <<
"[-round [float]] "
460 <<
"[-[no]clean] [-[no]execute] [-[no]verbose] "
466 if (input_format ==
"bamg") in.is() >>
bamg;
467 else if (input_format ==
"vtk") in.is() >>
vtk;
468 else if (input_format ==
"geo") in.is() >>
rheo;
470 std::cerr <<
"geo: invalid input format \""<<input_format<<
"\"" << std::endl;
489 hmin = std::numeric_limits<Float>::max();
491 for (
size_t iedg = 0, nedg = omega.geo_element_ownership(1).size(); iedg < nedg; ++iedg) {
492 const geo_element& E = omega.get_geo_element (1, iedg);
493 const point& x0 = omega.dis_node(E[0]);
494 const point& x1 = omega.dis_node(E[1]);
497 hmax = max(hmax, hloc);
501 #ifdef _RHEOLEF_HAVE_MPI
502 hmin = mpi::all_reduce (comm(),
hmin, mpi::minimum<Float>());
503 hmax = mpi::all_reduce (comm(), hmax, mpi::maximum<Float>());
504 #endif // _RHEOLEF_HAVE_MPI
514 return is_min ? (
m*one).min_abs() : (
m*one).
max_abs();
516 int main(
int argc,
char**argv) {
518 check_macro (communicator().size() == 1,
"geo: command may be used as mono-process only");
522 bool do_upgrade = false ;
523 bool do_check = false ;
524 bool do_add_bdry = false ;
525 bool do_stereo = false ;
526 bool show_n_element = false ;
527 bool show_n_vertex = false ;
528 bool show_sys_coord = false ;
529 bool show_hmin = false ;
530 bool show_hmax = false ;
531 bool show_xmin = false ;
532 bool show_xmax = false ;
533 bool show_min_element_measure = false ;
534 bool show_max_element_measure = false ;
535 bool do_round = false ;
536 Float round_prec =
pow(10., -std::numeric_limits<Float>::digits10/2);
537 std::string
name =
"output";
546 dout.
os() << setnormal(
point(-0.015940197423022637, -0.9771157601293953, -0.21211011624358989));
547 dout.
os() << setorigin(
point(std::numeric_limits<Float>::max()));
548 std::string filename;
549 std::string input_format =
"geo";
554 for (
int i = 1; i < argc; i++) {
557 if (strcmp (argv[i],
"-clean") == 0)
dout.
os() <<
clean;
558 else if (strcmp (argv[i],
"-noclean") == 0)
dout.
os() << noclean;
559 else if (strcmp (argv[i],
"-execute") == 0)
dout.
os() << execute;
560 else if (strcmp (argv[i],
"-noexecute") == 0)
dout.
os() << noexecute;
561 else if (strcmp (argv[i],
"-verbose") == 0) { bverbose =
true;
dout.
os() <<
verbose; }
562 else if (strcmp (argv[i],
"-noverbose") == 0) { bverbose =
false;
dout.
os() << noverbose; }
563 else if (strcmp (argv[i],
"-add-boundary") == 0) { do_add_bdry =
true; }
564 else if (strcmp (argv[i],
"-rz") == 0) {
sys_coord =
"rz"; }
565 else if (strcmp (argv[i],
"-zr") == 0) {
sys_coord =
"zr"; }
566 else if (strcmp (argv[i],
"-size") == 0) { show_n_element =
true; }
567 else if (strcmp (argv[i],
"-n-element") == 0) { show_n_element =
true; }
568 else if (strcmp (argv[i],
"-n-vertex") == 0) { show_n_vertex =
true; }
569 else if (strcmp (argv[i],
"-sys-coord") == 0) { show_sys_coord =
true; }
570 else if (strcmp (argv[i],
"-hmin") == 0) { show_hmin =
true; }
571 else if (strcmp (argv[i],
"-hmax") == 0) { show_hmax =
true; }
572 else if (strcmp (argv[i],
"-xmin") == 0) { show_xmin =
true; }
573 else if (strcmp (argv[i],
"-xmax") == 0) { show_xmax =
true; }
574 else if (strcmp (argv[i],
"-min-element-measure") == 0) { show_min_element_measure =
true; }
575 else if (strcmp (argv[i],
"-max-element-measure") == 0) { show_max_element_measure =
true; }
576 else if (strcmp (argv[i],
"-I") == 0) {
577 if (i == argc-1) { std::cerr <<
"geo -I: option argument missing" << std::endl;
usage(); }
590 else if (strcmp (argv[i],
"-full") == 0) {
dout.
os() << full; }
591 else if (strcmp (argv[i],
"-nofull") == 0) {
dout.
os() << nofull; }
592 else if (strcmp (argv[i],
"-fill") == 0) {
dout.
os() << fill; }
593 else if (strcmp (argv[i],
"-nofill") == 0) {
dout.
os() << nofill; }
594 else if (strcmp (argv[i],
"-stereo") == 0) {
dout.
os() << stereo; do_stereo =
true; }
595 else if (strcmp (argv[i],
"-nostereo") == 0) {
dout.
os() << nostereo; }
596 else if (strcmp (argv[i],
"-cut") == 0) {
dout.
os() << cut; }
597 else if (strcmp (argv[i],
"-nocut") == 0) {
dout.
os() << nocut; }
598 else if (strcmp (argv[i],
"-shrink") == 0) {
dout.
os() << shrink; }
599 else if (strcmp (argv[i],
"-noshrink") == 0) {
dout.
os() << noshrink; }
600 else if (strcmp (argv[i],
"-lattice") == 0) {
dout.
os() << lattice; }
601 else if (strcmp (argv[i],
"-nolattice") == 0) {
dout.
os() << nolattice; }
602 else if (strcmp (argv[i],
"-showlabel") == 0) {
dout.
os() << showlabel; }
603 else if (strcmp (argv[i],
"-noshowlabel") == 0){
dout.
os() << noshowlabel; }
604 else if (strcmp (argv[i],
"-subdivide") == 0) {
605 if (i == argc-1) { std::cerr <<
"geo -subdivide: option argument missing" << std::endl;
usage(); }
606 size_t nsub = atoi(argv[++i]);
607 dout.
os() << setsubdivide (nsub);
609 else if (strcmp (argv[i],
"-image-format") == 0) {
610 if (i == argc-1) { std::cerr <<
"geo -image-format: option argument missing" << std::endl;
usage(); }
611 std::string format = argv[++i];
612 if (format ==
"jpeg") format =
"jpg";
613 if (format ==
"postscript") format =
"ps";
614 dout.
os() << setimage_format(format);
616 else if (strcmp (argv[i],
"-resolution") == 0) {
617 if (i == argc-1 || !isdigit(argv[i+1][0])) { std::cerr <<
"geo -resolution: option argument missing" << std::endl;
usage(); }
618 size_t nx = atoi(argv[++i]);
619 size_t ny = (i < argc-1 && isdigit(argv[i+1][0])) ? atoi(argv[++i]) :
nx;
622 else if (strcmp (argv[i],
"-round") == 0) {
625 if (i+1 < argc &&
is_float(argv[i+1])) {
630 else if (strcmp (argv[i],
"-upgrade") == 0) { do_upgrade =
true;
dout.
os() <<
rheo; render =
file_render; }
631 else if (strcmp (argv[i],
"-check") == 0) { do_check =
true; }
632 else if (strcmp (argv[i],
"-name") == 0) {
633 if (i == argc-1) { std::cerr <<
"geo -name: option argument missing" << std::endl;
usage(); }
636 else if (strcmp (argv[i],
"-if") == 0 ||
637 strcmp (argv[i],
"-input-format") == 0) {
638 if (i == argc-1) { std::cerr <<
"geo "<<argv[i]<<
": option argument missing" << std::endl;
usage(); }
639 input_format = argv[++i];
641 else if (strcmp (argv[i],
"-") == 0) {
644 else if (argv[i][0] !=
'-') {
652 if (filename ==
"") {
653 std::cerr <<
"geo: no input file specified" << std::endl;
655 }
else if (filename ==
"-") {
657 if (do_upgrade) std::cin >> upgrade;
659 if (
name !=
"output") thename =
name;
660 std::cin >> setbasename(thename);
663 dout.
os() << setbasename(
name) << reader_on_stdin;
666 std::string suffix = input_format;
667 if (
name ==
"output") {
671 ips.open (filename, suffix);
672 check_macro(ips.good(),
"\"" << filename <<
"[."<<suffix<<
"[.gz]]\" not found.");
673 if (do_upgrade) ips.is() >> upgrade;
676 ips.is() >> setbasename(
name);
682 if (do_add_bdry) { omega.boundary(); }
685 size_t nsub = iorheo::getsubdivide (std::cout);
688 new_omega.build_by_subdividing (omega, nsub);
693 check_macro (omega.check(bverbose),
"geo check failed");
695 bool show = show_min_element_measure
696 || show_max_element_measure
697 || show_hmin || show_hmax
698 || show_xmin || show_xmax
699 || show_n_element || show_n_vertex || show_sys_coord;
701 if (show_hmin) {
dout <<
"hmin = " << omega.hmin() << std::endl; }
702 if (show_hmax) {
dout <<
"hmax = " << omega.hmax() << std::endl; }
703 if (show_xmin) {
dout <<
"xmin = " << omega.xmin() << std::endl; }
704 if (show_xmax) {
dout <<
"xmax = " << omega.xmax() << std::endl; }
705 if (show_n_element) {
dout <<
"size = " << omega.dis_size() << std::endl; }
706 if (show_n_vertex) {
dout <<
"n_vertex = " << omega.dis_size(0) << std::endl; }
707 if (show_sys_coord) {
dout <<
"sys_coord = " << omega.coordinate_system_name() << std::endl; }
708 if (show_min_element_measure) {
711 if (show_max_element_measure) {
717 dout.
os() << setrounding_precision(round_prec);
721 #if (_RHEOLEF_PARAVIEW_VERSION_MAJOR >= 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR >= 5)
723 if (do_stereo || omega.dimension() >= 2) {
725 if (do_stereo || omega.dimension() == 3) {