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

Using trig/hyperbolic functions with dimensioned scalars

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 20, 2013, 23:16
Default Using trig/hyperbolic functions with dimensioned scalars
  #1
New Member
 
Chris Prohoda
Join Date: Mar 2013
Posts: 6
Rep Power: 13
cpro is on a distinguished road
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!
cpro is offline   Reply With Quote

Old   April 21, 2013, 04:37
Default
  #2
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
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
Lieven is offline   Reply With Quote

Old   April 21, 2013, 15:35
Default
  #3
New Member
 
Chris Prohoda
Join Date: Mar 2013
Posts: 6
Rep Power: 13
cpro is on a distinguished road
Quote:
Originally Posted by Lieven View Post
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?
cpro is offline   Reply With Quote

Old   April 21, 2013, 17:55
Default
  #4
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Ok, try adding 'Foam::' :
Code:
Foam::cosh(Argument.value())/Foam::sinh(Argument.value())
Cheers,

L
Lieven is offline   Reply With Quote

Old   April 21, 2013, 19:27
Default
  #5
New Member
 
Chris Prohoda
Join Date: Mar 2013
Posts: 6
Rep Power: 13
cpro is on a distinguished road
That worked! Thank you, Lieven
cpro is offline   Reply With Quote

Reply

Tags
hyperbolic functions, scalar types, trig functions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
field functions - table crevoise STAR-CCM+ 3 March 26, 2013 10:37
Field functions and table crevoise Siemens 0 March 20, 2013 11:51
Flux functions for User-Defined Scalars Zhengcai Ye FLUENT 0 October 8, 2004 11:34
The Field Scalars in Tascflow Darcy CFX 0 November 19, 2003 23:14
N-S equations:divergence free functions? D. Puigjaner Main CFD Forum 1 July 27, 2000 13:43


All times are GMT -4. The time now is 02:07.