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#ifdef USE_PETSC
19#include <mpi.h>
20#endif
21
22#include "BaseLib/Logging.h"
23#include "InfoLib/GitInfo.h"
25
26int main(int argc, char* argv[])
27{
28 WARN(
29 "Due to lack of functionality to handle VTU field data, this tool is "
30 "replaced with a new tool, pvtu2vtu. Please use pvtu2vtu instead. If "
31 "you use this tool, please make sure that the field data of the VTU "
32 "file are not used in an OGS simulation.");
33
34 TCLAP::CmdLine cmd(
35 "Reads a VTK partitioned unstructured grid (*.pvtu), cleans the ghost "
36 "information and saves the data as as a regular, connected mesh file."
37 "\n\nOpenGeoSys-6 software, version " +
39 ".\n"
40 "Copyright (c) 2012-2024, OpenGeoSys Community "
41 "(http://www.opengeosys.org)",
43
44 TCLAP::ValueArg<std::string> output_arg(
45 "o", "output", "the output mesh (*.vtu)", true, "", "output.vtu");
46 cmd.add(output_arg);
47
48 TCLAP::ValueArg<std::string> input_arg(
49 "i", "input", "the partitioned input mesh (*.pvtu)", true, "",
50 "input.pvtu");
51 cmd.add(input_arg);
52 cmd.parse(argc, argv);
53
54#ifdef USE_PETSC
55 MPI_Init(&argc, &argv);
56#endif
57
58 vtkSmartPointer<vtkXMLPUnstructuredGridReader> reader =
59 vtkSmartPointer<vtkXMLPUnstructuredGridReader>::New();
60 reader->SetFileName(input_arg.getValue().c_str());
61
62 vtkSmartPointer<vtkRemoveGhosts> ghosts =
63 vtkSmartPointer<vtkRemoveGhosts>::New();
64 ghosts->SetInputConnection(reader->GetOutputPort());
65
66 vtkSmartPointer<vtkCleanUnstructuredGrid> clean =
67 vtkSmartPointer<vtkCleanUnstructuredGrid>::New();
68 clean->SetInputConnection(ghosts->GetOutputPort());
69
70 vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer =
71 vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
72 writer->SetInputConnection(clean->GetOutputPort());
73 writer->SetFileName(output_arg.getValue().c_str());
74 writer->Write();
75
76#ifdef USE_PETSC
77 MPI_Finalize();
78#endif
79 return EXIT_SUCCESS;
80}
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