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

Reference "mesh" inside a class

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 4, 2010, 17:31
Default Reference "mesh" inside a class
  #1
Member
 
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 7
tonyuprm is on a distinguished road
Hi all,

I'm trying to create a class which references the "mesh" class within itself. I want to call mesh.cells and mesh.C from within the class. Is there a way to use some kind of pointer within the constructor to do this? For other variables (like U) it can be done because its is of type volVectorField and the code is like:

myClass::myClass(volVectorField& U_)

I want to include a reference to the mesh class instead of the U_.

Thanks,

Tony
tonyuprm is offline   Reply With Quote

Old   November 5, 2010, 03:10
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 8
kathrin_kissling is on a distinguished road
Hi Tony,

you can just do U_.mesh() and you have the reference to the mesh class.

Hope this helps

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   November 5, 2010, 05:21
Default
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,619
Rep Power: 25
ngj will become famous soon enoughngj will become famous soon enough
Hi Tony

Alternatively, your constructor call could be

Code:
myClass::myClass(const fvMesh & mesh, volVectorField & U);
and within the constructor do
Code:
myClass::myClass(const fvMesh & mesh, volVectorField & U)
:
mesh_(mesh)
... etc
{


}
where mesh_ is defined as follows in your header file:
Code:
const fvMesh & mesh_;
Best regards,

Niels
ngj is offline   Reply With Quote

Old   November 5, 2010, 11:30
Default
  #4
Member
 
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 7
tonyuprm is on a distinguished road
Thanks Kathrin,

That worked just fine. Thanks for the reply Niels, I will use the first approach though.

Tony
tonyuprm is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
G95 + CGNS Bruno Main CFD Forum 1 January 30, 2007 01:34
Building OpenFoAm on SGI Altix 64bits anne OpenFOAM Installation 8 June 15, 2006 09:27
meshing F1 front wing Steve FLUENT 0 April 17, 2003 12:37


All times are GMT -4. The time now is 15:06.