OGS
anonymous_namespace{postLIE.cpp} Namespace Reference

Functions

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)

Function Documentation

◆ postPVD()

void anonymous_namespace{postLIE.cpp}::postPVD ( std::string const & in_pvd_filename,
std::string const & out_pvd_filename,
bool const allow_overwrite )

Definition at line 64 of file postLIE.cpp.

67{
68 auto const in_pvd_file_dir = BaseLib::extractPath(in_pvd_filename);
69 auto const out_pvd_file_dir = BaseLib::extractPath(out_pvd_filename);
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);
74
75 for (auto& dataset : pt.get_child("VTKFile.Collection"))
76 {
77 if (dataset.first != "DataSet")
78 {
79 continue;
80 }
81
82 // get VTU file name
83 auto const org_vtu_filename =
84 dataset.second.get<std::string>("<xmlattr>.file");
85 auto const org_vtu_filebasename =
86 BaseLib::extractBaseName(org_vtu_filename);
87 auto org_vtu_dir = BaseLib::extractPath(org_vtu_filename);
88 if (org_vtu_dir.empty())
89 {
90 org_vtu_dir = in_pvd_file_dir;
91 }
92 auto const org_vtu_filepath =
93 BaseLib::joinPaths(org_vtu_dir, org_vtu_filebasename);
94 INFO("processing {:s}...", org_vtu_filepath);
95
96 // post-process the VTU and save into the new file
97 auto const dest_vtu_filename = "post_" + org_vtu_filebasename;
98 auto const dest_vtu_filepath =
99 BaseLib::joinPaths(out_pvd_file_dir, dest_vtu_filename);
100 if (!allow_overwrite && BaseLib::IsFileExisting(dest_vtu_filepath))
101 {
102 INFO("The destination file already exists. Skip overwriting it.");
103 }
104 else
105 {
106 postVTU(org_vtu_filepath, dest_vtu_filepath);
107 }
108
109 // create a new VTU file and update XML
110 dataset.second.put("<xmlattr>.file", dest_vtu_filename);
111 }
112
113 // save into the new PVD file
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);
117}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
std::string extractPath(std::string const &pathname)
bool IsFileExisting(const std::string &strFilename)
Returns true if given file exists.
Definition FileTools.cpp:23
std::string joinPaths(std::string const &pathA, std::string const &pathB)
std::string extractBaseName(std::string const &pathname)
void postVTU(std::string const &int_vtu_filename, std::string const &out_vtu_filename)
Definition postLIE.cpp:26

References BaseLib::extractBaseName(), BaseLib::extractPath(), INFO(), BaseLib::IsFileExisting(), BaseLib::joinPaths(), and postVTU().

Referenced by main().

◆ postVTU()

void anonymous_namespace{postLIE.cpp}::postVTU ( std::string const & int_vtu_filename,
std::string const & out_vtu_filename )

Definition at line 26 of file postLIE.cpp.

28{
29 // read VTU with simulation results
30 std::unique_ptr<MeshLib::Mesh const> mesh(
31 MeshLib::IO::readMeshFromFile(int_vtu_filename));
32 if (mesh->hasNonlinearElement())
33 {
34 mesh = MeshToolsLib::convertToLinearMesh(*mesh, mesh->getName());
35 }
36
37 // post-process
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);
51
53 vec_fracture_mat_IDs,
54 vec_fracture_nodes,
55 vec_fracture_matrix_elements,
56 vec_branch_nodeID_matIDs,
57 vec_junction_nodeID_matIDs);
58
59 // create a new VTU file
60 INFO("create {:s}", out_vtu_filename);
61 MeshLib::IO::writeMeshToFile(post.getOutputMesh(), out_vtu_filename);
62}
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)
std::unique_ptr< MeshLib::Mesh > convertToLinearMesh(MeshLib::Mesh const &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)

References MeshToolsLib::convertToLinearMesh(), ProcessLib::LIE::getFractureMatrixDataInMesh(), ProcessLib::LIE::PostProcessTool::getOutputMesh(), INFO(), MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeMeshToFile().

Referenced by main(), and postPVD().