OGS
RemoveGhostData.cpp
Go to the documentation of this file.
1
10#include <tclap/CmdLine.h>
11#include <vtkCleanUnstructuredGrid.h>
12#include <vtkRemoveGhosts.h>
13#include <vtkSmartPointer.h>
14#include <vtkUnstructuredGrid.h>
15#include <vtkXMLPUnstructuredGridReader.h>
16#include <vtkXMLUnstructuredGridWriter.h>
17
18#include "BaseLib/Logging.h"
19#include "BaseLib/MPI.h"
21#include "InfoLib/GitInfo.h"
23
24int main(int argc, char* argv[])
25{
26 TCLAP::CmdLine cmd(
27 "Reads a VTK partitioned unstructured grid (*.pvtu), cleans the ghost "
28 "information and saves the data as as a regular, connected mesh file."
29 "\n\nOpenGeoSys-6 software, version " +
31 ".\n"
32 "Copyright (c) 2012-2025, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
35
36 TCLAP::ValueArg<std::string> output_arg(
37 "o", "output", "Output (.vtu). The output mesh file", true, "",
38 "OUTPUT_FILE");
39 cmd.add(output_arg);
40
41 TCLAP::ValueArg<std::string> input_arg(
42 "i", "input", "Input (.pvtu). The partitioned input mesh file", true,
43 "", "INPUT_FILE");
44 cmd.add(input_arg);
45
46 auto log_level_arg = BaseLib::makeLogLevelArg();
47 cmd.add(log_level_arg);
48 cmd.parse(argc, argv);
49
50 BaseLib::MPI::Setup mpi_setup(argc, argv);
51 BaseLib::initOGSLogger(log_level_arg.getValue());
52
53 WARN(
54 "Due to lack of functionality to handle VTU field data, this tool is "
55 "replaced with a new tool, pvtu2vtu. Please use pvtu2vtu instead. If "
56 "you use this tool, please make sure that the field data of the VTU "
57 "file are not used in an OGS simulation.");
58
59 vtkSmartPointer<vtkXMLPUnstructuredGridReader> reader =
60 vtkSmartPointer<vtkXMLPUnstructuredGridReader>::New();
61 reader->SetFileName(input_arg.getValue().c_str());
62
63 vtkSmartPointer<vtkRemoveGhosts> ghosts =
64 vtkSmartPointer<vtkRemoveGhosts>::New();
65 ghosts->SetInputConnection(reader->GetOutputPort());
66
67 vtkSmartPointer<vtkCleanUnstructuredGrid> clean =
68 vtkSmartPointer<vtkCleanUnstructuredGrid>::New();
69 clean->SetInputConnection(ghosts->GetOutputPort());
70
71 vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer =
72 vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
73 writer->SetInputConnection(clean->GetOutputPort());
74 writer->SetFileName(output_arg.getValue().c_str());
75 writer->Write();
76
77 return EXIT_SUCCESS;
78}
Git information.
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:42
int main(int argc, char *argv[])
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
GITINFOLIB_EXPORT const std::string ogs_version