|
[Sponsors] |
June 27, 2016, 12:59 |
scalar to double! get error!
|
#1 |
Senior Member
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 16 |
Hi,
I'm trying to extract a double value of a velocity vector component (x-component), using the following code Code:
scalar u = U[mycell].x(); scalar v = U[mycell].y(); scalar w = U[mycell].z(); double u1= u.value(); Code:
error: âxâ was not declared in this scope |
|
June 27, 2016, 19:38 |
|
#2 |
Senior Member
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 16 |
Any comment?
|
|
June 27, 2016, 22:41 |
|
#3 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
please report the full error, I guess you can just use your u value, don't need to define another value as u1.
|
|
June 28, 2016, 11:37 |
|
#4 |
Senior Member
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 16 |
||
June 28, 2016, 14:34 |
|
#5 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17 |
This should work
Code:
double u1 = u; |
|
June 28, 2016, 14:39 |
|
#6 |
Senior Member
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 16 |
||
June 29, 2016, 06:40 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
By the way, why you do something like that?
As hk318i already stated, double and scalar are similar! This will only introduce a new operation of memory allocation etc. In addition I would use references instead of copy values! Code:
scalar& u = u[cellI].x(); const scalar& u = u[cellI].x(); Code:
double& u = u[cellI].x(); const double& u = u[cellI].x(); Code:
using scalar = double;
__________________
Keep foaming, Tobias Holzmann |
|
July 6, 2016, 02:45 |
|
#8 | ||||
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12 |
If you go to the source code of scalar, you will find that the scalar is the same thing as double. Besides, they add template specialization for pTraits<Scalar>.
In doubleScalar.H: Quote:
Quote:
Quote:
In Scalar.H: Quote:
|
|||||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Building OpenFOAM1.7.0 from source | ata | OpenFOAM Installation | 46 | March 6, 2022 13:21 |
Errors in UDF | shashank312 | Fluent UDF and Scheme Programming | 6 | May 30, 2013 20:30 |
Compile problem | ivanyao | OpenFOAM Running, Solving & CFD | 1 | October 12, 2012 09:31 |
How to install CGNS under windows xp? | lzgwhy | Main CFD Forum | 1 | January 11, 2011 18:44 |
How to get the max value of the whole field | waynezw0618 | OpenFOAM Running, Solving & CFD | 4 | June 17, 2008 05:07 |