- **OpenFOAM**
(*https://www.cfd-online.com/Forums/openfoam/*)

- - **Calculating the cosine of a Foam::scalar field**
(*https://www.cfd-online.com/Forums/openfoam/84117-calculating-cosine-foam-scalar-field.html*)

Calculating the cosine of a Foam::scalar fieldHi!
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 |

Hi Roland,
try Foam::cos(...) instead of cos(...) Martin |

Hi Martin,
it works! Thanks a bunch!! Roland |

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. |

All times are GMT -4. The time now is 19:24. |