gctl_mesh/lib/mesh/meshdata.h

158 lines
4.7 KiB
C
Raw Normal View History

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"
#include "gctl/geometry.h"
namespace gctl
{
/**
* @brief
*/
enum mesh_data_value_e
{
Scalar, ///< 标量数据
Vector, ///< 矢量数据
Tensor, ///< 张量数据
};
/**
* @brief
*/
class meshdata
{
protected:
std::string datname; // 数据的名称
mesh_data_type_e dattype; // 数据的赋值属性 顶点或是元素(设置后不可更改)
mesh_data_value_e valtype; // 数据的类型(设置后不可更改)
bool output_ok; // 是否可输出数据
public:
// 构造函数
meshdata(std::string in_name, mesh_data_type_e in_type, bool if_output);
// 析构函数
virtual ~meshdata();
/**
* @brief
*
* @param[in] in_name
*/
void set_datname(std::string in_name);
/**
* @brief
*
* @return
*/
std::string get_datname();
/**
* @brief
*
* @return
*/
mesh_data_type_e get_dattype();
/**
* @brief
*
* @return
*/
mesh_data_value_e get_valtype();
/**
* @brief
*
* @param[in] if_output
*/
void set_output(bool if_output);
/**
* @brief
*
* @return
*/
bool get_output();
/**
* @brief
*/
void show_info(std::ostream &os = std::clog);
/**
* @brief
*/
virtual void show_stats(std::ostream &os = std::clog) = 0;
/**
* @brief gctl::array类型
*
* @note
*
* @return
*/
virtual void *get_datval_ptr() = 0;
/**
* @brief
*
* @warning
*
* @param infile
*/
virtual void load_binary(std::ifstream &infile) = 0;
/**
* @brief
*
* @warning
*
* @param outfile
*/
virtual void save_binary(std::ofstream &outfile) = 0;
/**
* @brief
*
* @param obj_ptr
*/
static void destroy(meshdata *obj_ptr)
{
delete obj_ptr;
obj_ptr = nullptr;
return;
}
};
}
#endif //_GCTL_MESHDATA_H