OGS
GocadSGridReader.cpp
Go to the documentation of this file.
1 
11 
12 #include <spdlog/spdlog.h>
13 #include <tclap/CmdLine.h>
14 
15 #include <fstream>
16 #include <sstream>
17 #include <string>
18 
20 #include "BaseLib/FileTools.h"
21 #include "InfoLib/GitInfo.h"
24 #include "MeshLib/Mesh.h"
26 #include "MeshLib/Node.h"
27 
28 int main(int argc, char* argv[])
29 {
30  TCLAP::CmdLine cmd(
31  "Reads a Gocad stratigraphic grid file (file ending sg) and writes the "
32  "data in the vtk unstructured grid file format. The documentation is "
33  "available at "
34  "https://www.opengeosys.org/docs/tools/meshing/gocadsgridreader/.\n\n "
35  "OpenGeoSys-6 "
36  "software, version " +
38  ".\n"
39  "Copyright (c) 2012-2021, OpenGeoSys Community "
40  "(http://www.opengeosys.org)",
42 
43  TCLAP::SwitchArg face_set_arg("f", "generate-face-sets",
44  "Generate face sets.");
45  cmd.add(face_set_arg);
46 
47  TCLAP::ValueArg<std::string> mesh_output_arg(
48  "o", "output-mesh", "vtk unstructured grid file name", true, "",
49  "file_name.vtu");
50  cmd.add(mesh_output_arg);
51 
52  TCLAP::ValueArg<std::string> sg_file_arg(
53  "s", "sg", "Gocad stratigraphic grid file name", true, "",
54  "file_name.sg");
55  cmd.add(sg_file_arg);
56 
57  cmd.parse(argc, argv);
58 
59  // read the Gocad SGrid
60  INFO("Start reading Gocad SGrid.");
61  FileIO::Gocad::GocadSGridReader reader(sg_file_arg.getValue());
62  INFO("End reading Gocad SGrid.");
63 
64  if (face_set_arg.getValue())
65  {
66  INFO("Generating a mesh for every face set.");
68  reader, BaseLib::extractPath(sg_file_arg.getValue()));
69  }
70 
71  std::unique_ptr<MeshLib::Mesh> mesh(reader.getMesh());
73 
74  INFO("Writing mesh to '{:s}'.", mesh_output_arg.getValue());
75  MeshLib::IO::writeMeshToFile(*mesh, mesh_output_arg.getValue());
76 
77  return 0;
78 }
Definition of the Element class.
Filename manipulation routines.
Git information.
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
Definition of the MeshInformation class.
Definition of the Mesh class.
Definition of the Node class.
int main(int argc, char *argv[])
std::unique_ptr< MeshLib::Mesh > getMesh() const
static void writePropertyVectorInformation(const MeshLib::Mesh &mesh)
writes out property vector information
std::string extractPath(std::string const &pathname)
Definition: FileTools.cpp:207
void generateFaceSets(GocadSGridReader const &reader, std::string const &path)
GITINFOLIB_EXPORT const std::string ogs_version
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)