This commit is contained in:
张壹 2025-04-04 22:36:13 +08:00
parent b7508642a7
commit 807e472dee
10 changed files with 31 additions and 46 deletions

View File

@ -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;
}

View File

@ -276,9 +276,8 @@ const gctl::array<double> *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;
}

View File

@ -366,9 +366,8 @@ const gctl::array<double> *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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -530,31 +530,19 @@ void wavelet(const std::vector<std::string> &cmd_units)
void sum_data(const std::vector<std::string> &cmd_units)
{
// sum-data \<new-data-name\> \<data-name1\> \<data-name2\>
// sum-data \<new-data\> \<data1\> \<data2\>
if (cmd_units.size() < 4) throw std::runtime_error("sum: insufficient parameters.");
gctl::array<std::string> 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<std::string> &cmd_units)
{
// sum-data \<new-data-name\> \<data-name1\> \<data-name2\>
// diff \<new-data\> \<data1\> \<data2\>
if (cmd_units.size() < 4) throw std::runtime_error("diff: insufficient parameters.");
gctl::array<std::string> 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;
}

View File

@ -32,10 +32,10 @@ data type of the used data. 'dx' and 'dy' give the calculation directions. highe
#### wavelet \<data-name\> \<wavelet-name\> \<order\> [\<show-summary\>]
Using a wavelet \<wavelet-name\> to decompose the selecte data. Avaiable wavelets include 'bd2'... .The order of decomposition could be set using \<order\>. And set \<show-summary\> to yes to see the summary.
#### sum \<new-data-name\> \<data-name1\> \<data-name2\>
#### sum \<new-data\> \<data1\> \<data2\>
Calculate the sum of the two data. The arguments' format should be clear enough.
#### diff \<new-data-name\> \<data-name1\> \<data-name2\>
#### diff \<new-data\> \<data1\> \<data2\>
Calculate the difference of the two data. The arguments' format should be clear enough.
#### bool \<new-data-name\> \<data-name1> \<bool-data\> [reverse]