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

writing link between two CGNS files

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

Like Tree1Likes
  • 1 Post By t.teschner

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 3, 2014, 05:37
Question writing link between two CGNS files
  #1
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 197
Rep Power: 12
t.teschner is on a distinguished road
I am currently trying to output two separate CGNS files one of which contains the geometry (unstructured, 3D mesh) and the other the calculated solution (at a later stage transient data will be stored in separate CGNS files hence the linking to the geometry file). Unfortunately the documentation on links is rather poor, I have read the Users guide and mid level calls and consulted the SIDS documentation as well without luck. I was hoping someone has already done something similar and can look at my code, see below (I have shorten the subroutine just to see the writing / linking part. When I write everything into one file then it works so it is the linking which is giving me problems)

writing the geometry file

Code:
SUBROUTINE WRITEGEOMETRY
            
      USE VARIABLES
      INCLUDE 'PANTARHEI.INC'

C--Include CGNS here     
# include "../../libraries/cgnslib_3.1.4/src/cgnslib_f.h" 

	CALL CG_OPEN_F('geometry.cgns',
     +	CG_MODE_WRITE,INDEX_FILE,IER)

	BASENAME='BASE_GEOMETRY'
	ZONENAME='ZONE_GEOMETRY'
	
	ICELLDIM = 3
	IPHYSDIM = 3

	CALL CG_BASE_WRITE_F(INDEX_FILE,BASENAME,
     +	ICELLDIM,IPHYSDIM,INDEX_BASE,IER)
     
	ISIZE(1,1)=NVERT_CGNS
C--Number of Cells
	ISIZE(1,2)=NCELL_CGNS
c--Number of Boundary Vertecis
	ISIZE(1,3)=0

C--Write Zone Node 
	CALL CG_ZONE_WRITE_F(INDEX_FILE,INDEX_BASE,
     +	ZONENAME,ISIZE,Unstructured,INDEX_ZONE,IER)
     
C--Write GridCoordinate node
	CALL CG_GRID_WRITE_F(INDEX_FILE,INDEX_BASE,INDEX_ZONE,
     +	'GridCoordinates',INDEX_GRID,IER)

C--Write Coordinates to CGNS
	CALL CG_COORD_WRITE_F(INDEX_FILE,INDEX_BASE,
     +	INDEX_ZONE,RealDouble,'CoordinateX',XCGNS,
     +	INDEX_COORD,IER)
	
	CALL CG_COORD_WRITE_F(INDEX_FILE,INDEX_BASE,
     +	INDEX_ZONE,RealDouble,'CoordinateY',YCGNS,
     +	INDEX_COORD,IER)
	
	CALL CG_COORD_WRITE_F(INDEX_FILE,INDEX_BASE,
     +	INDEX_ZONE,RealDouble,'CoordinateZ',ZCGNS,
     +	INDEX_COORD,IER)
	
C--Now write the connectivity required for unstructured meshes
	CALL CG_SECTION_WRITE_F(INDEX_FILE,INDEX_BASE,INDEX_ZONE,
     +  'Elements',HEXA_8,1,ISIZE(1,2),0,IVCELL_CGNSTEMP,
     +  INDEX_SECTION,IER)
	
C--Coordinated have been written to CGNS file, closing file
	CALL CG_CLOSE_F(INDEX_FILE,IER)
 
      END


And the Flow solution file, linking to the geometry file



Code:
SUBROUTINE WRITETOCGNS
      
      USE VARIABLES
      INCLUDE 'PANTARHEI.INC'

C--Include CGNS here     
# include "../../libraries/cgnslib_3.1.4/src/cgnslib_f.h"

C--Convert timestep to string
	CURRENTTIMESTEP = LASTTIMESTEP + NTIMSTEP
	WRITE(INT2STR,'(I7.7)') CURRENTTIMESTEP

	FILENAME = 'result'
	FILENAME = trim(FILENAME) // INT2STR(:7) // '.cgns'
	
C--Create and open CGNS result file for specified timestep here
	CALL CG_OPEN_F(FILENAME,CG_MODE_WRITE,INDEX_FILE,IER)
	
	ICELLDIM = 3
	IPHYSDIM = 3

	CALL CG_BASE_WRITE_F(INDEX_FILE,'BASE_RESULT',
     +	ICELLDIM,IPHYSDIM,INDEX_BASE,IER)
     
C--Number of Vertecis
	ISIZE(1,1)=NVERT_CGNS
C--Number of Cells
	ISIZE(1,2)=NCELL_CGNS
c--Number of Boundary Vertecis
	ISIZE(1,3)=0

C--Write Zone Node 
	CALL CG_ZONE_WRITE_F(INDEX_FILE,INDEX_BASE,
     +	'ZONE_RESULT',ISIZE,Unstructured,INDEX_ZONE,IER)

C--Link GridCoordinate node
	CALL CG_GOTO_F(INDEX_FILE,INDEX_BASE,IER,
     +	'Zone_t',1,'end')

	CALL CG_LINK_WRITE_F('GridCoordinates',
     +  'geometry.cgns',
     +  'BASE_GEOMETRY/ZONE_GEOMETRY/GridCoordinates',IER)

	CALL CG_SOL_WRITE_F(INDEX_FILE,1,1,'FlowSolution',
     +  CellCenter,INDEX_FLOW,IER)
     
C--Output Pressure to CGNS
	CALL CG_FIELD_WRITE_F(INDEX_FILE,1,1,INDEX_FLOW,RealDouble,
     +  'Pressure',PCGNS,INDEX_FIELD,IER)

C--Output Velocities to CGNS
     	CALL CG_FIELD_WRITE_F(INDEX_FILE,1,1,INDEX_FLOW,RealDouble,
     +  'VelocityX',U1CGNS,INDEX_FIELD,IER)
     
     	CALL CG_FIELD_WRITE_F(INDEX_FILE,1,1,INDEX_FLOW,RealDouble,
     +  'VelocityY',U2CGNS,INDEX_FIELD,IER)

     	CALL CG_FIELD_WRITE_F(INDEX_FILE,1,1,INDEX_FLOW,RealDouble,
     +  'VelocityZ',U3CGNS,INDEX_FIELD,IER)
	
C--Close result filere here
	CALL CG_CLOSE_F(INDEX_FILE,IER)

      END

By the way, if I do

Code:
CALL CG_OPEN_F(FILENAME,CG_MODE_READ,INDEX_FILE_LINK,IER)
	CALL CG_GOTO_F(INDEX_FILE_LINK,1,IER,
     +	'Zone_t',1,'end')
	
	CALL CG_LINK_READ_F(FILENAME,LINK_PATH,IER)
than IER from CG_LINK_READ_F will return 1 which is why I suspect something is wrong with the linking

Last edited by t.teschner; February 3, 2014 at 06:44.
t.teschner is offline   Reply With Quote

Old   February 4, 2014, 10:26
Default
  #2
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 197
Rep Power: 12
t.teschner is on a distinguished road
Solved it. Just in case somebody has the same problem and stumbles upon it, in my case I have an unstructured mesh and forgot to link the connectivity array (the look up table if you want).
AshwaniAssam likes this.
t.teschner is offline   Reply With Quote

Reply

Tags
cgns, link

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error writing files while calculating ehfeinberg FLUENT 0 July 9, 2013 14:44
parallel support with CGNS format not yet implemented kirkrich SU2 3 January 18, 2013 15:39
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 07:21
Problems with result files Kasper CFX 5 December 14, 2006 02:41
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 20:51


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