-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeshTools.py
More file actions
61 lines (48 loc) · 1.24 KB
/
MeshTools.py
File metadata and controls
61 lines (48 loc) · 1.24 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Tools to set up meshing and potential distributions
DSPotential
"""
import numpy as np
from PotentialFlows.Uniform import UniformFlow
def setupGrid(n, xbounds, ybounds):
"""
Returns a set of x and y coordinates (meshgrid)
Parameters
----------
n: float
Number of points in the meshgrid
xbounds: ndarray
x-axis bounds of the meshgrid (e.g.: [-2, 2])
ybounds: float
y-axis bounds of the meshgrid (e.g.: [-2, 2])
Returns
-------
X: ndarray
X array of meshgrid
Y: ndarray
Y array of meshgrid
"""
x_min, x_max = xbounds
y_min, y_max = ybounds
x = np.linspace(x_min, x_max, n)
y = np.linspace(y_min, y_max, n)
X, Y = np.meshgrid(x, y)
return X, Y
def computeCp(u, v, uniformFlow:UniformFlow):
"""
Returns the pressure coefficient distribution
Parameters
----------
u: ndarray
x-component of the velocity field
v: ndarray
y-component of the velocity field
uniformFlow: UniformFlow
UniformFlow object
Returns
-------
Cp: ndarray
Pressure coefficient distribution
"""
Cp = 1 - (u**2 + v**2) / uniformFlow.strength**2
return Cp