-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathintroduction.html
More file actions
227 lines (201 loc) · 13.5 KB
/
introduction.html
File metadata and controls
227 lines (201 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>About pyCGNS — intro</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/pycgns.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/pyCGNS-logo-tiny.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="CGNS How to?" href="ch2/cgnshowto.html" />
<link rel="prev" title="A Python package for CGNS" href="index.html" />
</head><body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="search.html" title="search"
accesskey="S">search</a>
</li>
<li class="right" >
<a href="glossary.html" title="glossary"
accesskey="G">glossary</a>
|</li>
<li class="right" >
<a href="genindex.html" title="General Index"
accesskey="I">index</a>
|</li>
<li class="right" >
<a href="ch2/cgnshowto.html" title="CGNS How to?"
accesskey="N">next</a>
|</li>
<li class="right" >
<a href="index.html" title="A Python package for CGNS"
accesskey="P">previous</a>
|</li>
<li class="right" >
<a href="index.html" title="pyCGNS top page"
accesskey="M">top</a>
|</li>
<li><a href=index.html>pyCGNS</a> »</li>
<li class="nav-item nav-item-0"><a href="index.html">intro</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 align=center><a href="index.html">
<img class="logo" src="_static/intro-logo-small.png" alt="pyCGNS"/>
</a></h1>
<div>
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">About pyCGNS</a><ul>
<li><a class="reference internal" href="#cgns-standard">CGNS Standard</a></li>
<li><a class="reference internal" href="#package-contents">Package contents</a></li>
<li><a class="reference internal" href="#quick-start">Quick start</a><ul>
<li><a class="reference internal" href="#loading-a-cgns-hdf-file-with-map">Loading a CGNS/HDF file with MAP</a></li>
<li><a class="reference internal" href="#using-pat-to-modify-a-cgns-tree">Using PAT to modify a CGNS tree</a></li>
<li><a class="reference internal" href="#using-pat-to-create-a-cgns-tree">Using PAT to create a CGNS tree</a></li>
<li><a class="reference internal" href="#browsing-your-cgns-tree-with-nav">Browsing your CGNS tree with NAV</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="about-pycgns">
<h1>About pyCGNS<a class="headerlink" href="#about-pycgns" title="Permalink to this headline">¶</a></h1>
<div class="section" id="cgns-standard">
<h2>CGNS Standard<a class="headerlink" href="#cgns-standard" title="Permalink to this headline">¶</a></h2>
<p>The purpose of these pages is not to describe the standard. There is
the <a class="reference internal" href="glossary.html#term-cgns.org"><span class="xref std std-term">cgns.org</span></a> web site with a lot of documentation. Anyway, there is
a set of <a class="reference internal" href="ch2/cgnshowto.html#cgnshowto"><span class="std std-ref">How to’s</span></a> using <em>pyCGNS</em> you can browse and learn
a bit about this standard.</p>
<div class="toctree-wrapper compound">
</div>
</div>
<div class="section" id="package-contents">
<h2>Package contents<a class="headerlink" href="#package-contents" title="Permalink to this headline">¶</a></h2>
<p>The pyCGNS Python module is a collection of 7 modules around the
CGNS standard. Before v4, these modules were independent Python modules
with more or less dependancies to each other. We gather all of them to
have a common build/install/doc and test process, moreover this insures a
better consistency between them.</p>
<p>The pyCGNS module now includes (former package names)</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference external" href="MAP/readme.html">MAP</a>, the Mapper, new in v4 gives basic load/save
function from/to <em>CGNS/SIDS</em> and <em>CGNS/HDF5</em>. This very sinple module is
able to read/write GCNS/HDF5 files and translate them to CGNS/Python.
This is the main feature of pyCGNS v4.0.</p></li>
<li><p><a class="reference external" href="PAT/readme.html">PAT</a>, the PatterMaker, a full <em>CGNS/SIDS</em> patterns using
the <em>CGNS/Python</em> mapping. This is pure python module, it creates and modify
CGNS/Python trees without the help of any HDF5 or even ADf calls.</p></li>
<li><p><a class="reference external" href="NAV/readme.html">NAV</a>, the Navigater (was pyS7), a graphical browser that can
handle <em>CGNS/Python</em>, <em>CGNS/HDF5</em> and <em>CGNS/ADF</em> file formats. It is slightly
different to <em>cgnsviewer</em> because it actually is a tree editor, you can
copy/cut/paste CGNS/Python trees and quickly draft or modify your CGNS tree.</p></li>
<li><p>VAL,the Validater (was pyC5), an XML grammar based validation of a <em>CGNS/Python</em>
tree, for example produced using <em>MAP</em> or <em>PAT</em>.</p></li>
<li><p>DAT, the DataTracer (was pyDAX), some DBMS services for <em>CGNS/HDF5</em> files.
<em>Not maintained anymore in v4.0 (to be resumed 2014/2015)</em></p></li>
<li><p>APP, the ApplicationSampler, a set of applications using other modules.</p></li>
</ul>
</div></blockquote>
</div>
<div class="section" id="quick-start">
<h2>Quick start<a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h2>
<div class="section" id="loading-a-cgns-hdf-file-with-map">
<h3>Loading a CGNS/HDF file with MAP<a class="headerlink" href="#loading-a-cgns-hdf-file-with-map" title="Permalink to this headline">¶</a></h3>
<p>The <em>CGNS.MAP</em> module implements the <em>CGNS/Python</em> mapping. You can
load/save a <em>CGNS/HDF5</em> file using the simple <em>MAP</em> functions (below,
the <code class="docutils literal notranslate"><span class="pre">>>></span></code> string is the python interpreter prompt):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">CGNS.MAP</span>
<span class="gp">>>> </span><span class="p">(</span><span class="n">tree</span><span class="p">,</span><span class="n">links</span><span class="p">,</span><span class="n">paths</span><span class="p">)</span><span class="o">=</span><span class="n">CGNS</span><span class="o">.</span><span class="n">MAP</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s2">"./001Disk.hdf"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">print</span> <span class="n">tree</span>
<span class="go">['CGNSTree', None, [['CGNSLibraryVersion',array([ 2.4000001],dtype=float32),</span>
<span class="go">[], 'CGNSLibraryVersion_t'], ['Disk', array([3, 3], dtype=int32),</span>
<span class="go">[['.Solver#Command', ... ]</span>
</pre></div>
</div>
<p>Now <code class="docutils literal notranslate"><span class="pre">tree</span></code> is a Python list with <code class="docutils literal notranslate"><span class="pre">./001Disk.hdf</span></code> CGNS tree
into, with the data structure as described
in <span class="xref std std-ref">SIDS-to-Python</span>.</p>
</div>
<div class="section" id="using-pat-to-modify-a-cgns-tree">
<h3>Using PAT to modify a CGNS tree<a class="headerlink" href="#using-pat-to-modify-a-cgns-tree" title="Permalink to this headline">¶</a></h3>
<p>The previously loaded <em>CGNS/Python</em> tree is modified using plain Python
functions and types. The <em>CGNS.APP</em> module contains utilities, we use the
<code class="docutils literal notranslate"><span class="pre">getNodeByPath</span></code> function which returns a <em>CGNS/Python</em> node with the
target tree and the target node path as parameters. In the example hereafter,
we are loading a sample tree from the <em>pyCGNS</em> test suite:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">CGNS.PAT.cgnsutils</span> <span class="k">as</span> <span class="nn">CGU</span>
<span class="kn">import</span> <span class="nn">CGNS.PAT.test.disk</span> <span class="k">as</span> <span class="nn">data</span>
<span class="n">node</span><span class="o">=</span><span class="n">CGU</span><span class="o">.</span><span class="n">getNodeByPath</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">T</span><span class="p">,</span><span class="s2">"/{Base#1}/{Zone-D1}/ZoneGridConnectivity/{CT-D1-D2}"</span><span class="p">)</span>
<span class="nb">print</span> <span class="n">node</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="nb">print</span> <span class="n">node</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">tostring</span><span class="p">()</span>
</pre></div>
</div>
<p>The returned node is a list of 4 Python values, the name (a string),
the value of the node (a <em>Numpy</em> array), the list of children and
the CGNS type of the node (string). The returned node of the example is a string
array, you may want to use the <code class="docutils literal notranslate"><span class="pre">tostring</span></code> function to make it more readable.</p>
</div>
<div class="section" id="using-pat-to-create-a-cgns-tree">
<h3>Using PAT to create a CGNS tree<a class="headerlink" href="#using-pat-to-create-a-cgns-tree" title="Permalink to this headline">¶</a></h3>
<p>We want to create a <em>CGNS/HDF5</em> file with a simple <em>base</em> and a <em>reference
state</em>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">CGNS.PAT.cgnslib</span> <span class="k">as</span> <span class="nn">CGL</span>
<span class="n">T</span><span class="o">=</span><span class="n">CGL</span><span class="o">.</span><span class="n">newCGNSTree</span><span class="p">()</span>
<span class="n">CGL</span><span class="o">.</span><span class="n">newBase</span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="s1">'Test Case 01'</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span> <span class="c1"># name, physical dim, topological dim</span>
<span class="n">CGL</span><span class="o">.</span><span class="n">newSimulationType</span><span class="p">(</span><span class="n">T</span><span class="p">)</span>
<span class="n">CGL</span><span class="o">.</span><span class="n">newReferenceState</span><span class="p">(</span><span class="n">T</span><span class="p">)</span>
</pre></div>
</div>
<p>Each time you call a function you pass the parent node and some parameters.
The tree is built as a python list, the top list is referenced by the <code class="docutils literal notranslate"><span class="pre">T</span></code>
variable here. As it is passed as argument to each call the new nodes are
added to <code class="docutils literal notranslate"><span class="pre">T</span></code> into the function. The the resulting <code class="docutils literal notranslate"><span class="pre">T</span></code> is changed in place.</p>
</div>
<div class="section" id="browsing-your-cgns-tree-with-nav">
<h3>Browsing your CGNS tree with NAV<a class="headerlink" href="#browsing-your-cgns-tree-with-nav" title="Permalink to this headline">¶</a></h3>
<p>The CGNS.NAV tool is a CGNS tree brower. You start it typing <code class="docutils literal notranslate"><span class="pre">CGNS.NAV</span></code>
(or <code class="docutils literal notranslate"><span class="pre">cg_look</span></code>) and you can open several views on your file.</p>
<a class="reference internal image-reference" href="_images/cgnsnav_quick_1.png"><img alt="_images/cgnsnav_quick_1.png" class="align-center" src="_images/cgnsnav_quick_1.png" style="width: 24cm;" /></a>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer" role="contentinfo">
© Copyright 2018-2022, M. P..
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
</div>
</body>
</html>