# How to convert boundaryField into "double" floating point?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 14, 2018, 22:05 How to convert boundaryField into "double" floating point? #1 Member   yehanyu Join Date: Mar 2012 Location: Beijing, China Posts: 48 Rep Power: 8 Hello everybody, I am recently working on modifying the compressible solver "rhoCentralFoam". Here I want to retrieve the boundary field of "e" and "p", then substitute them into a user-defined function named "ep_d", then assigned the result to the boundary field "rho". ... p.correctBoundaryConditions(); forAll(rho.boundaryField(),i) { rho.boundaryField()[i] = pp.ep_d(e.boundaryField()[i], p.boundaryField()[i]); } runTime.write(); ... However I got a compilation error: nistCentralFoam.C: In function ‘int main(int, char**)’: nistCentralFoam.C:248:85: error: no matching function for call to ‘phys_property::ep_d(Foam::fvPatchField&, Foam::fvPatchField&)’ rho.boundaryField()[i] = pp.ep_d(e.boundaryField()[i], p.boundaryField()[i]); ^ In file included from nistCentralFoam.C:46:0: property.H:248:6: note: candidate: double phys_property::ep_d(double, double) REAL phys_property::ep_d(REAL e, REAL p) ^ property.H:248:6: note: no known conversion for argument 1 from ‘Foam::fvPatchField’ to ‘double’ So what is the solution? Thank you very much.

 April 17, 2018, 01:34 #2 Senior Member   Adhiraj Join Date: Sep 2010 Location: Maryland, United States Posts: 112 Rep Power: 10 Will this work: Code: ```forAll(rho.boundaryField(), patchI) { fvPatchScalarField& rhoPatch = rho.boundaryField()[patchI]; fvPatchScalarField& ePatch = e.boundaryField()[patchI]; fvPatchScalarField& pPatch = p.boundaryField()[patchI]; forAll(pPatch, faceI) { const scalar ei = ePatch[faceI]; const scalar pi = pPatch[faceI]; rhoPatch[faceI] = pp.ep_d(ei, pi); } }```

April 17, 2018, 21:21
#3
Member

yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 48
Rep Power: 8
Quote:
 Originally Posted by adhiraj Will this work: Code: ```forAll(rho.boundaryField(), patchI) { fvPatchScalarField& rhoPatch = rho.boundaryField()[patchI]; fvPatchScalarField& ePatch = e.boundaryField()[patchI]; fvPatchScalarField& pPatch = p.boundaryField()[patchI]; forAll(pPatch, faceI) { const scalar ei = ePatch[faceI]; const scalar pi = pPatch[faceI]; rhoPatch[faceI] = pp.ep_d(ei, pi); } }```
Yes, it works. Thank you.

 Tags boundaryfield, rhocentralfoam