OGS
GocadSGridReader.cpp File Reference

Detailed Description

Definition in file GocadSGridReader.cpp.

#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 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 31 of file GocadSGridReader.cpp.

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}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
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)

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().