|
1 | 1 | from typing import Tuple, get_args
|
2 | 2 |
|
3 |
| -import numpy as np |
4 |
| - |
5 | 3 | from classy_blocks.assemble.depot import Depot
|
6 | 4 | from classy_blocks.assemble.dump import AssembledDump
|
7 | 5 | from classy_blocks.assemble.settings import Settings
|
|
15 | 13 | from classy_blocks.lists.patch_list import PatchList
|
16 | 14 | from classy_blocks.lists.vertex_list import VertexList
|
17 | 15 | from classy_blocks.lookup.point_registry import HexPointRegistry
|
18 |
| -from classy_blocks.optimize.grid import HexGrid |
19 | 16 | from classy_blocks.util import constants
|
20 | 17 |
|
21 | 18 |
|
22 | 19 | class MeshAssembler:
|
23 |
| - def __init__(self, depot: Depot, settings: Settings): |
| 20 | + def __init__(self, depot: Depot, settings: Settings, merge_tol=constants.TOL): |
24 | 21 | self.depot = depot
|
25 | 22 | self.settings = settings
|
| 23 | + self.merge_tol = merge_tol |
26 | 24 |
|
27 | 25 | # once the mesh is assembled, adding new stuff to depot will break things;
|
28 | 26 | # better (and faster) is to cache status quo
|
29 | 27 | self._operations = self.depot.operations
|
30 |
| - self._grid = HexGrid.from_elements(self._operations) |
| 28 | + |
| 29 | + self._points = HexPointRegistry.from_operations(self._operations, self.merge_tol) |
31 | 30 |
|
32 | 31 | def _create_blocks(self, vertex_list: VertexList) -> BlockList:
|
33 | 32 | block_list = BlockList()
|
34 | 33 |
|
35 | 34 | for iop, operation in enumerate(self._operations):
|
36 |
| - op_indexes = self._grid.addressing[iop] |
| 35 | + op_indexes = self._points.cell_addressing[iop] |
37 | 36 | op_vertices = [vertex_list.vertices[i] for i in op_indexes]
|
38 | 37 |
|
39 | 38 | # duplicate vertices on slave patches
|
@@ -111,14 +110,11 @@ def _create_patches(self, block_list: BlockList) -> Tuple[PatchList, FaceList]:
|
111 | 110 | return patch_list, face_list
|
112 | 111 |
|
113 | 112 | def _update_neighbours(self, block_list: BlockList) -> None:
|
114 |
| - points = np.array([[v.position for v in b.vertices] for b in block_list.blocks]) |
115 |
| - |
116 |
| - navigator = HexPointRegistry(HexPointRegistry.flatten(points, 8 * len(block_list.blocks)), constants.TOL) |
117 |
| - block_list.update_neighbours(navigator) |
| 113 | + block_list.update_neighbours(self._points) |
118 | 114 |
|
119 | 115 | def assemble(self) -> AssembledDump:
|
120 | 116 | # Create reused/indexes vertices from operations' points
|
121 |
| - vertex_list = VertexList([Vertex(pos, i) for i, pos in enumerate(self._grid.points)]) |
| 117 | + vertex_list = VertexList([Vertex(pos, i) for i, pos in enumerate(self._points.unique_points)]) |
122 | 118 | # Create blocks from vertices; when there's a slave patch specified in an operation,
|
123 | 119 | # duplicate vertices for that patch
|
124 | 120 | block_list = self._create_blocks(vertex_list)
|
|
0 commit comments