|
6 | 6 | :class:`Volume`
|
7 | 7 | """
|
8 | 8 |
|
9 |
| -# External modules |
10 |
| -import numpy as np |
11 |
| - |
12 | 9 | # Local modules
|
13 | 10 | from . import libspline # noqa: F401
|
14 |
| -from .pyCurve import Curve |
15 |
| -from .pySurface import Surface |
16 |
| -from .pyVolume import Volume |
17 |
| -from .utils import Error |
18 |
| - |
19 |
| -# ---------------------------------------------------------------------- |
20 |
| -# Misc Helper Functions |
21 |
| -# ---------------------------------------------------------------------- |
22 |
| - |
23 |
| - |
24 |
| -def trilinearVolume(*args): |
25 |
| - """This is a short-cut function to create a trilinear b-spline |
26 |
| - volume. It can be created with ``x`` **OR** with ``xmin`` and |
27 |
| - ``xmax``. |
28 |
| -
|
29 |
| - Parameters |
30 |
| - ---------- |
31 |
| - x : array of size (2, 2, 2, 3) |
32 |
| - Coordinates of the corners of the box. |
33 |
| -
|
34 |
| - xmin : array of size (3) |
35 |
| - The extreme lower corner of the box |
36 |
| - xmax : array of size (3) |
37 |
| - The extreme upper corner of the box. In this case, by |
38 |
| - construction, the box will be coordinate axis aligned. |
39 |
| - """ |
40 |
| - tu = [0, 0, 1, 1] |
41 |
| - tv = [0, 0, 1, 1] |
42 |
| - tw = [0, 0, 1, 1] |
43 |
| - ku = 2 |
44 |
| - kv = 2 |
45 |
| - kw = 2 |
46 |
| - |
47 |
| - if len(args) == 1: |
48 |
| - return Volume(coef=args[0], tu=tu, tv=tv, tw=tw, ku=ku, kv=kv, kw=kw) |
49 |
| - elif len(args) == 2: |
50 |
| - xmin = np.array(args[0]).astype("d") |
51 |
| - xmax = np.array(args[1]).astype("d") |
52 |
| - |
53 |
| - xLow = xmin[0] |
54 |
| - xHigh = xmax[0] |
55 |
| - yLow = xmin[1] |
56 |
| - yHigh = xmax[1] |
57 |
| - zLow = xmin[2] |
58 |
| - zHigh = xmax[2] |
59 |
| - |
60 |
| - coef = np.zeros((2, 2, 2, 3)) |
61 |
| - coef[0, 0, 0, :] = [xLow, yLow, zLow] |
62 |
| - coef[1, 0, 0, :] = [xHigh, yLow, zLow] |
63 |
| - coef[0, 1, 0, :] = [xLow, yHigh, zLow] |
64 |
| - coef[1, 1, 0, :] = [xHigh, yHigh, zLow] |
65 |
| - coef[0, 0, 1, :] = [xLow, yLow, zHigh] |
66 |
| - coef[1, 0, 1, :] = [xHigh, yLow, zHigh] |
67 |
| - coef[0, 1, 1, :] = [xLow, yHigh, zHigh] |
68 |
| - coef[1, 1, 1, :] = [xHigh, yHigh, zHigh] |
69 |
| - |
70 |
| - return Volume(coef=coef, tu=tu, tv=tv, tw=tw, ku=ku, kv=kv, kw=kw) |
71 |
| - else: |
72 |
| - raise Error("An unknown number of arguments was passed to trilinear Volume") |
73 |
| - |
74 |
| - |
75 |
| -def bilinearSurface(*args): |
76 |
| - """This is short-cut function to create a bilinear surface. |
77 |
| -
|
78 |
| - Args can contain: |
79 |
| -
|
80 |
| - 1. ``x`` array of size(4, 3). The four corners of the array |
81 |
| - arranged in the coordinate direction orientation:: |
82 |
| -
|
83 |
| - 2 3 |
84 |
| - +----------+ |
85 |
| - | | |
86 |
| - | | |
87 |
| - | | |
88 |
| - +----------+ |
89 |
| - 0 1 |
90 |
| -
|
91 |
| - 2. ``p1``, ``p2``, ``p3``, ``p4``. Individual corner points in CCW Ordering:: |
92 |
| -
|
93 |
| - 3 2 |
94 |
| - +----------+ |
95 |
| - | | |
96 |
| - | | |
97 |
| - | | |
98 |
| - +----------+ |
99 |
| - 0 1 |
100 |
| - """ |
101 |
| - if len(args) == 1: |
102 |
| - # One argument passed in ... assume its X |
103 |
| - if len(args[0]) != 4: |
104 |
| - raise Error("A single argument passed to bilinear surface must contain 4 points and be of size (4, 3)") |
105 |
| - coef = np.zeros((2, 2, 3)) |
106 |
| - coef[0, 0] = args[0][0] |
107 |
| - coef[1, 0] = args[0][1] |
108 |
| - coef[0, 1] = args[0][2] |
109 |
| - coef[1, 1] = args[0][3] |
110 |
| - return Surface(coef=coef, tu=[0, 0, 1, 1], tv=[0, 0, 1, 1], ku=2, kv=2) |
111 |
| - else: |
112 |
| - # Assume 4 arguments |
113 |
| - coef = np.zeros([2, 2, 3]) |
114 |
| - coef[0, 0] = args[0] |
115 |
| - coef[1, 0] = args[1] |
116 |
| - coef[0, 1] = args[3] |
117 |
| - coef[1, 1] = args[2] |
118 |
| - return Surface(coef=coef, tu=[0, 0, 1, 1], tv=[0, 0, 1, 1], ku=2, kv=2) |
119 |
| - |
120 |
| - |
121 |
| -def line(*args, **kwargs): |
122 |
| - """This is a short cut function to create a line as a pySpline Curve object. |
123 |
| -
|
124 |
| - Args can contain: (pick one) |
125 |
| -
|
126 |
| - 1. ``X`` array of size(2, ndim). The two end points |
127 |
| - 2. ``x1``, ``x2`` The two end points (each of size ndim) |
128 |
| - 3. ``x```, dir=direction. A point and a displacement vector |
129 |
| - 4. ``x1``, dir=direction, length=length. As 3. but with a specific length |
130 |
| - """ |
131 |
| - |
132 |
| - if len(args) == 2: |
133 |
| - # Its a two-point type |
134 |
| - return Curve(coef=[args[0], args[1]], k=2, t=[0, 0, 1, 1]) |
135 |
| - elif len(args) == 1: |
136 |
| - if len(args[0]) == 2: # its X |
137 |
| - return Curve(coef=args[0], k=2, t=[0, 0, 1, 1]) |
138 |
| - elif "dir" in kwargs: |
139 |
| - # We have point and direction |
140 |
| - if "length" in kwargs: |
141 |
| - x2 = args[0] + kwargs["dir"] / np.linalg.norm(kwargs["dir"]) * kwargs["length"] |
142 |
| - else: |
143 |
| - x2 = args[0] + kwargs["dir"] |
144 |
| - |
145 |
| - return Curve(coef=[args[0], x2], k=2, t=[0, 0, 1, 1]) |
146 |
| - else: |
147 |
| - Error("Error: dir must be specified if only 1 argument is given") |
| 11 | +from .pyCurve import Curve # noqa: F401 |
| 12 | +from .pySurface import Surface # noqa: F401 |
| 13 | +from .pyVolume import Volume # noqa: F401 |
| 14 | +from .utils import ( # noqa: F401 |
| 15 | + bilinearSurface, |
| 16 | + checkInput, |
| 17 | + closeTecplot, |
| 18 | + line, |
| 19 | + openTecplot, |
| 20 | + trilinearVolume, |
| 21 | + writeTecplot1D, |
| 22 | + writeTecplot2D, |
| 23 | + writeTecplot3D, |
| 24 | +) |
0 commit comments