HPC FEniCS
Treat FEniCS as a family with two main stacks: classic FEniCS and DOLFINx.
Start
- 1. Read
references/runtime-selection.md first. - Read
references/dolfinx-boundary-workflow.md when targeting DOLFINx boundary conditions. - Read
references/ufl-and-solver-patterns.md when translating PDEs, choosing spaces, or building forms. - Read
references/pde-template-cookbook.md when mapping common PDE classes to known formulation patterns. - Read
references/time-dependent-and-nonlinear-patterns.md when building transient or nonlinear solvers. - Read
references/implementation-skeletons.md when you need a concrete script shape for classic FEniCS or DOLFINx. - Read
references/petsc-solver-playbook.md when choosing linear, nonlinear, or block solver settings. - Read
references/mixed-problems-and-output.md when working with mixed spaces, XDMF, or post-processing. - Read
references/cluster-execution-playbook.md when staging a FEniCS or DOLFINx script for scheduler-backed cluster execution. - Read
references/boundary-io-and-errors.md when repairing runtime failures or resolving IO issues.
Work sequence
- 1. Choose one stack and stay consistent:
- classic FEniCS:
fenics or
dolfin
- modern stack:
dolfinx
- 2. Translate the PDE into the correct weak form before writing code.
- Match unknown type and space:
- scalar field -> scalar space
- vector field -> vector space
- mixed formulation -> mixed space with explicit subspace handling
- 4. For linear problems, use
TrialFunction and TestFunction. - For nonlinear problems, use a
Function for the unknown and solve a residual form. - Write outputs in a format the expected post-processor can open, usually XDMF for mesh-coupled fields.
Guardrails
- - Do not mix classic FEniCS imports with DOLFINx APIs in one script.
- Do not use
TrialFunction for a nonlinear unknown. - Do not guess a boundary condition if the PDE is under-constrained; say what is missing.
- Do not ignore shape and rank mismatches in UFL expressions.
Additional References
Load these on demand:
- -
references/gmsh-meshtags-and-refinement.md for imported meshes, physical groups, markers, and refinement transfer - INLINECODE18 for XDMF, VTK, VTX, and visualization-safe output
- INLINECODE19 for ownership, boundary marking, and parallel consistency
- INLINECODE20 for function-space, boundary-condition, and writer-selection matrices
- INLINECODE21 for MPI launch, environment pinning, and cluster-side IO planning
Reusable Templates
Use assets/templates/ when a concrete script scaffold is needed, especially:
- - INLINECODE23
- INLINECODE24
- INLINECODE25
Outputs
Report:
- - chosen stack and version family if known
- PDE form and space selection
- boundary conditions applied
- expected output files
- the exact failure class if the script is being repaired
HPC FEniCS
将FEniCS视为一个包含两大技术栈的家族:经典FEniCS和DOLFINx。
开始
- 1. 首先阅读 references/runtime-selection.md。
- 处理DOLFINx边界条件时,阅读 references/dolfinx-boundary-workflow.md。
- 翻译偏微分方程、选择空间或构建形式时,阅读 references/ufl-and-solver-patterns.md。
- 将常见PDE类别映射到已知公式模式时,阅读 references/pde-template-cookbook.md。
- 构建瞬态或非线性求解器时,阅读 references/time-dependent-and-nonlinear-patterns.md。
- 需要经典FEniCS或DOLFINx的具体脚本模板时,阅读 references/implementation-skeletons.md。
- 选择线性、非线性或块求解器设置时,阅读 references/petsc-solver-playbook.md。
- 处理混合空间、XDMF或后处理时,阅读 references/mixed-problems-and-output.md。
- 为调度器支持的集群执行准备FEniCS或DOLFINx脚本时,阅读 references/cluster-execution-playbook.md。
- 修复运行时故障或解决IO问题时,阅读 references/boundary-io-and-errors.md。
工作流程
- 1. 选择一个技术栈并保持一致:
- 经典FEniCS:fenics 或 dolfin
- 现代技术栈:dolfinx
- 2. 在编写代码前,将PDE转换为正确的弱形式。
- 匹配未知量类型和空间:
- 标量场 -> 标量空间
- 向量场 -> 向量空间
- 混合公式 -> 具有显式子空间处理的混合空间
- 4. 对于线性问题,使用 TrialFunction 和 TestFunction。
- 对于非线性问题,使用 Function 作为未知量并求解残差形式。
- 以预期后处理器可打开的格式写入输出,通常网格耦合场使用XDMF格式。
约束规则
- - 不要在一个脚本中混合使用经典FEniCS导入和DOLFINx API。
- 不要对非线性未知量使用 TrialFunction。
- 如果PDE欠约束,不要猜测边界条件;应说明缺失的内容。
- 不要忽略UFL表达式中的形状和秩不匹配问题。
附加参考
按需加载以下内容:
- - references/gmsh-meshtags-and-refinement.md:用于导入网格、物理组、标记和细化传递
- references/io-visualization-and-writers.md:用于XDMF、VTK、VTX和可视化安全的输出
- references/parallel-and-mpi-caveats.md:用于所有权、边界标记和并行一致性
- references/space-boundary-output-matrix.md:用于函数空间、边界条件和写入器选择矩阵
- references/cluster-execution-playbook.md:用于MPI启动、环境锁定和集群端IO规划
可复用模板
当需要具体脚本框架时,使用 assets/templates/,特别是:
- - poissondolfinx.py
- transientdiffusion_dolfinx.py
- fenics-dolfinx-slurm.sh
输出
报告以下内容:
- - 所选技术栈及版本系列(如已知)
- PDE形式和空间选择
- 应用的边界条件
- 预期的输出文件
- 如果正在修复脚本,报告确切的故障类别