OGS
FEFLOW2OGS.cpp File Reference
#include <memory>
#include <string>
#include <tclap/CmdLine.h>
#include "BaseLib/FileTools.h"
#include "BaseLib/RunTime.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 31 of file FEFLOW2OGS.cpp.

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-2021, OpenGeoSys Community "
41  "(http://www.opengeosys.org)",
43 
44  TCLAP::ValueArg<std::string> ogs_mesh_arg(
45  "o",
46  "out",
47  "filename for output mesh (if extension is msh, old OGS fileformat is "
48  "written)",
49  true,
50  "",
51  "filename as string");
52  cmd.add(ogs_mesh_arg);
53 
54  TCLAP::ValueArg<std::string> feflow_mesh_arg(
55  "i", "in", "FEFLOW input file (*.fem)", true, "", "filename as string");
56  cmd.add(feflow_mesh_arg);
57 
58  cmd.parse(argc, argv);
59 
60  // *** read mesh
61  INFO("Reading {:s}.", feflow_mesh_arg.getValue());
62 #ifndef WIN32
63  BaseLib::MemWatch mem_watch;
64  unsigned long mem_without_mesh(mem_watch.getVirtMemUsage());
65 #endif
66  BaseLib::RunTime run_time;
67  run_time.start();
69  std::unique_ptr<MeshLib::Mesh const> mesh(
70  feflowIO.readFEFLOWFile(feflow_mesh_arg.getValue()));
71 
72  if (mesh == nullptr)
73  {
74  INFO("Could not read mesh from {:s}.", feflow_mesh_arg.getValue());
75  return EXIT_FAILURE;
76  }
77 #ifndef WIN32
78  unsigned long mem_with_mesh(mem_watch.getVirtMemUsage());
79  INFO("Mem for mesh: {} MiB",
80  (mem_with_mesh - mem_without_mesh) / (1024 * 1024));
81 #endif
82  INFO("Time for reading: {:f} seconds.", run_time.elapsed());
83  INFO("Read {:d} nodes and {:d} elements.", mesh->getNumberOfNodes(),
84  mesh->getNumberOfElements());
85 
86  std::string ogs_mesh_fname(ogs_mesh_arg.getValue());
87  INFO("Writing {:s}.", ogs_mesh_fname);
88  MeshLib::IO::writeMeshToFile(*mesh, ogs_mesh_fname);
89  INFO("\tDone.");
90  return EXIT_SUCCESS;
91 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
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, [[maybe_unused]] std::set< std::string > variable_output_names)

References BaseLib::RunTime::elapsed(), BaseLib::MemWatch::getVirtMemUsage(), INFO(), GitInfoLib::GitInfo::ogs_version, FileIO::FEFLOWMeshInterface::readFEFLOWFile(), BaseLib::RunTime::start(), and MeshLib::IO::writeMeshToFile().