<commit_before>#include "libmesh_config.h"

// C++ includes
#include <algorithm>
#include <fstream>
#ifdef LIBMESH_HAVE_GETOPT_H
// GCC 2.95.3 (and maybe others) do not include
// getopt.h in unistd.h...  Hower IBM xlC has no
// getopt.h!  This works around that.
#include <getopt.h>
#endif
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <vector>

// Local Includes
#include "boundary_info.h"
#include "boundary_mesh.h"
#include "dof_map.h"
#include "elem.h"
#include "elem_quality.h"
#include "gmv_io.h"
#include "inf_elem_builder.h"
#include "legacy_xdr_io.h"
#include "libmesh.h"
#include "mesh.h"
#include "mesh_data.h"
#include "mesh_modification.h"
#include "mesh_refinement.h"
#include "perfmon.h"
#include "statistics.h"


using namespace libMesh;


/*
 * convenient enum for the mode in which the boundary mesh
 * should be written
 */
enum BoundaryMeshWriteMode {BM_DISABLED=0, BM_MESH_ONLY, BM_WITH_MESHDATA};


void usage(char *progName)
{
  std::string baseName;
  static std::string helpList =
    "usage:\n"
    "        %s [options] ...\n"
    "\n"
    "options:\n"
    "    -d <dim>                      <dim>-dimensional mesh\n"
    "    -i <string>                   Input file name\n"
    "    -o <string>                   Output file name\n"
    "    -s <string>                   Solution file name\n"
  "\n    -b                            Write the boundary conditions\n"
    "    -B                            Like -b, but with activated MeshData\n"
    "    -D <factor>                   Randomly move interior nodes by D*hmin\n"
    "    -h                            Print help menu\n"
    "    -p <count>                    Partition into <count> subdomains\n"
#ifdef LIBMESH_ENABLE_AMR
    "    -r <count>                    Globally refine <count> times\n"
#endif
    "    -t (-d 2 only)                Convert to triangles first\n"
    "                                  (allows to write .unv file of the\n"
    "                                  boundary with the correct node ids)\n"
    "    -v                            Verbose\n"
    "    -2                            Converts a mesh of linear elements\n"
    "                                  to their second-order counterparts:\n"
    "                                  Quad4 -> Quad8, Tet4 -> Tet10 etc\n"
    "    -3                            Same, but to the highest possible:\n"
    "                                  Quad4 -> Quad9, Hex8 -> Hex27 etc\n"
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
  "\n    -a                            Add infinite elements\n"
    "    -x <coord>                    Specify infinite element origin\n"
    "    -y <coord>                    coordinates. If none given, origin\n"
    "    -z <coord>                    is determined automatically.\n"
    "    -X                            When building infinite elements \n"
    "    -Y                            treat mesh as x/y/z-symmetric.\n"
    "    -Z                            When -X is given, -x <coord> also\n"
    "                                  has to be given.  Similar for y,z.\n"
#endif
/*  "\n    -l                            Build the L connectivity matrix \n"         */
/*    "    -L                            Build the script L connectivity matrix \n"  */
    "\n"
    "\n"
    " This program is used to convert and partions from/to a variety of\n"
    " formats.  File types are inferred from file extensions.  For example,\n"
    " the command:\n"
    "\n"
    "  ./meshtool -d 2 -i in.exd -o out.plt\n"
    "\n"
    " will read a 2D mesh in the ExodusII format (from Cubit, for example)\n"
    " from the file in.exd.  It will then write the mesh in the Tecplot\n"
    " binary format to out.plt.\n"
    "\n"
    " and\n"
    "\n"
    "  ./meshtool -d 3 -i bench12.mesh.0000 -o out.gmv -s bench12.soln.0137\n"
    "\n"
    " will read a 3D MGF mesh from the file bench12.mesh.0000, read a\n"
    " solution from bench12.soln.0137, and write the output in GMV format\n"
    " to out.gmv\n"
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
    "\n"
    " and\n"
    "\n"
    "  ./meshtool -d 3 -i dry.unv -o packed.gmv -a -x 30.5 -y -10.5 -X\n"
    "\n"
    " will read a 3D Universal file, determine the z-coordinate of the origin\n"
    " automatically, e.g. z_origin = 3., build infinite elements with the\n"
    " origin (30.5, -10.5, 3.) on top of volume elements, while preserving\n"
    " a symmetry plane through (30.5, -10.5, 3.) perpendicular to x.\n"
    " It is imperative that the origin lies _inside_ the given volume mesh.\n"
    " If not, infinite elements are not correctly built!\n"
#endif
    "\n"
    " Currently this program supports the following formats:\n"
    "\n"
    "INPUT:\n"
    "     .exd -- Sandia's ExodusII binary grid format\n"
    "     .mgf -- MGF binary mesh format\n"
    "     .ucd -- AVS unstructured ASCII grid format\n"
    "     .unv -- SDRC I-Deas Universal File ASCII format\n"
    "     .xda -- libMesh human-readable ASCII format\n"
    "     .xdr -- libMesh binary format\n"
    "\n"
    "OUTPUT:\n"
    "     .dat   -- Tecplot ASCII format\n"
    "     .e     -- Sandia's ExodusII format\n"
    "     .exd   -- Sandia's ExodusII format\n"
    "     .fro   -- ACDL's .fro format\n"
    "     .gmv   -- LANL's General Mesh Viewer format\n"
    "     .mesh  -- MEdit mesh format\n"
    "     .mgf   -- MGF binary mesh format\n"
    "     .msh   -- GMSH ASCII file\n"
    "     .plt   -- Tecplot binary format\n"
    "     .poly  -- TetGen ASCII file\n"
    "     .pvtu  -- Paraview VTK format\n"
    "     .ucd   -- AVS's ASCII UCD format\n"
    "     .ugrid -- Kelly's DIVA ASCII format (3D only)\n"
    "     .unv   -- I-deas Universal format\n"
    "     .xda   -- libMesh ASCII format\n"
    "     .xdr   -- libMesh binary format\n"
    "     .gz    -- any above format gzipped\n"
    "     .bz2   -- any above format bzip2'ed\n"
    "\n"
    " Direct questions to:\n"
    " <EMAIL>\n";

    
  if (progName == NULL)
    baseName = "UNKNOWN";
  else 
    baseName = progName;

  
  fprintf(stderr, helpList.c_str(), baseName.c_str());
  fflush(stderr);

  abort();
}



void process_cmd_line(int argc, char **argv,
                      std::vector<std::string>& names,
                      unsigned int& n_subdomains,
                      unsigned int& n_rsteps,
                      unsigned int& dim,
                      double& dist_fact,
                      bool& verbose,
                      BoundaryMeshWriteMode& write_bndry,
                      unsigned int& convert_second_order,
                      bool& triangulate,
                      bool& addinfelems,

#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
                      InfElemBuilder::InfElemOriginValue& origin_x,
                      InfElemBuilder::InfElemOriginValue& origin_y,
                      InfElemBuilder::InfElemOriginValue& origin_z,
#endif

                      bool& x_sym,
                      bool& y_sym,<commit_msg>No need for meshtool to abort just because we printed the usage message<commit_after>#include "libmesh_config.h"

// C++ includes
#include <algorithm>
#include <fstream>
#ifdef LIBMESH_HAVE_GETOPT_H
// GCC 2.95.3 (and maybe others) do not include
// getopt.h in unistd.h...  Hower IBM xlC has no
// getopt.h!  This works around that.
#include <getopt.h>
#endif
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <vector>

// Local Includes
#include "boundary_info.h"
#include "boundary_mesh.h"
#include "dof_map.h"
#include "elem.h"
#include "elem_quality.h"
#include "gmv_io.h"
#include "inf_elem_builder.h"
#include "legacy_xdr_io.h"
#include "libmesh.h"
#include "mesh.h"
#include "mesh_data.h"
#include "mesh_modification.h"
#include "mesh_refinement.h"
#include "perfmon.h"
#include "statistics.h"


using namespace libMesh;


/*
 * convenient enum for the mode in which the boundary mesh
 * should be written
 */
enum BoundaryMeshWriteMode {BM_DISABLED=0, BM_MESH_ONLY, BM_WITH_MESHDATA};


void usage(char *progName)
{
  std::string baseName;
  static std::string helpList =
    "usage:\n"
    "        %s [options] ...\n"
    "\n"
    "options:\n"
    "    -d <dim>                      <dim>-dimensional mesh\n"
    "    -i <string>                   Input file name\n"
    "    -o <string>                   Output file name\n"
    "    -s <string>                   Solution file name\n"
  "\n    -b                            Write the boundary conditions\n"
    "    -B                            Like -b, but with activated MeshData\n"
    "    -D <factor>                   Randomly move interior nodes by D*hmin\n"
    "    -h                            Print help menu\n"
    "    -p <count>                    Partition into <count> subdomains\n"
#ifdef LIBMESH_ENABLE_AMR
    "    -r <count>                    Globally refine <count> times\n"
#endif
    "    -t (-d 2 only)                Convert to triangles first\n"
    "                                  (allows to write .unv file of the\n"
    "                                  boundary with the correct node ids)\n"
    "    -v                            Verbose\n"
    "    -2                            Converts a mesh of linear elements\n"
    "                                  to their second-order counterparts:\n"
    "                                  Quad4 -> Quad8, Tet4 -> Tet10 etc\n"
    "    -3                            Same, but to the highest possible:\n"
    "                                  Quad4 -> Quad9, Hex8 -> Hex27 etc\n"
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
  "\n    -a                            Add infinite elements\n"
    "    -x <coord>                    Specify infinite element origin\n"
    "    -y <coord>                    coordinates. If none given, origin\n"
    "    -z <coord>                    is determined automatically.\n"
    "    -X                            When building infinite elements \n"
    "    -Y                            treat mesh as x/y/z-symmetric.\n"
    "    -Z                            When -X is given, -x <coord> also\n"
    "                                  has to be given.  Similar for y,z.\n"
#endif
/*  "\n    -l                            Build the L connectivity matrix \n"         */
/*    "    -L                            Build the script L connectivity matrix \n"  */
    "\n"
    "\n"
    " This program is used to convert and partions from/to a variety of\n"
    " formats.  File types are inferred from file extensions.  For example,\n"
    " the command:\n"
    "\n"
    "  ./meshtool -d 2 -i in.exd -o out.plt\n"
    "\n"
    " will read a 2D mesh in the ExodusII format (from Cubit, for example)\n"
    " from the file in.exd.  It will then write the mesh in the Tecplot\n"
    " binary format to out.plt.\n"
    "\n"
    " and\n"
    "\n"
    "  ./meshtool -d 3 -i bench12.mesh.0000 -o out.gmv -s bench12.soln.0137\n"
    "\n"
    " will read a 3D MGF mesh from the file bench12.mesh.0000, read a\n"
    " solution from bench12.soln.0137, and write the output in GMV format\n"
    " to out.gmv\n"
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
    "\n"
    " and\n"
    "\n"
    "  ./meshtool -d 3 -i dry.unv -o packed.gmv -a -x 30.5 -y -10.5 -X\n"
    "\n"
    " will read a 3D Universal file, determine the z-coordinate of the origin\n"
    " automatically, e.g. z_origin = 3., build infinite elements with the\n"
    " origin (30.5, -10.5, 3.) on top of volume elements, while preserving\n"
    " a symmetry plane through (30.5, -10.5, 3.) perpendicular to x.\n"
    " It is imperative that the origin lies _inside_ the given volume mesh.\n"
    " If not, infinite elements are not correctly built!\n"
#endif
    "\n"
    " Currently this program supports the following formats:\n"
    "\n"
    "INPUT:\n"
    "     .exd -- Sandia's ExodusII binary grid format\n"
    "     .mgf -- MGF binary mesh format\n"
    "     .ucd -- AVS unstructured ASCII grid format\n"
    "     .unv -- SDRC I-Deas Universal File ASCII format\n"
    "     .xda -- libMesh human-readable ASCII format\n"
    "     .xdr -- libMesh binary format\n"
    "\n"
    "OUTPUT:\n"
    "     .dat   -- Tecplot ASCII format\n"
    "     .e     -- Sandia's ExodusII format\n"
    "     .exd   -- Sandia's ExodusII format\n"
    "     .fro   -- ACDL's .fro format\n"
    "     .gmv   -- LANL's General Mesh Viewer format\n"
    "     .mesh  -- MEdit mesh format\n"
    "     .mgf   -- MGF binary mesh format\n"
    "     .msh   -- GMSH ASCII file\n"
    "     .plt   -- Tecplot binary format\n"
    "     .poly  -- TetGen ASCII file\n"
    "     .pvtu  -- Paraview VTK format\n"
    "     .ucd   -- AVS's ASCII UCD format\n"
    "     .ugrid -- Kelly's DIVA ASCII format (3D only)\n"
    "     .unv   -- I-deas Universal format\n"
    "     .xda   -- libMesh ASCII format\n"
    "     .xdr   -- libMesh binary format\n"
    "     .gz    -- any above format gzipped\n"
    "     .bz2   -- any above format bzip2'ed\n"
    "\n"
    " Direct questions to:\n"
    " <EMAIL>\n";

    
  if (progName == NULL)
    baseName = "UNKNOWN";
  else 
    baseName = progName;

  
  fprintf(stderr, helpList.c_str(), baseName.c_str());
  fflush(stderr);

  exit(0);
}



void process_cmd_line(int argc, char **argv,
                      std::vector<std::string>& names,
                      unsigned int& n_subdomains,
                      unsigned int& n_rsteps,
                      unsigned int& dim,
                      double& dist_fact,
                      bool& verbose,
                      BoundaryMeshWriteMode& write_bndry,
                      unsigned int& convert_second_order,
                      bool& triangulate,
                      bool& addinfelems,

#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
                      InfElemBuilder::InfElemOriginValue& origin_x,
                      InfElemBuilder::InfElemOriginValue& origin_y,
                      InfElemBuilder::InfElemOriginValue& origin_z,
#endif

                      bool& x_sym,
                      bool& y_sym,
{'fraction_non_alphanumeric': 0.11351122405760271, 'fraction_numerical': 0.010235775801214176, 'mean_word_length': 1.5092100602196246, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6772477', 'n_tokens_mistral': 4832, 'n_tokens_neox': 4517, 'n_words': 1339}