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

floor function problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2014, 16:34
Default floor function problem
  #1
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Hi,

Trying to implement the following code snippet in a Ueqns routine:

Code:
volScalarField Ad
   (
        "Ad",
        floor( min( scalar(1.0), mag(Ua)/limitV ) )
    );
and I get the following error at compile,

Code:
UEqns.H:9:48: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ for argument ‘1’ to ‘double floor(double)’
The expression min( scalar(1.0), mag(Ua)/limitV ) compiles properly but it is refused by floor() which expects a double. I would have expected it to be converted automatically but it is not the case. Using the float version floorf() returns the same error with float instead of double.

Any ideas how it can be fixed?

Thanks
ziad is offline   Reply With Quote

Old   May 24, 2014, 19:34
Default
  #2
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Posting the solution just in case it comes in handy for someone else.

It seems floor() does not map over an entire array like min() does. The following modification compiled without any problems. Still have to test the code to see if I get the correct anticipated result.

Code:
volScalarField Ad
(
   "Ad",
   //floor( min( scalar(1.0), mag(Ua)/limitV ) )
   min( scalar(1.0), mag(Ua)/limitV )
 );

 forAll ( mesh.C(), celli )
 {
    Ad[celli] = floor( Ad[celli] );
 }
ziad is offline   Reply With Quote

Reply


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
UDF compiling problem Wouter Fluent UDF and Scheme Programming 6 June 6, 2012 05:43
Gambit - meshing over airfoil wrapping (?) problem JFDC FLUENT 1 July 11, 2011 06:59
natural convection problem for a CHT problem Se-Hee CFX 2 June 10, 2007 07:29
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 20:13
Is this problem well posed? Thomas P. Abraham Main CFD Forum 5 September 8, 1999 15:52


All times are GMT -4. The time now is 06:40.