OGS
FEFLOW2OGS.cpp File Reference

Detailed Description

Definition in file FEFLOW2OGS.cpp.

#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include "BaseLib/FileTools.h"
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/RunTime.h"
#include "BaseLib/TCLAPArguments.h"
#include "InfoLib/GitInfo.h"
#include "BaseLib/MemWatch.h"
#include "Applications/FileIO/FEFLOW/FEFLOWMeshInterface.h"
#include "MeshLib/IO/Legacy/MeshIO.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
Include dependency graph for FEFLOW2OGS.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 33 of file FEFLOW2OGS.cpp.

34{
35 TCLAP::CmdLine cmd(
36 "Converting a mesh in FEFLOW file format (ASCII, version 5.4) to a vtk "
37 "unstructured grid file (new OGS file format) or to the old OGS file "
38 "format - see options.\n\n"
39 "OpenGeoSys-6 software, version " +
41 ".\n"
42 "Copyright (c) 2012-2025, OpenGeoSys Community "
43 "(http://www.opengeosys.org)",
45
46 TCLAP::ValueArg<std::string> ogs_mesh_arg(
47 "o",
48 "out",
49 "Output. Filename for output mesh (if extension is msh, old OGS file "
50 "format is "
51 "written)",
52 true,
53 "",
54 "OUTPUT_FILE");
55 cmd.add(ogs_mesh_arg);
56
57 TCLAP::ValueArg<std::string> feflow_mesh_arg(
58 "i", "in", "Input (.fem). FEFLOW input file", true, "", "INPUT_FILE");
59 cmd.add(feflow_mesh_arg);
60
61 auto log_level_arg = BaseLib::makeLogLevelArg();
62 cmd.add(log_level_arg);
63 cmd.parse(argc, argv);
64
65 BaseLib::MPI::Setup mpi_setup(argc, argv);
66 BaseLib::initOGSLogger(log_level_arg.getValue());
67
68 // *** read mesh
69 INFO("Reading {:s}.", feflow_mesh_arg.getValue());
70#ifndef WIN32
71 BaseLib::MemWatch mem_watch;
72 unsigned long mem_without_mesh(mem_watch.getVirtMemUsage());
73#endif
74 BaseLib::RunTime run_time;
75 run_time.start();
77 std::unique_ptr<MeshLib::Mesh const> mesh(
78 feflowIO.readFEFLOWFile(feflow_mesh_arg.getValue()));
79
80 if (mesh == nullptr)
81 {
82 INFO("Could not read mesh from {:s}.", feflow_mesh_arg.getValue());
83 return EXIT_FAILURE;
84 }
85#ifndef WIN32
86 unsigned long mem_with_mesh(mem_watch.getVirtMemUsage());
87 INFO("Mem for mesh: {} MiB",
88 (mem_with_mesh - mem_without_mesh) / (1024 * 1024));
89#endif
90 INFO("Time for reading: {:f} seconds.", run_time.elapsed());
91 INFO("Read {:d} nodes and {:d} elements.", mesh->getNumberOfNodes(),
92 mesh->getNumberOfElements());
93
94 std::string ogs_mesh_fname(ogs_mesh_arg.getValue());
95 INFO("Writing {:s}.", ogs_mesh_fname);
96 MeshLib::IO::writeMeshToFile(*mesh, ogs_mesh_fname);
97 INFO("\tDone.");
98 return EXIT_SUCCESS;
99}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
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)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
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::RunTime::elapsed(), BaseLib::MemWatch::getVirtMemUsage(), INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, FileIO::FEFLOWMeshInterface::readFEFLOWFile(), BaseLib::RunTime::start(), and MeshLib::IO::writeMeshToFile().