Repository navigation
Expand file tree
/
Copy pathauxiliaryFunctions.py
More file actions
102 lines (81 loc) · 3.18 KB
/
Copy pathauxiliaryFunctions.py
File metadata and controls
102 lines (81 loc) · 3.18 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import numpy as np
import argparse
import jsonref as json
def initialize():
parser = argparse.ArgumentParser(
prog='(py)gmsh based tool for the simpliest turbomachinery mesh',
description='For more information see README.md.')
parser.add_argument('path', metavar='path', type=str,
help='path to json with description of the case')
parser.add_argument('-planar', action='store_true',
help='generate truly 2D mesh')
args = parser.parse_args()
if args.planar:
print('Truly 2D mesh will be generated.')
featuresFile = open(args.path)
f = json.load(featuresFile)
f['2D'] = args.planar
dictionaries = [f, f['geometry'], f['geometry']['profile'], f['mesh'], f['domain']]
for dictionary in dictionaries:
keysToDelete = []
for key in dictionary.keys():
if not dictionary[key]:
keysToDelete.append(key)
for key in keysToDelete:
del dictionary[key]
return f
def loadProfile(features):
profile = features['geometry']['profile']
coor_suction = np.genfromtxt(features['working directory']+profile['name of suction' ],
delimiter=profile['delimiter'], dtype=float)
coor_pressure = np.genfromtxt(features['working directory']+profile['name of pressure'],
delimiter=profile['delimiter'], dtype=float)
if'reverse suction' in profile.keys():
coor_suction = np.flip(coor_suction, axis=0)
if'reverse pressure' in profile.keys():
coor_pressure = np.flip(coor_pressure, axis=0)
if 'scaled by' in profile:
coor_suction = coor_suction *profile['scaled by']
coor_pressure = coor_pressure*profile['scaled by']
return coor_suction, coor_pressure
def lengths(angle, length):
return np.cos(np.deg2rad(angle))*length, np.sin(np.deg2rad(angle))*length
def elementSize(f):
domain = f['domain']
mesh = f['mesh']
iterator = 0
arr = [mesh["SW BL properties"]["size first"]]
while np.sum(arr) <= domain['thickness']/2:
arr = np.append(
arr,
np.min([
mesh["SW BL properties"]["size first"]*mesh["SW BL properties"]['ratio']**iterator,
mesh["SW BL properties"]["size last"]
])
)
iterator +=1
return arr
def getExtrusionParameters(f):
domain = f['domain']
mesh = f['mesh']
extrude_z = domain['thickness']
if mesh['n layers in z'] == 1:
extrude_num = [1]
extrude_heights = []
else:
if 'side walls boundary layer' not in mesh.keys():
extrude_num = [mesh['n layers in z']]
extrude_heights = []
else:
extrude_size = elementSize(f)
extrude_num = np.ones(len(extrude_size)*2)
print(f'Number of cells in z is {len(extrude_size)*2}.')
extrude_size = np.append(extrude_size, np.flip(extrude_size))
extrude_heights = np.ones(len(extrude_size))
extrude_heights[0] = mesh["SW BL properties"]["size first"]
for i in range(1, len(extrude_heights)):
extrude_heights[i] = extrude_heights[i-1]+extrude_size[i]
extrude_heights = extrude_heights/extrude_heights[-1]
return extrude_z, extrude_num, extrude_heights
if __name__ == "__main__":
print('I do nothing, I am just a storage of functions.')