-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbc.py
More file actions
26 lines (19 loc) · 866 Bytes
/
bc.py
File metadata and controls
26 lines (19 loc) · 866 Bytes
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
import numpy as np
class BC(object):
def __init__(self, geom):
self.kind = np.empty(geom.faces.num, dtype="str")
self.val = np.zeros(geom.faces.num)
def side_gf_idx(self, geom, side):
if side is "left":
idx = np.logical_and(geom.faces.neighbors[0,:] < 0, geom.faces.normals[0,:] > 0)
elif side is "right":
idx = np.logical_and(geom.faces.neighbors[1,:] < 0, geom.faces.normals[0,:] > 0)
elif side is "bottom":
idx = np.logical_and(geom.faces.neighbors[0,:] < 0, geom.faces.normals[1,:] > 0)
elif side is "top":
idx = np.logical_and(geom.faces.neighbors[1,:] < 0, geom.faces.normals[1,:] > 0)
return idx
def dirichlet(self, geom, side, val):
idx = self.side_gf_idx(geom, side)
self.kind[idx] = "D"
self.val[idx] = val