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/MPI.h"
22#include "InfoLib/GitInfo.h"
25#include "MeshLib/Mesh.h"
26#include "MeshLib/Node.h"
28
29int main(int argc, char* argv[])
30{
31 TCLAP::CmdLine cmd(
32 "Reads a Gocad stratigraphic grid file (file ending sg) and writes the "
33 "data in the vtk unstructured grid file format. The documentation is "
34 "available at "
35 "https://www.opengeosys.org/docs/tools/meshing/gocadsgridreader/."
36 "\n"
37 "OpenGeoSys-6 "
38 "software, version " +
40 ".\n"
41 "Copyright (c) 2012-2024, OpenGeoSys Community "
42 "(http://www.opengeosys.org)",
44
45 TCLAP::SwitchArg face_set_arg("f", "generate-face-sets",
46 "Generate face sets.");
47 cmd.add(face_set_arg);
48
49 TCLAP::ValueArg<std::string> mesh_output_arg(
50 "o", "output-mesh", "vtk unstructured grid file name", true, "",
51 "file_name.vtu");
52 cmd.add(mesh_output_arg);
53
54 TCLAP::ValueArg<std::string> sg_file_arg(
55 "s", "sg", "Gocad stratigraphic grid file name", true, "",
56 "file_name.sg");
57 cmd.add(sg_file_arg);
58
59 cmd.parse(argc, argv);
60
61 BaseLib::MPI::Setup mpi_setup(argc, argv);
62
63 // read the Gocad SGrid
64 INFO("Start reading Gocad SGrid.");
65 FileIO::Gocad::GocadSGridReader reader(sg_file_arg.getValue());
66 INFO("End reading Gocad SGrid.");
67
68 if (face_set_arg.getValue())
69 {
70 INFO("Generating a mesh for every face set.");
72 reader, BaseLib::extractPath(sg_file_arg.getValue()));
73 }
74
75 std::unique_ptr<MeshLib::Mesh> mesh(reader.getMesh());
77
78 INFO("Writing mesh to '{:s}'.", mesh_output_arg.getValue());
79 MeshLib::IO::writeMeshToFile(*mesh, mesh_output_arg.getValue());
80 return EXIT_SUCCESS;
81}
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)