cape.cgns
: CGNS file interface¶
This module provides a class for reading CGNS files of certain types
that have been implemented. The main purpose is to read surface
triangulations with quads and convert it into a cape.tri.Tri
object. However, the class provided in this module,
cape.cgns.CGNS
, must be converted into a cape.tri.Tri
or other object externally. This module merely reads the file, reads
the data from each node, and constructs a sub-node table.
In order to create a triangulation interface from a CGNS file, see
cape.tri.Tri
, and use the cgns keyword argument.
- cape.cgns.ADFAddress2Pos(addr)¶
Convert ADF 12-byte code into position index
This is a hex code with but skipping the 8th character
- Call:
>>> pos = ADFAddress2Pos(addr)
- Inputs:
- addr:
str
12-character string hex code
- addr:
- Outputs:
- pos:
int
Position in file in bytes
- pos:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- class cape.cgns.CGNS(fname)¶
Interface to CGNS files
- Call:
>>> cgns = cape.cgns.CGNS(fname)
- Inputs:
- fname:
str
Name of CGNS file
- fname:
- Outputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- cgns.nNode:
int
Number of nodes read
- cgns.NodeNames:
np.ndarray
[str
] Names of each node
- cgns.NodeLabels:
np.ndarray
[str
] Labels for each node (often a data type holder)
- cgns.NodeAddresses:
np.ndarray
[int
] File position of the beginning of each node
- cgns.DataTypes:
list
(str
) Data type for each node
- cgns.Data:
list
[np.ndarray
|str
] Data set for each node
- cgns.SubNodeTables:
list
[list
|None
] List of any child nodes for each node
- cgns:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- GetCompIDInfo(comp)¶
Get the info for a named zone with type Elements_t
- Call:
>>> ka, kb, Elems = cgns.GetCompIDInfo(comp) >>> ka, kb, Elems = cgns.GetCompIDInfo(addr)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- comp:
str
Name of component to read
- addr:
int
Address of the node within the file
- cgns:
- Outputs:
- ka:
int
Element index of the first element in comp (1-based)
- kb:
int
Element index of the last element in comp (1-based)
- Elems:
np.ndarray
shape: (nElem, nVert)
Array of vertex indices for each element
- ka:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- GetNodeByAddress(addr)¶
Get index of node by explicit address (unique identifier)
- Call:
>>> k = cgns.GetNodeByAddress(addr)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- addr: {
None
} |int
Address of the beginning of the node
- cgns:
- Outputs:
- k:
int
Node index
- k:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- GetNodeIndex(name=None, label=None, addr=None)¶
Get index of a node by name and label or address
- Call:
>>> K = cgns.GetNodeIndex(name=None, label=None, addr=None) >>> K = cgns.GetNodeIndex(name) >>> K = cgns.GetNodeIndex(name, label) >>> K = cgns.GetNodeIndex(addr)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- name: {
None
} |str
Node name
- label: {
None
} |str
Node label
- addr: {
None
} |int
Address of the beginning of the node
- cgns:
- Outputs:
- k:
np.ndarray
[int
] Node index list
- k:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- GetSubNodeByLabel(k, label)¶
Get subnode by desired type
- Call:
>>> J = cgns.GetSubNodeByLabel(k, label)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- k:
int
Node index (0-based)
- label:
str
Desired label
- cgns:
- Outputs:
- J:
np.ndarray
[int
] List of such subnodes
- J:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- GetSubNodeByName(k, name)¶
Get subnode by desired name
- Call:
>>> J = cgns.GetSubNodeByName(k, name)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- k:
int
Node index (0-based)
- name:
str
Desired name
- cgns:
- Outputs:
- J:
np.ndarray
[int
] List of such subnodes
- J:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- ReadADF(f)¶
Read open CGNS/ADF file, currently at position 0
- Call:
>>> cgns.ReadADF(f)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of NoDe field
- cgns:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- ReadADFData(f, dt)¶
Read one DaTa entry from an open CGNS/ADF file
The next four bytes must be the string
"DaTa"
, and the following 12 bytes must give the address of the end of the field as a hex code string.- Call:
>>> data = cgns.ReadADFData(f, dt)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of DaTa field
- dt:
"MT"
|"C1"
|"I4"
|"R4"
|"R8"
Data type, two-digit code
- cgns:
- Outputs:
- data:
np.ndarray
|str
Data read from file
- data:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- ReadADFFree(f)¶
Read one FreE entry from an open CGNS/ADF file
The next 4 bytes must be the string
"FreE"
, and the following 12 bytes must give the address of the end of the field as a hex code string.- Call:
>>> cgns.ReadADFFreE(f)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of DaTa field
- cgns:
- Versions:
2018-03-05
@ddalle
: Version 1.0
- ReadADFNode(f)¶
Read a (new) node from an open CGNS/ADF file
- Call:
>>> cgns.ReadADFNode(f)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of NoDe field
- cgns:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- ReadADFSubNodeTable(f)¶
Read one SNTb entry from an open CGNS/ADF file
The next four bytes must be the string
"SNTb"
, and the following 12 bytes must give the address of the end of the field as a hex code string.- Call:
>>> sntb = cgns.ReadADFSubNodeTable(f)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of DaTa field
- cgns:
- Outputs:
- sntb:
np.array
[[str
,int
]] List of name and begin addresses of any subnodes
- sntb:
- Versions:
2018-03-02
@ddalle
: Version 1.0
- ReadADFZs(f)¶
Read strings like “zzzzzzzzzzzz” until a relevant char
- Call:
>>> cgns.ReadADFZs(f)
- Inputs:
- cgns:
cape.cgns.CGNS
CGNS file interface
- f:
file
Open file currently at the beginning of DaTa field
- cgns:
- Versions:
2018-03-05
@ddalle
: Version 1.0