Transcript pyCGNS

CGNS
And pyCGNS, its Python binding
Poinot Marc
ONERA - DSNA/ELSA
/ELSA/PRS-02036
[email protected]
http://www.onera.fr
Overview
CGNS
pyCGNS
Goals
History
Actors/ Components
Examples
Future/ ISO process
Goals/ Status
Interoperability architecture
Examples
/ELSA/PRS-02036
ISO data format and semantics
Proprietary data format and semantics
CFD (Computational Fluid Dynamics) General Notation System
CFD standard
/ELSA/PRS-02036
We want to use a common data representation for interoperability
• Data semantics
• Physical representation
Grid creation/ Solvers/ Visualizers
Pre/Post processing of very large amount of data
We want to ensure our data a long life format
• Consistency
• Timelessness
Provide a general,
portable and extensible
standard for storage and
retrieval of CFD analysis
data.
Brief history
Started 1994
NASA + Boeing to improve technology transfert
NASA contract 1995-1998
SIDS document written by S.Allmaras, Boeing
Library implementation (+ICEM +NPARC Alliance)
/ELSA/PRS-02036
Steering Committee 1999…
Gather people
• 17 members
• +500 users
• web site
Software and documentation releases
ISO Process
• Initiated and supported by Boeing
/ELSA/PRS-02036
Steering Committee
Airbus
Boeing commercial
Boeing Phantom Works
Boeing Space & Communications
CD ADAPCO Group
Fluent, Inc.
ICEM CFD Engineering
Intelligent Light
NASA Ames
NASA Langley
NASA Glenn
NUMECA International
ONERA
Pointwise, Inc.
Pratt & Whitney Aircraft
Rolls-Royce Allison
US Air Force
Mission
Ensure the continuation of CGNS
Responsabilities
Software devt., maintenance, test…
Documentation
Insure a soft. and doc. free distribution
Provide expertise and extensions
proposals
Promote acceptance of the standard
Organization
Main meeting once per year
One chairperson per organization
Governs by consensus
Welcomes participation of all parties,
members or not
Overall architecture
/ELSA/PRS-02036
CGNSLib
Data semantics and Syntax
Specific Sub-trees API
Node API
File format
Components
Documentation
SIDS document
API and users documentation
Technical papers
/ELSA/PRS-02036
Libraries/ sources
MLL and ADF libraries (Fortran +C)
• Binaries
• Sources
User tutorial examples
Data file examples
Data exchange example - An informal view
WB234
body
wingZones
wing
solution#1
coordX
bodyConnectivity
/ELSA/PRS-02036
Mesh generator
density
pressure
Fluid solver
Communication layer
drag
Post processor
Example - A CGNS tree
wing
WB234
CGNSBase_t
Solution#1
Description
Wing and body test case 234
Descriptor_t
Date
13/03/2002
Descriptor_t
wing
Zone_t
Structured
ZoneType_t
CoordinateX
GridCoordinates_t
/ELSA/PRS-02036
WB234
coordX
density
solution#1
FlowSolution_t
Density
DataArray_t
Drag
UserDefined_t
DimensionalUnits
DimensionalUnits_t
dragCoef
DataArray_t
drag
Example - An ADF node
WB234
wing
Solution#1
coordX
Name:
Label:
DataType:
Dimensions:
DimensionValues:
Data:
Cardinality:
Parameters:
/ELSA/PRS-02036
Children:
Density
DataArray_t
DataType
IndexDimension
DataSize[]
[values]
0,N
DataType,
IndexDimension,
DataSize
[nodes]
density
drag
Development process
Community
Mailing list+ Web site+ Users
Meeting in Reno (AIAA annual conf.)
Teleconferences (every 2 months)
Actors
Started with ICEM CFD as main developper
Now Intelligent Light also
Members/ users contributions
/ELSA/PRS-02036
Means/ process
CVS server
Heavy testing/ Insure compatibility/ Check portability
Extension process
Extending the standard
The SIDS and its implementation has been though extensible from start
Documentation and consensus first
Process
Extension submission and discussions using mailing lists
Sub-group creation, seek for expertise, document drafting
Proposal for extension, implementation
/ELSA/PRS-02036
Some in-progress extensions
Periodic boundary condition/ Interfaces/ Rotating coordinates
Chemical species/ Multi-Phase and liquid spray/ Gravity
Object-oriented API/ In-memory tree representation
ISO process
ISO/STEP
Application Protocol 237 - Fluid dynamics
Part 110 - Computational Fluid Dynamics
Part 52 - Mesh-based topology
Part 53 - Numerical analysis
Schedule
Approval as IS in the second half of 2003 for parts 110, 52 and 53
AP 237 second quarter of 2005
/ELSA/PRS-02036
Drafts comments
PDF files + CGNS mailing list
See CGNS web site
Our users
Users
/ELSA/PRS-02036
Aerospace community
• Industry
• Research (Academy, Govt.)
Software editors
• CAD, mesh generation
• Post-processing tools, viewers
Up to 500 registered users (25 countries)
No declared user in Asia or Japan
Sample users
Boeing
• Adopted CFD data format
• Many benefits
– Common data semantics
– Improved modularity
– Workflow optimization
• Conformance to CGNS for new
CFD tools
Pratt & Whitney
• Translation tools between
proprietary format and CGNS
• Improve workflow
• Automation of design processes
NASA Langley
• Add CGNS capabalities to CFL3D
code
Future directions
Evolve/ Maintain
Use web site to scatter/gather information, examples, tools
Adds extension to meet users needs
Document more and more, tutorial, practical guides
Provide or refer to open source tools
/ELSA/PRS-02036
Spread
ISO
AIAA recommended practice
Emphasize on the use of CGNS in actual computations
Participate to conferences (including NASA/ESA Aerospace PDE workshop)
Keep source and docs as Open Source
ONERA
The French aeronautics and space research center
From basic research to flight testing
All disciplines involved in aircraft, spacecraft and missile design
DSNA
Computational Fluid Dynamics and Aeroacoustics Dept.
ELSA: Software unit in charge of elsA software
/ELSA/PRS-02036
elsA
New generation CFD solver
• Industrial tool
• Framework for research
• Gather 20 years of CFD methods and software expertise
Technologies leading edge
• OO design and implementation (C++, Python)
• Efficiency (scalar/vector, space/time)
• High level QA
CGNS related developments at ONERA
elsA
Main I/O data representation
• SIDS compliant
• Interoperability / Multi-processing
– In-memory and disk tree low level
• Validation resources
/ELSA/PRS-02036
pyCGNS
A Python binding to CGNS
Used as gluing language for application framework
• e.g. translators to CGNS trees
– From/To Tecplot and Aerospace actors data format
Open source
elsA Software
Interoperability
Multi-platform/ Multi-applications
• Fluid/ Structures/ Optimization/ Thermics/
pre/post processing know how
/ELSA/PRS-02036
Technologies
OO design/ implementation
• C++ kernel
• Fortran for computation leaves
• Python user interface
A single representation for I/O
• XDT trees + parsers for subset translation from/to
 CGNS/ XML/ Python
Python programming langage
Interpreted and OO script language
Easy to learn
Powerful and extensible
• Shared libraries
• Package system
• Very large scope of applications
Portable
• Including NEC, Cray, Fujitsu
/ELSA/PRS-02036
Efficient modules for numerical applications
Address numerical simulation interoperability concerns
• Contiguous memory arrays
• Can point to an already allocated zone
• Optimized operations on whole data
Ease of use example
a=1.4+0.2
b=[1.2, 0.3E-10, 1.4]
import Numeric
c=Numeric.ones([3])*a+b
print "Values :", c
/ELSA/PRS-02036
import math
for d in c:
print math.cos(d)
Values : array([2.8, 1.6, 3.])
-0.942222340669
-0.0291995223313
-0.9899924966
In-memory trees
Goal
Have a in-memory representation of trees
• Communicate semantics using trees
• Have a contiguous memory zone
– share
– transfert
• Use memory buffer based systems
– MPI/ SHM/ RPC/
• Fast dump to disk/ recovery
/ELSA/PRS-02036
Implementation
ADF API unchanged
• New implementation
• Thanks the two layers design of CGNS libraries
Architecture with Python modules
/ELSA/PRS-02036
Tree in-memory: Python interpreter
RPC
MPI
SHM
TCP/IP
Tree on disk: File system/DBMS
Interoperability example
Two solvers and glue
Structure solver
Glue FFT+CGNS tree
Fluid solver
Visualization
/ELSA/PRS-02036
Main loop
Structure computation
Translator HOST/ CGNS
• SPARK parser
• Numerical Python (arrays+FFT)
• pyCGNS tree
Fluid computation
• Full CGNS
Tecplot viewer
• Read CGNS
Semantic/structure & efficiency
Same tree
/ELSA/PRS-02036
Data consistency
"Blind" interoperability
Space/time efficiency
Ease of use
Archival example
Validation database
/ELSA/PRS-02036
RDBMS+ proprietary tool
• Store CGNS file as binary large object
– PostgreSQL blob
• Add attributes
Extracted from tree
• Hidden to MLL
RDBMS extra features
• Access control
• Query
• Clever archival server
Code example - pyCGNS
#!/usr/bin/env python
# CFD General Notation System - CGNS lib wrapper
# ONERA/DSNA/ELSA - [email protected]
# User's Guide to CGNS - C.L.Rumsey et al. examples translation
#
from CGNS
import midlevel
from CGNS.wrap import *
from Numeric
import *
#
#
open CGNS file for read-only
file=pyCGNS('grid.cgns',midlevel.MODE_READ)
index_base=1
index_zone=1
index_flow=1
isize=file.zoneread(index_base,index_zone)[3]
irmin=[1,1,1]
irmax=[isize[0],isize[1],isize[2]]
(loc,name)=file.solinfo(index_base,index_zone,index_flow)
/ELSA/PRS-02036
if (loc != midlevel.Vertex):
print "Error, GridLocation must be Vertex!
print midlevel.GridLocation[loc]
Currently:",
#
read flow solution
r=file.fieldread(index_base,index_zone,index_flow,
'Density',midlevel.RealSingle,irmin,irmax)
p=file.fieldread(index_base,index_zone,index_flow,
'Pressure',midlevel.RealSingle,irmin,irmax)
#
close CGNS file
del file
print "Successfully read flow solution from file 'grid.cgns'"
print "For example, r,p(21,17,9)=",r[20,16,8],p[20,16,8]
print "Program successful... ending now"
Parts of XML tree
(ADF tree dump using parseTree.py on web site example multi.cgns)
/ELSA/PRS-02036
<NODE name='ADF MotherNode' label='Root Node of ADF File'>
<DATA type='MT' />
<DIMENSIONS total='0' />
<NODE name='CGNSLibraryVersion' label='CGNSLibraryVersion_t'>
<DATA type='R4' />
<NODE name='CoordinateX' label='DataArray_t'>
<DIMENSIONS total='1'>
<DATA type='R8' />
</NODE>
<DIMENSIONS total='6150'>
</NODE>
2
123
25
</DIMENSIONS>
<VALUES>
</VALUES>
</NODE>
<NODE name='InputFileUsed 4' label='Descriptor_t'>
<DATA type='C1' />
<DIMENSIONS total='19926'>
19926
</DIMENSIONS>
<VALUES>
FILES:
challenge.cgns
...
</VALUES>
</NODE>
pyCGNS Status
/ELSA/PRS-02036
v0.4
Binding
• Full ADF wrapper + 60% MLL wrapper
• Experimental OOL layer
Python + Numerical Python
• Standard package
• Documentation+ test suite
In-memory representation
• Python/C/C++/Fortran in-memory tree sharing
Tools
• SIFT - SIDS instance description check
• ParseTree - Tree dump/display as XML tree
• StampNode - Add sub-nodes with specific stamps (date, ownership…)
pyCGNS v1.0 commitments
/ELSA/PRS-02036
v1.0 (4Q2002)
Binding
• Full ADF+MLL wrapper
• Full OOL layer
Documentation
• Features 100% documented + tutorial
• Design partly documented
Test suite
• Complete test suite for OOL/MLL/ADF
Tools
• Tree parser + XML I/O with DTD
• DBMS interface for blobs
• Translators
CGNS and pyCGNS references summary
CGNS
http://www.cgns.org
AIAA 2002-0752 - CFD General Notation System (CGNS): Status and future directions S.Legensky, D.Edwards, R.Bush, D.Poirier, C.Rumsey, R.Cosner, C.Towne
ONERA DSNA/ELSA
http://www.onera.fr
http://elsa.onera.fr
AIAA 2002-0108 - An efficient Object-Oriented solution to CFD complexity - L.Cambier, M.Gazaix
pyCGNS
/ELSA/PRS-02036
http://elsa.onera.fr/CGNS/releases
Python
http://www.python.org