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 "BaseLib/Logging.h"
22#include "BaseLib/MPI.h"
24#include "InfoLib/GitInfo.h"
27#include "MeshLib/Mesh.h"
28#include "MeshLib/Node.h"
30
31int main(int argc, char* argv[])
32{
33 TCLAP::CmdLine cmd(
34 "Reads a Gocad stratigraphic grid file (file ending sg) and writes the "
35 "data in the vtk unstructured grid file format. The documentation is "
36 "available at "
37 "https://www.opengeosys.org/docs/tools/meshing/gocadsgridreader/."
38 "\n"
39 "OpenGeoSys-6 "
40 "software, version " +
42 ".\n"
43 "Copyright (c) 2012-2025, OpenGeoSys Community "
44 "(http://www.opengeosys.org)",
46
47 TCLAP::SwitchArg face_set_arg("f", "generate-face-sets",
48 "Generate face sets.");
49 cmd.add(face_set_arg);
50
51 TCLAP::ValueArg<std::string> mesh_output_arg(
52 "o", "output-mesh", "Output (.vtu). Unstructured grid filename", true,
53 "", "OUTPUT_FILE");
54 cmd.add(mesh_output_arg);
55
56 TCLAP::ValueArg<std::string> sg_file_arg(
57 "s", "sg", "Input (.sg). Gocad stratigraphic grid filename", true, "",
58 "INPUT_FILE");
59 cmd.add(sg_file_arg);
60 auto log_level_arg = BaseLib::makeLogLevelArg();
61 cmd.add(log_level_arg);
62
63 cmd.parse(argc, argv);
64
65 BaseLib::MPI::Setup mpi_setup(argc, argv);
66 BaseLib::initOGSLogger(log_level_arg.getValue());
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 return EXIT_SUCCESS;
86}
Definition of the Element class.
Filename manipulation routines.
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
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
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
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)