tilasoldo |
July 13, 2017 09:21 |
scalarCodedSource and cellZones in OF 4.x
Hi everyone,
I am currently setting up a case with a time-varying volumetric energy source in OpenFOAM 4.x; I use scalarCodedSource fvOptions to achieve that, and after some research (in particular here…), I have managed to write this fvOptions file :
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
heatSource
{
type scalarCodedSource;
active true;
name sourceTime;
scalarCodedSourceCoeffs
{
selectionMode cellSet;
cellSet heaterCellSet;
fields (e);
codeInclude
#{
#};
codeCorrect
#{
Pout<< "**codeCorrect**" << endl;
#};
codeAddSup
#{
const Time& time = mesh().time();
const scalarField& V = mesh_.V();
scalarField& heSource = eqn.source();
const labelList& cellIDs = cells();
forAll(cellIDs, i)
{
label cellI = cellIDs[i];
heSource[cellI] -= 0.0001*sqr(time.value())*V[cellI];
}
#};
codeSetValue
#{
Pout<< "**codeSetValue**" << endl;
#};
// Dummy entry. Make dependent on above to trigger recompilation
code
#{
$codeInclude
$codeCorrect
$codeAddSup
$codeSetValue
#};
}
sourceTimeCoeffs
{
$scalarCodedSourceCoeffs;
}
}
// ************************************************************************* //
Source term indeed needs to be applied only on cellSet cells, as does
Code:
const labelList& cellIDs = cells();
.
However, I get the following error :
Code:
.../fvOptions.heatSource.scalarCodedSourceCoeffs:45:40: error: use of undeclared identifier 'cells'
, even if I found this solution in the OpenFOAM issue tracker (!) for version 4.1. Am I doing this right? Do I miss an include?
I also tried to replace cells() by mesh_.cells(), which does not work any better since it returns a cellList instead of a labelList.
If anyone knows about this please share it with me :)
Regards,
X. Lamboley
|