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

How to use List< List<vector> >

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By JNSN
  • 3 Post By JNSN

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2013, 11:12
Default How to use List< List<vector> >
  #1
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
HakikiCanakkaleli is on a distinguished road
Hi,

== 1 ==

I defined the following list of the list of vectors.

Code:
List< List<vector> > example(...);
== 2 ==

I populate this with a number of lists of vectors. e.g. list1, list2, list3 ... etc.

== 3 ==

The question is that how I can reach one of the vectors inside example?

For example, I can reach the 3rd vector inside a "List<vector> other_example" like that:

Code:
Info << other_example[2] << endl;
But I couldn't achieve the same task for the list< list<vector> >.

== 4 ==

In the end, I would like to use this example list of lists in for loops so that I can do some algeabraic operation with them.

Many thanks for any help in advance.
HakikiCanakkaleli is offline   Reply With Quote

Old   October 10, 2013, 04:33
Default
  #2
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
have you tried
Code:
anotherExample[2][0]
?
HakikiCanakkaleli likes this.
JNSN is offline   Reply With Quote

Old   October 10, 2013, 05:01
Default
  #3
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
Code:
    vector exampleVector = vector::zero;

    Info << "vector:" << tab << exampleVector << endl;

    scalar listLength(5);

    List<vector> exampleVectorList(listLength,vector::zero);

    forAll(exampleVectorList, i)
    {
        vector& v = exampleVectorList[i];

        v = vector(i,2*i,3*i);

        Info << "vector:" << tab << v << endl;
    }

    Info << endl << endl;

    List<List<vector> > exampleVectorListList(listLength,exampleVectorList);

    forAll(exampleVectorListList,i)
    {
        List<vector>& vList = exampleVectorListList[i];

        forAll(vList,j)
        {
            vector& v = vList[j];

            Info << "vector:" << tab << v << endl;
        }
    }
JNSN is offline   Reply With Quote

Old   October 10, 2013, 05:28
Default
  #4
Senior Member
 
Canakkale Dardanelspor
Join Date: Aug 2012
Posts: 135
Rep Power: 13
HakikiCanakkaleli is on a distinguished road
Many thanks for this reply.

I had tried example[2][0] at the first hand; but, it seems I misunderstood the error message. Now, it confirmed that I made some other mistake. Many thanks.
HakikiCanakkaleli is offline   Reply With Quote

Reply


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
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM Programming & Development 1 February 16, 2011 20:52
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM 0 December 16, 2010 07:08
CAD -> gMsh -> enGrid -> OpenFOAM Problem AlGates OpenFOAM 7 August 6, 2010 12:46
[Netgen] Geometry > Netgen > OpenFOAM ericnutsch OpenFOAM Meshing & Mesh Conversion 9 February 22, 2010 07:39
convection......-> conduction......-> convection madasu FLUENT 3 November 24, 2002 01:15


All times are GMT -4. The time now is 20:41.