CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Sum over non-boundary cells (http://www.cfd-online.com/Forums/openfoam-post-processing/102923-sum-over-non-boundary-cells.html)

Soder June 6, 2012 09:11

Sum over non-boundary cells
 
Hi,
I would like to make a post-process skript where I sum only non-boundary cell values. Does anyone know how this can be done?


Example mass (pseudo-code)

forAll(mesh.V(), celli)
{
if cell != boundaryCell
{
mass = (mesh.V()[celli]*rho[celli]);forAll(mesh.V(), celli)
massSum += mass;
}
}

best regards
Martin Soder

olesen June 8, 2012 08:03

Quote:

Originally Posted by Soder (Post 365029)
Hi,
I would like to make a post-process skript where I sum only non-boundary cell values. Does anyone know how this can be done?


Example mass (pseudo-code)

forAll(mesh.V(), celli)
{
if cell != boundaryCell
{
mass = (mesh.V()[celli]*rho[celli]);forAll(mesh.V(), celli)
massSum += mass;
}
}

best regards
Martin Soder

Just an idea (no code):

Create a list of bools for each cell of your mesh and mark each with "true", for example,
Code:


PackedBoolList isInterior(mesh.nCells(), true);


Loop over the boundary faces, marking the cell owner (which is a boundary cell) as being non-interior:
Code:

const labelUList& owner = mesh.faceOwner();
for (label faceI=mesh.nInternalFaces(); faceI < mesh.nFaces(); ++faceI)
{
    isInterior.unset(owner[faceI]);
    //OR isInterior.set(owner[faceI], false);
}

The cells in isInterior that are still 'true' must be your interior cells.
The easiest is probably to use this as a mask when iterating over all cells:
Code:

forAll(mesh.V(), cellI)
{
    if (isInterior[cellI])
    {
    ...
    }
}

There may be a more elegant way, but this should at least get you going.


All times are GMT -4. The time now is 16:49.