CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Access cell volume from boundry condition (https://www.cfd-online.com/Forums/openfoam-programming-development/85797-access-cell-volume-boundry-condition.html)

JimKnopf March 7, 2011 09:48

Access cell volume from boundry condition
 
Hej there!

I'm struggling with a probably little problem. I want to access the volume of the first cell normal to a boundry from within the boundry condition.

For example like rho*CellVolume for mass of the first cell normal to a boundary.

Probably it's just one line of code, but I don't get, since I'm quite new to OpenFoam programming.

Thanks and greetings
Jim

cliffoi March 7, 2011 11:33

The functionality isn't directly available (at least not in the older versions of OF). Maybe theres a better way in OF-1.6 or newer, but this should do the trick.
From with xxxFvPatchField<type>::someFunc()

const fvPatchScalarField& rhop = patch().lookupPatchField<volScalarField, scalar>("rho");
const scalarField& V = patch().boundaryMesh().mesh().V();
const unallocLabelList& faceCells = this->patch().faceCells();

scalarField rhoVp(this->size());

forAll(faceCells, faceI)
{
rhoVp[faceI] = rhop[faceI]*V[faceCells[faceI]];
}

JimKnopf March 10, 2011 04:29

Thanks! It did the job.


All times are GMT -4. The time now is 14:13.