File: read_meshio.py

package info (click to toggle)
netgen 6.2.2501%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,980 kB
  • sloc: cpp: 165,197; tcl: 6,310; python: 2,804; sh: 522; makefile: 87
file content (22 lines) | stat: -rw-r--r-- 629 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from netgen.meshing import *

def ReadViaMeshIO(filename):
    import meshio
    import numpy as np
    
    # print ("reading via meshio:", filename)

    m = meshio.read(filename)
    pts = m.points
    
    mesh = Mesh(dim=pts.shape[1])
    # mesh.AddPoints ( np.asarray(pts, dtype=np.float64) )  # needed for correct little/big endian
    mesh.AddPoints ( pts )  

    fd = mesh.Add (FaceDescriptor(bc=1))
    for cb in m.cells:
        # mesh.AddElements(dim=cb.dim, index=1, data=np.asarray(cb.data, dtype=np.int32), base=0)
        mesh.AddElements(dim=cb.dim, index=1, data=cb.data, base=0)
            
    return mesh