CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

Read multiple solution of a cgns file with paraview

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

Like Tree6Likes
  • 1 Post By t.teschner
  • 2 Post By wyldckat
  • 1 Post By wyldckat
  • 1 Post By t.teschner
  • 1 Post By tonyuprm

Reply
 
LinkBack Thread Tools Display Modes
Old   May 13, 2012, 09:54
Default Read multiple solution of a cgns file with paraview
  #1
New Member
 
Christos
Join Date: May 2012
Posts: 3
Rep Power: 4
cbarmpar is on a distinguished road
Dear All,

I am trying to read a cgns file which has multiple solutions.

Tecplot can read it with no problems by simply selecting the relevant zone.

But both paraview and VisIt can only read the first solution set.

Is there any way to read all the solution fields of the cgns file?

Regards,

Christos
cbarmpar is offline   Reply With Quote

Old   February 4, 2014, 12:28
Default
  #2
Member
 
Felipe Portela
Join Date: Dec 2012
Location: London
Posts: 58
Rep Power: 3
fportela is on a distinguished road
Quote:
Originally Posted by cbarmpar View Post
Dear All,

I am trying to read a cgns file which has multiple solutions.

Tecplot can read it with no problems by simply selecting the relevant zone.

But both paraview and VisIt can only read the first solution set.

Is there any way to read all the solution fields of the cgns file?

Regards,

Christos
Hi Christos,

Did you find a solution to this problem? I bumped into the same problem and can't seem to find the solution...

Cheers,
Felipe
fportela is offline   Reply With Quote

Old   February 7, 2014, 15:33
Default
  #3
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,327
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings to all!

@Felipe: If you can provide a small example file, I can have a look into this.
And knowing what application was used to generate the CGNS data, would also make it easier to diagnose what can be done.

Nonetheless, I'm guessing that with ParaView, it's best to export each time snapshot into independent files, and then open the group. For example, export the CGNS data into these files:
Code:
data_001.cgns
data_002.cgns
data_003.cgns
data_004.cgns
Then open in ParaView the group of these files, namely the pseudo-file "data_..cgns".

It could also be something like this:
Code:
data_000.cgns
data_010.cgns
data_020.cgns
data_030.cgns
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   February 20, 2014, 09:22
Default
  #4
New Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: London
Posts: 24
Rep Power: 4
t.teschner is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Greetings to all!

@Felipe: If you can provide a small example file, I can have a look into this.
And knowing what application was used to generate the CGNS data, would also make it easier to diagnose what can be done.
Hi Bruno,

I am working together with Felipe on that problem, we created one master cgns file that contains the grid coordinates and connectivity array (unstructured, hexa-8 mesh) and then we have created several flow solutions which link to the master cgns file (since it is an unsteady DNS simulation, we wanted to split the files to make them handable). this is all done in fortran.

you can have a look here: www.siteless.de/CGNS.tar.gz
it contains the master cgns file, 3 example flow solutions and the fortran subroutine how it is created (master and flow solution). the idea is to link from the master file to the flow solution (not the other way around since the timesteps are also stored in the master cgns file and everything should be available in that file)

we would be glad if you have any ideas to what the problem could be

kind regards,
tom
fportela likes this.
t.teschner is offline   Reply With Quote

Old   February 22, 2014, 13:35
Default
  #5
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,327
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Hi Tom,

I've done some research on the code that ParaView uses and the critical class is "avtCGNSFileFormat", which is part of the VistIt-Bridge, located in the folder "Utilities/VisItBridge/databases/CGNS" in ParaView's source code. The code is maintained outside of ParaView, for which there is a mirror here: https://github.com/robertmaynard/Vis...databases/CGNS
This VisIt Bridge is roughly explained here: http://www.paraview.org/Wiki/VisIt_Database_Bridge
The most recent version of this source code is at VisIt's repository: http://portal.nersc.gov/svn/visit/tr...atabases/CGNS/ - but it didn't change much.

The problem is that this class (whichever version) cannot open more than one file at a time and it does not have a way to interconnect between several instances of the same class.

The way I see it, you've got a few ways to address this issue:
  • You can request this feature at VisIt's bug tracker: https://visitbugs.ornl.gov/projects/visit
  • Hack into the source code yourself and add the feature you need, then build ParaView from source with the modified code.
  • Embed the mesh into every time snapshot and load the files as a group, as explained in my previous post.
All of this is because the VisIt bridge is not able to use all of CGNS' capabilities.

Best regards,
Bruno
t.teschner and fportela like this.
wyldckat is offline   Reply With Quote

Old   February 22, 2014, 13:50
Default
  #6
New Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: London
Posts: 24
Rep Power: 4
t.teschner is on a distinguished road
Thanks for looking into that! However, we failed one step before that, when actually creating the links inside the file. Linking from the flow solution data to the geometry works fine but linking from the geometry to the flow solution failed. Since paraview seems to support cgns links (when flow solution links to geometry, i.e. the flow solution file contains only the flow solution and the geometry is in the linked, separate, file) I suspected that the other way around shouldn't give any problems, but as i've said, we've failed at creating the actual links. And since this is all done for DNS simulation, writing the grid at every time step (we are talking about ~10^8 cells) is not feasible.
But your information are non the less very valuable, I was running into some VisIt compatibility problems before, seems to be because of what you just mentioned.
t.teschner is offline   Reply With Quote

Old   February 22, 2014, 14:41
Default
  #7
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,327
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Hi Tom,

Mmm... then I suggest that you have a look into XDMF (XML + HDF5): http://en.wikipedia.org/wiki/XDMF

Of course you could also try and create a new XDMF format that relies on CGNS for heavy data, but... someone did try this back in 2006, where CGNS was using HDF5: http://www.paraview.org/pipermail/pa...ry/002445.html but this is waaaay too messy...

Best regards,
Bruno
fportela likes this.
wyldckat is offline   Reply With Quote

Old   March 3, 2014, 17:15
Default CGNS and Paraview
  #8
Member
 
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 6
tonyuprm is on a distinguished road
Hi all,

I'm having the same problem reading the data with Paraview.
I have several cgns files which were created using CGNS 3.2.1

cgns_1.cgns
cgns_2.cgns
cgns_3.cgns
...
cgns_500.cgns

When I try to load them as a group, Paraview only loads the first time, and is not able to advance in time using the time controls.

I get the following message from PV:

*** Warning:The file being read is more recent that the CGNS library used ***

Has anyone found a way to fix this issue?

Thanks,

Tony
tonyuprm is offline   Reply With Quote

Old   March 4, 2014, 04:44
Default
  #9
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,327
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Hi Tony,
Quote:
Originally Posted by tonyuprm View Post
Has anyone found a way to fix this issue?
From my investigation into the source code, that I reported in post #5, the conclusion was that the plug-in is hard-coded to load CGNS data only from a single file.

In your case, a few questions:
  1. Does each CGNS file have both mesh and results?
  2. Does each CGNS file only have 1 hard-coded time frame?
  3. Or do all CGNS files have the complete time plan, even though they only have data for a single time snapshot?
I ask this because there might be 2 possible ways to approach this, if #1 and #2 from the above list are true:
  1. It might be possible to rely on a Python script placed in the Animation section to load each file for you. Sometime ago I wrote a similar kind of script: Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 post #6 - but it's meant for rescaling data. In theory, we could change the script to hack into the CGNS reader entry to change to another file, when the time changes.
  2. Or use a Programmable Source, which does almost the same thing, but it should have a higher success rate, since it does have specific capabilities to tell ParaView/VTK what time instances there are.
On the other hand, if your CGNS files are split into parts, as Tom's, where the mesh and time were in the first file, but all others only had the mesh... then you'll need some application to stitch the CGNS files into a single one or to convert them to XDMF+HDF5.

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   March 4, 2014, 14:29
Default
  #10
Member
 
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 6
tonyuprm is on a distinguished road
Hi Bruno,

Thanks for your reply.

1. Each file has both mesh and data.

2. Each file has one time frame.

I'm trying now to write the time history onto the CGNS file and have only one file with all the time history. I'll report back soon.

Thanks,

Tony
tonyuprm is offline   Reply With Quote

Old   March 4, 2014, 14:49
Default
  #11
New Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: London
Posts: 24
Rep Power: 4
t.teschner is on a distinguished road
Quote:
Originally Posted by tonyuprm View Post
I'm trying now to write the time history onto the CGNS file and have only one file with all the time history. I'll report back soon.
Yes, this seems to be the problem. Paraview needs to know how many time steps there are and how the files are connected to each other. I have no problem loading transient data into paraview, as long as they are all stored in one file. as soon as you split them you will need to employ links between the cgns files to make paraview (or any other post processor) understand that it is actually a transient problem. i really like the structure of the cgns format, but when it comes to write transient data, it is a little bit messy, below i've posted the way i write transient data to a cgns file, hope that helps.

Code:
c--write time dependence
c--t is the number of timesteps 
	call cg_biter_write_f(index_file,index_base,
     #	'TimeIterValues',t,ier)
	call cg_goto_f(index_file,index_base,ier,
     #	'BaseIterativeData_t',1,'end')
c--create array that stores the total time (well obviously that is case dependend)
	do time=1,t
	  ta(time) = 0.5*real(time)-0.5
	enddo
c--write time array to cgns
	call cg_array_write_f('TimeValues',RealSingle,
     #	1,t,ta,ier)
c--write zone for transient solution
	call cg_ziter_write_f(index_file,index_base,
     #	index_zone,'ZoneIterData',ier)
c--goto zone iterative data
	call cg_goto_f(index_file,index_base,ier,
     #	'Zone_t',1,'ZoneIterativeData_t',1,'end')
c--link flowsolutions to timesteps
c--flowarray (from 1:t) holds the name of the flow solutions, i.e.
c--flowsolution001, flowsolution002, flowsolution003 etc.
c--these will be the names for your flow solution nodes
	idata(1) = 32
	idata(2) = t
	call cg_array_write_f('FlowSolutionPointers',Character,
     #	2,idata,flowarray,ier)
c--tell cgns that it is a transient solution
	call cg_simulation_type_write_f(index_file,index_base,
     #	TimeAccurate,ier)
wyldckat likes this.
t.teschner is offline   Reply With Quote

Old   March 18, 2014, 15:45
Default cgns_to_vtk
  #12
Member
 
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 6
tonyuprm is on a distinguished road
Hi all,

So after spending too much time on this I've decided the best way to go is the following.
I use the utility cgns_to_vtk to convert the files to VTK and that should load them into paraview without too much trouble.

I use the following bash script to go through all the files and convert them.

Code:
for file in ./*.cgns
do
   filename="${file//.cgns/}.vtk"
   /usr/local/cgns/bin/cgnstools/cgns_to_vtk $file
   mv Zone.vtk $filename
done
If anyone finds a solution to loading multiple time-steps in paraview using CGNS, please let us know.

Cheers,

Tony
elvis likes this.

Last edited by tonyuprm; March 20, 2014 at 21:57.
tonyuprm is offline   Reply With Quote

Reply

Tags
cgns, paraview, visit

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM Install Script ljsh OpenFOAM Installation 82 October 12, 2009 11:47
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
Paraview command not found hardy OpenFOAM Paraview & paraFoam 7 September 18, 2008 04:59
Compiling OpenFOAM13 on AMD64 with Redhat Enterprise mbeaudoin OpenFOAM Installation 20 June 17, 2008 06:43
Transient solution multiple CGNS files in Tecplot Ramses Galaz Tecplot 3 October 17, 2006 10:43


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