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

How to read a list from a dictionary?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By vigneshTG

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 29, 2009, 14:12
Default How to read a list from a dictionary?
  #1
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
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
ivan_cozza is offline   Reply With Quote

Old   December 29, 2009, 15:22
Default
  #2
Member
 
Ola Widlund
Join Date: Mar 2009
Location: Sweden
Posts: 87
Rep Power: 17
olwi is on a distinguished road
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
olwi is offline   Reply With Quote

Old   December 29, 2009, 18:33
Default
  #3
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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
l_r_mcglashan is offline   Reply With Quote

Old   January 2, 2010, 12:11
Default
  #4
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
Thank you Laurence,
I tested your solution, and it works fine for me!
Ivan

Quote:
Originally Posted by l_r_mcglashan View Post
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.
ivan_cozza is offline   Reply With Quote

Old   August 29, 2014, 10:48
Default
  #5
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 12
PicklER is on a distinguished road
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
PicklER is offline   Reply With Quote

Old   November 7, 2014, 05:13
Default IO object syntax for labelListList
  #6
Member
 
Vignesh
Join Date: Oct 2012
Location: Darmstadt, Germany
Posts: 66
Rep Power: 14
vigneshTG is on a distinguished road
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
),

);
I tried compiling it but i get an error as shown below
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
Can some one tell me what i am missing in definition ?

Have a nice weekend !!
__________________
Thanks and Regards

Vignesh
vigneshTG is offline   Reply With Quote

Old   November 7, 2014, 09:31
Default
  #7
Member
 
Vignesh
Join Date: Oct 2012
Location: Darmstadt, Germany
Posts: 66
Rep Power: 14
vigneshTG is on a distinguished road
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
            )
     );
Please correct me if i am wrong !
__________________
Thanks and Regards

Vignesh
vigneshTG 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
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


All times are GMT -4. The time now is 08:44.