openfoam寻找与某一边界相邻的一层网格

基本思路

  • 定位到边界的faceID
  • 在owner中根据faceID选择网格cell
volScalarField post
    (
        IOobject
        (
            "post",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
	mesh,
	dimensionedScalar("0.0",dimensionSet(0,0,0,0,0),0.0)
    );
label patchID = mesh.boundaryMesh().findPatchID("cylinder");
if(patchID == -1){
	FatalErrorIn("can not find patch, please check you patch name")
		<< abort(FatalError);
}
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];

const unallocLabelList& neighbour = mesh.neighbour();
const unallocLabelList& owner = mesh.owner();
forAll(cPatch,faceI){
	label faceId = cPatch.start() + faceI;
	label cellId = owner[faceId];
	post[cellId]=1;
	Info<<"cellId = "<<cellId<<endl;
}
post.write();

你可能感兴趣的:(openfoam,notes)