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