CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   snappyHexMesh: cell lower corner instead of cell centre (

andrea.pasquali February 5, 2013 12:03

snappyHexMesh: cell lower corner instead of cell centre
Hi all,

I would like to change the criterion that snappyHexMesh uses to keep cells into the domain during the refinement stage (cast). I would like to keep in the domain all the cells that have not the cell centre but the cell lower corner into the domain.
I am trying to modify the code in the file "src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C". At line 75 there is the cell centres vector definition:

const pointField& cellCentres = mesh_.cellCentres();
I would like to obtain the cell lower corner vector as follows:

forAll(mesh_.points(), nodeI)
forAll(mesh_.cellPoints(), cellI)
if (mesh_.cellPoints()[cellI][0] == nodeI)
Info << mesh_.points()[nodeI] << endl; // this is right
const vector& cellLowerCorners = mesh_.points()[nodeI];
My problem is that the vector "cellLowerCorners" that I am trying to write "works" just inside the if statments. I am not able to append the values to the vector each iteration of the "for" loop.
I think I am not writing/initializing the vector correctly. Does anyone have any suggesstion?

Thanks in advance


andrea.pasquali February 7, 2013 09:07

Hi All,

I solved the problem using a Dynamic Vector. This is fine and I have all the cell-lower-corner in a vector.
If I am understanding correctly, OpenFOAM selects the cells that have to be deleted according to an index defined in cellRegion:

    regionSplit cellRegion(mesh_);

    DynamicList<label> cellsToRemove(mesh_.nCells());
    forAll(cellRegion, cellI)
        if (cellRegion[cellI] != regionI)

I guess this index is 0 when the cell-centre is in the keepPoint region and 1 when outside.
I would like to change this: no cell-centre criterion but cell-lower-corner.
Does anyone know which is the file I have to look for?

Thanks for any help


andrea.pasquali February 7, 2013 11:53

Now I am able to change the vector:

with a new vector where I have only the cells with the lover corner into the stl. I called it:

But I got problem some lines below:

    labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemoveLowerCorner));

    if (exposedFaces.size())
            "meshRefinement::splitMeshRegions(const point&)"
        )  << "Removing non-reachable cells should only expose boundary faces"
            << nl
            << "ExposedFaces:" << exposedFaces << abort(FatalError);

The error I got when I run snappyHexMesh is:

Removing non-reachable cells should only expose boundary faces
ExposedFaces:8(475 477 479 481 483 485 487 488)

From function meshRefinement::splitMeshRegions(const point&)
in file autoHexMesh/meshRefinement/meshRefinement.C at line 1970.

FOAM aborting
Why now changing only the "cellsToRemove" vector I have these ExposedFaces while not before?


andrea.pasquali February 11, 2013 07:21

Hi All,
finally I have it.
I changed the "edge" definition into meshRefinement.C file

andrea.pasquali February 11, 2013 07:22

Hi All,
finally I have it. I changed the "edge" definition into the meshRefinement.C file


All times are GMT -4. The time now is 04:43.