编写代码的过程中如果能约定变量命名的规则,那么可以极大地提高代码的可读性。OpenFOAM中也有一些规则,下面是笔者总结的一些常见规则,如果能掌握这些规则,那么看见变量名之后可以快速知晓其类型
const GeometricField<Type, fvPatchField, volMesh>& vf;
const Field<Type>& vfi = vf;
const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf;
const Field<Type>& issf = ssf;
tmp<GeometricField<RetType, fvsPatchField, surfaceMesh>> tsf
(
GeometricField<RetType, fvsPatchField, surfaceMesh>::New
(//新建一个场
"tmp field",
mesh,
dimless;
)
);
const fvMesh& mesh = ssf.mesh();//获取网格
forAll(mesh.boundary(), patchi){//对每个patch遍历,注:往往边界是由若干个patch组成的
//do something
};