4 Support functions for reading or calculating DISPATCH2 grid and geometry information. 11 """Calculate and store the geometric factors used by curvilinear grids.""" 48 """Initialise geometric factors based on coord. type.""" 55 """Initialise geometric factors for a Cartesian coord. system.""" 60 self[
'h2c'] = np.ones(n1)
61 self[
'h2f'] = np.ones(n1)
62 self[
'h31c'] = self[
'h2c'].view()
63 self[
'h31f'] = self[
'h2f'].view()
66 self[
'h32c'] = np.ones(n2)
67 self[
'h32f'] = self[
'h32c'].view()
70 self[
'dx1c'] = np.ones(n1) * p.ds[0]
71 self[
'dx1f'] = np.ones(n1) * p.ds[0]
72 self[
'dx2c'] = np.ones(n2) * p.ds[1]
73 self[
'dx2f'] = np.ones(n2) * p.ds[1]
74 self[
'dx3c'] = np.ones(n3) * p.ds[2]
75 self[
'dx3f'] = np.ones(n3) * p.ds[2]
78 self[
'dvol1c'] = np.ones(n1) * p.ds[0]
79 self[
'dvol1f'] = np.ones(n1) * p.ds[0]
80 self[
'dvol2c'] = np.ones(n2) * p.ds[1]
81 self[
'dvol2f'] = np.ones(n2) * p.ds[1]
82 self[
'dvol3c'] = np.ones(n3) * p.ds[2]
83 self[
'dvol3f'] = np.ones(n3) * p.ds[2]
86 self[
'dar1c'] = self[
'h31c'] * self[
'h2c']
87 self[
'dar1f'] = self[
'h31f'] * self[
'h2f']
88 self[
'dar2c'] = self[
'h31f'] * p.ds[0] / self[
'dvol1c']
89 self[
'dar2f'] = self[
'h31c'] * p.ds[0] / self[
'dvol1f']
90 self[
'dar31c'] = self[
'h2f'] * p.ds[0] / self[
'dvol1c']
91 self[
'dar31f'] = self[
'h2c'] * p.ds[0] / self[
'dvol1f']
92 self[
'dar32c'] = p.ds[1] / self[
'dvol2c']
93 self[
'dar32f'] = p.ds[1] / self[
'dvol2f']
96 """Initialise geometric factors for a cylindrical coord. system.""" 101 self[
'h2c'] = np.ones(n1)
102 self[
'h2f'] = np.ones(n1)
103 self[
'h31c'] = self[
'h2c'].view()
104 self[
'h31f'] = self[
'h2f'].view()
107 pos_c = np.array(p.y )
108 pos_f = np.array(p.ys)
109 self[
'h32c'] = abs(pos_c)
110 self[
'h32f'] = abs(pos_f)
113 self[
'dx1c'] = np.ones(n1) * p.ds[0]
114 self[
'dx1f'] = np.ones(n1) * p.ds[0]
115 self[
'dx2c'] = np.ones(n2) * p.ds[1]
116 self[
'dx2f'] = np.ones(n2) * p.ds[1]
117 self[
'dx3c'] = np.ones(n3) * p.ds[2]
118 self[
'dx3f'] = np.ones(n3) * p.ds[2]
121 self[
'dvol1c'] = np.ones(n1) * p.ds[0]
122 self[
'dvol1f'] = np.ones(n1) * p.ds[0]
123 self[
'dvol2c'] = np.empty_like(pos_c)
124 self[
'dvol2f'] = np.empty_like(pos_f)
125 for j
in xrange(len(pos_c)-1):
126 self[
'dvol2c'][j] = 0.5 * abs( self[
'h32f'][j+1] * pos_f[j+1]
127 - self[
'h32f'][j ] * pos_f[j ] )
128 self[
'dvol2f'][j] = 0.5 * abs( self[
'h32c'][j ] * pos_c[j ]
129 - self[
'h32c'][j-1] * pos_c[j-1] )
130 self[
'dvol3c'] = np.ones(n3) * p.ds[2]
131 self[
'dvol3f'] = np.ones(n3) * p.ds[2]
134 self[
'dar1c'] = self[
'h31c'] * self[
'h2c']
135 self[
'dar1f'] = self[
'h31f'] * self[
'h2f']
136 self[
'dar2c'] = self[
'h31f'] * p.ds[0] / self[
'dvol1c']
137 self[
'dar2f'] = self[
'h31c'] * p.ds[0] / self[
'dvol1f']
138 self[
'dar31c'] = self[
'h2f'] * p.ds[0] / self[
'dvol1c']
139 self[
'dar31f'] = self[
'h2c'] * p.ds[0] / self[
'dvol1f']
140 self[
'dar32c'] = p.ds[1] / self[
'dvol2c']
141 self[
'dar32f'] = p.ds[1] / self[
'dvol2f']
144 """Initialise geometric factors for a spherical coord. system.""" 149 rpos_c = np.array(p.x)
150 rpos_f = np.array(p.xs)
151 self[
'h2c'] = abs(rpos_c)
152 self[
'h2f'] = abs(rpos_f)
153 self[
'h31c'] = self[
'h2c'].view()
154 self[
'h31f'] = self[
'h2f'].view()
157 tpos_c = np.array(p.y)
158 tpos_f = np.array(p.ys)
159 self[
'h32c'] = abs(np.sin(tpos_c))
160 self[
'h32f'] = abs(np.sin(tpos_f))
163 self[
'dx1c'] = np.ones(n1) * p.ds[0]
164 self[
'dx1f'] = np.ones(n1) * p.ds[0]
165 self[
'dx2c'] = np.ones(n2) * p.ds[1]
166 self[
'dx2f'] = np.ones(n2) * p.ds[1]
167 self[
'dx3c'] = np.ones(n3) * p.ds[2]
168 self[
'dx3f'] = np.ones(n3) * p.ds[2]
171 self[
'dvol1c'] = np.empty_like(rpos_c)
172 self[
'dvol1f'] = np.empty_like(rpos_f)
173 for i
in xrange(len(rpos_c)-1):
174 self[
'dvol1c'] = (self[
'h2f'][i+1] * self[
'h31f'][i+1] * rpos_f[i+1] / 3.0
175 - self[
'h2f'][i ] * self[
'h31f'][i ] * rpos_f[i ] / 3.0)
176 self[
'dvol1f'] = (self[
'h2c'][i ] * self[
'h31c'][i ] * rpos_c[i ] / 3.0
177 - self[
'h2c'][i-1] * self[
'h31c'][i-1] * rpos_c[i-1] / 3.0)
178 self[
'dvol2c'] = np.empty_like(tpos_c)
179 self[
'dvol2f'] = np.empty_like(tpos_f)
180 for j
in xrange(len(tpos_c)-1):
181 self[
'dvol2c'] = -np.cos(tpos_c[j+1]) + np.cos(tpos_c[j ])
182 self[
'dvol2f'] = -np.cos(tpos_f[j ]) + np.cos(tpos_f[j-1])
183 self[
'dvol3c'] = np.ones(n3) * p.ds[2]
184 self[
'dvol3f'] = np.ones(n3) * p.ds[2]
187 self[
'dar1c'] = self[
'h31c'] * self[
'h2c']
188 self[
'dar1f'] = self[
'h31f'] * self[
'h2f']
189 self[
'dar2c'] = self[
'h31f'] * p.ds[0] / self[
'dvol1c']
190 self[
'dar2f'] = self[
'h31c'] * p.ds[0] / self[
'dvol1f']
191 self[
'dar31c'] = self[
'h2f'] * p.ds[0] / self[
'dvol1c']
192 self[
'dar31f'] = self[
'h2c'] * p.ds[0] / self[
'dvol1f']
193 self[
'dar32c'] = p.ds[1] / self[
'dvol2c']
194 self[
'dar32f'] = p.ds[1] / self[
'dvol2f']
def init_Cartesian(self, p)
def init_spherical(self, p)
def init_cylindrical(self, p)
def __init__(self, patch)