|
[Sponsors] |
December 29, 2009, 14:12 |
How to read a list from a dictionary?
|
#1 |
Senior Member
|
Hi Foamers,
I need to read a list of lists from a dictionary composed as follows: listName number of elements ( (a b c d e f) (g h i l m n) .... ) where letters are labels. Something like blockMesh does when reading the blocks in blockMeshDict. Can someone suggest me how to do it? Thank you in advance, Ivan |
|
December 29, 2009, 15:22 |
|
#2 |
Member
Ola Widlund
Join Date: Mar 2009
Location: Sweden
Posts: 87
Rep Power: 17 |
Hi Ivan,
Knowing there's another piece of code that already does what you want is half the answer: If I was you, I would have a look at the source code for blockMesh, and see what it does to read the blockMeshDict. /Ola |
|
December 29, 2009, 18:33 |
|
#3 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
I read in labels from a file using labelIOList, which is just a typedef for IOList<label>, so I imagine labelListIOList (IOList<labelList>) is what you want. It's probably used as follows:
labelListIOList listListName ( IOobject ( "listListName", runTime.time().constant(), // Assuming your dictionary is in constant/ mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), variable of type List<labelList> ); It looks like the functionality you looking for with reading the listList from a dictionary is in the file createTopology.C in the blockMesh folder.
__________________
Laurence R. McGlashan :: Website |
|
January 2, 2010, 12:11 |
|
#4 | |
Senior Member
|
Thank you Laurence,
I tested your solution, and it works fine for me! Ivan Quote:
|
||
August 29, 2014, 10:48 |
|
#5 |
Member
Join Date: Jul 2014
Posts: 39
Rep Power: 12 |
Hello
Could you (Laurence or Ivan) please elaborate a little bit more how to achieve the reading in of a list. Say I want to read in the list "datP" that is (0.5 5.0 10.0) from the a file called "Data" in the constant directory. I followed the solution of Laurence but my lack of knowledge of C++ is not helping In my my main program (solver): #include "labelListIOList.H" and #include "readData.H" readData.H looks as follows: labelListIOList Data ( IOobject ( "Data", runTime.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), labelList(datP)); I know the labelList(datP) is not correct. My Data file looks as follows (all files include headers): datP (0.5 5.0 10.0); Kind regards |
|
November 7, 2014, 05:13 |
IO object syntax for labelListList
|
#6 |
Member
Vignesh
Join Date: Oct 2012
Location: Darmstadt, Germany
Posts: 66
Rep Power: 14 |
Dear All,
I tried to create IO object of type labelListList using the information i found in this thread which is given below Code:
labelListIOList proxCells ( IOobject ( "proxCells", runTime.time().constant(), // Assuming your dictionary is in constant/ mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), ); Code:
p, li { white-space: pre-wrap; } findProxCells.C: In function 'int main(int, char**)': findProxCells.C:95:1: error: expected primary-expression before ')' token make: *** [Make/linux64GccDPOpt/findProxCells.o] Error 1 Have a nice weekend !!
__________________
Thanks and Regards Vignesh |
|
November 7, 2014, 09:31 |
|
#7 |
Member
Vignesh
Join Date: Oct 2012
Location: Darmstadt, Germany
Posts: 66
Rep Power: 14 |
Dear All,
Finally i found a solution, here it is !! Code:
IOList<labelList> proximityCells( IOobject( "proximityCells", runTime.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) );
__________________
Thanks and Regards Vignesh |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
reading a list of lists from a dictionary | kian | OpenFOAM Running, Solving & CFD | 2 | June 3, 2009 11:44 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 15:37 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |