Files
FemLite/docs/02_software_architecture_design.md
shenw a2126f360c
FemLite CI / build-test (push) Has been cancelled
Release 0.6.5 real IPC worker
2026-07-05 21:09:37 +08:00

65 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 02 软件架构设计
文档状态:0.6.5 版整理稿
## 1. 架构概览
FemLite 采用 Fortran 95 风格的过程式架构。核心数据集中存放在数据库模块中,求解器、单元、材料、边界、接触、输出和接口层围绕数据库协作。
```text
输入层 -> 数据库 -> 单元/材料/边界/接触 -> 求解器 -> 输出/API
```
## 2. 主要目录
| 目录 | 职责 |
|---|---|
| `src/base` | 全局精度、错误、控制参数、公共 API、诊断接口 |
| `src/input` | Abaqus INP 子集读取与控制块解析 |
| `src/mesh` | 节点、单元、集合、材料、截面和 DOF 数据库 |
| `src/element` | 单元拓扑、形函数、积分、质量、刚度、内力和状态 |
| `src/material` | 材料模型、Mohr-Coulomb、强度折减和材料点驱动 |
| `src/boundary` | 约束、接触、mortar/AL、cohesive、滚压/刚体工具 |
| `src/solver` | 静力、隐式、非线性、线性求解器、屈曲和模态工具 |
| `src/output` | CSV、VTU/PVD、restart 和模态输出 |
| `src/interface` | Fortran-C bridge 和 C ABI |
| `tests` | 单元、模块、接口、CLI、benchmark 和性能测试 |
| `tools` | benchmark 编排、测试辅助和脚本 |
| `examples` | 可运行示例和 benchmark 输入 |
## 3. 数据流
1. `fem_initialize` 初始化控制参数、日志、诊断和数据库状态。
2. `fem_read_inp` 读取输入文件并填充模型数据库。
3. `fem_build_model` 校验模型、建立边界 facet 和必要的派生数据。
4. 求解器根据命令行或 API 调用执行显式、静力、隐式或专用 benchmark 路径。
5. 输出层写入 CSV、VTU/PVD、restart 或诊断文件。
6. API 层提供模型状态、节点、元素、接触和诊断查询。
7. `fem_finalize` 释放数据库、关闭日志并重置生命周期状态。
## 4. 单元基础设施
0.6.3 后单元基础设施分层如下:
- `fem_element_topology`:单元名称、种类、节点数、边/面拓扑和积分点计数。
- `fem_quadrature`:积分规则描述符、Gauss/Gauss-Lobatto/Newton-Cotes/simplex 规则。
- `fem_shape_functions`:各单元形函数和自然坐标导数。
- `fem_element_stiffness`、`fem_element_internal`、`fem_element_mass`:单元计算路径。
- `fem_api_state_access`:元素查询 API,不直接暴露内部数组。
## 5. 接口层
公开接口分三层:
- Fortran API:`src/base/fem_api.f90` 及其子模块。
- C ABI:`include/femlite_c_api.h` 和 `src/interface/fem_c_api.c`。
- 命令行程序:`src/app/fem_program.f90`。
C ABI 只做薄包装,不改变 Fortran API 的物理含义。多维数组以 Fortran 顺序展平成 C 缓冲区。
## 6. 版本治理
- 版本号由 `CMakeLists.txt` 和 `src/base/fem_precision.f90` 同步维护。
- 版本计划、验收报告和 benchmark 矩阵统一合并到 `09_release_history.md`、`10_development_roadmap.md` 和 `11_benchmark_matrix.md`。
- 新功能必须同步更新需求、算法、接口、测试、用户手册和开发者手册中的相关章节。