tmp
This commit is contained in:
parent
807e472dee
commit
00c6a64d83
@ -4,15 +4,15 @@ project(GCTL_MESH VERSION 1.0)
|
||||
# 添加配置配件编写的函数
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# ExprTK库在macOS 15.4中编译会有错误 添加以下命令对应检查项
|
||||
add_compile_options(-Wno-missing-template-arg-list-after-template-kw)
|
||||
|
||||
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
|
||||
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
|
||||
message(STATUS "Processor: " ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
|
||||
find_package(GCTL REQUIRED)
|
||||
message(STATUS "GCTL Version: " ${GCTL_VERSION})
|
||||
#if(${GCTL_VERSION} LESS 1.0)
|
||||
# message(FATAL_ERROR "GCTL's version must be v1.0 or bigger.")
|
||||
#endif()
|
||||
|
||||
option(GCTL_MESH_EXPRTK "Use the exprtk library." ON)
|
||||
option(GCTL_MESH_WAVELIB "Use the WaveLib library" ON)
|
||||
|
@ -35,6 +35,15 @@ gctl::base_mesh::base_mesh()
|
||||
meshinfo_ = "Undefined";
|
||||
node_num_ = ele_num_ = 0;
|
||||
initialized_ = false;
|
||||
// 注意这里我们一定要预先为datalist_分配空间,因为
|
||||
// datalist_为vector类型,所以元素增加时可能造成
|
||||
// 原有的迭代器失效造成访问失败。一个简单的例子是做
|
||||
// 网格加法时,我们通过get_data获取两个网格数据并将
|
||||
// 计算结果通过add_data保存,这时候就可能出现vector
|
||||
// 扩容造成get_data获取的数据无法访问,访问失败。
|
||||
// 默认可以保存100个网格数据,应该是够用了。同时
|
||||
// 在add_data中添加相应的错误提示。
|
||||
datalist_.reserve(100);
|
||||
}
|
||||
|
||||
gctl::base_mesh::~base_mesh()
|
||||
@ -182,6 +191,8 @@ gctl::meshdata &gctl::base_mesh::add_data(mesh_data_type_e in_loctype, mesh_data
|
||||
std::string name, double init_val, bool if_output, double nan_val)
|
||||
{
|
||||
check_initiated();
|
||||
if (datalist_.size() == 100) throw std::runtime_error("[gctl::base_mesh] Maximal data number reached.");
|
||||
|
||||
meshdata new_data(in_loctype, in_valtype, 0, name, if_output, nan_val);
|
||||
|
||||
if (in_loctype == NodeData && in_valtype == Scalar) new_data.datval_.resize(node_num_, init_val);
|
||||
@ -200,6 +211,8 @@ gctl::meshdata &gctl::base_mesh::add_data(mesh_data_type_e in_loctype, std::stri
|
||||
const array<double> &init_arr, bool if_output, double nan_val)
|
||||
{
|
||||
check_initiated();
|
||||
if (datalist_.size() == 100) throw std::runtime_error("[gctl::base_mesh] Maximal data number reached.");
|
||||
|
||||
meshdata new_data(in_loctype, Scalar, 0, name, if_output, nan_val);
|
||||
|
||||
if (in_loctype == NodeData)
|
||||
@ -222,6 +235,8 @@ gctl::meshdata &gctl::base_mesh::add_data(mesh_data_type_e in_loctype, std::stri
|
||||
const array<point3dc> &init_arr, bool if_output, double nan_val)
|
||||
{
|
||||
check_initiated();
|
||||
if (datalist_.size() == 100) throw std::runtime_error("[gctl::base_mesh] Maximal data number reached.");
|
||||
|
||||
meshdata new_data(in_loctype, Vector, 0, name, if_output, nan_val);
|
||||
|
||||
if (in_loctype == NodeData)
|
||||
@ -258,6 +273,8 @@ gctl::meshdata &gctl::base_mesh::add_data(mesh_data_type_e in_loctype, std::stri
|
||||
const array<tensor> &init_arr, bool if_output, double nan_val)
|
||||
{
|
||||
check_initiated();
|
||||
if (datalist_.size() == 100) throw std::runtime_error("[gctl::base_mesh] Maximal data number reached.");
|
||||
|
||||
meshdata new_data(in_loctype, Tensor, 0, name, if_output, nan_val);
|
||||
|
||||
if (in_loctype == NodeData)
|
||||
|
@ -950,7 +950,6 @@ void gctl::regular_grid::diff(std::string newname, std::string datname, std::str
|
||||
}
|
||||
|
||||
meshdata &new_data = add_data(data_type1, value_type1, newname, 0.0, true, GCTL_BDL_MAX);
|
||||
|
||||
for (size_t i = 0; i < new_data.datval_.size(); i++)
|
||||
{
|
||||
new_data.datval_[i] = data_1.datval_[i] - data_2.datval_[i];
|
||||
|
Loading…
Reference in New Issue
Block a user