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

A silly question about scalar

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By su_junwei
  • 2 Post By mattijs
  • 1 Post By su_junwei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 28, 2008, 01:27
Default Dear everyone I made a simp
  #1
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Dear everyone

I made a simple test about the class scalar, the code
are listed below


#include "IOstreams.H"
#include "scalar.H"
using namespace Foam;
int main()
{
scalar s=10;
scalar ss=exp(s);
#ifdef DP
Info<<ss<<endl;
#endif
}


but the compiler always complained with message below
test.C:87: error: call of overloaded 'exp(Foam::scalar&)' is ambiguous
/usr/include/bits/mathcalls.h:101: note: candidates are: double exp(double)
/home/sujunwei/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/Scalar.H:179: note: Foam::doubleScalar Foam::exp(Foam::doubleScalar)
/home/sujunwei/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/Scalar.H:179: note: Foam::floatScalar Foam::exp(Foam::floatScalar)

anything wrong ?
but code with
scalar ss=expf(s);
it passed !

it seems that the function macro

#define transFunc(func) \
inline Scalar func(const Scalar s) \
{ \
return ::func##f(s); \
}

in floatScalar.H was activated by default ?

compilation with double precision is default in OpenFOAM ?
Democritus likes this.
su_junwei is offline   Reply With Quote

Old   April 28, 2008, 04:59
Default Modify your code to make sure
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Modify your code to make sure you select the Foam one:

scalar ss=Foam::exp(s);
elmo555 and Democritus like this.
mattijs is offline   Reply With Quote

Old   April 28, 2008, 06:02
Default Thank you!
  #3
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Thank you!
Democritus likes this.
su_junwei 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
Question about scalar transport osimonsimon OpenFOAM Running, Solving & CFD 33 August 21, 2020 11:45
User Defined Scalar (UDS) question (units) D FLUENT 0 March 1, 2006 21:04
Scalar problem Dougal McQueen CFX 0 November 21, 2003 08:23
scalar ? pr Main CFD Forum 2 September 1, 2003 01:26
user scalar zhu CFX 0 May 22, 2002 01:38


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