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

Calculating the cosine of a Foam::scalar field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2011, 08:58
Default Calculating the cosine of a Foam::scalar field
  #1
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15
RoE is on a distinguished road
Hi!

I'm trying to calculate a smoothed Dirac delta function (volScalarField deltaSmooth) from a volScalarField phiLS with the following code:

forAll(deltaSmooth, i)
{
if (mag(phiLS[i])<epsLS.value())
deltaSmooth[i] = (1 + cos(pi*phiLS[i]/epsLS.value()))/(2*epsLS.value());
else
deltaSmooth[i] = 0.0;
}

However, I get the following compilation error:

levelSet.C:88: error: call of overloaded ‘cos(Foam::scalar)’ is ambiguous
/usr/include/bits/mathcalls.h:64: note: candidates are: double cos(double)
/opt/openfoam171/src/OpenFOAM/lnInclude/dimensionedScalar.H:76: note: Foam::dimensionedScalar Foam::cos(const Foam::dimensionedScalar&)
/opt/openfoam171/src/OpenFOAM/lnInclude/Scalar.H:238: note: Foam::doubleScalar Foam::cos(Foam::doubleScalar)
/opt/openfoam171/src/OpenFOAM/lnInclude/Scalar.H:238: note: Foam::floatScalar Foam::cos(Foam::floatScalar)

I also tried phiLS[i].value but without success...

Thanks for any advice!
Roland
RoE is offline   Reply With Quote

Old   January 20, 2011, 09:13
Default
  #2
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22
MartinB will become famous soon enough
Hi Roland,

try Foam::cos(...) instead of cos(...)

Martin
MartinB is offline   Reply With Quote

Old   January 20, 2011, 09:15
Default
  #3
RoE
New Member
 
Roland Engberg
Join Date: Jan 2011
Posts: 14
Rep Power: 15
RoE is on a distinguished road
Hi Martin,

it works!

Thanks a bunch!!
Roland
RoE is offline   Reply With Quote

Old   January 20, 2011, 09:49
Default
  #4
New Member
 
Alton Luder III
Join Date: Oct 2009
Location: Michigan
Posts: 22
Rep Power: 17
sleepdeprivation is on a distinguished road
OpenFOAM overloads the cos function. Check namespace issues.
Try Foam::cos(), and then test it to make sure its doing what you want.

I'm not sure why it can't decide if its a doubleScalar or floatScalar, that's usually picked at compile time.
sleepdeprivation 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
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
LiftDrag coefficient in LES fabian_korn OpenFOAM Post-Processing 1 September 22, 2008 03:34
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
Problems calculating field gh with interFoam cricke OpenFOAM Running, Solving & CFD 0 December 10, 2007 08:17
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27


All times are GMT -4. The time now is 00:57.