File: plugin.py

package info (click to toggle)
gmsh 4.15.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 52,880 kB
  • sloc: cpp: 440,657; ansic: 114,930; f90: 15,611; python: 13,907; yacc: 7,438; java: 3,491; lisp: 3,206; lex: 633; perl: 571; makefile: 500; xml: 414; sh: 407; javascript: 113; modula3: 32
file content (38 lines) | stat: -rw-r--r-- 1,113 bytes parent folder | download | duplicates (6)
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
import gmsh
import sys

gmsh.initialize(sys.argv)

# Copied from discrete.py...
gmsh.model.add("test")
gmsh.model.addDiscreteEntity(2, 1)
gmsh.model.mesh.addNodes(2, 1, [1, 2, 3, 4],
                         [0., 0., 0., 1., 0., 0., 1., 1., 0., 0., 1., 0.])
gmsh.model.mesh.addElements(2, 1, [2], [[1, 2]], [[1, 2, 3, 1, 3, 4]])
# ... end of copy

# create a view with some data
t = gmsh.view.add("some data")
gmsh.view.addModelData(t, 0, "test", "NodeData", [1, 2, 3, 4],
                       [[1.], [10.], [20.], [1.]])

# test getting data back
dataType, tags, data, time, numComp = gmsh.view.getModelData(t, 0)
print(dataType, tags)

# compute the iso-curve at value 11
gmsh.plugin.setNumber("Isosurface", "Value", 11.)
gmsh.plugin.run("Isosurface")

# delete the source view
gmsh.view.remove(t)

# check how many views the plugin created (a priori, a single list-based one)
tags = gmsh.view.getTags()
if len(tags) == 1:
    gmsh.view.write(tags[0], "iso.msh")
    # test getting data back
    dataTypes, numElements, data = gmsh.view.getListData(tags[0])
    print(dataTypes, numElements)

gmsh.finalize()