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

Json

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 8, 2013, 15:49
Default Json
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: South Bend, IN, USA
Posts: 688
Blog Entries: 9
Rep Power: 12
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
-------------
NatHaz Modeling Laboratory
Department of Civil & Environmental Engineering & Earth Sciences
University of Notre Dame, USA
Email || My Personal CFD Blog

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
 
Håkon Strandenes
Join Date: Dec 2011
Location: Norway
Posts: 111
Rep Power: 10
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: South Bend, IN, USA
Posts: 688
Blog Entries: 9
Rep Power: 12
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.
__________________
~
Daniel WEI
-------------
NatHaz Modeling Laboratory
Department of Civil & Environmental Engineering & Earth Sciences
University of Notre Dame, USA
Email || My Personal CFD Blog
lakeat is offline   Reply With Quote

Old   April 8, 2013, 17:56
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
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: South Bend, IN, USA
Posts: 688
Blog Entries: 9
Rep Power: 12
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
-------------
NatHaz Modeling Laboratory
Department of Civil & Environmental Engineering & Earth Sciences
University of Notre Dame, USA
Email || My Personal CFD Blog
lakeat is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:11.