tmp
This commit is contained in:
parent
f25100399b
commit
8949847d5a
@ -32,6 +32,6 @@ int main(int argc, char *argv[])
|
||||
gctl::regular_mesh_sph_3d rm_3ds;
|
||||
rm_3ds.init("mesh-1", "null", 30.25, 30.25, 2005, 0.5, 0.5, 10, 40, 40, 50);
|
||||
rm_3ds.add_data(gctl::ElemData, gctl::Scalar, "data-1", 2.5);
|
||||
rm_3ds.save_gmsh("mesh_sample10",gctl::OverWrite, gctl::NotPacked);
|
||||
rm_3ds.save_gmsh_withdata("mesh_sample10",gctl::OverWrite, gctl::NotPacked);
|
||||
return 0;
|
||||
}
|
@ -57,7 +57,7 @@ int main(int argc, char *argv[]) try
|
||||
}
|
||||
}
|
||||
|
||||
rg_mesh.save_gmsh("sample6-out", gctl::OverWrite);
|
||||
rg_mesh.save_gmsh_withdata("sample6-out", gctl::OverWrite);
|
||||
return 0;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -48,7 +48,7 @@ int main(int argc, char *argv[]) try
|
||||
}
|
||||
}
|
||||
|
||||
rg_mesh.save_gmsh("sample7-out", "double-data", gctl::OverWrite);
|
||||
rg_mesh.save_gmsh_withdata("sample7-out", "double-data", gctl::OverWrite);
|
||||
return 0;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) try
|
||||
t_mesh.load_triangle("sample8", gctl::Packed);
|
||||
t_mesh.add_data(gctl::ElemData, gctl::Scalar, "example", 1.0);
|
||||
|
||||
t_mesh.save_gmsh("sample8-out", "example", gctl::OverWrite, gctl::NotPacked);
|
||||
t_mesh.save_gmsh_withdata("sample8-out", "example", gctl::OverWrite, gctl::NotPacked);
|
||||
t_mesh.save_binary("sample8-out");
|
||||
|
||||
gctl::triangle2d_mesh t2_mesh;
|
||||
|
@ -56,7 +56,7 @@ int main(int argc, char *argv[]) try
|
||||
}
|
||||
}
|
||||
|
||||
l2d_mesh.save_gmsh("sample9-out", gctl::OverWrite, gctl::NotPacked);
|
||||
l2d_mesh.save_gmsh_withdata("sample9-out", gctl::OverWrite, gctl::NotPacked);
|
||||
return 0;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -282,16 +282,3 @@ void gctl::linear_mesh_2d::save_gmsh(std::string filename, index_packed_e packed
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void gctl::linear_mesh_2d::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::linear_mesh_2d::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, double xmin, double ymin,
|
||||
const array<double> &xsizes, const array<double> &ysizes);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_mesh_2d的专有函数
|
||||
*/
|
||||
@ -57,6 +57,9 @@ namespace gctl
|
||||
const array<double> &xsizes, const array<double> &ysizes);
|
||||
virtual ~linear_mesh_2d();
|
||||
|
||||
void init(std::string in_name, std::string in_info, double xmin, double ymin,
|
||||
const array<double> &xsizes, const array<double> &ysizes);
|
||||
|
||||
int get_xbnum() const;
|
||||
int get_ybnum() const;
|
||||
double get_xmin() const;
|
||||
@ -66,10 +69,6 @@ namespace gctl
|
||||
const array<double> *get_xsizes() const;
|
||||
const array<double> *get_ysizes() const;
|
||||
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
protected:
|
||||
int lm_xbnum, lm_ybnum;
|
||||
double lm_xmin, lm_ymin;
|
||||
|
@ -372,15 +372,3 @@ void gctl::linear_mesh_3d::save_gmsh(std::string filename, index_packed_e packed
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::linear_mesh_3d::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::linear_mesh_3d::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
@ -40,15 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, double xmin, double ymin,
|
||||
double zmin, const array<double> &xsizes, const array<double> &ysizes,
|
||||
const array<double> &zsizes);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_mesh_2d的专有函数
|
||||
*/
|
||||
@ -59,6 +58,10 @@ namespace gctl
|
||||
const array<double> &zsizes);
|
||||
virtual ~linear_mesh_3d();
|
||||
|
||||
void init(std::string in_name, std::string in_info, double xmin, double ymin,
|
||||
double zmin, const array<double> &xsizes, const array<double> &ysizes,
|
||||
const array<double> &zsizes);
|
||||
|
||||
int get_xbnum() const;
|
||||
int get_ybnum() const;
|
||||
int get_zbnum() const;
|
||||
@ -72,10 +75,6 @@ namespace gctl
|
||||
const array<double> *get_ysizes() const;
|
||||
const array<double> *get_zsizes() const;
|
||||
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
protected:
|
||||
int lm_xbnum, lm_ybnum, lm_zbnum;
|
||||
double lm_xmin, lm_ymin, lm_zmin;
|
||||
|
@ -306,14 +306,15 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, output_type_e out
|
||||
{
|
||||
if (out_mode == OverWrite) save_gmsh(filename, packed);
|
||||
|
||||
std::ofstream outfile;
|
||||
gctl::open_outfile(outfile, filename, ".msh", std::ios::out|std::ios::app);
|
||||
//std::ofstream outfile;
|
||||
//gctl::open_outfile(outfile, filename, ".msh", std::ios::out|std::ios::app);
|
||||
|
||||
for (size_t i = 0; i < datalist_.size(); i++)
|
||||
{
|
||||
if (datalist_[i].loctype_ == NodeData)
|
||||
{
|
||||
if (datalist_[i].valtype_ == Scalar) gctl::save_gmsh_data(outfile, datalist_[i].name_, datalist_[i].datval_, gctl::NodeData, packed);
|
||||
//gctl::save_gmsh_data(outfile, datalist_[i].name_, datalist_[i].datval_, gctl::NodeData, packed);
|
||||
if (datalist_[i].valtype_ == Scalar) meshio_.save_data(datalist_[i].name_, datalist_[i].datval_, NodeData);
|
||||
else if (datalist_[i].valtype_ == Vector)
|
||||
{
|
||||
array<point3dc> vec_data(node_num_);
|
||||
@ -324,7 +325,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, output_type_e out
|
||||
vec_data[j].z = datalist_[i].datval_[3*j+2];
|
||||
}
|
||||
|
||||
gctl::save_gmsh_data(outfile, datalist_[i].name_, vec_data, gctl::NodeData, packed);
|
||||
//gctl::save_gmsh_data(outfile, datalist_[i].name_, vec_data, gctl::NodeData, packed);
|
||||
meshio_.save_data(datalist_[i].name_, vec_data, NodeData);
|
||||
}
|
||||
//else if (datalist_[i].valtype_ == Tensor)
|
||||
//{
|
||||
@ -348,7 +350,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, output_type_e out
|
||||
}
|
||||
else if (datalist_[i].loctype_ == ElemData)
|
||||
{
|
||||
if (datalist_[i].valtype_ == Scalar) gctl::save_gmsh_data(outfile, datalist_[i].name_, datalist_[i].datval_, gctl::ElemData, packed);
|
||||
//gctl::save_gmsh_data(outfile, datalist_[i].name_, datalist_[i].datval_, gctl::ElemData, packed);
|
||||
if (datalist_[i].valtype_ == Scalar) meshio_.save_data(datalist_[i].name_, datalist_[i].datval_, ElemData);
|
||||
else if (datalist_[i].valtype_ == Vector)
|
||||
{
|
||||
array<point3dc> vec_data(ele_num_);
|
||||
@ -359,7 +362,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, output_type_e out
|
||||
vec_data[j].z = datalist_[i].datval_[3*j+2];
|
||||
}
|
||||
|
||||
gctl::save_gmsh_data(outfile, datalist_[i].name_, vec_data, gctl::ElemData, packed);
|
||||
//gctl::save_gmsh_data(outfile, datalist_[i].name_, vec_data, gctl::ElemData, packed);
|
||||
meshio_.save_data(datalist_[i].name_, vec_data, ElemData);
|
||||
}
|
||||
//else if (datalist_[i].valtype_ == Tensor)
|
||||
//{
|
||||
@ -383,8 +387,6 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, output_type_e out
|
||||
}
|
||||
else throw std::runtime_error("[gctl::base_mesh] Invalid input data location.");
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -392,13 +394,14 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, std::string datna
|
||||
{
|
||||
if (out_mode == OverWrite) save_gmsh(filename, packed);
|
||||
|
||||
std::ofstream outfile;
|
||||
gctl::open_outfile(outfile, filename, ".msh", std::ios::out|std::ios::app);
|
||||
//std::ofstream outfile;
|
||||
//gctl::open_outfile(outfile, filename, ".msh", std::ios::out|std::ios::app);
|
||||
|
||||
const meshdata &data = get_data(datname);
|
||||
if (data.loctype_ == NodeData)
|
||||
{
|
||||
if (data.valtype_ == Scalar) gctl::save_gmsh_data(outfile, data.name_, data.datval_, gctl::NodeData, packed);
|
||||
//gctl::save_gmsh_data(outfile, data.name_, data.datval_, gctl::NodeData, packed);
|
||||
if (data.valtype_ == Scalar) meshio_.save_data(data.name_, data.datval_, NodeData);
|
||||
else if (data.valtype_ == Vector)
|
||||
{
|
||||
array<point3dc> vec_data(node_num_);
|
||||
@ -409,7 +412,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, std::string datna
|
||||
vec_data[j].z = data.datval_[3*j+2];
|
||||
}
|
||||
|
||||
gctl::save_gmsh_data(outfile, data.name_, vec_data, gctl::NodeData, packed);
|
||||
//gctl::save_gmsh_data(outfile, data.name_, vec_data, gctl::NodeData, packed);
|
||||
meshio_.save_data(data.name_, vec_data, NodeData);
|
||||
}
|
||||
//else if (data.valtype_ == Tensor)
|
||||
//{
|
||||
@ -433,7 +437,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, std::string datna
|
||||
}
|
||||
else if (data.loctype_ == ElemData)
|
||||
{
|
||||
if (data.valtype_ == Scalar) gctl::save_gmsh_data(outfile, data.name_, data.datval_, gctl::ElemData, packed);
|
||||
//gctl::save_gmsh_data(outfile, data.name_, data.datval_, gctl::ElemData, packed);
|
||||
if (data.valtype_ == Scalar) meshio_.save_data(data.name_, data.datval_, ElemData);
|
||||
else if (data.valtype_ == Vector)
|
||||
{
|
||||
array<point3dc> vec_data(ele_num_);
|
||||
@ -444,7 +449,8 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, std::string datna
|
||||
vec_data[j].z = data.datval_[3*j+2];
|
||||
}
|
||||
|
||||
gctl::save_gmsh_data(outfile, data.name_, vec_data, gctl::ElemData, packed);
|
||||
//gctl::save_gmsh_data(outfile, data.name_, vec_data, gctl::ElemData, packed);
|
||||
meshio_.save_data(data.name_, vec_data, ElemData);
|
||||
}
|
||||
//else if (data.valtype_ == Tensor)
|
||||
//{
|
||||
@ -467,8 +473,59 @@ void gctl::base_mesh::save_gmsh_withdata(std::string filename, std::string datna
|
||||
else throw std::runtime_error("[gctl::base_mesh] Invalid input data value type.");
|
||||
}
|
||||
else throw std::runtime_error("[gctl::base_mesh] Invalid input data location.");
|
||||
return;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
void gctl::base_mesh::load_gmsh_withdata(std::string filename, index_packed_e packed)
|
||||
{
|
||||
load_gmsh(filename, packed);
|
||||
|
||||
_2d_vector all_node_data, all_elem_data;
|
||||
_1s_vector nodedata_names, elemdata_names;
|
||||
meshio_.read_data(all_node_data, nodedata_names, NodeData);
|
||||
meshio_.read_data(all_elem_data, elemdata_names, ElemData);
|
||||
|
||||
array<double> tmp_data;
|
||||
meshdata *data_ptr = nullptr;
|
||||
for (size_t i = 0; i < nodedata_names.size(); i++)
|
||||
{
|
||||
add_data(NodeData, Scalar, nodedata_names[i], 0.0);
|
||||
data_ptr = get_data_ptr(nodedata_names[i]);
|
||||
if (data_ptr != nullptr)
|
||||
{
|
||||
for (size_t n = 0; n < node_num_; n++)
|
||||
{
|
||||
data_ptr->datval_[i] = all_node_data[i][n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < elemdata_names.size(); i++)
|
||||
{
|
||||
add_data(ElemData, Scalar, elemdata_names[i], 0.0);
|
||||
data_ptr = get_data_ptr(elemdata_names[i]);
|
||||
if (data_ptr != nullptr)
|
||||
{
|
||||
for (size_t n = 0; n < ele_num_; n++)
|
||||
{
|
||||
data_ptr->datval_[i] = all_elem_data[i][n];
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::base_mesh::load_gmsh_withdata(std::string filename, std::string datname,
|
||||
mesh_data_type_e type, index_packed_e packed)
|
||||
{
|
||||
load_gmsh(filename, packed);
|
||||
|
||||
array<double> tmp_data;
|
||||
meshio_.read_data(tmp_data, datname);
|
||||
|
||||
if (type == NodeData) add_data(NodeData, datname, tmp_data);
|
||||
else if (type == ElemData) add_data(NodeData, datname, tmp_data);
|
||||
else throw std::runtime_error("[gctl::base_mesh] Invalid mesh data type.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,22 @@ namespace gctl
|
||||
*/
|
||||
void save_gmsh_withdata(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief 保存网格到Gmsh文件,并读入所有数据。
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @param packed 索引是否为紧凑(从0开始)
|
||||
*/
|
||||
void load_gmsh_withdata(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief 保存网格到Gmsh文件,并读入特定数据。
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @param packed 索引是否为紧凑(从0开始)
|
||||
*/
|
||||
void load_gmsh_withdata(std::string filename, std::string datname, mesh_data_type_e type, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数)保存网格到Gmsh文件。
|
||||
*
|
||||
@ -266,10 +282,12 @@ namespace gctl
|
||||
virtual void save_gmsh(std::string filename, index_packed_e packed = Packed) = 0;
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数)显示网格的维度信息
|
||||
* @brief (基类纯虚函数)读入Gmsh文件。
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @param packed 索引是否为紧凑(从0开始)
|
||||
*/
|
||||
virtual void show_mesh_dimension(std::ostream &os) const = 0;
|
||||
virtual void load_gmsh(std::string filename, index_packed_e packed = Packed) = 0;
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数)读入二进制网格文件
|
||||
@ -285,11 +303,17 @@ namespace gctl
|
||||
*/
|
||||
virtual void save_binary(std::string filename) = 0;
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数)显示网格的维度信息
|
||||
*/
|
||||
virtual void show_mesh_dimension(std::ostream &os) const = 0;
|
||||
|
||||
protected:
|
||||
mesh_type_e meshtype_;
|
||||
mesh_dim_e meshdim_;
|
||||
std::string meshname_;
|
||||
std::string meshinfo_;
|
||||
gmshio meshio_;
|
||||
|
||||
int node_num_, ele_num_;
|
||||
bool initialized_;
|
||||
|
@ -659,18 +659,6 @@ void gctl::regular_grid::save_gmsh(std::string filename, index_packed_e packed)
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_grid::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_grid::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_grid::save_text(std::string filename, const array<std::string> &datname)
|
||||
{
|
||||
meshdata &curr_data = get_data(datname[0]);
|
||||
|
@ -49,6 +49,8 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数的具体实现)保存网格到Gmsh文件。
|
||||
*
|
||||
@ -57,11 +59,6 @@ namespace gctl
|
||||
*/
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数的具体实现)显示网格的维度信息
|
||||
*/
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数的具体实现)读入二进制网格文件
|
||||
*
|
||||
@ -76,6 +73,11 @@ namespace gctl
|
||||
*/
|
||||
void save_binary(std::string filename);
|
||||
|
||||
/**
|
||||
* @brief (基类纯虚函数的具体实现)显示网格的维度信息
|
||||
*/
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_grid的专有函数
|
||||
*/
|
||||
@ -198,25 +200,6 @@ namespace gctl
|
||||
*/
|
||||
void save_surfer_grid(std::string filename, std::string datname, surfer_file_type_e grid_type = Surfer7Grid);
|
||||
|
||||
/**
|
||||
* @brief 保存规则网格数据到Gmsh文件中
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @param out_mode 输出模式
|
||||
* @param packed 索引是否为紧凑(从0开始)
|
||||
*/
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief 保存规则网格数据到Gmsh文件中
|
||||
*
|
||||
* @param filename 文件名
|
||||
* @param datname 数据名称
|
||||
* @param out_mode 输出模式
|
||||
* @param packed 索引是否为紧凑(从0开始)
|
||||
*/
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
/**
|
||||
* @brief 保存规则网格数据到文本文件中
|
||||
*
|
||||
|
@ -219,15 +219,3 @@ void gctl::regular_mesh_2d::save_gmsh(std::string filename, index_packed_e packe
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_2d::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_2d::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, int xbnum, int ybnum,
|
||||
double xmin, double ymin, double xsize, double ysize);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_mesh_2d的专有函数
|
||||
*/
|
||||
@ -57,6 +57,9 @@ namespace gctl
|
||||
double xmin, double ymin, double xsize, double ysize);
|
||||
virtual ~regular_mesh_2d();
|
||||
|
||||
void init(std::string in_name, std::string in_info, int xbnum, int ybnum,
|
||||
double xmin, double ymin, double xsize, double ysize);
|
||||
|
||||
int get_xbnum() const;
|
||||
int get_ybnum() const;
|
||||
double get_xmin() const;
|
||||
@ -64,10 +67,6 @@ namespace gctl
|
||||
double get_xsize() const;
|
||||
double get_ysize() const;
|
||||
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
protected:
|
||||
int rm_xbnum, rm_ybnum;
|
||||
double rm_xmin, rm_ymin;
|
||||
|
@ -266,43 +266,3 @@ void gctl::regular_mesh_3d::save_gmsh(std::string filename, index_packed_e packe
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_3d::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_3d::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
void gctl::regular_mesh_3d::edit_data(std::string datname, physical_type_e p_type, value_operator_e v_type, std::string para_str, double in_val)
|
||||
{
|
||||
std::string err_str;
|
||||
meshdata *dat_ptr = get_data(datname);
|
||||
if (dat_ptr->get_valtype() != Double)
|
||||
{
|
||||
err_str = "Incompatible value type of data: " << datname << ". From regular_mesh_3d::edit_data(...)";
|
||||
throw runtime_error(err_str);
|
||||
}
|
||||
|
||||
array<double>* val_ptr = (array<double>*) dat_ptr->get_datval();
|
||||
// 按形体类型解析参数字符串
|
||||
if (p_type == Block)
|
||||
{
|
||||
double xmin, xmax, ymin, ymax, zmin, zmax;
|
||||
block_parameter_parser(para_str, xmin, xmax, ymin, ymax, zmin, zmax);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
err_str = "Invalid physical entity type. From regular_mesh_3d::edit_data(...)";
|
||||
throw runtime_error(err_str);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -40,14 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, int xbnum, int ybnum, int zbnum,
|
||||
double xmin, double ymin, double zmin, double xsize, double ysize, double zsize);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_mesh_3d的专有函数
|
||||
*/
|
||||
@ -57,6 +57,9 @@ namespace gctl
|
||||
double xmin, double ymin, double zmin, double xsize, double ysize, double zsize);
|
||||
virtual ~regular_mesh_3d();
|
||||
|
||||
void init(std::string in_name, std::string in_info, int xbnum, int ybnum, int zbnum,
|
||||
double xmin, double ymin, double zmin, double xsize, double ysize, double zsize);
|
||||
|
||||
int get_xbnum() const;
|
||||
int get_ybnum() const;
|
||||
int get_zbnum() const;
|
||||
@ -67,13 +70,6 @@ namespace gctl
|
||||
double get_ysize() const;
|
||||
double get_zsize() const;
|
||||
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
//void edit_data(std::string datname, physical_type_e p_type, value_operator_e v_type, std::string para_str, double in_val);
|
||||
//void purge_data(std::string datname, double in_val);
|
||||
|
||||
protected:
|
||||
int rm_xbnum, rm_ybnum, rm_zbnum;
|
||||
double rm_xmin, rm_ymin, rm_zmin;
|
||||
|
@ -284,15 +284,3 @@ void gctl::regular_mesh_sph_3d::save_gmsh(std::string filename, index_packed_e p
|
||||
tmp_nodes.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_sph_3d::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_mesh_sph_3d::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
@ -39,13 +39,14 @@ namespace gctl
|
||||
/**
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
void init(std::string in_name, std::string in_info, double lon_min, double lat_min, double rad_min,
|
||||
double lon_size, double lat_size, double rad_size, int lon_bnum, int lat_bnum, int rad_bnum);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed){}
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为regular_mesh_sph_3d的专有函数
|
||||
@ -55,6 +56,9 @@ namespace gctl
|
||||
double rad_min, double lon_size, double lat_size, double rad_size, int lon_bnum, int lat_bnum, int rad_bnum);
|
||||
virtual ~regular_mesh_sph_3d();
|
||||
|
||||
void init(std::string in_name, std::string in_info, double lon_min, double lat_min, double rad_min,
|
||||
double lon_size, double lat_size, double rad_size, int lon_bnum, int lat_bnum, int rad_bnum);
|
||||
|
||||
int get_lon_bnum() const;
|
||||
int get_lat_bnum() const;
|
||||
int get_rad_bnum() const;
|
||||
@ -65,10 +69,6 @@ namespace gctl
|
||||
double get_lat_size() const;
|
||||
double get_rad_size() const;
|
||||
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
protected:
|
||||
int rm_lon_bnum, rm_lat_bnum, rm_rad_bnum;
|
||||
double rm_lon_min, rm_lat_min, rm_rad_min;
|
||||
|
@ -203,15 +203,3 @@ void gctl::tetrahedron_mesh::save_gmsh(std::string filename, index_packed_e pack
|
||||
outfile.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::tetrahedron_mesh::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::tetrahedron_mesh::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, const array<vertex3dc> &in_nodes,
|
||||
const array<tetrahedron> &in_tets);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为triangle_mesh的专有函数
|
||||
*/
|
||||
@ -57,14 +57,13 @@ namespace gctl
|
||||
const array<tetrahedron> &in_tets);
|
||||
virtual ~tetrahedron_mesh();
|
||||
|
||||
void init(std::string in_name, std::string in_info, const array<vertex3dc> &in_nodes,
|
||||
const array<tetrahedron> &in_tets);
|
||||
|
||||
const array<vertex3dc> &get_nodes() const;
|
||||
const array<tetrahedron> &get_elements() const;
|
||||
|
||||
void load_tetgen(std::string filename, index_packed_e packed = Packed);
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
|
||||
protected:
|
||||
array<vertex3dc> nodes;
|
||||
|
@ -27,28 +27,28 @@
|
||||
|
||||
#include "tri2d_mesh.h"
|
||||
|
||||
void gctl::triangle2d_mesh::init(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes,
|
||||
void gctl::triangle2d_mesh::init(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes_,
|
||||
const array<triangle2d> &in_triangles)
|
||||
{
|
||||
check_initiated(true); // 检查是否已经初始化
|
||||
base_mesh::init(TRI_TET_MESH, MESH_2D, in_name, in_info);
|
||||
|
||||
node_num_ = in_nodes.size();
|
||||
node_num_ = in_nodes_.size();
|
||||
ele_num_ = in_triangles.size();
|
||||
|
||||
nodes.resize(node_num_);
|
||||
nodes_.resize(node_num_);
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
nodes[i] = in_nodes[i];
|
||||
nodes_[i] = in_nodes_[i];
|
||||
}
|
||||
|
||||
elements.resize(ele_num_);
|
||||
elems_.resize(ele_num_);
|
||||
for (int i = 0; i < ele_num_; i++)
|
||||
{
|
||||
elements[i].id = i;
|
||||
elems_[i].id = i;
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
elements[i].vert[j] = nodes.get(in_triangles[i].vert[j]->id);
|
||||
elems_[i].vert[j] = nodes_.get(in_triangles[i].vert[j]->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,8 +58,8 @@ void gctl::triangle2d_mesh::init(std::string in_name, std::string in_info, const
|
||||
|
||||
void gctl::triangle2d_mesh::show_mesh_dimension(std::ostream &os) const
|
||||
{
|
||||
os << "node num: " << node_num_ << std::endl;
|
||||
os << "elem num: " << ele_num_ << std::endl;
|
||||
os << "Node num: " << node_num_ << std::endl;
|
||||
os << "Elem num: " << ele_num_ << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -68,8 +68,7 @@ void gctl::triangle2d_mesh::load_binary(std::string filename)
|
||||
check_initiated(true); // 检查是否已经初始化
|
||||
|
||||
std::ifstream infile;
|
||||
gctl::open_infile(infile, filename, ".2m",
|
||||
std::ios::in|std::ios::binary);
|
||||
gctl::open_infile(infile, filename, ".2m", std::ios::in|std::ios::binary);
|
||||
|
||||
// 读入网格头信息
|
||||
load_headinfo(infile, TRI_TET_MESH, MESH_2D);
|
||||
@ -78,22 +77,22 @@ void gctl::triangle2d_mesh::load_binary(std::string filename)
|
||||
infile.read((char*)&node_num_, sizeof(int));
|
||||
infile.read((char*)&ele_num_, sizeof(int));
|
||||
|
||||
nodes.resize(node_num_);
|
||||
elements.resize(ele_num_);
|
||||
nodes_.resize(node_num_);
|
||||
elems_.resize(ele_num_);
|
||||
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
infile.read((char*)nodes.get(i), sizeof(gctl::vertex2dc));
|
||||
infile.read((char*)nodes_.get(i), sizeof(gctl::vertex2dc));
|
||||
}
|
||||
|
||||
int in_index;
|
||||
for (int i = 0; i < ele_num_; i++)
|
||||
{
|
||||
elements[i].id = i;
|
||||
elems_[i].id = i;
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
infile.read((char*)&in_index, sizeof(int));
|
||||
elements[i].vert[j] = nodes.get(in_index);
|
||||
elems_[i].vert[j] = nodes_.get(in_index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +109,7 @@ void gctl::triangle2d_mesh::save_binary(std::string filename)
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
|
||||
std::ofstream outfile;
|
||||
gctl::open_outfile(outfile, filename, ".2m",
|
||||
std::ios::out|std::ios::binary);
|
||||
gctl::open_outfile(outfile, filename, ".2m", std::ios::out|std::ios::binary);
|
||||
|
||||
// 首先输出网格的头信息
|
||||
save_headinfo(outfile);
|
||||
@ -122,7 +120,7 @@ void gctl::triangle2d_mesh::save_binary(std::string filename)
|
||||
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
outfile.write((char*)nodes.get(i), sizeof(gctl::vertex2dc));
|
||||
outfile.write((char*)nodes_.get(i), sizeof(gctl::vertex2dc));
|
||||
}
|
||||
|
||||
int in_index;
|
||||
@ -130,7 +128,7 @@ void gctl::triangle2d_mesh::save_binary(std::string filename)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
in_index = elements[i].vert[j]->id;
|
||||
in_index = elems_[i].vert[j]->id;
|
||||
outfile.write((char*)&in_index, sizeof(int));
|
||||
}
|
||||
}
|
||||
@ -144,10 +142,10 @@ void gctl::triangle2d_mesh::save_binary(std::string filename)
|
||||
|
||||
gctl::triangle2d_mesh::triangle2d_mesh() : base_mesh::base_mesh(){}
|
||||
|
||||
gctl::triangle2d_mesh::triangle2d_mesh(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes,
|
||||
gctl::triangle2d_mesh::triangle2d_mesh(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes_,
|
||||
const array<triangle2d> &in_triangles)
|
||||
{
|
||||
init(in_name, in_info, in_nodes, in_triangles);
|
||||
init(in_name, in_info, in_nodes_, in_triangles);
|
||||
}
|
||||
|
||||
gctl::triangle2d_mesh::~triangle2d_mesh(){}
|
||||
@ -155,23 +153,39 @@ gctl::triangle2d_mesh::~triangle2d_mesh(){}
|
||||
const gctl::array<gctl::vertex2dc> &gctl::triangle2d_mesh::get_nodes() const
|
||||
{
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
return nodes;
|
||||
return nodes_;
|
||||
}
|
||||
|
||||
const gctl::array<gctl::triangle2d> &gctl::triangle2d_mesh::get_elements() const
|
||||
{
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
return elements;
|
||||
return elems_;
|
||||
}
|
||||
|
||||
void gctl::triangle2d_mesh::reorder2anticlockwise()
|
||||
{
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
vertex2dc *v_ptr;
|
||||
for (size_t i = 0; i < get_elenum(); i++)
|
||||
{
|
||||
if (cross(*elems_[i].vert[1] - *elems_[i].vert[0], *elems_[i].vert[2] - *elems_[i].vert[0]) < 0)
|
||||
{
|
||||
v_ptr = elems_[i].vert[1];
|
||||
elems_[i].vert[1] = elems_[i].vert[2];
|
||||
elems_[i].vert[2] = v_ptr;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::triangle2d_mesh::load_triangle(std::string filename, index_packed_e packed)
|
||||
{
|
||||
gctl::read_Triangle_node(filename, nodes, packed);
|
||||
gctl::read_Triangle_element(filename, elements, nodes, packed);
|
||||
gctl::read_Triangle_node(filename, nodes_, packed);
|
||||
gctl::read_Triangle_element(filename, elems_, nodes_, packed);
|
||||
|
||||
// 设置名称与信息等
|
||||
node_num_ = nodes.size();
|
||||
ele_num_ = elements.size();
|
||||
node_num_ = nodes_.size();
|
||||
ele_num_ = elems_.size();
|
||||
base_mesh::init(TRI_TET_MESH, MESH_2D, filename, "Imported from a .node and .ele file.");
|
||||
initialized_ = true;
|
||||
return;
|
||||
@ -179,37 +193,96 @@ void gctl::triangle2d_mesh::load_triangle(std::string filename, index_packed_e p
|
||||
|
||||
void gctl::triangle2d_mesh::load_gmsh(std::string filename, index_packed_e packed)
|
||||
{
|
||||
std::ifstream infile;
|
||||
gctl::open_infile(infile, filename, ".msh");
|
||||
gctl::read_gmsh_node(infile, nodes, packed);
|
||||
gctl::read_gmsh_element(infile, elements, nodes, packed);
|
||||
infile.close();
|
||||
meshio_.init_file(filename, Input);
|
||||
meshio_.set_packed(packed, Input);
|
||||
meshio_.read_mesh(elems_, nodes_, &elems_tag_);
|
||||
|
||||
// 设置名称与信息等
|
||||
node_num_ = nodes.size();
|
||||
ele_num_ = elements.size();
|
||||
node_num_ = nodes_.size();
|
||||
ele_num_ = elems_.size();
|
||||
base_mesh::init(TRI_TET_MESH, MESH_2D, filename, "Imported from a .msh file.");
|
||||
initialized_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::triangle2d_mesh::load_gmsh_groups()
|
||||
{
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
meshio_.read_physical_groups(groups_);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::triangle2d_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);
|
||||
gctl::save2gmsh(outfile, elems_, nodes_, packed);
|
||||
outfile.close();
|
||||
|
||||
meshio_.init_file(filename, Output);
|
||||
meshio_.set_packed(packed, Output);
|
||||
meshio_.save_mesh(elems_, nodes_);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::triangle2d_mesh::save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed)
|
||||
void gctl::triangle2d_mesh::groups2data(std::string datname, _1s_vector phynames, _1d_vector phyvals)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, out_mode, packed);
|
||||
return;
|
||||
}
|
||||
check_initiated(); // 检查是否已经初始化
|
||||
|
||||
void gctl::triangle2d_mesh::save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed)
|
||||
{
|
||||
base_mesh::save_gmsh_withdata(filename, datname, out_mode, packed);
|
||||
if (phynames.size() != phyvals.size() || phynames.empty())
|
||||
{
|
||||
throw std::invalid_argument("The size of phynames and phyvals must be the same and non-empty.");
|
||||
}
|
||||
|
||||
if (groups_.empty() || elems_tag_.empty())
|
||||
{
|
||||
throw std::invalid_argument("No physical groups found.");
|
||||
}
|
||||
|
||||
if (elems_tag_.empty()) throw std::invalid_argument("No physical tags found.");
|
||||
for (size_t i = 0; i < ele_num_; i++)
|
||||
{
|
||||
if (elems_tag_[i].empty()) throw std::invalid_argument("No physical tags found.");
|
||||
}
|
||||
|
||||
array<int> tag_idx(phynames.size());
|
||||
for (size_t i = 0; i < phynames.size(); i++)
|
||||
{
|
||||
tag_idx[i] = meshio_.physical_name2tag(groups_, phynames[i]);
|
||||
}
|
||||
|
||||
if (saved(datname))
|
||||
{
|
||||
meshdata &dat = get_data(datname);
|
||||
if (dat.loctype_ != ElemData) throw std::invalid_argument("The data type must be ElemData.");
|
||||
|
||||
for (size_t i = 0; i < ele_num_; i++)
|
||||
{
|
||||
for (size_t e = 0; e < phynames.size(); e++)
|
||||
{
|
||||
if (elems_tag_[i][0] == tag_idx[e])
|
||||
{
|
||||
dat.datval_[i] = phyvals[e];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
meshdata &newdat = add_data(ElemData, Scalar, datname, 0.0);
|
||||
|
||||
for (size_t i = 0; i < ele_num_; i++)
|
||||
{
|
||||
for (size_t e = 0; e < phynames.size(); e++)
|
||||
{
|
||||
if (elems_tag_[i][0] == tag_idx[e])
|
||||
{
|
||||
newdat.datval_[i] = phyvals[e];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
@ -40,14 +40,14 @@ namespace gctl
|
||||
* 以下为mesh类型的虚函数实现
|
||||
*/
|
||||
|
||||
void init(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes,
|
||||
const array<triangle2d> &in_triangles);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
|
||||
void load_binary(std::string filename);
|
||||
void save_binary(std::string filename);
|
||||
|
||||
void show_mesh_dimension(std::ostream &os) const;
|
||||
|
||||
/**
|
||||
* 以下为triangle2d_mesh的专有函数
|
||||
*/
|
||||
@ -57,18 +57,31 @@ namespace gctl
|
||||
const array<triangle2d> &in_triangles);
|
||||
virtual ~triangle2d_mesh();
|
||||
|
||||
void init(std::string in_name, std::string in_info, const array<vertex2dc> &in_nodes,
|
||||
const array<triangle2d> &in_triangles);
|
||||
|
||||
const array<vertex2dc> &get_nodes() const;
|
||||
const array<triangle2d> &get_elements() const;
|
||||
|
||||
void reorder2anticlockwise();
|
||||
|
||||
void load_triangle(std::string filename, index_packed_e packed = Packed);
|
||||
void load_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void save_gmsh(std::string filename, std::string datname, output_type_e out_mode, index_packed_e packed = Packed);
|
||||
void load_gmsh_groups();
|
||||
|
||||
/**
|
||||
* @brief 将模型物理分组转换为模型数据组
|
||||
*
|
||||
* @param datname 赋值给模型数据组的名称(如果数组不存在则新建)
|
||||
* @param phynames 物理组名称
|
||||
* @param phyvals 物理组值
|
||||
*/
|
||||
void groups2data(std::string datname, _1s_vector phynames, _1d_vector phyvals);
|
||||
|
||||
protected:
|
||||
array<vertex2dc> nodes;
|
||||
array<triangle2d> elements;
|
||||
array<vertex2dc> nodes_;
|
||||
array<triangle2d> elems_;
|
||||
array<gmsh_physical_group> groups_;
|
||||
_2i_vector elems_tag_;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ void save_gmsh(const std::vector<std::string> &cmd_units)
|
||||
// save gmsh <file>
|
||||
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
|
||||
|
||||
rg.save_gmsh(cmd_units[2], OverWrite, NotPacked);
|
||||
rg.save_gmsh_withdata(cmd_units[2], OverWrite, NotPacked);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user