CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

How to convert boundaryField into "double" floating point?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 14, 2018, 21:05
Question How to convert boundaryField into "double" floating point?
  #1
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 48
Rep Power: 8
yhy20081016 is on a distinguished road
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<double>&, Foam::fvPatchField<double>&)’
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<double>’ to ‘double’

So what is the solution? Thank you very much.
yhy20081016 is offline   Reply With Quote

Old   April 17, 2018, 00:34
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Maryland, United States
Posts: 110
Rep Power: 9
adhiraj is on a distinguished road
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);
    }
}
adhiraj is offline   Reply With Quote

Old   April 17, 2018, 20:21
Default
  #3
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 48
Rep Power: 8
yhy20081016 is on a distinguished road
Quote:
Originally Posted by adhiraj View Post
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.
yhy20081016 is offline   Reply With Quote

Reply

Tags
boundaryfield, rhocentralfoam

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define to right point for locationInMesh Mirage12 OpenFOAM Native Meshers: snappyHexMesh and Others 7 March 13, 2016 14:07
simpleFoam Floating point error (Core Dumped) sam.ho OpenFOAM Running, Solving & CFD 2 December 31, 2013 06:57
snappyHexMesh and cyclic boundaries Ruli OpenFOAM Meshing & Mesh Conversion 2 December 9, 2013 06:51
pimpleDyMFoam constantly giving floating point exception and solution divergence fedvasu OpenFOAM Running, Solving & CFD 0 November 28, 2013 00:53
determining displacement for added points CFDnewbie147 OpenFOAM Native Meshers: snappyHexMesh and Others 1 October 22, 2013 09:53


All times are GMT -4. The time now is 04:42.