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

Example use case for the pyCAPS.capsProblem.loadCAPS() and pyCAPS.capsProblem.saveCAPS() functions - using a CAPS file to initiate a new problem.

1 # Use: Load a analysis module (AIM) into the problem, save the problem, then use that CAPS file
2 # to initiate a new problem
3 
4 from __future__ import print_function
5 
6 # Import pyCAPS module (Linux and OSx = pyCAPS.so file; Windows = pyCAPS.pyd file)
7 import pyCAPS
8 
9 # Instantiate our CAPS problem "myProblem"
10 print("Initiating capsProblem")
11 myProblem = pyCAPS.capsProblem()
12 
13 # Load a *.csm file "./csmData/cfdMultiBody.csm" into our newly created problem. The
14 # project name "basicTest" may be optionally set here; if no argument is provided
15 # the CAPS file provided is used as the project name.
16 print("Loading file into our capsProblem")
17 myGeometry = myProblem.loadCAPS("./csmData/cfdMultiBody.csm", "basicTest")
18 
19 # Load FUN3D aim
20 myAnalysis = myProblem.loadAIM(aim = "fun3dAIM",
21  altName = "fun3d",
22  analysisDir = "FUN3DAnalysisTest",
23  capsIntent = "CFD")
24 
25 # Run pre and post to get the analysis in a "clean" state
26 myAnalysis.preAnalysis()
27 myAnalysis.postAnalysis()
28 
29 # Add a value/parameter to problem
30 myValye = myProblem.createValue("Mach", 0.5)
31 
32 # Save our problem - use default name
33 print("Saving out problem")
34 myProblem.saveCAPS()
35 
36 # Close our problem
37 print("Closing our problem")
38 myProblem.closeCAPS()
39 
40 #Create a new problem
41 myProblem = pyCAPS.capsProblem()
42 
43 # Reload the saved problem
44 print("Reload the saved problem")
45 myGeometry = myProblem.loadCAPS("saveCAPS.caps")
46 
47 # Get a copy of the analysis object
48 myAnalysis = myProblem.analysis["fun3d"]
49 
50 # Get analysis
51 myAnalysis.getAnalysisInfo()
52 
53 # Check other features of analysis object
54 print(myAnalysis.aimName)
55 print(myAnalysis.analysisDir)
56 
57 # Get a copy of the value object
58 myValue = myProblem.value["Mach"]
59 print("Value =", myValue.value)
60