OGS
GocadSGridReader.cpp File Reference
#include "Applications/FileIO/GocadIO/GocadSGridReader.h"
#include <spdlog/spdlog.h>
#include <tclap/CmdLine.h>
#include <fstream>
#include <sstream>
#include <string>
#include "Applications/FileIO/GocadIO/GenerateFaceSetMeshes.h"
#include "BaseLib/FileTools.h"
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
#include "MeshToolsLib/MeshInformation.h"
Include dependency graph for Utils/FileConverter/GocadSGridReader.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 25 of file Utils/FileConverter/GocadSGridReader.cpp.

26{
27 TCLAP::CmdLine cmd(
28 "Reads a Gocad stratigraphic grid file (file ending sg) and writes the "
29 "data in the vtk unstructured grid file format. The documentation is "
30 "available at "
31 "https://www.opengeosys.org/docs/tools/meshing/gocadsgridreader/."
32 "\n"
33 "OpenGeoSys-6 "
34 "software, version " +
36 ".\n"
37 "Copyright (c) 2012-2026, OpenGeoSys Community "
38 "(http://www.opengeosys.org)",
40
41 TCLAP::SwitchArg face_set_arg("f", "generate-face-sets",
42 "Generate face sets.");
43 cmd.add(face_set_arg);
44
45 TCLAP::ValueArg<std::string> mesh_output_arg(
46 "o", "output-mesh", "Output (.vtu). Unstructured grid filename", true,
47 "", "OUTPUT_FILE");
48 cmd.add(mesh_output_arg);
49
50 TCLAP::ValueArg<std::string> sg_file_arg(
51 "s", "sg", "Input (.sg). Gocad stratigraphic grid filename", true, "",
52 "INPUT_FILE");
53 cmd.add(sg_file_arg);
54 auto log_level_arg = BaseLib::makeLogLevelArg();
55 cmd.add(log_level_arg);
56
57 cmd.parse(argc, argv);
58
59 BaseLib::MPI::Setup mpi_setup(argc, argv);
60 BaseLib::initOGSLogger(log_level_arg.getValue());
61
62 // read the Gocad SGrid
63 INFO("Start reading Gocad SGrid.");
64 FileIO::Gocad::GocadSGridReader reader(sg_file_arg.getValue());
65 INFO("End reading Gocad SGrid.");
66
67 if (face_set_arg.getValue())
68 {
69 INFO("Generating a mesh for every face set.");
71 reader, BaseLib::extractPath(sg_file_arg.getValue()));
72 }
73
74 std::unique_ptr<MeshLib::Mesh> mesh(reader.getMesh());
76
77 INFO("Writing mesh to '{:s}'.", mesh_output_arg.getValue());
78 MeshLib::IO::writeMeshToFile(*mesh, mesh_output_arg.getValue());
79 return EXIT_SUCCESS;
80}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
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:56
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)

References BaseLib::extractPath(), FileIO::Gocad::generateFaceSets(), FileIO::Gocad::GocadSGridReader::getMesh(), INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::writeMeshToFile(), and MeshToolsLib::MeshInformation::writePropertyVectorInformation().