CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   list new element (

peterwy May 27, 2010 04:59

list new element

the question is probably quite easy, but still some basics are missing and I'm not able to find it in the forum ...

I want to make a list or something similiar where I can store elements and I have dynamics memory allocation.

As a result of a search in the mesh I get a couple of cell numbers:
Sometimes only perhaps 5 another time 500000.

So I need to make a list, where I'm able to store just the cell numbers in. One by one, the order doesn't matter at the end. (At the beginning of the storing process it's not clear how much cells will be in at the end)

If the forAll command is working would be great but of course no must have.

Hope its clear so far what I would like to have.

Is there anybody who is able to help me?

Thx @ all & best Regards,

herbert May 27, 2010 05:29

Hi Peter,

I think you can use DynamicList<label> declared in DynamicList.H. You can use the member append to insert your cell numbers at the end of this list. The forAll command is working.


peterwy May 27, 2010 06:45

it works
Thx for your help.
It worked great.
Just for the next one who is looking for something similar:

Initialize: DynamicList<int> bla;
Append value: bla.append(5);
Clear all entries: bla.clear();

(That are the commands that I needed.)

Best Regards,

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