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