pyCAPS
pyCAPS: A Python Extension Module for CAPS
analysis7.py

Example use cases for interacting the pyCAPS._capsAnalysis.addAttribute() and pyCAPS._capsAnalysis.getAttribute() functions.

1 from __future__ import print_function
2 
3 # Import pyCAPS module (Linux and OSx = pyCAPS.so file; Windows = pyCAPS.pyd file)
4 import pyCAPS
5 
6 # Instantiate our CAPS problem "myProblem"
7 print("Initiating capsProblem")
8 myProblem = pyCAPS.capsProblem()
9 
10 # Load a *.csm file "./csmData/cfdMultiBody.csm" into our newly created problem. The
11 # project name "basicTest" may be optionally set here; if no argument is provided
12 # the CAPS file provided is used as the project name.
13 print("Loading file into our capsProblem")
14 myGeometry = myProblem.loadCAPS("./csmData/cfdMultiBody.csm", "basicTest")
15 
16 # Load Tetgen aim
17 tetgen = myProblem.loadAIM(aim = "tetgenAIM",
18  altName = "tetgen",
19  analysisDir = "TetGenAnalysisTest",
20  capsIntent = "CFD")
21 
22 # Add attribute
23 tetgen.addAttribute("testAttr", [1, 2, 3])
24 
25 # Add another attribute
26 tetgen.addAttribute("testAttr_2", "anotherAttribute")
27 
28 myValue = tetgen.getAttribute("testAttr")
29 print("Value = ", myValue)
30 
31 myValue = tetgen.getAttribute("testAttr_2")
32 print("Value = ", myValue)
33 
34 # Close our problems
35 print("Closing our problem")
36 myProblem.closeCAPS()
37