diff --git a/example/mesh_ex1.cpp b/example/mesh_ex1.cpp index 3963ab5..41759c6 100644 --- a/example/mesh_ex1.cpp +++ b/example/mesh_ex1.cpp @@ -45,7 +45,10 @@ int main(int argc, char *argv[]) std::cout << "data name: " << data3.name_ << std::endl; data3.datval_.show(); + rgd.diff("data-4", "data-1", "data-3"); + rgd.remove_data("data-1"); rgd.show_info(); + rgd.save_gmsh_withdata("ex1_out", gctl::OverWrite, gctl::NotPacked); return 0; } \ No newline at end of file diff --git a/lib/mesh/linear_mesh_2d.cpp b/lib/mesh/linear_mesh_2d.cpp index 1a5f6a2..9018640 100644 --- a/lib/mesh/linear_mesh_2d.cpp +++ b/lib/mesh/linear_mesh_2d.cpp @@ -276,9 +276,8 @@ const gctl::array *gctl::linear_mesh_2d::get_ysizes() const void gctl::linear_mesh_2d::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } \ No newline at end of file diff --git a/lib/mesh/linear_mesh_3d.cpp b/lib/mesh/linear_mesh_3d.cpp index 161e60e..a283e65 100644 --- a/lib/mesh/linear_mesh_3d.cpp +++ b/lib/mesh/linear_mesh_3d.cpp @@ -366,9 +366,8 @@ const gctl::array *gctl::linear_mesh_3d::get_zsizes() const void gctl::linear_mesh_3d::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } \ No newline at end of file diff --git a/lib/mesh/regular_grid.cpp b/lib/mesh/regular_grid.cpp index 819d000..d16cb31 100644 --- a/lib/mesh/regular_grid.cpp +++ b/lib/mesh/regular_grid.cpp @@ -652,10 +652,9 @@ void gctl::regular_grid::save_surfer_grid(std::string filename, std::string datn void gctl::regular_grid::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } diff --git a/lib/mesh/regular_mesh_2d.cpp b/lib/mesh/regular_mesh_2d.cpp index d8742df..7e95384 100644 --- a/lib/mesh/regular_mesh_2d.cpp +++ b/lib/mesh/regular_mesh_2d.cpp @@ -213,9 +213,8 @@ double gctl::regular_mesh_2d::get_ysize() const void gctl::regular_mesh_2d::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } \ No newline at end of file diff --git a/lib/mesh/regular_mesh_3d.cpp b/lib/mesh/regular_mesh_3d.cpp index 49e42ee..1957438 100644 --- a/lib/mesh/regular_mesh_3d.cpp +++ b/lib/mesh/regular_mesh_3d.cpp @@ -260,9 +260,8 @@ double gctl::regular_mesh_3d::get_zsize() const void gctl::regular_mesh_3d::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } \ No newline at end of file diff --git a/lib/mesh/regular_mesh_sph_3d.cpp b/lib/mesh/regular_mesh_sph_3d.cpp index 5dcecae..c4a4cf7 100644 --- a/lib/mesh/regular_mesh_sph_3d.cpp +++ b/lib/mesh/regular_mesh_sph_3d.cpp @@ -277,10 +277,10 @@ void gctl::regular_mesh_sph_3d::save_gmsh(std::string filename, index_packed_e p tmp_nodes[i].y = tmp_c.y; tmp_nodes[i].z = tmp_c.z; } - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, tmp_nodes, packed); - outfile.close(); + + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, tmp_nodes); tmp_nodes.clear(); return; } \ No newline at end of file diff --git a/lib/mesh/tet_mesh.cpp b/lib/mesh/tet_mesh.cpp index 461e464..cb51a0f 100644 --- a/lib/mesh/tet_mesh.cpp +++ b/lib/mesh/tet_mesh.cpp @@ -197,9 +197,8 @@ void gctl::tetrahedron_mesh::load_gmsh(std::string filename, index_packed_e pack void gctl::tetrahedron_mesh::save_gmsh(std::string filename, index_packed_e packed) { - std::ofstream outfile; - gctl::open_outfile(outfile, filename, ".msh"); - gctl::save2gmsh(outfile, elements, nodes, packed); - outfile.close(); + meshio_.init_file(filename, Output); + meshio_.set_packed(packed, Output); + meshio_.save_mesh(elements, nodes); return; } \ No newline at end of file diff --git a/tool/gridmanager/gridmanager.cpp b/tool/gridmanager/gridmanager.cpp index e49a073..326c415 100644 --- a/tool/gridmanager/gridmanager.cpp +++ b/tool/gridmanager/gridmanager.cpp @@ -530,31 +530,19 @@ void wavelet(const std::vector &cmd_units) void sum_data(const std::vector &cmd_units) { - // sum-data \ \ \ + // sum-data \ \ \ if (cmd_units.size() < 4) throw std::runtime_error("sum: insufficient parameters."); - gctl::array copy_str(3, "null"); - for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++) - { - copy_str[i - 1] = cmd_units[i]; - } - - rg.sum(copy_str[0], copy_str[1], copy_str[2]); + rg.sum(cmd_units[1], cmd_units[2], cmd_units[3]); return; } void diff_data(const std::vector &cmd_units) { - // sum-data \ \ \ + // diff \ \ \ if (cmd_units.size() < 4) throw std::runtime_error("diff: insufficient parameters."); - gctl::array copy_str(3, "null"); - for (size_t i = 1; i <= GCTL_MIN(cmd_units.size() - 1, 3); i++) - { - copy_str[i - 1] = cmd_units[i]; - } - - rg.diff(copy_str[0], copy_str[1], copy_str[2]); + rg.diff(cmd_units[1], cmd_units[2], cmd_units[3]); return; } diff --git a/tool/gridmanager/readme_gridmanager.md b/tool/gridmanager/readme_gridmanager.md index 9bdd88f..6315131 100644 --- a/tool/gridmanager/readme_gridmanager.md +++ b/tool/gridmanager/readme_gridmanager.md @@ -32,10 +32,10 @@ data type of the used data. 'dx' and 'dy' give the calculation directions. highe #### wavelet \ \ \ [\] Using a wavelet \ to decompose the selecte data. Avaiable wavelets include 'bd2'... .The order of decomposition could be set using \. And set \ to yes to see the summary. -#### sum \ \ \ +#### sum \ \ \ Calculate the sum of the two data. The arguments' format should be clear enough. -#### diff \ \ \ +#### diff \ \ \ Calculate the difference of the two data. The arguments' format should be clear enough. #### bool \ \ \ [reverse]