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

Json

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By lakeat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2013, 15:49
Default Json
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
I am wondering why doesn't OpenFOAM go with JSON format for its files? That would be easier for other programmers to parse.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email

Last edited by lakeat; April 8, 2013 at 16:44.
lakeat is offline   Reply With Quote

Old   April 8, 2013, 16:12
Default
  #2
Senior Member
 
Join Date: Dec 2011
Posts: 111
Rep Power: 19
haakon will become famous soon enough
There is absolutely no rational reason for a tool like OpenFOAM to use JSON, XML or any other text/ASCII/UTF-8 based storage format. This is simply because 99.99999% (approx.) of the data stored as results from a CFD simulation is floating point numbers. Storing this as text is highly inefficient, independent on the format chosen (current format/JSON/XML etc.).

In my opinion, the only sensible choice is to store the data in a binary format. This should be based on commonly available and freely licensed APIs. My suggestions is HDF5 or CGNS, witch are two quite different formats (HDF5 is a general HPC data container, while CGNS is a CFD-specific file format).
haakon is offline   Reply With Quote

Old   April 8, 2013, 16:29
Default
  #3
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Thanks, It is actually just this (1-99.99999%=0.00001%) files like fvSchemes or fvSolution that are what I am interested in and are what I would like to parse with. The information in these files is "kind of" "config" information.

Anyway, my point is, no matter what format OF uses, either HDF5 or CGNS or any other "popular" format, the outsiders can then use a relatively "standalone" program to parse OF files "cleanly" without calling OF libraries.
Hughtong likes this.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   April 8, 2013, 17:56
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by lakeat View Post
Thanks, It is actually just this (1-99.99999%=0.00001%) files like fvSchemes or fvSolution that are what I am interested in and are what I would like to parse with. The information in these files is "kind of" "config" information.

Anyway, my point is, no matter what format OF uses, either HDF5 or CGNS or any other "popular" format, the outsiders can then use a relatively "standalone" program to parse OF files "cleanly" without calling OF libraries.
In addition to what Hakon said there is also a pragmatic reason: when you look at http://en.wikipedia.org/wiki/JSON you see that this format was first conceived in 2001 and became popular around 2005. The OpenFOAM file-format originates (if I'm not mistaken) from the mid-90s ... around the time or even before XML was specified.

Writing a parser for the OpenFOAM-format is not THAT difficult. I mean: I managed with the parser that is in PyFoam. There are some interesting corner-cases but if you use a parser-generator then writing a parser that correctly reads >90% of all OF-files is pretty straight forward. And in principle the OF-format is just lists and dictionaries so if your programming language supports these then you "only" have to map the parsed data onto those data structures
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 8, 2013, 17:58
Default
  #5
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Quote:
Originally Posted by gschaider View Post
Writing a parser for the OpenFOAM-format is not THAT difficult. I mean: I managed with the parser that is in PyFoam. There are some interesting corner-cases but if you use a parser-generator then writing a parser that correctly reads >90% of all OF-files is pretty straight forward. And in principle the OF-format is just lists and dictionaries so if your programming language supports these then you "only" have to map the parsed data onto those data structures
That is what I am doing right now.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



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