用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/SWMFsoftware/FLEKS --skill add-new-source命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | add-new-source |
| description | Create new compiled .cpp/.h files or selectable FLEKS user source templates following project conventions |
This skill creates new source files following FLEKS conventions.
| File Type | Directory |
|---|---|
Headers (.h) | include/ |
Implementation (.cpp) | src/ |
| Interface code | srcInterface/ |
| Selectable user source templates | userfiles/*Source.h |
| Active generated user source | include/UserSource.h |
include/UserSource.h is the selected local copy used by Domain.cpp. Add
reusable user source implementations under userfiles/ and select them with
./Config.pl -u=<Name> instead of editing include/UserSource.h directly.
PascalCase (e.g., FluidInterface.cpp, GridUtility.h)PascalCase (e.g., class FluidInterface)snake_case (e.g., void apply_float_boundary())camelCase (e.g., int nCellPerPatch)camelCase (e.g., bool doRestart)Create include/NewFeature.h:
#ifndef _NEWFEATURE_H_
#define _NEWFEATURE_H_
// Standard headers
#include <memory>
#include <vector>
// AMReX headers
#include <AMReX.H>
// User headers
#include "Utility.h"
class NewFeature {
public:
NewFeature() = default;
~NewFeature() = default;
// Public methods
void initialize();
void do_something();
// Getters (use const)
int get_value() const { return value; }
private:
// Member variables (camelCase, matching project style)
int value = 0;
};
#endif // _NEWFEATURE_H_
Create src/NewFeature.cpp:
#include "NewFeature.h"
// Standard headers
#include <iostream>
// AMReX headers (can use 'using namespace amrex' in .cpp only)
using namespace amrex;
void NewFeature::initialize() {
// Implementation
}
void NewFeature::do_something() {
// Implementation
}
Create include/NewFeature.h with the template above. Ensure proper
include guards (#ifndef _NEWFEATURE_H_).
Create src/NewFeature.cpp with the template above.
Important: Add the new .cpp file to the SRCS variable in
src/Makefile. The source list starts at line 5:
SRCS := \
Domain.cpp \
...
FleksDistributionMap.cpp \
NewFeature.cpp # <-- add here
This is required — files in src/ are NOT auto-discovered.
make LIB -j8
This happens automatically with the build, but you can force it:
make compile_commands
Use this workflow when adding a selectable source-term implementation for
#SOURCE, not a normal compiled .cpp file.
Create userfiles/NewSource.h. The filename must end in Source.h; the
selection name is the prefix before Source.h (New in this example).
#ifndef _NEWSOURCE_H_
#define _NEWSOURCE_H_
#include "SourceInterface.h"
class UserSource : public SourceInterface {
public:
UserSource(const FluidInterface& other, int id, std::string tag,
FluidType typeIn = SourceFluid)
: SourceInterface(other, id, tag, typeIn) {
info = "New Source";
}
};
#endif
For sources that depend on fluid fields, set useFluidSource = true in the
constructor and override set_source(const FluidInterface& other). Override
sum_to_single_source() only when the source needs post-processing before
particle injection (e.g., region-split mode with _PT_COMPONENT_).
List available templates:
./Config.pl -u
Select one template:
./Config.pl -u=New
This copies userfiles/NewSource.h to include/UserSource.h. A plain install
seeds include/UserSource.h from userfiles/DefaultSource.h when no selected
copy exists.
Set #SOURCE in PARAM.in when the source should be active:
#SOURCE
T useSource
PT builds enable source use by default unless #SOURCE sets it to false.
Always order includes as:
// 1. Standard library headers
#include <algorithm>
#include <memory>
#include <vector>
// 2. AMReX headers
#include <AMReX.H>
#include <AMReX_MultiFab.H>
// 3. Project headers
#include "Grid.h"
#include "Utility.h"
nullptr instead of NULLunique_ptr, shared_ptr) for ownershipconst wherever possibleusing namespace in header files.clang-format)If your new class needs to work with existing code:
Grid.h, Domain.h)Grid — for classes that need AMR grid access (inherits AmrCore)FluidInterface — for fluid coupling dataSourceInterface — for source terms#ifndef _FILENAME_H_)PascalCaseusing namespace in headerconst used where applicableSRCS in src/Makefilecompile_commands.json updateduserfiles/*Source.h./Config.pl -u lists any new user source optionPARAM.XML documents any new parameter needed by the source