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

single linked list iterator does not work

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2010, 08:00
Unhappy single linked list iterator does not work
  #1
Member
 
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17
woody is on a distinguished road
Hello All!

I am just trying to create a SLList (single linked list) to store my timedependent data, a scalarField ...

I already managed to create the List, but the iterator function is not working...


Any Ideas why??

I created a dummy test:

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 int main(int argc, char *argv[])
 {
    scalar t=0;
    scalarField a(6);
    SLList<scalarField> test;
    for (int i=0; i<=5; i++)
    {
        a[i]=i;
    }
    
    for (int i=0; i<=5; i++)
    {
        a[0]=t;
        for (int j=1; j<=5; j++)
        {
        a[j]+=1;
        }
        t++;
        test.append(a);

    Info << "test " << test.size()  <<endl;
    Info << "test "<< test.first()<<endl;
    Info << "test "<< test.last()<<endl;
    }
    
    SLList<scalarField>::iterator iterTest;
    for( iterTest=test.begin(); iterTest != test.end(); ++iterTest) 
    {
        Info << "Iterator" << iterTest << endl;
    }
}
thx

Tobi
woody is offline   Reply With Quote

Old   July 20, 2010, 22:02
Default
  #2
Member
 
Jianye Xia
Join Date: Mar 2009
Posts: 32
Rep Power: 18
bioexplore is on a distinguished road
what do u mean the iterater not work? can u post the output of this test code?
bioexplore is offline   Reply With Quote

Old   July 21, 2010, 05:15
Default
  #3
Member
 
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17
woody is on a distinguished road
Hi,

sure... when I compile it the output is:


Code:
Making dependency list for source file test.C
test.C: In function ‘int main(int, char**)’: 
test.C:61: error: no matching function for call to ‘Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator::iterator()’
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/LList.H:246: note: candidates are: Foam::LList<LListBase, T>::iterator::iterator(typename LListBase::iterator) [with LListBase = Foam::SLListBase, T = Foam::Field<double>]
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/LList.H:238: note:                 Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator::iterator(const Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator&)
test.C:64: error: no match for ‘operator<<’ in ‘Foam::operator<<(((Foam::Ostream&)(&((Foam::OSstream*)Foam::Info.Foam::messageStream::operator Foam::OSstream&())->Foam::OSstream::<anonymous>)), ((const char*)"Iterator")) << iterTest’                                                                                                                           
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/scalarRange.H:134: note: candidates are: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::scalarRange&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/lduMatrix.H:840: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::lduMatrix&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/globalMeshData.H:409: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::globalMeshData&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/lduSchedule.H:68: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::lduScheduleEntry&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellZone.H:266: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellZone&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/faceZone.H:324: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::faceZone&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointZone.H:268: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::pointZone&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/boundBox.H:227: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::boundBox&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/polyBoundaryMesh.H:199: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::polyBoundaryMesh&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/polyPatch.H:358: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::polyPatch&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/objectHit.H:123: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::objectHit&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/patchIdentifier.H:150: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::patchIdentifier&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/nil.H:83: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::nil&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellShape.H:164: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellShape&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellModel.H:175: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellModel&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/SHA1Digest.H:80: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::SHA1Digest&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/instant.H:147: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::instant&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Switch.H:196: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::Switch&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/dimensionSet.H:296: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::dimensionSet&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/dictionary.H:478: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::dictionary&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/entry.H:177: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::entry&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/long.H:58: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, long int)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Pstream.H:507: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::Pstream::commsStruct&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:433: note:                 std::ostream& Foam::operator<<(std::ostream&, const Foam::InfoProxy<Foam::token>&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:432: note:                 std::ostream& Foam::operator<<(std::ostream&, const Foam::token::punctuationToken&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:431: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token::punctuationToken&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:434: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token::compound&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:422: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/error.H:284: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOerror&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/error.H:179: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::error&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Ostream.H:212: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::IOstream& (*)(Foam::IOstream&))
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Ostream.H:206: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::Ostream& (*)(Foam::Ostream&))
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:556: note:                 Foam::IOstream& Foam::operator<<(Foam::IOstream&, Foam::IOstream& (*)(Foam::IOstream&))
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:546: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOstream::versionNumber&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:545: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOstream::streamFormat&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/fileName.H:178: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::fileName&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Scalar.H:282: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::doubleScalar)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Scalar.H:282: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::floatScalar)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/uint.H:58: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, unsigned int)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/bool.H:50: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, bool)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/int.H:59: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, int)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/word.H:134: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::word&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/string.H:69: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const std::string&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/string.H:215: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::string&)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/char.H:52: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, const char*)
~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/char.H:51: note:                 Foam::Ostream& Foam::operator<<(Foam::Ostream&, char)
make: *** [Make/linux64GccDPOpt/test.o] Error 1
any idea?

Tobi
woody is offline   Reply With Quote

Old   July 21, 2010, 05:21
Default
  #4
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
That won't even compile. The iterator needs one constructor argument:

Code:
for( SLList<scalarField>::iterator iterTest=test1.begin(); iterTest != test1.end(); ++iterTest)
    {
        Info << "Iterator" << *iterTest << endl;
    }
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   July 21, 2010, 05:53
Default
  #5
Member
 
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17
woody is on a distinguished road
Hy Laurence,

thanks it works. Do I understand right, that there is no empty constructor for this iterator??
woody is offline   Reply With Quote

Old   July 21, 2010, 06:09
Default
  #6
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Have a look in the source here, from line 235. SLList inherits the iterator from LListBase. It would appear you have to either initialise the iterator with one argument, or implicitly assign an initial iterator value as I have done.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   July 21, 2010, 22:45
Default
  #7
Member
 
Jianye Xia
Join Date: Mar 2009
Posts: 32
Rep Power: 18
bioexplore is on a distinguished road
Code:
 
//iterator must be initiated first
SLList<scalarField>::iterator iterTest=test.begin();
and there was no match output operator function related to Info<<sllist<Type>;
so you must call the operator() or operator* member function of the iterator first before you output it's value:
Code:
Info << "Iterator" << *iterTest << endl;
or
Code:
Info << "Iterator" << iterTest() << endl;
bioexplore 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
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 16:45
Why my code is ok with single processor but doesnbt work in openmpi xiuying OpenFOAM Running, Solving & CFD 0 November 23, 2007 14:44
Linked list errors hjasak OpenFOAM 0 October 7, 2005 08:14
Linked list errors hjasak OpenFOAM 1 September 13, 2005 10:56
P4 1.5 or Dual P3 800EB on Gibabyte board Danial FLUENT 4 September 12, 2001 12:44


All times are GMT -4. The time now is 23:53.