15个版本 (3个稳定版)
1.1.0 | 2024年5月1日 |
---|---|
0.9.0 | 2024年1月18日 |
0.8.0 | 2023年10月26日 |
0.5.0 | 2023年7月3日 |
0.1.0 | 2021年10月23日 |
在数学类别中排名131
每月下载79次
被pmsim使用
2MB
33K SLoC
有限元分析中的几何、网格和数值积分
内容
简介
本crate包含用于几何计算的结构和函数,生成网格,以及进行有限元分析(FEM/FEA)的数值积分。
文档
安装
目前,Gemlab在以下系统中运行:Linux (Debian/Ubuntu; 可能还有Arch)。
TL;DR (Debian/Ubuntu/Linux)
首先
sudo apt-get install -y --no-install-recommends \
g++ \
gdb \
gfortran \
liblapacke-dev \
libmumps-seq-dev \
libopenblas-dev \
libsuitesparse-dev
然后
cargo add gemlab
详细信息
此crate依赖于russell_lab
,因此需要一些外部库。请参阅russell_lab
的安装所需依赖项。
设置Cargo.toml
👆 检查crate版本并相应地更新Cargo.toml
[dependencies]
gemlab = "*"
示例
use gemlab::integ;
use gemlab::mesh::{At, Features, Mesh};
use gemlab::shapes::Scratchpad;
use gemlab::StrError;
use std::collections::HashSet;
fn main() -> Result<(), StrError> {
// Input the raw mesh data using a text file
//
// 1.0 5------,6.------7
// | [3],' `.[4] |
// | ,' `. |
// |,' `.|
// 0.5 3 [2] 4
// |`. .'|
// | `. .' |
// | [0]`. .'[1] |
// 0.0 0------`1'------2
// 0.0 0.5 1.0
let path = "./data/meshes/four_tri3_one_qua4.msh";
let mesh = Mesh::from_text_file(path)?;
// Extract features such boundary edges and faces.
// Search entities along the boundary of the mesh given coordinates.
// The `At` enum provides an easy way to define the type of the
// constraint such as line, plane, circle, etc.
let feat = Features::new(&mesh, false);
assert_eq!(feat.search_point_ids(At::Y(0.5), |_| true)?, &[3, 4]);
assert_eq!(feat.search_edge_keys(At::X(1.0), |_| true)?, &[(2, 4), (4, 7)]);
// Perform numerical integration to compute
// the area of cell # 2
let ndim = 2;
let cell_2 = &mesh.cells[2];
let mut pad = Scratchpad::new(ndim, cell_2.kind)?;
mesh.set_pad(&mut pad, &cell_2.points);
let ips = integ::default_points(cell_2.kind);
let mut area = 0.0;
for p in 0..ips.len() {
let iota = &ips[p];
let weight = ips[p][3];
let det_jac = pad.calc_jacobian(iota)?;
area += weight * det_jac;
}
assert_eq!(area, 0.5);
Ok(())
}
路线图
- 实现读写网格函数
- 为数值积分添加测试
- 实现三角形和四面体生成器
- 实现绘图函数
附录A - 节点的形状和局部编号
线(Lin)
三角形(Tri)
四边形(Qua)
四面体(Tet)
六面体(Hex)
附录B - 几何与空间维度
下表显示了可能的几何维度(geo_ndim
)和空间维度(space_ndim
)的组合。共有三种情况
- 情况
CABLE
--geo_ndim = 1
和space_ndim = 2 或 3
;例如,2D或3D中的线(绳索和杆子) - 情况
SHELL
--geo_ndim = 2
和space_ndim = 3
;例如,3D中的Tri或Qua(壳体和表面) - 情况
SOLID
--geo_ndim = space_ndim
;例如,2D中的Tri和Qua或3D中的Tet和Hex
geo_ndim |
space_ndim= 2 |
space_ndim= 3 |
---|---|---|
1 | CABLE |
CABLE |
2 | SOLID |
SHELL |
3 | 不可能 | SOLID |
依赖关系
~10MB
~174K SLoC