Define an array of "volVectroField" type
Hi all, ;)
When I define a variable "Uold" as: volVectorField Uold("Uold", U); Uold = U; it works. However, I would like to define an array of Uold. I mean, I want to have Uold1, Uold2, ..... So When I define the above expression inside a loop it does not work I.e. for (int i=1; i < 100; i++) { volVectorField Uold[i] ("Uold", U); Uold[i] = U; } Could anybody please help me how to define an array of the object "volVectroField" type?:) Thanks |
Hi!
You can be inspired by what is done for multicomponent mass transfer where there is a table of volScalarField Y. You first have to reserve the memory with a list of pointer : Code:
PtrList <volScalarField> Y(speciesNames.size()); Code:
wordList speciesNames Code:
forAll(speciesNames, s) Cyp |
Loop over volVectorField
Thanks a lot Cyp.
Your information was pretty helpful to me.:) Regards Reza |
what does wordList specieName contain?
is it used to input size of the array? and how do I define it in transportProperties? Thank You i would hiGhly appreciate any sort of help/feedback |
Quote:
Code:
Z Code:
speciesNames |
What about the same procedure but for several regions?
for example: Code:
forAll(regions, i) |
Quote:
Code:
PtrList<PtrList<volScalarField>> Y(regions.size()); |
Quote:
It compiles well and it works great when I have 1 species (speciesNames.size() = 1, s = 0) However, when I run the code with 2 species (speciesNames.size() = 2, s = 0,1 ), I got the following error for s = 1: Code:
#0 Foam::error::printStack(Foam::Ostream&) at ??:? Code:
Y[s].set |
Quote:
the following lines: Code:
Y.set Code:
Y.set |
All times are GMT -4. The time now is 01:35. |