gctl_mesh/lib/mesh/meshdata.h

144 lines
4.7 KiB
C
Raw Normal View History

2025-01-12 23:39:36 +08:00
/********************************************************
2024-09-10 20:02:00 +08:00
*
*
*
*
*
*
* 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"
2025-01-12 23:39:36 +08:00
#include "gctl/geometry/point3c.h"
#include "gctl/geometry/tensor.h"
2024-09-10 20:02:00 +08:00
namespace gctl
{
2025-01-12 23:39:36 +08:00
/**
2024-09-10 20:02:00 +08:00
* @brief
*/
enum mesh_data_value_e
{
Scalar, ///< 标量数据
Vector, ///< 矢量数据
Tensor, ///< 张量数据
};
2025-01-12 23:39:36 +08:00
/**
* @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_; // 无效数据的标记值
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
meshdata();
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
*
* @param in_loctype
* @param in_valtype
* @param size
* @param name
* @param if_output
* @param nan_val
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
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);
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
virtual ~meshdata();
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
void clear();
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
*
* @param in_loctype
* @param in_valtype
* @param size
* @param name
* @param if_output
* @param nan_val
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
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);
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
array<point3dc> export_vector() const;
2024-09-10 20:02:00 +08:00
/**
2025-01-12 23:39:36 +08:00
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
array<tensor> export_tensor() const;
2024-09-10 20:02:00 +08:00
2025-01-12 23:39:36 +08:00
/**
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
void show_info(std::ostream &os = std::clog) const;
2024-09-10 20:02:00 +08:00
2025-01-12 23:39:36 +08:00
/**
* @brief
2024-09-10 20:02:00 +08:00
*/
2025-01-12 23:39:36 +08:00
void show_stats(std::ostream &os = std::clog) const;
2024-09-10 20:02:00 +08:00
2025-01-12 23:39:36 +08:00
/**
2024-09-10 20:02:00 +08:00
* @brief
*
* @warning
*
* @param infile
*/
2025-01-12 23:39:36 +08:00
void load_binary(std::ifstream &infile);
2024-09-10 20:02:00 +08:00
/**
* @brief
*
* @warning
*
* @param outfile
*/
2025-01-12 23:39:36 +08:00
void save_binary(std::ofstream &outfile);
};
2024-09-10 20:02:00 +08:00
}
2025-01-12 23:39:36 +08:00
#endif // _GCTL_MESHDATA_H