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"
20#include "InfoLib/GitInfo.h"
22
23int main(int argc, char* argv[])
24{
25 WARN(
26 "Due to lack of functionality to handle VTU field data, this tool is "
27 "replaced with a new tool, pvtu2vtu. Please use pvtu2vtu instead. If "
28 "you use this tool, please make sure that the field data of the VTU "
29 "file are not used in an OGS simulation.");
30
31 TCLAP::CmdLine cmd(
32 "Reads a VTK partitioned unstructured grid (*.pvtu), cleans the ghost "
33 "information and saves the data as as a regular, connected mesh file."
34 "\n\nOpenGeoSys-6 software, version " +
36 ".\n"
37 "Copyright (c) 2012-2024, OpenGeoSys Community "
38 "(http://www.opengeosys.org)",
40
41 TCLAP::ValueArg<std::string> output_arg(
42 "o", "output", "the output mesh (*.vtu)", true, "", "output.vtu");
43 cmd.add(output_arg);
44
45 TCLAP::ValueArg<std::string> input_arg(
46 "i", "input", "the partitioned input mesh (*.pvtu)", true, "",
47 "input.pvtu");
48 cmd.add(input_arg);
49 cmd.parse(argc, argv);
50
51 BaseLib::MPI::Setup mpi_setup(argc, argv);
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}
Git information.
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
int main(int argc, char *argv[])
GITINFOLIB_EXPORT const std::string ogs_version