10 #include <tclap/CmdLine.h>
12 #include <boost/property_tree/ptree.hpp>
13 #include <boost/property_tree/xml_parser.hpp>
29 void postVTU(std::string
const& int_vtu_filename,
30 std::string
const& out_vtu_filename)
33 std::unique_ptr<MeshLib::Mesh const> mesh(
35 if (mesh->hasNonlinearElement())
41 std::vector<MeshLib::Element*> vec_matrix_elements;
42 std::vector<int> vec_fracture_mat_IDs;
43 std::vector<std::vector<MeshLib::Element*>> vec_fracture_elements;
44 std::vector<std::vector<MeshLib::Element*>> vec_fracture_matrix_elements;
45 std::vector<std::vector<MeshLib::Node*>> vec_fracture_nodes;
46 std::vector<std::pair<std::size_t, std::vector<int>>>
47 vec_branch_nodeID_matIDs;
48 std::vector<std::pair<std::size_t, std::vector<int>>>
49 vec_junction_nodeID_matIDs;
51 *mesh, vec_matrix_elements, vec_fracture_mat_IDs, vec_fracture_elements,
52 vec_fracture_matrix_elements, vec_fracture_nodes,
53 vec_branch_nodeID_matIDs, vec_junction_nodeID_matIDs);
58 vec_fracture_matrix_elements,
59 vec_branch_nodeID_matIDs,
60 vec_junction_nodeID_matIDs);
63 INFO(
"create {:s}", out_vtu_filename);
67 void postPVD(std::string
const& in_pvd_filename,
68 std::string
const& out_pvd_filename,
69 bool const allow_overwrite)
73 INFO(
"start reading the PVD file {:s}", in_pvd_filename);
74 boost::property_tree::ptree pt;
75 read_xml(in_pvd_filename, pt,
76 boost::property_tree::xml_parser::trim_whitespace);
78 for (
auto& dataset : pt.get_child(
"VTKFile.Collection"))
80 if (dataset.first !=
"DataSet")
86 auto const org_vtu_filename =
87 dataset.second.get<std::string>(
"<xmlattr>.file");
88 auto const org_vtu_filebasename =
91 if (org_vtu_dir.empty())
93 org_vtu_dir = in_pvd_file_dir;
95 auto const org_vtu_filepath =
97 INFO(
"processing {:s}...", org_vtu_filepath);
100 auto const dest_vtu_filename =
"post_" + org_vtu_filebasename;
101 auto const dest_vtu_filepath =
105 INFO(
"The destination file already exists. Skip overwriting it.");
109 postVTU(org_vtu_filepath, dest_vtu_filepath);
113 dataset.second.put(
"<xmlattr>.file", dest_vtu_filename);
117 INFO(
"save into the new PVD file {:s}", out_pvd_filename);
118 boost::property_tree::xml_writer_settings<std::string> settings(
'\t', 1);
119 write_xml(out_pvd_filename, pt, std::locale(), settings);
124 int main(
int argc,
char* argv[])
127 "Post-process results of the LIE approach.\n\n"
128 "OpenGeoSys-6 software, version " +
131 "Copyright (c) 2012-2021, OpenGeoSys Community "
132 "(http://www.opengeosys.org)",
134 TCLAP::ValueArg<std::string> arg_out_file(
135 "o",
"output-file",
"the name of the new PVD or VTU file",
true,
"",
137 cmd.add(arg_out_file);
138 TCLAP::ValueArg<std::string> arg_in_file(
139 "i",
"input-file",
"the original PVD or VTU file name",
true,
"",
141 cmd.add(arg_in_file);
142 TCLAP::SwitchArg nooverwrite_arg(
145 "don't overwrite existing post processed VTU files");
146 cmd.add(nooverwrite_arg);
148 cmd.parse(argc, argv);
151 if (in_file_ext ==
".pvd")
153 postPVD(arg_in_file.getValue(), arg_out_file.getValue(),
154 !nooverwrite_arg.getValue());
156 else if (in_file_ext ==
".vtu")
158 postVTU(arg_in_file.getValue(), arg_out_file.getValue());
162 OGS_FATAL(
"The given file type ({:s}) is not supported.", in_file_ext);
void INFO(char const *fmt, Args const &... 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)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)
std::unique_ptr< MeshLib::Mesh > convertToLinearMesh(MeshLib::Mesh const &org_mesh, std::string const &new_mesh_name)
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.