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/)
-   -   How to creat a new volScalarField? (https://www.cfd-online.com/Forums/openfoam-programming-development/186947-how-creat-new-volscalarfield.html)

SH_Zhong April 25, 2017 10:01

How to creat a new volScalarField?
 
Hello foamers,

I want to create a volScalarField about the sensibly enthalpy of one specie based on
virtual scalar Hs
(
const label speciei,
const scalar p,
const scalar T
) const = 0;
OK, the return type is scalar,
So I try to make scalar into a volScalarField.
First,
forAll(Hsi,celli)
{
Hsi[celli] = composition.Hs(i, p[celli], T[celli]);
}
It works fine. And for the boundaryField,
volScalarField::Boundary& pBf = p.boundaryFieldRef();
volScalarField::Boundary& TBf = T.boundaryFieldRef();
volScalarField::Boundary& HsiBf = Hsi.boundaryFieldRef();

forAll(Hsi.boundaryField(), patchi)
{
fvPatchScalarField& TPatch = pBf.boundaryFieldRef()[patchi];
fvPatchScalarField& pPatch = TBf.boundaryFieldRef()[patchi];
fvPatchScalarField& HsiPatch = HsiBf.boundaryFieldRef()[patchi];

forAll(HsiPatch,facei)
{
HsiPatch[facei] = composition.Hs(i, pPatch[facei], TPatch[facei]);
}
}
I get a lot of probelms.
YEqn.H: In function ‘int main(int, char**)’:
YEqn.H:54:65: error: passing ‘const volScalarField {aka const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ as ‘this’ argument of ‘Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary& Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryFieldRef() [with Type = double; PatchField = Foam::fvPatchField; GeoMesh = Foam::volMesh]’ discards qualifiers [-fpermissive]
volScalarField::Boundary& TBf = T.boundaryFieldRef();
^
YEqn.H:59:48: error: ‘class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary’ has no member named ‘boundaryFieldRef’
fvPatchScalarField& TPatch = pBf.boundaryFieldRef()[patchi];
^
YEqn.H:60:48: error: ‘class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary’ has no member named ‘boundaryFieldRef’
fvPatchScalarField& pPatch = TBf.boundaryFieldRef()[patchi];
^
YEqn.H:61:52: error: ‘class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::Boundary’ has no member named ‘boundaryFieldRef’
fvPatchScalarField& HsiPatch = HsiBf.boundaryFieldRef()[patchi];
^
make: *** [Make/linux64GccDPInt64Opt/reactingPolynomialDi.o] Error 1
Any advice will be appreciated!
Zhong


All times are GMT -4. The time now is 19:53.