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

Define an array of "volVectroField" type

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 20, 2013, 18:15
Default Define an array of "volVectroField" type
  #1
New Member
 
reza
Join Date: Apr 2013
Posts: 16
Rep Power: 4
haghgoo_reza is on a distinguished road
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
haghgoo_reza is offline   Reply With Quote

Old   June 21, 2013, 02:55
Default
  #2
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 228
Rep Power: 9
Cyp is on a distinguished road
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());
where speciesNames is a list of word defined elsewhere. For example,
Code:
wordList speciesNames
(
    transportProperties.lookup("speciesNames")
);
Then you create your speciesNames.size() objects on the heap:

Code:
forAll(speciesNames, s)
{
   Y.set
   (
        s,
        new volScalarField
        (
            IOobject
            (
                 speciesNames[s],
                 runTime.timeName(),
                 mesh,
                 IOobject::MUST_READ,
                 IOobject::AUTO_WRITE
        ),
        mesh
   );
}
Best,
Cyp
Cyp is offline   Reply With Quote

Old   June 24, 2013, 19:53
Default Loop over volVectorField
  #3
New Member
 
reza
Join Date: Apr 2013
Posts: 16
Rep Power: 4
haghgoo_reza is on a distinguished road
Thanks a lot Cyp.
Your information was pretty helpful to me.

Regards
Reza
haghgoo_reza 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
rhoSimpleFoam claco OpenFOAM 7 April 20, 2010 04:32
buoyantSimpleRadiationFoam msarkar OpenFOAM 0 February 15, 2010 07:22
Flow Around a Cylinder ronaldo OpenFOAM 5 September 18, 2009 08:13
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
UDF FOR UNSTEADY TIME STEP mayur FLUENT 3 August 9, 2006 10:19


All times are GMT -4. The time now is 11:42.