CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Using trig/hyperbolic functions with dimensioned scalars (http://www.cfd-online.com/Forums/openfoam-programming-development/116500-using-trig-hyperbolic-functions-dimensioned-scalars.html)

cpro April 20, 2013 22:16

Using trig/hyperbolic functions with dimensioned scalars
 
I'm trying to compute the cosh and sinh of a dimensionedScalar, and it won't accept the arguments. Here is my code:

Code:

forAll(M,celli){
Argument = fitParameter*H[celli].x()/T[celli];
M[celli].x()=Msat*(cosh(Argument)/sinh(Argument));
}

"Argument" is a dimensioned scalar, and "M" is a volVectorField. I get the error "cannot convert 'Foam::dimensioned<double>' to 'double' in assignment" on the second line of code.

Two questions:
(1) Is there a way to perform cosh et al on a vector or field? From the documentation, it looks like it only accepts scalars, but I'm not sure.

(2) How can I solve the issue? Argument.value() doesn't seem to work, and using a const dimensionedScalar doesn't make sense with my problem.

I really appreciate your help. Thanks!

Lieven April 21, 2013 03:37

It is not allowed to compute the cosh or sinh of a dimensioned numer. Just this about it, what would be the meaning of
Code:

scalar cosFive = cos(5 m/s)
cosh or sinh are no exception for this.

For your case, you could use
Code:

cosh(Argument.value())/sinh(Argument.value())
to solve this.

Cheers,

L

cpro April 21, 2013 14:35

Quote:

Originally Posted by Lieven (Post 422049)
It is not allowed to compute the cosh or sinh of a dimensioned numer. Just this about it, what would be the meaning of
Code:

scalar cosFive = cos(5 m/s)
cosh or sinh are no exception for this.

For your case, you could use
Code:

cosh(Argument.value())/sinh(Argument.value())
to solve this.

Cheers,

L

Thank you for your suggestion. However, when I try using Argument.value(), I get this error: "overloaded function cosh(double&) is ambiguous. Candidates are double cosh(double)."

What does the "double&" mean, and does anyone have any suggestions for how to solve this?

Lieven April 21, 2013 16:55

Ok, try adding 'Foam::' :
Code:

Foam::cosh(Argument.value())/Foam::sinh(Argument.value())
Cheers,

L

cpro April 21, 2013 18:27

That worked! Thank you, Lieven


All times are GMT -4. The time now is 10:28.