|
[Sponsors] |
August 13, 2010, 08:25 |
A question related to defining a variable
|
#1 |
Senior Member
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16 |
Hi all,
I am attempting to modify the forces.C file to include a point "CofE" (similar to the built in CofR in purpose). My question is what files besides forces.C and forces.H must be modified to make OF read a user inputed value of CofE in the controlDict file such as given below: functions ( forces { type forces; functionObjectLibs ("libforces.so"); //Lib to load -> dylib on Mac and so on Linux log true; outputControl timeStep; outputInterval 1; patches (hull hull_hull); //Name of patche to integrate forces rhoInf 1025.0; //Reference density for fluid - can be changed later ... CofR (-7.069 0 -0.67); //Origin for moment calculations CofE (-7.069 0 7); //location of center of effort of sail } I ask all of this because I copied verbatim the format of CofR in both files yet the error "CofE was not declared in this scope" shows up when I go to compile it. Any suggestions would be greatly appreciated. -Dave |
|
August 16, 2010, 08:37 |
|
#2 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
Hi Dave,
I'm not very into the forces calculation, but your problem seems to be quite basic c++. Could you post your constructor part of the .C file and the declaration part of the private data from the .H file. This might clear the clouds. Without source code it will get very had to clarfy this. Best Kathrin |
|
August 17, 2010, 05:33 |
|
#3 |
Senior Member
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16 |
Below is the relevant sections of forces.C and forces.H (I only am posting the sections that make any mention of CofR_ because the rest of files are unchanged). I think that this should work (I made some changes, particularly to the conditional statement), but I have yet to run it (it does spit out some compiler errors which I am looking into, but I am hoping to test it with a known test case later today). Any insights would certainly be appreciated. -Dave
//From forces.H: protected: // Private data // Read from dictionary //- Centre of rotation vector CofR_; //- Centre of Effort vector CofE_; //From forces.C: // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::forces::forces ( const word& name, const objectRegistry& obr, const dictionary& dict, const bool loadFromFiles ) : name_(name), obr_(obr), active_(true), log_(false), patchSet_(), pName_(word::null), UName_(word::null), rhoName_(word::null), directForceDensity_(false), fDName_(""), rhoRef_(VGREAT), pRef_(0), CofR_(vector::zero), CofE_(vector::zero), forcesFilePtr_(NULL) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::forces::read(const dictionary& dict) { // Centre of rotation for moment calculations CofR_ = dict.lookup("CofR"); // Centre of effort for moment calculations CofE_ = dict.lookup("CofE"); } Foam::forces::forcesMoments Foam::forces::calcForcesMoment() const { //Original forces.C version in line below: //vectorField Md = mesh.C().boundaryField()[patchi] - CofR_; //revised version that has a conditional to use CofE_ or CofR_ depending on if CofE_ //is zero or not vectorField Md = (CofE_ == zero) ? mesh.C().boundaryField()[patchi] - CofR_ : vectorField Md = 1.5*mesh.C().boundaryField()[patchi] - 0.5*CofE_; vectorField pf = Sfb[patchi]*(p.boundaryField()[patchi] - pRef); fm.first().first() += rho(p)*sum(pf); fm.second().first() += rho(p)*sum(Md ^ pf); //fm.third().first() += rho(p)*sum(Md ^ pf); vectorField vf = Sfb[patchi] & devRhoReffb[patchi]; fm.first().second() += sum(vf); fm.second().second() += sum(Md ^ vf); //fm.third().second() += sum(Md ^ vf); } |
|
August 17, 2010, 21:53 |
Solution found
|
#4 |
Senior Member
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16 |
I figured out the problem, the line below is correctly written to work:
vectorField Md = (CofE_ == vector::zero) ? mesh.C().boundaryField()[patchi] - CofR_ : 1.5*mesh.C().boundaryField()[patchi] - 0.5*CofE_; both the 1st part of the statement (CofE_ == vector::zero) and the last part of the statement were incorrect. Unfortunately for me I discovered that the basic formula is incorrect for what I need so I am back to square one. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Variable name for heat flux | peterle | CFX | 4 | February 13, 2014 03:21 |
Instalation on ubuntu 710 | basilwatson | OpenFOAM Installation | 17 | March 16, 2012 21:16 |
How to limit a variable | ash | OpenFOAM Running, Solving & CFD | 1 | June 26, 2008 21:32 |
Simple question about defining a volume in Gambit | Amit | FLUENT | 4 | January 24, 2007 18:10 |
Multi_component Vs Additional Variable | Anurag | CFX | 2 | February 4, 2005 17:45 |