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 Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 14, 2018, 22:05
Question How to convert boundaryField into "double" floating point?
  #1
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 48
Rep Power: 14
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, 01:34
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
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, 21:21
Default
  #3
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 48
Rep Power: 14
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


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 Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 17:20.