CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > 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 Search this Thread Display Modes
Old   April 4, 2012, 12:11
Default Foam::FixedList accepts only static data members?
  #1
Member
 
Hagen Müller
Join Date: Nov 2010
Posts: 34
Rep Power: 15
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, 03:51
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,677
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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, 04:08
Default
  #3
Member
 
Hagen Müller
Join Date: Nov 2010
Posts: 34
Rep Power: 15
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, 04:29
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,677
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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 Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: uninitialized local variable 't' used MASOUD Fluent UDF and Scheme Programming 5 October 17, 2016 05:24
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
defining a term for a domain using DEFINE_ADJUST MASOUD Fluent UDF and Scheme Programming 1 September 24, 2010 06:08
enum MASOUD Fluent UDF and Scheme Programming 0 June 5, 2010 01: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 03:44.