320 likes | 579 Views
CGNS And pyCGNS, its Python binding. Poinot Marc ONERA - DSNA/ELSA /ELSA/PRS-02036 poinot@onera.fr http://www.onera.fr. CGNS Goals History Actors/ Components Examples Future/ ISO process. pyCGNS Goals/ Status Interoperability architecture Examples. ISO data format and semantics.
E N D
CGNSAnd pyCGNS, its Python binding Poinot Marc ONERA - DSNA/ELSA /ELSA/PRS-02036 poinot@onera.fr http://www.onera.fr
CGNS Goals History Actors/ Components Examples Future/ ISO process pyCGNS Goals/ Status Interoperability architecture Examples ISO data format and semantics Proprietary data format and semantics Overview
CFD (Computational Fluid Dynamics) General Notation System • CFD standard • 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) • Steering Committee 1999… • Gather people • 17 members • +500 users • web site • Software and documentation releases • ISO Process • Initiated and supported by Boeing
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 Steering Committee
Overall architecture Data semantics and Syntax SIDS SIDS Specific Sub-trees API CGNSLib MLL Node API ADF File format
Components • Documentation • SIDS document • API and users documentation • Technical papers • Libraries/ sources • MLL and ADF libraries (Fortran +C) • Binaries • Sources • User tutorial examples • Data file examples SIDS MLL ADF
SIDS MLL ADF Data exchange example - An informal view WB234 body wingZones wing solution#1 coordX density pressure bodyConnectivity drag Mesh generator Fluid solver Post processor Communication layer
WB234 wing Solution#1 coordX drag Date 13/03/2002 density Descriptor_t wing Zone_t Structured ZoneType_t CoordinateX GridCoordinates_t Example - A CGNS tree WB234 CGNSBase_t Description Wing and body test case 234 Descriptor_t solution#1 FlowSolution_t Density DataArray_t Drag UserDefined_t DimensionalUnits DimensionalUnits_t dragCoef DataArray_t
WB234 Name: Density wing Label: DataArray_t DataType: DataType Solution#1 Dimensions: IndexDimension DimensionValues: DataSize[] coordX drag Data: [values] density Cardinality: 0,N Parameters: DataType, IndexDimension, DataSize Children: [nodes] Example - An ADF node
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 • 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 • 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 • Drafts comments • PDF files + CGNS mailing list • See CGNS web site
Users 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 Our users
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 • 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 • 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 • 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 • 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 • 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
a=1.4+0.2 b=[1.2, 0.3E-10, 1.4] import Numeric c=Numeric.ones([3])*a+b print "Values :", c import math for d in c: print math.cos(d) Values : array([2.8, 1.6, 3.]) -0.942222340669 -0.0291995223313 -0.9899924966 Ease of use example
In-memory trees MLL • 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 • Implementation • ADF API unchanged • New implementation • Thanks the two layers design of CGNS libraries ADF
Architecture with Python modules Tree in-memory: Python interpreter RPC MPI SHM TCP/IP A B C elsA Tree on disk: File system/DBMS
Interoperability example • Two solvers and glue • Structure solver • Glue FFT+CGNS tree • Fluid solver • Visualization • Main loop • Structure computation • Translator HOST/ CGNS • SPARK parser • Numerical Python (arrays+FFT) • pyCGNS tree • Fluid computation • Full CGNS • Tecplot viewer • Read CGNS A B C elsA
elsA Numpy pyCGNS post Semantic/structure & efficiency • Same tree • Data consistency • "Blind" interoperability • Space/time efficiency • Ease of use
PostgreSQL val elsA Archival example • Validation database • 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 - poinot@onera.fr # 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) if (loc != midlevel.Vertex): print "Error, GridLocation must be Vertex! Currently:", print midlevel.GridLocation[loc] # 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) • <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' /> • <DIMENSIONS total='1'> • </NODE> • </NODE> • <NODE name='InputFileUsed 4' label='Descriptor_t'> • <DATA type='C1' /> • <DIMENSIONS total='19926'> • 19926 • </DIMENSIONS> • <VALUES> • FILES: • challenge.cgns • ... • </VALUES> • </NODE> <NODE name='CoordinateX' label='DataArray_t'> <DATA type='R8' /> <DIMENSIONS total='6150'> 2 123 25 </DIMENSIONS> <VALUES> </VALUES> </NODE>
pyCGNS Status • 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 • 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 • http://elsa.onera.fr/CGNS/releases • Python • http://www.python.org