CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Cells at the intersection between a plane and a patch (https://www.cfd-online.com/Forums/openfoam-programming-development/144648-cells-intersection-between-plane-patch.html)

dmoroian November 18, 2014 14:41

Cells at the intersection between a plane and a patch
 
Hello,
I would like to be able to access the cells at the intersection between a plane and a boundary. The snippet I'm trying is:
Code:

word patchName = "surf_wall_exterior_wind_shield";
label patchID = mesh.boundaryMesh().findPatchID(patchName);
const fvPatch& cPatch = mesh.boundary()[patchID];
const labelList& patchCells = cPatch.faceCells();
...
const point p0(2.099,-0.714,1.099);
const point p1(2.050,-0.741,1.182);
const point p2(2.768,-0.572,1.474);
plane pl1(p0,(p1-p0)^(p2-p0));
 
cuttingPlane cutPlane(pl1,mesh,true);
const labelList& cutCells = cutPlane.cutCells();
label found = 0;
 
forAll(cutCells,cellI)//loop over the cells intersecting the plane
{
  forAll(patchCells, pCelli)//loop over the cells adjacent to a patch
  {
      if(pCelli == cellI)
      {
          alpha1[cellI] = 0.0;
          found++;
      }
    }
}

But it seems that I don't put the zeros where I actually want. Is there anyone that can identify the error?

Thanks,
Dragos

dmoroian November 19, 2014 14:13

Ok, I think the error is in the usage of the index. I will test if this is the right way:
Code:

word patchName = "surf_wall_exterior_wind_shield";
label patchID = mesh.boundaryMesh().findPatchID(patchName);
const fvPatch& cPatch = mesh.boundary()[patchID];
const labelList& patchCells = cPatch.faceCells();
...
const point p0(2.099,-0.714,1.099);
const point p1(2.050,-0.741,1.182);
const point p2(2.768,-0.572,1.474);
plane pl1(p0,(p1-p0)^(p2-p0));
 
cuttingPlane cutPlane(pl1,mesh,true);
const labelList& cutCells = cutPlane.cutCells();
label found = 0;
 
forAll(cutCells,cellI)//loop over the cells intersecting the plane
{
  forAll(patchCells, pCelli)//loop over the cells adjacent to a patch
  {
      if(patchCells[pCelli] == cutCells[cellI])
      {
          alpha1[cutCells[cellI]] = 0.0;
          found++;
      }
    }
}

Update: tested and it works as supposed to!


All times are GMT -4. The time now is 11:18.