OGS
GocadSGridReader.cpp
Go to the documentation of this file.
1
11
12#include <spdlog/spdlog.h>
13#include <tclap/CmdLine.h>
14
15#ifdef USE_PETSC
16#include <mpi.h>
17#endif
18
19#include <fstream>
20#include <sstream>
21#include <string>
22
24#include "BaseLib/FileTools.h"
25#include "InfoLib/GitInfo.h"
28#include "MeshLib/Mesh.h"
29#include "MeshLib/Node.h"
31
32int main(int argc, char* argv[])
33{
34 TCLAP::CmdLine cmd(
35 "Reads a Gocad stratigraphic grid file (file ending sg) and writes the "
36 "data in the vtk unstructured grid file format. The documentation is "
37 "available at "
38 "https://www.opengeosys.org/docs/tools/meshing/gocadsgridreader/."
39 "\n"
40 "OpenGeoSys-6 "
41 "software, version " +
43 ".\n"
44 "Copyright (c) 2012-2024, OpenGeoSys Community "
45 "(http://www.opengeosys.org)",
47
48 TCLAP::SwitchArg face_set_arg("f", "generate-face-sets",
49 "Generate face sets.");
50 cmd.add(face_set_arg);
51
52 TCLAP::ValueArg<std::string> mesh_output_arg(
53 "o", "output-mesh", "vtk unstructured grid file name", true, "",
54 "file_name.vtu");
55 cmd.add(mesh_output_arg);
56
57 TCLAP::ValueArg<std::string> sg_file_arg(
58 "s", "sg", "Gocad stratigraphic grid file name", true, "",
59 "file_name.sg");
60 cmd.add(sg_file_arg);
61
62 cmd.parse(argc, argv);
63
64#ifdef USE_PETSC
65 MPI_Init(&argc, &argv);
66#endif
67
68 // read the Gocad SGrid
69 INFO("Start reading Gocad SGrid.");
70 FileIO::Gocad::GocadSGridReader reader(sg_file_arg.getValue());
71 INFO("End reading Gocad SGrid.");
72
73 if (face_set_arg.getValue())
74 {
75 INFO("Generating a mesh for every face set.");
77 reader, BaseLib::extractPath(sg_file_arg.getValue()));
78 }
79
80 std::unique_ptr<MeshLib::Mesh> mesh(reader.getMesh());
82
83 INFO("Writing mesh to '{:s}'.", mesh_output_arg.getValue());
84 MeshLib::IO::writeMeshToFile(*mesh, mesh_output_arg.getValue());
85#ifdef USE_PETSC
86 MPI_Finalize();
87#endif
88 return EXIT_SUCCESS;
89}
Definition of the Element class.
Filename manipulation routines.
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
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)
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, std::set< std::string > variable_output_names)