#finite-element #mesh #geometry #fem

gemlab

有限元分析的几何和网格实验室

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

Download history 199/week @ 2024-04-26 24/week @ 2024-05-03 3/week @ 2024-05-17 1/week @ 2024-05-24 26/week @ 2024-07-19 53/week @ 2024-07-26

每月下载79
pmsim使用

MIT许可证

2MB
33K SLoC

Rust 23K SLoC // 0.1% comments Wolfram 10K SLoC // 0.1% comments BASH 8 SLoC // 0.2% comments

有限元分析中的几何、网格和数值积分

codecov Test & Coverage

documentation

内容

简介

本crate包含用于几何计算的结构和函数,生成网格,以及进行有限元分析(FEM/FEA)的数值积分。

文档

documentation

安装

目前,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

Crates.io

👆 检查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)

lin_cells

三角形(Tri)

tri_cells

四边形(Qua)

qua_cells

四面体(Tet)

tet_cells

六面体(Hex)

hex_cells

附录B - 几何与空间维度

下表显示了可能的几何维度(geo_ndim)和空间维度(space_ndim)的组合。共有三种情况

  1. 情况 CABLE -- geo_ndim = 1space_ndim = 23;例如,2D或3D中的线(绳索和杆子)
  2. 情况 SHELL -- geo_ndim = 2space_ndim = 3;例如,3D中的Tri或Qua(壳体和表面)
  3. 情况 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