Newer
Older
// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.

Christophe Geuzaine
committed
#include "GmshMessage.h"
#include "Context.h"
#include "Options.h"

Christophe Geuzaine
committed
#if !defined(HAVE_NO_POST)
#include "PView.h"
#endif
#error Please run 'make tag'.
#error
#endif
void Print_Usage(const char *name)
{
// texinfo documentation (doc/texinfo/command_line.texi) and the man
// page (doc/gmsh.1)
Msg::Direct("Usage: %s [options] [files]", name);
Msg::Direct("Geometry options:");
Msg::Direct(" -0 Output unrolled geometry, then exit");
Msg::Direct(" -tol float Set geometrical tolerance");
Msg::Direct("Mesh options:");
Msg::Direct(" -1, -2, -3 Perform 1D, 2D or 3D mesh generation, then exit");
Msg::Direct(" -refine Perform uniform mesh refinement, then exit");
Msg::Direct(" -part Partition after batch mesh generation");
Msg::Direct(" -saveall Save all elements (discard physical group definitions)");
Msg::Direct(" -o file Specify mesh output file name");
Msg::Direct(" -format string Set output mesh format (msh, msh1, msh2, unv, vrml, stl, mesh,");
Msg::Direct(" bdf, p3d, cgns, med)");
Msg::Direct(" -bin Use binary format when available");
Msg::Direct(" -parametric Save vertices with their parametric coordinates");

Jean-François Remacle
committed
Msg::Direct(" -numsubedges Set the number of subdivisions when displaying high order elements");
Msg::Direct(" -algo string Select mesh algorithm (de, del2d, frontal, iso, netgen, tetgen)");
Msg::Direct(" -smooth int Set number of mesh smoothing steps");
Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements");
Msg::Direct(" -order int Set mesh order (1, ..., 5)");
Msg::Direct(" -optimize_hom Optimize higher order meshes (in 2D)");
Msg::Direct(" -clscale float Set characteristic length scaling factor");
Msg::Direct(" -clmin float Set minimum characteristic length");
Msg::Direct(" -clmax float Set maximum characteristic length");
Msg::Direct(" -clcurv Compute characteristic lengths from curvatures");
Msg::Direct(" -epslc1d Set the accuracy of the evaluation of the LCFIELD for 1D mesh");
Msg::Direct(" -swapangle Set the treshold angle (in degree) between two adjacent faces");
Msg::Direct(" below which a swap is allowed");
Msg::Direct(" -rand float Set random perturbation factor");
Msg::Direct(" -bgm file Load background mesh from file");
Msg::Direct("Post-processing options:");
Msg::Direct(" -noview Hide all views on startup");
Msg::Direct(" -link int Select link mode between views (0, 1, 2, 3, 4)");
Msg::Direct(" -combine Combine views having identical names into multi-time-step views");
Msg::Direct("Display options:");
Msg::Direct(" -nodb Disable double buffering");
Msg::Direct(" -fontsize int Specify the font size for the GUI");
Msg::Direct(" -theme string Specify FLTK GUI theme");
Msg::Direct(" -display string Specify display");
Msg::Direct("Other options:");
Msg::Direct(" - Parse input files, then exit");
Msg::Direct(" -a, -g, -m, -s, -p Start in automatic, geometry, mesh, solver or post-processing mode");
Msg::Direct(" -pid Print process id on stdout");
Msg::Direct(" -listen Always listen to incoming connection requests");
Msg::Direct(" -v int Set verbosity level");
Msg::Direct(" -nopopup Don't popup dialog windows in scripts");
Msg::Direct(" -string \"string\" Parse option string at startup");
Msg::Direct(" -option file Parse option file at startup");
Msg::Direct(" -convert files Convert files into latest binary formats, then exit");
Msg::Direct(" -version Show version number");
Msg::Direct(" -info Show detailed version information");
Msg::Direct(" -help Show this message");
int Get_GmshMajorVersion(){ return GMSH_MAJOR_VERSION; }
int Get_GmshMinorVersion(){ return GMSH_MINOR_VERSION; }
int Get_GmshPatchVersion(){ return GMSH_PATCH_VERSION; }
const char *Get_GmshExtraVersion(){ return GMSH_EXTRA_VERSION; }
const char *Get_GmshVersion(){ return GMSH_VERSION; }
const char *Get_GmshBuildDate(){ return GMSH_DATE; }
const char *Get_GmshBuildHost(){ return GMSH_HOST; }
const char *Get_GmshPackager(){ return GMSH_PACKAGER; }
const char *Get_GmshBuildOS(){ return GMSH_OS; }
const char *Get_GmshShortLicense(){ return GMSH_SHORT_LICENSE; }
std::string Get_GmshBuildOptions()
#endif
#if defined(HAVE_CHACO)
// print messages on terminal
int terminal = CTX.terminal;
CTX.terminal = 1;
// Create a dummy model during option processing so we cannot crash
// the parser, and so we can load files for -convert
GModel *dummy = new GModel();
ParseFile(CTX.session_filename_fullpath, 1);
ParseFile(CTX.options_filename_fullpath, 1);
if(!strcmp(argv[i] + 1, "socket")) {
i++;
if(argv[i] != NULL)
CTX.solver.socket_name = argv[i++];
else
Msg::Fatal("Missing string");
CTX.batch = -3;
}
else if(!strcmp(argv[i] + 1, "")) {
CTX.batch = -2;
i++;
}
else if(!strcmp(argv[i] + 1, "0")) {
CTX.batch = -1;
i++;
}
else if(!strcmp(argv[i] + 1, "1")) {
CTX.batch = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "2")) {
CTX.batch = 2;
i++;
}
else if(!strcmp(argv[i] + 1, "3")) {
CTX.batch = 3;
i++;
}
else if(!strcmp(argv[i] + 1, "4")) {
CTX.batch = 4;
i++;
}
else if(!strcmp(argv[i] + 1, "refine")) {
CTX.batch_after_mesh = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "new")) {
CTX.files.push_back("-new");
else if(!strcmp(argv[i] + 1, "a")) {
CTX.initial_context = 0;
i++;
else if(!strcmp(argv[i] + 1, "g")) {
CTX.initial_context = 1;
i++;
else if(!strcmp(argv[i] + 1, "m")) {
CTX.initial_context = 2;
i++;
else if(!strcmp(argv[i] + 1, "s")) {
CTX.initial_context = 3;
i++;
else if(!strcmp(argv[i] + 1, "p")) {
CTX.initial_context = 4;
i++;
else if(!strcmp(argv[i] + 1, "saveall")) {
CTX.mesh.save_all = 1;
i++;
else if(!strcmp(argv[i] + 1, "optimize")) {
CTX.mesh.optimize = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "optimize_netgen")) {
else if(!strcmp(argv[i] + 1, "nopopup")) {
CTX.nopopup = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "string")) {
i++;
if(argv[i] != NULL)
else
Msg::Fatal("Missing string");
else
Msg::Fatal("Missing file name");
else
Msg::Fatal("Missing file name");
if(argv[i] != NULL)
else
Msg::Fatal("Missing file name");
while(i < argc) {
char filename[256];
sprintf(filename, "%s_new", argv[i]);

Christophe Geuzaine
committed
#if !defined(HAVE_NO_POST)

Christophe Geuzaine
committed
#endif

Christophe Geuzaine
committed
#if !defined(HAVE_NO_POST)

Christophe Geuzaine
committed
#endif
// convert mesh to latest binary format
if(GModel::current()->getMeshStatus() > 0){
CTX.mesh.msh_file_version = 2.0;
Msg::Exit(0);
else
Msg::Fatal("Missing number");
if(argv[i] != NULL)
CTX.geom.scaling_factor = atof(argv[i++]);
else
Msg::Fatal("Missing number");
if(argv[i] != NULL)
CTX.mesh.scaling_factor = atof(argv[i++]);
else
Msg::Fatal("Missing number");
else
Msg::Fatal("Missing number");
CTX.mesh.lc_factor = atof(argv[i++]);
if(CTX.mesh.lc_factor <= 0.0)
Msg::Fatal("Characteristic length factor must be > 0");
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "clmin")) {
i++;
if(argv[i] != NULL) {
CTX.mesh.lc_min = atof(argv[i++]);
if(CTX.mesh.lc_min <= 0.0)
Msg::Fatal("Minimum length size must be > 0");
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "clmax")) {
i++;
if(argv[i] != NULL) {
CTX.mesh.lc_max = atof(argv[i++]);
if(CTX.mesh.lc_max <= 0.0)
Msg::Fatal("Maximum length size must be > 0");
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "edgelmin")) {
i++;
if(argv[i] != NULL) {
CTX.mesh.tolerance_edge_length = atof(argv[i++]);
if( CTX.mesh.tolerance_edge_length <= 0.0)
Msg::Fatal("Tolerance for model edge length must be > 0 (here %g)",
CTX.mesh.tolerance_edge_length);
}
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "epslc1d")) {
i++;
if(argv[i] != NULL) {
CTX.mesh.lc_integration_precision = atof(argv[i++]);
if(CTX.mesh.lc_integration_precision <= 0.0)
Msg::Fatal("Integration accuracy must be > 0");
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "swapangle")) {
i++;
if(argv[i] != NULL) {
CTX.mesh.allow_swap_edge_angle = atof(argv[i++]);
if(CTX.mesh.allow_swap_edge_angle <= 0.0)
Msg::Fatal("Treshold angle for edge swap must be > 0");
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "clcurv")) {
CTX.mesh.lc_from_curvature = 1;
i++;
}
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "order") || !strcmp(argv[i] + 1, "degree")) {
else
Msg::Fatal("Missing number");

Jean-François Remacle
committed
else if(!strcmp(argv[i] + 1, "numsubedges")) {
i++;
if(argv[i] != NULL)
opt_mesh_num_sub_edges(0, GMSH_SET, atof(argv[i++]));
else
Msg::Fatal("Missing number");
}
else if(!strcmp(argv[i] + 1, "c1")) {
i++;
else if(!strcmp(argv[i] + 1, "statreport")) {
i++;
if(argv[i] != NULL)
strcpy(CTX.statreport, argv[i++]);
else
Msg::Fatal("Missing argument");
}
else if(!strcmp(argv[i] + 1, "append_statreport")) {
i++;
if(argv[i] != NULL)
strcpy(CTX.statreport, argv[i++]);
else
Msg::Fatal("Missing argument");
else if(!strcmp(argv[i] + 1, "optimize_hom")) {
i++;
else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) {
else if(!strcmp(argv[i], "msh2")){
CTX.mesh.format = FORMAT_MSH;
else if(!strcmp(argv[i], "vrml"))
CTX.mesh.format = FORMAT_VRML;
CTX.mesh.format = FORMAT_STL;
else if(!strcmp(argv[i], "mesh"))
CTX.mesh.format = FORMAT_MESH;
else if(!strcmp(argv[i], "bdf"))
CTX.mesh.format = FORMAT_BDF;
else if(!strcmp(argv[i], "p3d"))
CTX.mesh.format = FORMAT_P3D;
else if(!strcmp(argv[i], "cgns"))
CTX.mesh.format = FORMAT_CGNS;
else if(!strcmp(argv[i], "diff"))
CTX.mesh.format = FORMAT_DIFF;
else if(!strcmp(argv[i], "med"))
CTX.mesh.format = FORMAT_MED;
else
Msg::Fatal("Unknown mesh format");
else
Msg::Fatal("Missing format");
else if(!strcmp(argv[i] + 1, "bin")) {
i++;
else if(!strcmp(argv[i] + 1, "parametric")) {
i++;
CTX.mesh.save_parametric = 1;
}
if(!strncmp(argv[i], "del3d", 5) || !strncmp(argv[i], "tetgen", 6))
CTX.mesh.algo2d = ALGO_3D_TETGEN_DELAUNAY;
else if(!strncmp(argv[i], "frontal", 7))
CTX.mesh.algo2d = ALGO_2D_FRONTAL;
else if(!strncmp(argv[i], "del2d", 5) || !strncmp(argv[i], "tri", 3))
else if(!strncmp(argv[i], "del", 3) || !strncmp(argv[i], "iso", 3))
else
Msg::Fatal("Unknown mesh algorithm");
else
Msg::Fatal("Missing algorithm");
else if(!strcmp(argv[i] + 1, "listen")) {
CTX.solver.listen = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "version") || !strcmp(argv[i] + 1, "-version")) {
Msg::Exit(0);
else if(!strcmp(argv[i] + 1, "info") || !strcmp(argv[i] + 1, "-info")) {
fprintf(stderr, "Version : %s\n", GMSH_VERSION);
fprintf(stderr, "GUI toolkit : FLTK %d.%d.%d\n", FL_MAJOR_VERSION,
fprintf(stderr, "GUI toolkit : none\n");
fprintf(stderr, "License : %s\n", GMSH_SHORT_LICENSE);
fprintf(stderr, "Build OS : %s\n", GMSH_OS);
fprintf(stderr, "Build options : %s\n", Get_GmshBuildOptions().c_str());
fprintf(stderr, "Build date : %s\n", GMSH_DATE);
fprintf(stderr, "Build host : %s\n", GMSH_HOST);
fprintf(stderr, "Packager : %s\n", GMSH_PACKAGER);
fprintf(stderr, "Web site : http://www.geuz.org/gmsh/\n");
fprintf(stderr, "Mailing list : gmsh@geuz.org\n");
Msg::Exit(0);
else if(!strcmp(argv[i] + 1, "help") || !strcmp(argv[i] + 1, "-help")) {
fprintf(stderr, "Gmsh, a 3D mesh generator with pre- and post-processing facilities\n");
fprintf(stderr, "Copyright (C) 1997-2008 Christophe Geuzaine and Jean-Francois Remacle\n");
Msg::Exit(0);
Msg::SetVerbosity(atoi(argv[i++]));
else
Msg::Fatal("Missing number");
terminal = 1;
else if(!strcmp(argv[i] + 1, "dual")) {
CTX.mesh.dual = 1;
i++;
else if(!strcmp(argv[i] + 1, "voronoi")) {
CTX.mesh.voronoi = 1;
i++;
}
else if(!strcmp(argv[i] + 1, "noview")) {
opt_view_visible(0, GMSH_SET, 0);
i++;
else if(!strcmp(argv[i] + 1, "link")) {
i++;
if(argv[i] != NULL)
CTX.post.link = atoi(argv[i++]);
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "smoothview")) {
CTX.post.smooth = 1;
i++;
else if(!strcmp(argv[i] + 1, "combine")) {
CTX.post.combine_time = 1;
i++;
}
if(argv[i] != NULL)
CTX.fontsize = atoi(argv[i++]);
else
Msg::Fatal("Missing number");
else if(!strcmp(argv[i] + 1, "theme") || !strcmp(argv[i] + 1, "scheme")) {
if(argv[i] != NULL)
CTX.gui_theme = argv[i++];
else
Msg::Fatal("Missing argument");
if(argv[i] != NULL)
CTX.display = argv[i++];
else
Msg::Fatal("Missing argument");
else if(!strncmp(argv[i] + 1, "psn", 3)) {
// The Mac Finder launches programs with a special command
// line argument of the form -psn_XXX: just ignore it silently
// (and don't exit!)
Msg::Error("Unknown option '%s'", argv[i]);
Msg::Exit(1);
strncpy(CTX.filename, CTX.default_filename_fullpath, 255);
else
strncpy(CTX.filename, CTX.files[0].c_str(), 255);
CTX.terminal = terminal;