|
[Sponsors] |
April 27, 2011, 09:31 |
Creating a new variable in a .C file?
|
#1 |
Member
Greg Givogue
Join Date: Aug 2010
Location: Ottawa Canada
Posts: 57
Rep Power: 15 |
Hi Everyone,
I'm relatively new with OpenFOAM and C++ programming. I'd like to modify the Forces.C file to include the following calc; vector CP = sum(Md^(vf+pf))/sum(vf+pf); I believe I have to update the forces.H file as well to define CP... but I'm not sure how. When I ran wmake in the forces folder I got: forces/forces.C:469: warning: unused variable ‘CP’ make: *** [Make/linux64GccDPOpt/forces.o] Error 1 Thanks for the help! Greg |
|
April 28, 2011, 04:18 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29 |
A "Warning" is not the same as an "Error". Ergo, you didn't include all messages from the compiler. Anyway, it's fine to define the variable in the .C file. I believe your problem is that "^" is not the operator you'd expect - use the Foam::pow() function instead.
|
|
April 28, 2011, 09:47 |
|
#3 |
Member
Greg Givogue
Join Date: Aug 2010
Location: Ottawa Canada
Posts: 57
Rep Power: 15 |
Thanks for the response. I tried a couple things and now I'm left with the following questions;
1) How do I declare CP within the scope of the write command at ln 374? 2) It doesn't seem to like my equation for CP at ln 467. I think it's the divide (/) that it doesn't like because I'm trying to divide 2 vector quantities. I think ^ is ok in this context. How would I use Foam:ow()? Thanks so much for your help! Apologies for the simple questions but I'm just starting to learn C++. Greg Last edited by Greg Givogue; April 28, 2011 at 10:13. |
|
April 28, 2011, 09:49 |
|
#4 |
Member
Greg Givogue
Join Date: Aug 2010
Location: Ottawa Canada
Posts: 57
Rep Power: 15 |
|
|
April 28, 2011, 17:10 |
|
#5 |
Senior Member
Pablo
Join Date: Mar 2009
Posts: 102
Rep Power: 17 |
you are declarating CP just in calcForcesMoment() function, if you want to use in other functions you need to declarate at the class (forces.h), or send like an argument
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 09:14 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 20:02 |
OpenFOAM Install Script | ljsh | OpenFOAM Installation | 82 | October 12, 2009 11:47 |
[OpenFOAM] ParaView 33 canbt open OpenFoam file | hariya03 | ParaView | 7 | September 25, 2008 17:33 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |