Files
FemLite/docs/03_detailed_design.md
T
shenw be02684827
FemLite CI / build-test (push) Has been cancelled
Release FemLite 0.3.0
2026-06-23 19:28:44 +08:00

23 KiB
Raw Blame History

FEM Detailed Design

文档状态:详细设计基线草稿

适用对象:船舶接触爆炸船体结构 FEM 核心库与小型分析程序

1. 文档目的

本文档给出各 Fortran95 模块的数据结构、数组维度、子程序接口、调用顺序和实现约定,用于直接指导编码。

本文档承接需求规格说明书和软件架构设计说明书。

2. 设计原则

代码实现应遵循:

  • 采用 Fortran95 过程式模块设计。
  • 模块名与文件名保持一致。
  • 使用集中式 fem_database 管理全局数据。
  • 允许模块共享 fem_database 中的全局 allocatable 数组。
  • 分量维度放在数组第一维,实体数量放在第二维。
  • 所有核心子程序通过 ierr 返回状态。
  • 核心库子程序不直接 stop,主程序根据 ierr 决定是否退出。
  • 输入解析、数据库构建、单元计算、材料更新、求解器、耦合和输出保持解耦。

3. 文件与模块组织

第一版建议文件结构:

src/base/fem_precision.f90
src/base/fem_error.f90
src/base/fem_log.f90
src/base/fem_control.f90
src/mesh/fem_database.f90
src/input/fem_inp_reader.f90
src/input/fem_inp_keywords.f90
src/material/fem_material_iso.f90
src/material/fem_material_j2.f90
src/element/fem_quadrature.f90
src/element/fem_shape_solid.f90
src/element/fem_shape_shell.f90
src/element/fem_element_solid.f90
src/element/fem_element_shell.f90
src/element/fem_element_driver.f90
src/boundary/fem_boundary.f90
src/coupling/fem_sph_coupling.f90
src/solver/fem_solver_explicit.f90
src/solver/fem_sparse_csr.f90
src/output/fem_output_csv.f90
src/app/fem_program.f90

第二版可增加:

src/boundary/fem_constraint.f90
src/boundary/fem_contact.f90
src/solver/fem_solver_implicit.f90
src/output/fem_output_vtk.f90
src/output/fem_restart.f90

第三版重点完善或增加:

src/solver/fem_solver_static.f90
src/solver/fem_solver_newmark.f90
src/element/fem_element_stiffness.f90
src/output/fem_output_convergence.f90

说明:

  • 静力求解可独立放在 fem_solver_static.f90,也可在 fem_solver_implicit.f90 中分子程序实现。
  • 单元静力刚度应由 fem_element_stiffness.f90 统一调度实体和壳单元。
  • 输出模块应统一显式、静力和隐式动力结果字段。

4. 全局精度与常量模块

模块:fem_precision.f90

职责:

  • 定义实数精度。
  • 定义常用整数常量。
  • 定义数组固定维度常量。

建议常量:

integer, parameter :: rk = selected_real_kind(12, 100)
integer, parameter :: ik = selected_int_kind(9)

integer, parameter :: NDIM = 3
integer, parameter :: NDOF_NODE = 6
integer, parameter :: NSTRESS = 6
integer, parameter :: MAX_NEN = 20
integer, parameter :: MAX_FACE_NODES = 8
integer, parameter :: NAME_LEN = 80
integer, parameter :: ELEM_TYPE_LEN = 16
integer, parameter :: MAT_MODEL_LEN = 32
integer, parameter :: NSTATEV_MAX = 32

应力、应变分量顺序:

1 XX / 11
2 YY / 22
3 ZZ / 33
4 XY / 12
5 XZ / 13
6 YZ / 23

剪切约定:

  • 应变数组中第 4、5、6 分量采用工程剪切应变 gamma12、gamma13、gamma23。
  • 应力数组中第 4、5、6 分量采用真实剪切应力 tau12、tau13、tau23。
  • 材料模块内部如需张量剪切应变,应在材料例程内部显式转换。

5. 错误与日志模块

模块:

  • fem_error.f90
  • fem_log.f90

错误码分组:

0     success
1000  input errors
2000  mesh and dof errors
3000  material and state errors
4000  solver errors
5000  coupling errors
6000  output errors
9000  internal errors

核心接口约定:

subroutine some_core_routine(..., ierr)
  integer, intent(out) :: ierr
end subroutine

日志模块至少提供:

subroutine log_info(message)
subroutine log_warning(message)
subroutine log_error(message)

6. 控制参数模块

模块:fem_control.f90

职责:

  • 保存分析控制参数。
  • 保存输出控制参数。
  • 保存材料和求解器选项。
  • 保存 SPH 耦合运行模式。

第一版关键变量:

real(rk) :: time_start
real(rk) :: time_end
real(rk) :: dt_user
real(rk) :: dt_stable
integer  :: nstep_max
integer  :: output_interval
logical  :: use_sph_coupling
logical  :: use_user_dt
logical  :: large_deformation

第三版静力和隐式控制变量:

character(len=32) :: analysis_type      ! EXPLICIT / STATIC_LINEAR / STATIC_NONLINEAR / IMPLICIT_DYNAMIC
integer  :: max_increment
integer  :: max_newton_iter
integer  :: current_increment
real(rk) :: static_time
real(rk) :: load_factor
real(rk) :: newton_tol_force
real(rk) :: newton_tol_disp
real(rk) :: newmark_beta
real(rk) :: newmark_gamma
real(rk) :: rayleigh_alpha_mass
real(rk) :: rayleigh_beta_stiffness
logical  :: use_line_search
logical  :: allow_step_cutback

显式求解默认:

  • large_deformation = .true.
  • use_user_dt 由输入文件或外部驱动器决定。
  • SPH 耦合模式下 dt 由外部驱动器传入。

7. 数据库模块

模块:fem_database.f90

职责:

  • 统一保存网格、材料、截面、集合、自由度、状态变量和全局向量。
  • 提供 allocate/deallocate/init 子程序。
  • 不承担具体单元、材料和求解算法。

7.1 网格数组

数组维度采用 Fortran 列主序友好形式:

integer :: nnode
integer :: nelem
integer :: ndof
integer :: ngauss_total

real(rk), allocatable :: coord0(:,:)      ! coord0(3,nnode)
real(rk), allocatable :: coord(:,:)       ! coord(3,nnode)
integer,  allocatable :: elem_conn(:,:)   ! elem_conn(MAX_NEN,nelem)
integer,  allocatable :: elem_nnode(:)    ! elem_nnode(nelem)
character(len=ELEM_TYPE_LEN), allocatable :: elem_type(:)
integer,  allocatable :: elem_mat(:)      ! elem_mat(nelem)
integer,  allocatable :: elem_sec(:)      ! elem_sec(nelem)
integer,  allocatable :: elem_status(:)   ! elem_status(nelem)

单元类型直接使用 Abaqus 字符串:

C3D4
C3D8
C3D10
C3D20
S3
S4
S6
S8

实现约定:

  • INP 读取时将单元类型转换为大写并去除多余空格。
  • 内部不使用整数单元类型编码作为主标识。
  • 单元调度通过字符串比较或统一的字符串选择例程完成。
  • 后续如需性能优化,可增加内部缓存编码,但 Abaqus 字符串仍作为数据库主字段。

单元状态建议:

0 active
1 deleted
2 inactive by input

7.2 自由度数组

每节点预留 6 个自由度:

integer, allocatable :: dof_id(:,:)       ! dof_id(6,nnode)

规则:

  • dof_id(1:3,node) 对应 UX、UY、UZ。
  • dof_id(4:6,node) 对应 RX、RY、RZ。
  • 实体单元只激活 1:3。
  • 壳单元激活 1:6。
  • 未激活自由度编号为 0。

7.3 全局向量

显式动力学第一版使用:

real(rk), allocatable :: u(:)          ! u(ndof)
real(rk), allocatable :: v(:)          ! v(ndof), output velocity
real(rk), allocatable :: a(:)          ! a(ndof)
real(rk), allocatable :: vhalf(:)      ! vhalf(ndof)
real(rk), allocatable :: mass_diag(:)  ! mass_diag(ndof)

real(rk), allocatable :: fint(:)       ! fint(ndof)
real(rk), allocatable :: fext(:)       ! fext(ndof)
real(rk), allocatable :: fsph(:)       ! fsph(ndof)
real(rk), allocatable :: fcontact(:)   ! fcontact(ndof), second version

速度约定:

  • 显式求解内部保存半步速度 vhalf。
  • 输出速度 v 可由相邻半步速度重建。
  • v 数组保存用于输出和外部接口的整步速度估计。

7.4 高斯点与状态变量

integer, allocatable :: elem_gp_start(:)  ! elem_gp_start(nelem)
integer, allocatable :: elem_ngp(:)       ! elem_ngp(nelem)

real(rk), allocatable :: stress(:,:)      ! stress(6,ngauss_total)
real(rk), allocatable :: strain(:,:)      ! strain(6,ngauss_total)
real(rk), allocatable :: statev(:,:)      ! statev(NSTATEV_MAX,ngauss_total)

固定 statev 布局:

1   eqps, equivalent plastic strain
2   damage
3   temperature
4   fail_flag, 0 active material point, 1 failed material point
5   plastic strain XX
6   plastic strain YY
7   plastic strain ZZ
8   plastic strain XY, engineering shear component
9   plastic strain XZ, engineering shear component
10  plastic strain YZ, engineering shear component
11  Fp11
12  Fp12
13  Fp13
14  Fp21
15  Fp22
16  Fp23
17  Fp31
18  Fp32
19  Fp33
20  eqps_rate
21  current_yield_stress
22  plastic_multiplier
23  internal_energy_density
24  reserved for temperature history
25-32 reserved

约定:

  • 小应变 J2 使用 1、2、3、4、5:10、20、21、22。
  • 大应变 J2 使用 1、2、3、4、11:19、20、21、22。
  • 未使用槽位置零。
  • 材料失效后设置 statev(4,gp)=1。
  • 单元删除由 elem_status 标记,不通过释放内存实现。

8. INP 读取模块

模块:

  • fem_inp_reader.f90
  • fem_inp_keywords.f90

职责:

  • 读取 Abaqus inp 文件。
  • 解析第一版支持的 keyword。
  • 构造数据库所需的原始数据。
  • 对不支持 keyword 记录 warning。
  • 对关键数据缺失返回 error。

第一版 keyword:

*NODE
*ELEMENT
*NSET
*ELSET
*MATERIAL
*DENSITY
*ELASTIC
*PLASTIC
*SOLID SECTION
*SHELL SECTION
*BOUNDARY
*CLOAD
*DLOAD
*AMPLITUDE
*STEP
*DYNAMIC

集合要求:

  • 支持 *NSET, GENERATE。
  • 支持 *ELSET, GENERATE。
  • 集合名统一转大写保存。

建议接口:

subroutine inp_read_file(filename, ierr)
  character(len=*), intent(in) :: filename
  integer, intent(out) :: ierr
end subroutine

9. 集合数据结构

节点集和单元集采用压缩连续存储。

integer :: n_nset
integer :: n_elset

character(len=NAME_LEN), allocatable :: nset_name(:)
integer, allocatable :: nset_start(:)
integer, allocatable :: nset_count(:)
integer, allocatable :: nset_items(:)

character(len=NAME_LEN), allocatable :: elset_name(:)
integer, allocatable :: elset_start(:)
integer, allocatable :: elset_count(:)
integer, allocatable :: elset_items(:)

规则:

  • set_start 指向 set_items 中的起始位置。
  • set_count 表示集合元素数。
  • 集合项保持输入编号,数据库构建时再映射为内部编号。

10. 材料模块

模块:

  • fem_material_iso.f90
  • fem_material_j2.f90

材料控制建议采用分解模型选项:

character(len=MAT_MODEL_LEN), allocatable :: mat_elastic_model(:)
character(len=MAT_MODEL_LEN), allocatable :: mat_plastic_model(:)
character(len=MAT_MODEL_LEN), allocatable :: mat_rate_model(:)
character(len=MAT_MODEL_LEN), allocatable :: mat_temp_model(:)
character(len=MAT_MODEL_LEN), allocatable :: mat_failure_model(:)

第一版材料选项:

elastic model: ISO_LINEAR
plastic model: NONE / J2_SMALL / J2_FINITE
hardening: IDEAL / LINEAR / TABULAR
rate model: NONE / JOHNSON_COOK
temperature model: NONE / JOHNSON_COOK
failure model: NONE / EQPS_LIMIT / JOHNSON_COOK

材料参数至少包含:

real(rk), allocatable :: mat_density(:)
real(rk), allocatable :: mat_e(:)
real(rk), allocatable :: mat_nu(:)
real(rk), allocatable :: mat_yield0(:)
real(rk), allocatable :: mat_hardening_modulus(:)

材料更新接口建议:

subroutine material_update_3d(mat_id, dt, strain_inc, defgrad, &
                              strain_rate, temperature, state_old, &
                              stress_old, stress_new, state_new, &
                              failed, ierr)
  integer, intent(in) :: mat_id
  real(rk), intent(in) :: dt
  real(rk), intent(in) :: strain_inc(6)
  real(rk), intent(in) :: defgrad(3,3)
  real(rk), intent(in) :: strain_rate
  real(rk), intent(in) :: temperature
  real(rk), intent(in) :: state_old(NSTATEV_MAX)
  real(rk), intent(in) :: stress_old(6)
  real(rk), intent(out) :: stress_new(6)
  real(rk), intent(out) :: state_new(NSTATEV_MAX)
  logical, intent(out) :: failed
  integer, intent(out) :: ierr
end subroutine

材料模块约束:

  • 不直接访问全局节点和单元数组。
  • 不执行单元删除,只返回 failed 标志。
  • 不施加边界条件。
  • 不写输出文件。

11. 形函数与积分模块

模块:

  • fem_shape_solid.f90
  • fem_shape_shell.f90
  • fem_quadrature.f90

接口建议:

subroutine shape_solid(elem_type, xi, nnode, n, dndxi, ierr)
  character(len=*), intent(in) :: elem_type
  real(rk), intent(in) :: xi(3)
  integer, intent(out) :: nnode
  real(rk), intent(out) :: n(MAX_NEN)
  real(rk), intent(out) :: dndxi(3,MAX_NEN)
  integer, intent(out) :: ierr
end subroutine
subroutine quadrature_rule(elem_type, ngauss, xi, weight, ierr)
  character(len=*), intent(in) :: elem_type
  integer, intent(out) :: ngauss
  real(rk), intent(out) :: xi(3,*)
  real(rk), intent(out) :: weight(*)
  integer, intent(out) :: ierr
end subroutine

第一版支持:

  • C3D4
  • C3D8
  • S4

12. 实体单元模块

模块:fem_element_solid.f90

职责:

  • 计算 C3D4、C3D8 集中质量。
  • 计算单元内力。
  • 计算线性静力单元刚度。
  • 为非线性静力和隐式动力提供切线刚度或近似切线刚度。
  • 更新高斯点应力和状态变量。
  • 估算稳定时间步。
  • 处理材料点失效并向单元删除逻辑报告。

接口建议:

subroutine solid_lumped_mass(elem, ierr)
  integer, intent(in) :: elem
  integer, intent(out) :: ierr
end subroutine

subroutine solid_internal_force(elem, dt, ierr)
  integer, intent(in) :: elem
  real(rk), intent(in) :: dt
  integer, intent(out) :: ierr
end subroutine

subroutine solid_stable_dt(elem, dtcrit, ierr)
  integer, intent(in) :: elem
  real(rk), intent(out) :: dtcrit
  integer, intent(out) :: ierr
end subroutine

subroutine solid_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
  integer, intent(in) :: elem
  integer, intent(out) :: elem_dofs(:)
  integer, intent(out) :: n_elem_dof
  real(rk), intent(out) :: ke(:,:)
  integer, intent(out) :: ierr
end subroutine

单元删除策略:

  • 删除后的单元在内存中保留且可访问。
  • 删除通过 elem_status(elem)=1 标记。
  • 删除单元不再贡献内力。
  • 删除单元不再接受面压力和 SPH facet 外载。
  • 删除单元的质量不从全局 mass_diag 中移除。
  • 删除单元不触发自由度重编号。
  • 输出中应保留删除状态。

13. 壳单元模块

模块:fem_element_shell.f90

第一版支持 S4。

职责:

  • 计算 S4 集中质量。
  • 计算 S4 内力。
  • 支持 S4 面压力。
  • 支持 S4 输出应力、应变和塑性应变。

第一版约束:

  • S4 作为可计算单元纳入第一版。
  • 壳大变形和有限转动能力在第一版中保持受限实现。
  • 二次壳单元和基础壳响应在第二版扩展,hourglass 控制、drilling DOF 稳定和壳静力刚度在第三版继续完善。

第二版状态:

  • S3、S6、S8 纳入基础能力。
  • S4 膜、弯曲、横向剪切和压力路径增强。
  • 壳单元仍优先服务显式动力学。

第三版要求:

  • 提供 S3、S4、S6、S8 线性静力刚度。
  • 支持 Mindlin-Reissner 壳膜、弯曲和横向剪切刚度装配。
  • 提供 drilling DOF 稳定处理。
  • 支持壳单元静力应力、应变和节点反力输出。
  • Scordelis-Lo 屋面壳体作为壳静力基准验收模型。

14. 边界与载荷模块

模块:fem_boundary.f90

第一版数据结构:

integer :: nbc
integer, allocatable :: bc_node(:)
integer, allocatable :: bc_dof(:)
real(rk), allocatable :: bc_value(:)
integer, allocatable :: bc_amp(:)

integer :: ncload
integer, allocatable :: cload_node(:)
integer, allocatable :: cload_dof(:)
real(rk), allocatable :: cload_value(:)
integer, allocatable :: cload_amp(:)

integer :: ndload
integer, allocatable :: dload_elem(:)
integer, allocatable :: dload_face(:)
real(rk), allocatable :: dload_value(:)
integer, allocatable :: dload_amp(:)

接口建议:

subroutine boundary_apply_dirichlet(time, ierr)
subroutine boundary_apply_cload(time, ierr)
subroutine boundary_apply_dload(time, ierr)

约定:

  • Dirichlet 支持位移约束。
  • 节点力写入 fext。
  • 面压力转换为等效节点力后写入 fext。
  • amplitude 编号为 0 时表示常值。

15. SPH 耦合模块

模块:fem_sph_coupling.f90

facet 数据结构:

integer :: nfacet
integer, allocatable :: facet_elem(:)
integer, allocatable :: facet_face(:)
integer, allocatable :: facet_nnode(:)
integer, allocatable :: facet_conn(:,:)     ! facet_conn(MAX_FACE_NODES,nfacet)
real(rk), allocatable :: facet_center(:,:)  ! facet_center(3,nfacet)
real(rk), allocatable :: facet_area(:)
real(rk), allocatable :: facet_normal(:,:)  ! facet_normal(3,nfacet)

导出数据应包含:

  • facet 编号
  • facet 所属单元和面号
  • facet 节点连接
  • facet 中心坐标
  • facet 节点坐标
  • facet 节点速度
  • facet 外法向
  • facet 面积

接口建议:

subroutine coupling_build_facets(ierr)
subroutine fem_get_boundary_facets(nfacet_out, conn, x, vnod, normal, area, ierr)
subroutine fem_apply_sph_nodal_forces(nnode_in, node_id, force, ierr)
subroutine fem_apply_sph_facet_tractions(nfacet_in, facet_id, pressure, shear, ierr)

约定:

  • coupling 层只做数据交换和力映射。
  • FEM 不依赖 SPH 程序。
  • solver 只接收已经映射完成的 fsph。
  • 删除单元不再作为有效 SPH facet 来源。

16. 求解器模块

模块:fem_solver_explicit.f90

核心接口:

subroutine fem_initialize(ierr)
subroutine fem_read_inp(filename, ierr)
subroutine fem_build_model(ierr)
subroutine fem_compute_lumped_mass(ierr)
subroutine fem_estimate_stable_dt(dtcrit, ierr)
subroutine fem_advance_explicit(dt, ierr)
subroutine fem_write_output(step, time, ierr)
subroutine fem_finalize(ierr)

显式单步流程:

clear fint, fext, fsph if required
apply prescribed loads
receive or keep SPH forces depending on coupling mode
loop over active elements and compute internal force
apply Dirichlet constraints
compute acceleration from lumped mass
update vhalf
update displacement u
reconstruct output velocity v
update current coordinates coord = coord0 + displacement
mark failed elements as deleted
write output if requested

第二版模块:

  • fem_solver_implicit.f90
  • fem_sparse_csr.f90

第一版只保留接口占位,不要求装配全局刚度矩阵。

第三版静力求解接口建议:

subroutine fem_solve_static_linear(max_iter, tol, iter, res_norm, ierr)
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_solve_static_nonlinear(max_increment, max_iter, tol, &
                                      iter, res_norm, ierr)
  integer, intent(in) :: max_increment
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_get_static_convergence(nincrement, niter, residual, ierr)
  integer, intent(out) :: nincrement
  integer, intent(out) :: niter
  real(rk), intent(out) :: residual
  integer, intent(out) :: ierr
end subroutine

第三版隐式动力接口建议:

subroutine fem_advance_implicit_newmark(dt, max_iter, tol, iter, res_norm, ierr)
  real(rk), intent(in) :: dt
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_run_implicit_newmark(max_iter, tol, iter_total, res_norm, ierr)
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter_total
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_advance_newmark_nonlinear(dt, max_iter, tol, iter, res_norm, ierr)
  real(rk), intent(in) :: dt
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_run_newmark_nonlinear(max_iter, tol, iter_total, res_norm, ierr)
  integer, intent(in) :: max_iter
  real(rk), intent(in) :: tol
  integer, intent(out) :: iter_total
  real(rk), intent(out) :: res_norm
  integer, intent(out) :: ierr
end subroutine

subroutine fem_set_rayleigh_damping(alpha_mass, beta_stiffness, ierr)
  real(rk), intent(in) :: alpha_mass
  real(rk), intent(in) :: beta_stiffness
  integer, intent(out) :: ierr
end subroutine

当前非线性 Newmark-Newton 实现约定:

  • 实体单元切线从当前积分点材料状态取得弹性/J2 算法切线。
  • 壳单元膜内项对 J2/J2_JC 使用当前积分点算法切线,弯曲和横向剪切项暂用弹性近似切线。
  • 每个非线性增量保存材料状态和单元状态备份,迭代试算前恢复,收敛后提交,失败后回滚。
  • Robin、MPC、刚性平面 penalty contact 和面-面 contact pair 的切线进入 Newton 有效刚度。
  • 静力和非线性 Newmark 均支持线搜索;可选步长缩减在失败时恢复增量起点状态后重试。

17. 稀疏矩阵模块

模块:fem_sparse_csr.f90

第二版主用 CSR。

第一版状态:

  • 可提供空接口或最小数据结构。
  • dense 仅用于单元局部矩阵和调试。
  • skyline 非第一优先级。

18. 输出模块

模块:fem_output_csv.f90

第一版 CSV 文件组织:

history.csv
nodes_step_xxxxx.csv
elements_step_xxxxx.csv

history.csv 至少包含:

  • step
  • time
  • kinetic_energy
  • internal_energy
  • external_work
  • max_displacement
  • max_velocity
  • deleted_element_count

nodes_step_xxxxx.csv 至少包含:

  • node_id
  • x
  • y
  • z
  • ux
  • uy
  • uz
  • vx
  • vy
  • vz
  • ax
  • ay
  • az

elements_step_xxxxx.csv 至少包含:

  • elem_id
  • elem_type
  • elem_status
  • stress components
  • strain components
  • plastic strain components
  • eqps
  • damage

第二版增加:

  • VTK 输出
  • restart 输出与读取

第三版增加:

  • convergence.csv:静力和隐式动力增量迭代历史。
  • reactions_step_xxxxx.csv:节点反力。
  • contact_step_xxxxx.csv:接触状态、接触力和接触功。
  • 静力求解结束后必须写出与显式结果一致的 VTK 场文件。

19. 主程序模块

模块:fem_program.f90

命令行程序 femlite 第一版流程:

parse command line
fem_initialize
fem_read_inp
fem_build_model
fem_compute_lumped_mass
time loop:
  fem_estimate_stable_dt if needed
  fem_advance_explicit
  fem_write_output
fem_finalize
return exit code

命令行建议:

femlite input.inp
femlite input.inp --dt 1.0e-8 --time 1.0e-4 --output-interval 10

第三版命令行建议:

femlite input.inp --static-linear
femlite input.inp --static-nonlinear --max-increment 20 --max-iter 25 --tol 1.0e-6
femlite input.inp --implicit-newmark --dt 1.0e-5 --time 1.0e-2
femlite input.inp --implicit-newmark-nonlinear --dt 1.0e-5 --time 1.0e-2

兼容性约定:

  • --implicit-linear 可作为 --static-linear 的兼容别名。
  • --run 保持显式动力学默认流程。
  • 静力模式和显式动力学模式不得在同一命令中同时启用。

20. 内存分配与释放

内存策略:

  • 读取 inp 后确定模型规模。
  • 根据节点数、单元数、集合大小、边界条件数量和高斯点总数 allocate。
  • 所有 allocate 失败必须返回 ierr。
  • fem_finalize 统一 deallocate。
  • 单元删除不释放单元、状态变量或自由度内存。

核心接口:

subroutine database_allocate(ierr)
subroutine database_initialize(ierr)
subroutine database_finalize(ierr)