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

A question related to defining a variable

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2010, 08:25
Default A question related to defining a variable
  #1
Senior Member
 
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16
daveatstyacht is on a distinguished road
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
daveatstyacht is offline   Reply With Quote

Old   August 16, 2010, 08:37
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   August 17, 2010, 05:33
Default
  #3
Senior Member
 
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16
daveatstyacht is on a distinguished road
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);
}
daveatstyacht is offline   Reply With Quote

Old   August 17, 2010, 21:53
Default Solution found
  #4
Senior Member
 
Dave
Join Date: Jul 2010
Posts: 100
Rep Power: 16
daveatstyacht is on a distinguished road
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.
daveatstyacht is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 18:08.