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

Reading 2D array from dictionary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2015, 14:37
Default Reading 2D array from dictionary
  #1
Member
 
Join Date: Aug 2015
Posts: 37
Rep Power: 10
knuckles is on a distinguished road
I'm interested in reading a 2D data array with arbitrary dimensions m x n from a dictionary. I've seen an implementation which uses a List<List<scalar>>, and expects input in the format
listName
5 // number of rows
(
4 (1.0 1.0 1.0 1.0) // row 1
4 (1.0 1.0 1.0 1.0) // row 2...
4 (1.0 1.0 1.0 1.0)
4 (1.0 1.0 1.0 1.0)
4 (1.0 1.0 1.0 1.0)
)
This is workable, but it doesn't naturally enforce the condition that all rows must have the same number of elements - if row 2 had an extra element, the code would accept it nonetheless. Applying this condition after-the-fact via assertions seems like a band-aid solution. I would prefer a class which naturally stores 2D data, and accepts input like
listName
5, 4 // 5 rows with 4 elements each
(
(1.0 1.0 1.0 1.0) // row 1
(1.0 1.0 1.0 1.0) // row 2...
(1.0 1.0 1.0 1.0)
(1.0 1.0 1.0 1.0)
(1.0 1.0 1.0 1.0)
)
Is there an OpenFOAM data type which is naturally suited to this? I looked into using a Matrix<>, but the intended usage of this class isn't clear to me and I haven't found a template to follow...
knuckles is offline   Reply With Quote

Reply

Tags
i/o


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
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52
Problem in running ICEM grid in Openfoam Tarak OpenFOAM 6 September 9, 2011 17:51
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51


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