codedSource
{
type vectorCodedSource;
selectionMode cellZone;
cellZone BANANA;
fields (U);
name codedSource;
codeAddSup
#{
const label cellZoneID = mesh().cellZones().findZoneID("BANANA"); // find ID for the cellZone "BANANA"
const cellZone& zone = mesh().cellZones()[cellZoneID];
const cellZoneMesh& zoneMesh = zone.zoneMesh();
const labelList& cellsZone = zoneMesh[cellZoneID]; //list of all cellZone cell ID's
const scalarField& V = mesh_.V(); // Cell volume
Foam::Field<Foam::Vector<double> >& USource = eqn.source(); // get source from fvMatrix
//scalarField & Udiag = eqn.diag(); // get diagonal of fvMatrix
const scalarField& rho = mesh().lookupObject<scalarField>("rho"); // get density field
const vector g (0,-9.81,0) // gravitational vector
forAll(cellsZone,i)
{
const label celli = cellsZone[i];
USource[celli] -= rho[celli]*g/V[celli];
}
#};
codeCorrect
#{
Pout<< "**codeCorrect**" << endl;
#};
codeSetValue
#{
Pout<< "**codeSetValue**" << endl;
#};
code
#{
$codeInclude
$codeCorrect
$codeAddSup
$codeSetValue
#};