|
[Sponsors] |
ERROR: attempt to access element from zero sized list |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 26, 2013, 08:03 |
ERROR: attempt to access element from zero sized list
|
#1 |
New Member
suhas jain suresh
Join Date: Aug 2012
Location: Stanford, USA
Posts: 27
Rep Power: 13 |
Hi everyone,
" // loop over faces forAll(faces, facei) { label faceI = faces[facei]; //find patch label patchI = psi.mesh().boundaryMesh().whichPatch(faceI); // if facei is in patch: patchI < -1 if (patchI > -1) { if (!isA<emptyFvPatch>(psi.boundaryField()[patchI])) { faceI = psi.mesh().boundaryMesh()[patchI].whichFace(faceI); psiBoundary = psi.boundaryField()[patchI][faceI]; } Info << " Face: " << faceI << " Psi value: " << psiBoundary; } } " I am using the above code to access the value of psi (a distance function) at the boundaries. But during the execution of the "psiBoundary"( as seen above) I am getting this error " --> FOAM FATAL ERROR: attempt to access element from zero sized list From function UList<T>::checkIndex(const label) in file /opt/openfoam220/src/OpenFOAM/lnInclude/UListI.H at line 103. FOAM aborting #0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" #1 Foam::error::abort() in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" #2 at /opt/openfoam220/src/OpenFOAM/lnInclude/errorManip.H:85 #3 at /opt/openfoam220/src/OpenFOAM/lnInclude/UListI.H:103 #4 at /opt/openfoam220/src/OpenFOAM/lnInclude/UListI.H:168 #5 at ~/OpenFOAM/suhas-2.2.0/applications/solvers/levelSetFoam/reinit.H:169 #6 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #7 " I just know this is something related to the index " i " in the UListI.H but I couldn't figure out what exactly is going on there. Any advice? Thanks in advance, Suhas |
|
June 26, 2013, 10:31 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21 |
First, I get that error when the list / field has been declared, but has not yet been allocated, and I try accessing it. It usually means it wasn't built properly. Maybe psi isn't built properly.
Second, are you mixing up facei and faceI? (This is bad practice to differentiate variables by case alone, but OpenFOAM is guilty of this too.) Just some thoughts.
__________________
~~~ Follow me on twitter @DavidGaden |
|
June 27, 2013, 07:46 |
|
#3 |
New Member
suhas jain suresh
Join Date: Aug 2012
Location: Stanford, USA
Posts: 27
Rep Power: 13 |
Thank you for the reply,
I checked everything but I dint see any mistake in psi field. According to the error, it is accessing value from zero sized array but when I printed out the value of "psi.boundaryField().size()", I got the value as 6, and I even tried printing out "psi.boundaryField()", It gave the correct boundary conditions as defined by me. That means it's not a zero sized array. But I still get the same error at Cell=0 ,patchI=0 and faceI=0 when I use "psi.boundaryField()[patchI][faceI] " |
|
June 27, 2013, 08:18 |
|
#4 |
New Member
suhas jain suresh
Join Date: Aug 2012
Location: Stanford, USA
Posts: 27
Rep Power: 13 |
I think it might be accessing an empty patch. How to give a condition so that it doesn't access an empty patch?
Thanks.. |
|
June 27, 2013, 11:36 |
|
#5 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21 |
It's true that empty patch fields do not initialize the boundary fields, so that would explain the error you are getting.
psi.boundaryField().size() would tell you how many boundary patches you have... that's not where the error would lie. If you try psi.boundaryfield()[0].size(), or [1], [2], etc. what do you get? Also, why are you finding which patch the face is in? It seems unnecessary. You have psi.boundaryField(), so why not restructure it just to loop over the structure of psi.boundaryField(), rather than all the faces? Such as: Code:
forAll(psi.boundaryField(), patchI) { forAll(psi.boundaryField()[patchI], localFaceI) { psiBoundary = psi.boundaryField()[patchI][localFaceI]; Info << " Local face: " << localFaceI; Info << " Psi value: " << psiBoundary << endl; } }
__________________
~~~ Follow me on twitter @DavidGaden |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Mesh Importing Problem | cuteapathy | ANSYS Meshing & Geometry | 2 | June 24, 2017 05:29 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 12:41 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 13:59 |
mpirun and selfcoded fvPatchField: "attempt to access element from zero sized list" | astein | OpenFOAM Running, Solving & CFD | 2 | July 14, 2010 04:49 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |