144 lines
4.7 KiB
C++
144 lines
4.7 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the GCTL, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#ifndef _GCTL_MESHDATA_H
|
|
#define _GCTL_MESHDATA_H
|
|
|
|
#include "gctl_mesh_config.h"
|
|
#include "gctl/core.h"
|
|
#include "gctl/geometry/point3c.h"
|
|
#include "gctl/geometry/tensor.h"
|
|
|
|
namespace gctl
|
|
{
|
|
/**
|
|
* @brief 网格数据的数值类型
|
|
*/
|
|
enum mesh_data_value_e
|
|
{
|
|
Scalar, ///< 标量数据
|
|
Vector, ///< 矢量数据
|
|
Tensor, ///< 张量数据
|
|
};
|
|
|
|
/**
|
|
* @brief 网格文件中的数据对象,可储存标量、矢量和张量数据。
|
|
*
|
|
*/
|
|
struct meshdata
|
|
{
|
|
std::string name_; // 数据的名称
|
|
mesh_data_type_e loctype_; // 数据的赋值位置属性 顶点或是元素
|
|
mesh_data_value_e valtype_; // 数据的类型
|
|
bool output_ok_; // 是否可输出数据
|
|
array<double> datval_; // 数据值 注意目前我们只支持浮点数据存储
|
|
double nan_val_; // 无效数据的标记值
|
|
|
|
/**
|
|
* @brief 构造函数
|
|
*/
|
|
meshdata();
|
|
|
|
/**
|
|
* @brief 创建数据对象
|
|
*
|
|
* @param in_loctype 数据的赋值位置属性 顶点或是元素
|
|
* @param in_valtype 数据的类型
|
|
* @param size 数据的大小
|
|
* @param name 数据的名称
|
|
* @param if_output 是否可输出数据
|
|
* @param nan_val 无效数据的标记值
|
|
*/
|
|
meshdata(mesh_data_type_e in_loctype, mesh_data_value_e in_valtype,
|
|
size_t size, std::string name = "untitled",
|
|
bool if_output = true, double nan_val = GCTL_BDL_MAX);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~meshdata();
|
|
|
|
/**
|
|
* @brief 清空数据对象
|
|
*/
|
|
void clear();
|
|
|
|
/**
|
|
* @brief 创建数据对象
|
|
*
|
|
* @param in_loctype 数据的赋值位置属性 顶点或是元素
|
|
* @param in_valtype 数据的类型
|
|
* @param size 数据的大小
|
|
* @param name 数据的名称
|
|
* @param if_output 是否可输出数据
|
|
* @param nan_val 无效数据的标记值
|
|
*/
|
|
void create(mesh_data_type_e in_loctype, mesh_data_value_e in_valtype,
|
|
size_t size, std::string name = "untitled",
|
|
bool if_output = true, double nan_val = GCTL_BDL_MAX);
|
|
|
|
/**
|
|
* @brief 返回适量数据。
|
|
*/
|
|
array<point3dc> export_vector() const;
|
|
|
|
/**
|
|
* @brief 返回张量数据。
|
|
*/
|
|
array<tensor> export_tensor() const;
|
|
|
|
/**
|
|
* @brief 显示数据对象的头信息
|
|
*/
|
|
void show_info(std::ostream &os = std::clog) const;
|
|
|
|
/**
|
|
* @brief 显示数据统计参数
|
|
*/
|
|
void show_stats(std::ostream &os = std::clog) const;
|
|
|
|
/**
|
|
* @brief 载入二进制文件
|
|
*
|
|
* @warning 不要直接调用此函数,应该在网格类型的相应函数中调用
|
|
*
|
|
* @param infile 输入文件的流(以二进制方式打开)
|
|
*/
|
|
void load_binary(std::ifstream &infile);
|
|
|
|
/**
|
|
* @brief 保存二进制文件
|
|
*
|
|
* @warning 不要直接调用此函数,应该在网格类型的相应函数中调用
|
|
*
|
|
* @param outfile 输出的文件流(以二进制方式打开)
|
|
*/
|
|
void save_binary(std::ofstream &outfile);
|
|
};
|
|
}
|
|
|
|
#endif // _GCTL_MESHDATA_H
|