# Sum over non-boundary cells

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 June 6, 2012, 09:11 Sum over non-boundary cells #1 New Member   Martin Söder Join Date: Jun 2011 Posts: 8 Rep Power: 8 Sponsored Links 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

June 8, 2012, 08:03
#2
Senior Member

Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 801
Rep Power: 21
Quote:
 Originally Posted by Soder 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.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post vishwa OpenFOAM Native Meshers: snappyHexMesh and Others 24 June 27, 2016 08:54 xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33 kyle OpenFOAM Running, Solving & CFD 4 January 4, 2011 12:17 FredPacheo FLUENT 5 September 5, 2008 05:45 Mark CFX 6 November 15, 2004 16:55