OGS
FEFLOW2OGS.cpp
Go to the documentation of this file.
1
11#include <tclap/CmdLine.h>
12
13#include <memory>
14#include <string>
15
16#include "BaseLib/FileTools.h"
17#include "BaseLib/MPI.h"
18#include "BaseLib/RunTime.h"
19#include "InfoLib/GitInfo.h"
20#ifndef WIN32
21#include "BaseLib/MemWatch.h"
22#endif
23
24// FileIO
29#include "MeshLib/Mesh.h"
30
31int main(int argc, char* argv[])
32{
33 TCLAP::CmdLine cmd(
34 "Converting a mesh in FEFLOW file format (ASCII, version 5.4) to a vtk "
35 "unstructured grid file (new OGS file format) or to the old OGS file "
36 "format - see options.\n\n"
37 "OpenGeoSys-6 software, version " +
39 ".\n"
40 "Copyright (c) 2012-2025, OpenGeoSys Community "
41 "(http://www.opengeosys.org)",
43
44 TCLAP::ValueArg<std::string> ogs_mesh_arg(
45 "o",
46 "out",
47 "Output. Filename for output mesh (if extension is msh, old OGS file "
48 "format is "
49 "written)",
50 true,
51 "",
52 "OUTPUT_FILE");
53 cmd.add(ogs_mesh_arg);
54
55 TCLAP::ValueArg<std::string> feflow_mesh_arg(
56 "i", "in", "Input (.fem). FEFLOW input file", true, "", "INPUT_FILE");
57 cmd.add(feflow_mesh_arg);
58
59 cmd.parse(argc, argv);
60
61 BaseLib::MPI::Setup mpi_setup(argc, argv);
62
63 // *** read mesh
64 INFO("Reading {:s}.", feflow_mesh_arg.getValue());
65#ifndef WIN32
66 BaseLib::MemWatch mem_watch;
67 unsigned long mem_without_mesh(mem_watch.getVirtMemUsage());
68#endif
69 BaseLib::RunTime run_time;
70 run_time.start();
72 std::unique_ptr<MeshLib::Mesh const> mesh(
73 feflowIO.readFEFLOWFile(feflow_mesh_arg.getValue()));
74
75 if (mesh == nullptr)
76 {
77 INFO("Could not read mesh from {:s}.", feflow_mesh_arg.getValue());
78 return EXIT_FAILURE;
79 }
80#ifndef WIN32
81 unsigned long mem_with_mesh(mem_watch.getVirtMemUsage());
82 INFO("Mem for mesh: {} MiB",
83 (mem_with_mesh - mem_without_mesh) / (1024 * 1024));
84#endif
85 INFO("Time for reading: {:f} seconds.", run_time.elapsed());
86 INFO("Read {:d} nodes and {:d} elements.", mesh->getNumberOfNodes(),
87 mesh->getNumberOfElements());
88
89 std::string ogs_mesh_fname(ogs_mesh_arg.getValue());
90 INFO("Writing {:s}.", ogs_mesh_fname);
91 MeshLib::IO::writeMeshToFile(*mesh, ogs_mesh_fname);
92 INFO("\tDone.");
93 return EXIT_SUCCESS;
94}
int main(int argc, char *argv[])
Filename manipulation routines.
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
Definition of the MemWatch class.
Definition of the MeshIO class.
Definition of the Mesh class.
Definition of the RunTime class.
Implementation of the VtuInterface class.
unsigned long getVirtMemUsage()
Definition MemWatch.cpp:59
Count the running time.
Definition RunTime.h:29
double elapsed() const
Get the elapsed time in seconds.
Definition RunTime.h:42
void start()
Start the timer.
Definition RunTime.h:32
MeshLib::Mesh * readFEFLOWFile(const std::string &filename)
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)