(dim:int, order: int)
| 33 | |
| 34 | _intrules = {} |
| 35 | def get_intrules(dim:int, order: int): |
| 36 | if (dim,order) in _intrules: |
| 37 | return _intrules[(dim, order)] |
| 38 | |
| 39 | rules = {} |
| 40 | if dim == 2: |
| 41 | if order > 3: |
| 42 | n = (order+2)//3 |
| 43 | |
| 44 | trig_points = [] |
| 45 | h = 1/n |
| 46 | for i in range(n): |
| 47 | for j in range(n-i): |
| 48 | trig_points += _make_trig(3, i*h, j*h, h, h) |
| 49 | |
| 50 | for i in range(n-1): |
| 51 | for j in range(n-i-1): |
| 52 | trig_points += _make_trig(3, (i+1)*h, (j+1)*h, -h, -h) |
| 53 | |
| 54 | quad_points = [] |
| 55 | for i in range(n): |
| 56 | for j in range(n): |
| 57 | quad_points += _make_quad(3, i*h, j*h, h, h) |
| 58 | |
| 59 | else: |
| 60 | trig_points = _make_trig(order) |
| 61 | quad_points = _make_quad(order) |
| 62 | |
| 63 | rules[ngs.ET.TRIG] = ngs.IntegrationRule(trig_points, [0,]*len(trig_points)) |
| 64 | rules[ngs.ET.QUAD] = ngs.IntegrationRule(quad_points, [0,]*len(quad_points)) |
| 65 | |
| 66 | elif dim == 3: |
| 67 | if order > 2: |
| 68 | raise RuntimeError("only order 1 and 2 supported in 3D") |
| 69 | |
| 70 | p1_tets = {} |
| 71 | p1_tets[ngs.ET.TET] = [[(1,0,0), (0,1,0), (0,0,1), (0,0,0)]] |
| 72 | p1_tets[ngs.ET.PYRAMID]=[[(1,0,0), (0,1,0), (0,0,1), (0,0,0)], |
| 73 | [(1,0,0), (0,1,0), (0,0,1), (1,1,0)]] |
| 74 | p1_tets[ngs.ET.PRISM] = [[(1,0,0), (0,1,0), (0,0,1), (0,0,0)], |
| 75 | [(0,0,1), (0,1,0), (0,1,1), (1,0,0)], |
| 76 | [(1,0,1), (0,1,1), (1,0,0), (0,0,1)]] |
| 77 | p1_tets[ngs.ET.HEX] = [[(1,0,0), (0,1,0), (0,0,1), (0,0,0)], |
| 78 | [(0,1,1), (1,1,1), (1,1,0), (1,0,1)], |
| 79 | [(1,0,1), (0,1,1), (1,0,0), (0,0,1)], |
| 80 | [(0,1,1), (1,1,0), (0,1,0), (1,0,0)], |
| 81 | [(0,0,1), (0,1,0), (0,1,1), (1,0,0)], |
| 82 | [(1,0,1), (1,1,0), (0,1,1), (1,0,0)]] |
| 83 | |
| 84 | def makeP2Tets( p1_tets ): |
| 85 | midpoint = lambda p0, p1: tuple((0.5*(p0[i]+p1[i]) for i in range(3))) |
| 86 | p2_tets = [] |
| 87 | for tet in p1_tets: |
| 88 | tet.append( midpoint(tet[0], tet[3]) ) |
| 89 | tet.append( midpoint(tet[1], tet[3]) ) |
| 90 | tet.append( midpoint(tet[2], tet[3]) ) |
| 91 | tet.append( midpoint(tet[0], tet[1]) ) |
| 92 | tet.append( midpoint(tet[0], tet[2]) ) |
no test coverage detected