一键导入
add-tutorial
Scaffold a new tutorial example under fluca/tutorials/. Generates the source file, registers it in CMakeLists.txt, and verifies it builds and runs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a new tutorial example under fluca/tutorials/. Generates the source file, registers it in CMakeLists.txt, and verifies it builds and runs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add a new test file or new test cases to an existing file in Fluca. Handles source generation, CMakeLists.txt registration, golden output capture, and ctest verification.
PETSc coding conventions for Fluca. Use when writing or reviewing C code in this project — covers naming, error handling, memory management, function structure, and the quick checklist.
Reference for DMStag grid layout and FlucaFD finite difference operators. Use when working on spatial discretization, stencils, operator composition, or understanding the collocated grid.
Recapture golden output files for tests whose behavior changed intentionally. Identifies failing tests, regenerates .out files, and verifies all tests pass.
Scaffold a new PETSc-style class (full lifecycle, ops table, package registration, CMake) or add a new subtype (impl data struct, factory function, ops wiring, registration) in Fluca.
| name | add-tutorial |
| description | Scaffold a new tutorial example under fluca/tutorials/. Generates the source file, registers it in CMakeLists.txt, and verifies it builds and runs. |
Scaffold a new tutorial example following Fluca conventions.
Ask the user for:
fd)fluca::* libraries to linkls fluca/tutorials/<module>/ex*.c
#include <flucasys.h>
/* Module headers as needed */
static const char help[] = "<Description>\n"
"Options:\n"
" -<opt> <type> : <desc>\n";
int main(int argc, char **argv)
{
/* Declarations at block top */
PetscCall(FlucaInitialize(&argc, &argv, NULL, help));
/* 1. Parse options
2. Create DM(s)
3. Create and configure objects
4. Solve / compute
5. Output results (ViewFromOptions or PetscPrintf)
6. Destroy in reverse creation order */
PetscCall(FlucaFinalize());
}
Tutorials differ from tests:
/*TEST*/ blocks with run-only semantics (exit code 0 = pass, no golden output files)fluca_parse_tutorial_file() in FlucaTestUtils.cmake, which calls RunTutorial.cmakeSetFromOptions / ViewFromOptions for runtime configurability/*TEST*/ blockAppend a /*TEST ... TEST*/ block at the end of the source file to register tutorial cases with ctest:
/*TEST
test:
suffix: default
nsize: 1
test:
suffix: high_peclet
nsize: 1
args: -gamma 0.01 -flucafd_limiter superbee
TEST*/
Each test: entry supports suffix (required), nsize (ignored), and args (optional). No output_file field — tutorials only check exit code.
Add to TUTORIAL_SRCS in fluca/tutorials/<module>/CMakeLists.txt:
set(TUTORIAL_SRCS
ex1.c
...
ex<N>.c # <-- add here
)
The fluca_parse_tutorial_file() call in the foreach loop automatically picks up the new file.
For a new module, also:
fluca/tutorials/<module>/CMakeLists.txt following the pattern (include FlucaTestUtils and call fluca_parse_tutorial_file)add_subdirectory(<module>) to fluca/tutorials/CMakeLists.txtcmake build # Re-configure to pick up new TEST blocks
cmake --build build # Build
ctest --test-dir build -R "tutorials_<module>" # Run tutorial test cases
/*TEST*/ block with at least one test caseTUTORIAL_SRCS in CMakeLists.txt