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

Foam::FixedList accepts only static data members?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 4, 2012, 11:11
Default Foam::FixedList accepts only static data members?
  #1
New Member
 
Hagen Müller
Join Date: Nov 2010
Posts: 27
Rep Power: 6
Hagen is on a distinguished road
Dear Foamers,

I need to define a new vector type with a fixed length. For that purpose I used:
typedef FixedList<scalar, n_> newType_;
This appears to work with n being defined as a "static const int" only. In my case, however, n is an integer, which is initialized in another class and passed on. Trying to compile produces the following error:
error: invalid use of non-static data member ‘Foam::specie::n_
Any help on this issue is greatly appreciated!

Hagen
Hagen is offline   Reply With Quote

Old   April 5, 2012, 02:51
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by Hagen View Post
Dear Foamers,

I need to define a new vector type with a fixed length. For that purpose I used:
typedef FixedList<scalar, n_> newType_;
This appears to work with n being defined as a "static const int" only. In my case, however, n is an integer, which is initialized in another class and passed on. Trying to compile produces the following error:
error: invalid use of non-static data member ‘Foam::specie::n_
Any help on this issue is greatly appreciated!

Hagen
The FixedList is a template class, you need to specify the type and dimension at compile time. If indeed you specify the "n" in the other class, you could also provide a typedef for the FixedList there too. It's hard to say without knowing what exactly you are trying to attempt.
olesen is offline   Reply With Quote

Old   April 5, 2012, 03:08
Default
  #3
New Member
 
Hagen Müller
Join Date: Nov 2010
Posts: 27
Rep Power: 6
Hagen is on a distinguished road
I would like to define the new type to store species properties, e.g. the critical temperature, in a multi-component solver. Thus the size of the vector depends on the number of species involved. In order to have a flexible code, suitable for changing number of species, I want to read the vector size from the "thermophysicalProperties" dictionary.
Do I get it right that this is not possible with the FixedList class since the size of it is fixed during compilation?
Any suggestions how to define a vector type with flexible size?

Thank you!
Hagen is offline   Reply With Quote

Old   April 5, 2012, 03:29
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by Hagen View Post
I would like to define the new type to store species properties, e.g. the critical temperature, in a multi-component solver. Thus the size of the vector depends on the number of species involved. In order to have a flexible code, suitable for changing number of species, I want to read the vector size from the "thermophysicalProperties" dictionary.
Do I get it right that this is not possible with the FixedList class since the size of it is fixed during compilation?
Any suggestions how to define a vector type with flexible size?

Thank you!
From your description: just use the List template class. You'll find lots of examples throughout OPENFOAM ... it's one of the most commonly used classes.
olesen 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
fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 12 May 2, 2013 10:52
error: uninitialized local variable 't' used MASOUD Fluent UDF and Scheme Programming 3 November 26, 2012 06:24
defining a term for a domain using DEFINE_ADJUST MASOUD Fluent UDF and Scheme Programming 1 September 24, 2010 05:08
enum MASOUD Fluent UDF and Scheme Programming 0 June 5, 2010 00:49
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27


All times are GMT -4. The time now is 16:33.