List<vector> a = (n,vector::zero)
vector a(vector::zero)
#include"Tuple2.H"
List<Tuple2<label, List<scalar>>> complexData(100);
forAll(complexData, i)
{
complexData[i].first() = rndGen.integer(0, Pstream::nProcs()-1);
complexData[i].second().setSize(3);
complexData[i].second()[0] = 1;
complexData[i].second()[1] = 2;
complexData[i].second()[2] = 3;
}
pos
和neg
函数:v = a, if x < b
v = c if x > b
// can be coded as
volScalarField v = neg(x - b)*a + pos(x-b)*c;
Sout
或者Pout
输出全部数据dictionary
中读取vector
和scalar
不同:vector U1(dict.lookup("U1"));
scalar r1(readScalar(dict.loocup("r1")));
对于label
读取没有专门函数,可以以scalar
类型读取后进行强制类型转换;
对于并计算:
Foam::gSum(a)
可以获取不同进程中场a的加和;
Pstream::nProcs()
获取并行的进程数;
Pstream::myProcNo()
获取当前的进程数
对于已经画好的网格需要在某个方向平移,或者放大缩小可以采用transformPoints
操作:
transformPoints -scale "(1 1 0.5)" //z方向网格点缩小0.5倍
transformPoints -translate "(0 0 0.5)" //z方向整体向上平移0.5
const faceList & ff = mesh.faces();
const pointField & pp = mesh.points();
forAll ( mesh.C(), celli)
{
const cell & cc = mesh.cells()[celli];
labelList pLabels(cc.labels(ff));
pointField pLocal(pLabels.size(), vector::zero);
forAll (pLabels, pointi)
pLocal[pointi] = pp[pLabels[pointi]];
}
求解器网站:地址,
注意:运行makeLib.sh(OpenFOAM-x.x.x/FoamFourierAnalysis/fftw-3.3.3/文件夹下configure加执行权限)。
FatalErrorIn("main.cpp pressure is unregular")
<< abort(FatalError);
system/fvSolution
下PIMPLE子文件中求解循环次数来解决。volScalarField Ux
(
IOobject
(
"Ux",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U.component(vector::X)
);
label patchId = mesh.boundaryMesh().findPatchID("inlet");
if(patchId == -1){
FatalErrorIn("main.cpp the patch name 'in' was not founded")
<< abort(FatalError);
}
const scalarField p_inlet = p.boundaryField()[patchId];
const scalarField area_face_inlet = mesh.magSf().boundaryField()[patchId];
patch
场IOField<vector> cfOut
(
IOobject
(
"cf",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.Cf().boundaryField()[ patchID ]
);
cfOut.write();
rotateMesh “(0 1 0)” “(0 0 1)”
polyMesh/sets/
里边的faceListfoamToVTK -faceSet nonOrthoFaces -time 0