CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   snappyHexMesh: cell lower corner instead of cell centre (http://www.cfd-online.com/Forums/openfoam-programming-development/112786-snappyhexmesh-cell-lower-corner-instead-cell-centre.html)

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:
Quote:

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

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

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:
Code:

    regionSplit cellRegion(mesh_);

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

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

andrea.pasquali February 7, 2013 11:53

Now I am able to change the vector:
Code:

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

    cellToRemoveLowerCorner
But I got problem some lines below:
Code:

    labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemoveLowerCorner));

    if (exposedFaces.size())
    {
        FatalErrorIn
        (
            "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:
Quote:

--> FOAM FATAL ERROR:
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?

Thanks
Andrea

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

Andrea


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