4#include <tclap/CmdLine.h>
6#include <boost/property_tree/ptree.hpp>
7#include <boost/property_tree/xml_parser.hpp>
26void postVTU(std::string
const& int_vtu_filename,
27 std::string
const& out_vtu_filename)
30 std::unique_ptr<MeshLib::Mesh const> mesh(
32 if (mesh->hasNonlinearElement())
38 std::vector<MeshLib::Element*> vec_matrix_elements;
39 std::vector<int> vec_fracture_mat_IDs;
40 std::vector<std::vector<MeshLib::Element*>> vec_fracture_elements;
41 std::vector<std::vector<MeshLib::Element*>> vec_fracture_matrix_elements;
42 std::vector<std::vector<MeshLib::Node*>> vec_fracture_nodes;
43 std::vector<std::pair<std::size_t, std::vector<int>>>
44 vec_branch_nodeID_matIDs;
45 std::vector<std::pair<std::size_t, std::vector<int>>>
46 vec_junction_nodeID_matIDs;
48 *mesh, vec_matrix_elements, vec_fracture_mat_IDs, vec_fracture_elements,
49 vec_fracture_matrix_elements, vec_fracture_nodes,
50 vec_branch_nodeID_matIDs, vec_junction_nodeID_matIDs);
55 vec_fracture_matrix_elements,
56 vec_branch_nodeID_matIDs,
57 vec_junction_nodeID_matIDs);
60 INFO(
"create {:s}", out_vtu_filename);
64void postPVD(std::string
const& in_pvd_filename,
65 std::string
const& out_pvd_filename,
66 bool const allow_overwrite)
70 INFO(
"start reading the PVD file {:s}", in_pvd_filename);
71 boost::property_tree::ptree pt;
72 read_xml(in_pvd_filename, pt,
73 boost::property_tree::xml_parser::trim_whitespace);
75 for (
auto& dataset : pt.get_child(
"VTKFile.Collection"))
77 if (dataset.first !=
"DataSet")
83 auto const org_vtu_filename =
84 dataset.second.get<std::string>(
"<xmlattr>.file");
85 auto const org_vtu_filebasename =
88 if (org_vtu_dir.empty())
90 org_vtu_dir = in_pvd_file_dir;
92 auto const org_vtu_filepath =
94 INFO(
"processing {:s}...", org_vtu_filepath);
97 auto const dest_vtu_filename =
"post_" + org_vtu_filebasename;
98 auto const dest_vtu_filepath =
102 INFO(
"The destination file already exists. Skip overwriting it.");
106 postVTU(org_vtu_filepath, dest_vtu_filepath);
110 dataset.second.put(
"<xmlattr>.file", dest_vtu_filename);
114 INFO(
"save into the new PVD file {:s}", out_pvd_filename);
115 boost::property_tree::xml_writer_settings<std::string> settings(
'\t', 1);
116 write_xml(out_pvd_filename, pt, std::locale(), settings);
121int main(
int argc,
char* argv[])
124 "Post-process results of the LIE approach.\n\n"
125 "OpenGeoSys-6 software, version " +
128 "Copyright (c) 2012-2026, OpenGeoSys Community "
129 "(http://www.opengeosys.org)",
131 TCLAP::ValueArg<std::string> arg_out_file(
133 "Output (.vtu | .pvd). The name of the new PVD or VTU file",
true,
"",
135 cmd.add(arg_out_file);
136 TCLAP::ValueArg<std::string> arg_in_file(
138 "Input (.vtu | .pvd). The original PVD or VTU file name",
true,
"",
140 cmd.add(arg_in_file);
141 TCLAP::SwitchArg nooverwrite_arg(
144 "don't overwrite existing post processed VTU files");
145 cmd.add(nooverwrite_arg);
147 cmd.add(log_level_arg);
149 cmd.parse(argc, argv);
155 if (in_file_ext ==
".pvd")
157 postPVD(arg_in_file.getValue(), arg_out_file.getValue(),
158 !nooverwrite_arg.getValue());
160 else if (in_file_ext ==
".vtu")
162 postVTU(arg_in_file.getValue(), arg_out_file.getValue());
166 OGS_FATAL(
"The given file type ({:s}) is not supported.", in_file_ext);
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
MeshLib::Mesh const & getOutputMesh() const
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
std::string getFileExtension(const std::string &path)
std::string extractPath(std::string const &pathname)
bool IsFileExisting(const std::string &strFilename)
Returns true if given file exists.
std::string joinPaths(std::string const &pathA, std::string const &pathB)
std::string extractBaseName(std::string const &pathname)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)
void getFractureMatrixDataInMesh(MeshLib::Mesh const &mesh, std::vector< MeshLib::Element * > &vec_matrix_elements, std::vector< int > &vec_fracture_mat_IDs, std::vector< std::vector< MeshLib::Element * > > &vec_fracture_elements, std::vector< std::vector< MeshLib::Element * > > &vec_fracture_matrix_elements, std::vector< std::vector< MeshLib::Node * > > &vec_fracture_nodes, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_branch_nodeID_matIDs, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_junction_nodeID_matIDs)
void postVTU(std::string const &int_vtu_filename, std::string const &out_vtu_filename)
void postPVD(std::string const &in_pvd_filename, std::string const &out_pvd_filename, bool const allow_overwrite)
int main(int argc, char *argv[])