10#include <tclap/CmdLine.h>
12#include <boost/property_tree/ptree.hpp>
13#include <boost/property_tree/xml_parser.hpp>
30void postVTU(std::string
const& int_vtu_filename,
31 std::string
const& out_vtu_filename)
34 std::unique_ptr<MeshLib::Mesh const> mesh(
36 if (mesh->hasNonlinearElement())
42 std::vector<MeshLib::Element*> vec_matrix_elements;
43 std::vector<int> vec_fracture_mat_IDs;
44 std::vector<std::vector<MeshLib::Element*>> vec_fracture_elements;
45 std::vector<std::vector<MeshLib::Element*>> vec_fracture_matrix_elements;
46 std::vector<std::vector<MeshLib::Node*>> vec_fracture_nodes;
47 std::vector<std::pair<std::size_t, std::vector<int>>>
48 vec_branch_nodeID_matIDs;
49 std::vector<std::pair<std::size_t, std::vector<int>>>
50 vec_junction_nodeID_matIDs;
52 *mesh, vec_matrix_elements, vec_fracture_mat_IDs, vec_fracture_elements,
53 vec_fracture_matrix_elements, vec_fracture_nodes,
54 vec_branch_nodeID_matIDs, vec_junction_nodeID_matIDs);
59 vec_fracture_matrix_elements,
60 vec_branch_nodeID_matIDs,
61 vec_junction_nodeID_matIDs);
64 INFO(
"create {:s}", out_vtu_filename);
68void postPVD(std::string
const& in_pvd_filename,
69 std::string
const& out_pvd_filename,
70 bool const allow_overwrite)
74 INFO(
"start reading the PVD file {:s}", in_pvd_filename);
75 boost::property_tree::ptree pt;
76 read_xml(in_pvd_filename, pt,
77 boost::property_tree::xml_parser::trim_whitespace);
79 for (
auto& dataset : pt.get_child(
"VTKFile.Collection"))
81 if (dataset.first !=
"DataSet")
87 auto const org_vtu_filename =
88 dataset.second.get<std::string>(
"<xmlattr>.file");
89 auto const org_vtu_filebasename =
92 if (org_vtu_dir.empty())
94 org_vtu_dir = in_pvd_file_dir;
96 auto const org_vtu_filepath =
98 INFO(
"processing {:s}...", org_vtu_filepath);
101 auto const dest_vtu_filename =
"post_" + org_vtu_filebasename;
102 auto const dest_vtu_filepath =
106 INFO(
"The destination file already exists. Skip overwriting it.");
110 postVTU(org_vtu_filepath, dest_vtu_filepath);
114 dataset.second.put(
"<xmlattr>.file", dest_vtu_filename);
118 INFO(
"save into the new PVD file {:s}", out_pvd_filename);
119 boost::property_tree::xml_writer_settings<std::string> settings(
'\t', 1);
120 write_xml(out_pvd_filename, pt, std::locale(), settings);
125int main(
int argc,
char* argv[])
128 "Post-process results of the LIE approach.\n\n"
129 "OpenGeoSys-6 software, version " +
132 "Copyright (c) 2012-2024, OpenGeoSys Community "
133 "(http://www.opengeosys.org)",
135 TCLAP::ValueArg<std::string> arg_out_file(
136 "o",
"output-file",
"the name of the new PVD or VTU file",
true,
"",
138 cmd.add(arg_out_file);
139 TCLAP::ValueArg<std::string> arg_in_file(
140 "i",
"input-file",
"the original PVD or VTU file name",
true,
"",
142 cmd.add(arg_in_file);
143 TCLAP::SwitchArg nooverwrite_arg(
146 "don't overwrite existing post processed VTU files");
147 cmd.add(nooverwrite_arg);
149 cmd.parse(argc, argv);
154 if (in_file_ext ==
".pvd")
156 postPVD(arg_in_file.getValue(), arg_out_file.getValue(),
157 !nooverwrite_arg.getValue());
159 else if (in_file_ext ==
".vtu")
161 postVTU(arg_in_file.getValue(), arg_out_file.getValue());
165 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
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.