forAllConstIter(labelHashSet, patchSet, iter)
    {
        const polyPatch& patch = bdry[iter.key()];

        const vectorField::subField fc = patch.faceCentres();
        
        forAll(fc, patchFaceI)
        {
            changedFaces[nPatchFaces] = patch.start() + patchFaceI;

            faceDist[nPatchFaces] = wallPoint(fc[patchFaceI], 0);

            nPatchFaces++;
        }
void TriangularMaze::initialize() {
  UINT r,c;
  for(r = 0; r < m_horizontalWall.getRowCount(); r++) {
    for(c = 0; c < m_horizontalWall.getColumnCount(); c++) {
      m_horizontalWall(r,c) = MazeWall(wallPoint(r,c),wallPoint(r,c+1));
    }
  }
  for(r = 0; r < m_verticalWall.getRowCount(); r++) {
    for(c = 0; c < m_verticalWall.getColumnCount(); c+=2) {
      m_verticalWall(r,c) = MazeWall(wallPoint(r,c/2),wallPoint(r+1,c/2));
    }
    int m1 = (r % 2 == 0) ? -1 :  1;
    for(c = 1; c < m_verticalWall.getColumnCount(); c+=2) {
      m_verticalWall(r,c) = MazeWall(wallPoint(r+1,(c+m1)/2),wallPoint(r,(c-m1)/2));
    }
  }

  reduceWallMatrix1(m_horizontalWall);
  reduceWallMatrix1(m_verticalWall);

  for(r = 0; r < m_cell.getRowCount(); r++) {
    for(c = 0; c < m_cell.getColumnCount(); c++) {
      MazeCell  &cell = m_cell(r, c);
      WallArray &wa   = cell.getWalls();
      int        wc   = 0;

      if(r % 2 == 0) {
        if(c % 2 == 0) {
          ADDWALL(m_horizontalWall,r  , c/2    );
          ADDWALL(m_verticalWall  ,r  , c+1    );
          ADDWALL(m_verticalWall  ,r  , c      );
        } else {
          ADDWALL(m_horizontalWall,r+1, (c-1)/2);
          ADDWALL(m_verticalWall  ,r  , c      );
          ADDWALL(m_verticalWall  ,r  , c+1    );
        }
      } else {
        if(c % 2 == 0) {
          ADDWALL(m_horizontalWall,r+1, (c+1)/2);
          ADDWALL(m_verticalWall  ,r  , c      );
          ADDWALL(m_verticalWall  ,r  , c+1    );
        } else {
          ADDWALL(m_horizontalWall,r  , (c-1)/2);
          ADDWALL(m_verticalWall  ,r  ,  c+1   );
          ADDWALL(m_verticalWall  ,r  ,  c     );
        }
      }
    }
  }
  reduceCellMatrix();
  reduceWalls();
  initStartEnd();
  if(isOk()) {
    removeWalls();
  }
}
void HexMaze::initialize() {
  UINT r,c;
  for(r = 0; r < m_horizontalWall.getRowCount(); r++) {
    for(c = 0; c < m_horizontalWall.getColumnCount(); c++) {
      m_horizontalWall(r,c) = MazeWall(wallPoint(r,c),wallPoint(r,c+1));
    }
  }
  for(r = 0; r < m_verticalWall1.getRowCount(); r++)  {
    for(c = 0; c < m_verticalWall1.getColumnCount(); c++) {
      m_verticalWall1(r,c) = MazeWall(wallPoint(2*r,2*c),wallPoint(2*r+1,2*c));
    }
  }
  for(r = 0; r < m_verticalWall2.getRowCount(); r++) {
    for(c = 0; c < m_verticalWall2.getColumnCount(); c++) {
      m_verticalWall2(r,c) = MazeWall(wallPoint(2*r+1,2*c+1),wallPoint(2*r+2,2*c+1));
    }
  }

  reduceWallMatrix1(m_horizontalWall);
  reduceWallMatrix1(m_verticalWall1);
  reduceWallMatrix1(m_verticalWall2);

  for(r = 0; r < m_cell.getRowCount(); r++) {
    for(c = 0; c < m_cell.getColumnCount(); c++) {
      MazeCell  &cell = m_cell(r,c);
      WallArray &wa   = cell.getWalls();
      int        wc   = 0;

      if(r % 2 == 0) {
        ADDWALL(m_horizontalWall,r  ,2*c  );
        ADDWALL(m_horizontalWall,r  ,2*c+1);
        ADDWALL(m_verticalWall1 ,r/2,c+1  );
        ADDWALL(m_horizontalWall,r+1,2*c+1);
        ADDWALL(m_horizontalWall,r+1,2*c  );
        ADDWALL(m_verticalWall1 ,r/2,c    );
      } else {
        ADDWALL(m_horizontalWall,r  ,2*c-1);
        ADDWALL(m_horizontalWall,r  ,2*c  );
        ADDWALL(m_verticalWall2 ,r/2,c    );
        ADDWALL(m_horizontalWall,r+1,2*c  );
        ADDWALL(m_horizontalWall,r+1,2*c-1);
        ADDWALL(m_verticalWall2 ,r/2,c-1  );
      }
    }
  }
  reduceCellMatrix();
  reduceWalls();
  initStartEnd();
  if (isOk()) {
    removeWalls();
  }
}
void Foam::inverseFaceDistanceDiffusivity::correct()
{
    const polyMesh& mesh = mSolver().mesh();
    const polyBoundaryMesh& bdry = mesh.boundaryMesh();

    labelHashSet patchSet(bdry.size());

    label nPatchFaces = 0;

    forAll(patchNames_, i)
    {
        const label pID = bdry.findPatchID(patchNames_[i]);

        if (pID > -1)
        {
            patchSet.insert(pID);
            nPatchFaces += bdry[pID].size();
        }
    }

    List<wallPoint> faceDist(nPatchFaces);
    labelList changedFaces(nPatchFaces);

    nPatchFaces = 0;

    forAllConstIter(labelHashSet, patchSet, iter)
    {
        const polyPatch& patch = bdry[iter.key()];

        const vectorField::subField fc(patch.faceCentres());

        forAll(fc, patchFaceI)
        {
            changedFaces[nPatchFaces] = patch.start() + patchFaceI;

            faceDist[nPatchFaces] = wallPoint(fc[patchFaceI], 0);

            nPatchFaces++;
        }
    }