10#include <tclap/CmdLine.h>
12#include <boost/property_tree/ptree.hpp>
13#include <boost/property_tree/xml_parser.hpp>
32void postVTU(std::string
const& int_vtu_filename,
33 std::string
const& out_vtu_filename)
36 std::unique_ptr<MeshLib::Mesh const> mesh(
38 if (mesh->hasNonlinearElement())
44 std::vector<MeshLib::Element*> vec_matrix_elements;
45 std::vector<int> vec_fracture_mat_IDs;
46 std::vector<std::vector<MeshLib::Element*>> vec_fracture_elements;
47 std::vector<std::vector<MeshLib::Element*>> vec_fracture_matrix_elements;
48 std::vector<std::vector<MeshLib::Node*>> vec_fracture_nodes;
49 std::vector<std::pair<std::size_t, std::vector<int>>>
50 vec_branch_nodeID_matIDs;
51 std::vector<std::pair<std::size_t, std::vector<int>>>
52 vec_junction_nodeID_matIDs;
54 *mesh, vec_matrix_elements, vec_fracture_mat_IDs, vec_fracture_elements,
55 vec_fracture_matrix_elements, vec_fracture_nodes,
56 vec_branch_nodeID_matIDs, vec_junction_nodeID_matIDs);
61 vec_fracture_matrix_elements,
62 vec_branch_nodeID_matIDs,
63 vec_junction_nodeID_matIDs);
66 INFO(
"create {:s}", out_vtu_filename);
70void postPVD(std::string
const& in_pvd_filename,
71 std::string
const& out_pvd_filename,
72 bool const allow_overwrite)
76 INFO(
"start reading the PVD file {:s}", in_pvd_filename);
77 boost::property_tree::ptree pt;
78 read_xml(in_pvd_filename, pt,
79 boost::property_tree::xml_parser::trim_whitespace);
81 for (
auto& dataset : pt.get_child(
"VTKFile.Collection"))
83 if (dataset.first !=
"DataSet")
89 auto const org_vtu_filename =
90 dataset.second.get<std::string>(
"<xmlattr>.file");
91 auto const org_vtu_filebasename =
94 if (org_vtu_dir.empty())
96 org_vtu_dir = in_pvd_file_dir;
98 auto const org_vtu_filepath =
100 INFO(
"processing {:s}...", org_vtu_filepath);
103 auto const dest_vtu_filename =
"post_" + org_vtu_filebasename;
104 auto const dest_vtu_filepath =
108 INFO(
"The destination file already exists. Skip overwriting it.");
112 postVTU(org_vtu_filepath, dest_vtu_filepath);
116 dataset.second.put(
"<xmlattr>.file", dest_vtu_filename);
120 INFO(
"save into the new PVD file {:s}", out_pvd_filename);
121 boost::property_tree::xml_writer_settings<std::string> settings(
'\t', 1);
122 write_xml(out_pvd_filename, pt, std::locale(), settings);
127int main(
int argc,
char* argv[])
130 "Post-process results of the LIE approach.\n\n"
131 "OpenGeoSys-6 software, version " +
134 "Copyright (c) 2012-2025, OpenGeoSys Community "
135 "(http://www.opengeosys.org)",
137 TCLAP::ValueArg<std::string> arg_out_file(
139 "Output (.vtu | .pvd). The name of the new PVD or VTU file",
true,
"",
141 cmd.add(arg_out_file);
142 TCLAP::ValueArg<std::string> arg_in_file(
144 "Input (.vtu | .pvd). The original PVD or VTU file name",
true,
"",
146 cmd.add(arg_in_file);
147 TCLAP::SwitchArg nooverwrite_arg(
150 "don't overwrite existing post processed VTU files");
151 cmd.add(nooverwrite_arg);
153 cmd.add(log_level_arg);
155 cmd.parse(argc, argv);
161 if (in_file_ext ==
".pvd")
163 postPVD(arg_in_file.getValue(), arg_out_file.getValue(),
164 !nooverwrite_arg.getValue());
166 else if (in_file_ext ==
".vtu")
168 postVTU(arg_in_file.getValue(), arg_out_file.getValue());
172 OGS_FATAL(
"The given file type ({:s}) is not supported.", in_file_ext);
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
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[])
Definition of readMeshFromFile function.