def _makeBlockMesh(self, r: reactors.Reactor, indexMap) -> ET.Element: cycle = r.p.cycle node = r.p.timeNode blks = r.getChildren(deep=True, predicate=lambda o: isinstance(o, blocks.Block)) blks = sorted(blks, key=lambda b: indexMap[b.p.serialNum]) groupName = "c{}n{}".format(cycle, node) # VTK stuff turns out to be pretty flexible blockMesh = utils.VtkMesh.empty() for b in blks: blockMesh.append(utils.createBlockMesh(b)) verts = blockMesh.vertices verticesInH5 = groupName + "/blk_vertices" self._meshH5[verticesInH5] = verts topoValues = numpy.array([], dtype=numpy.int32) offset = 0 for b in blks: nVerts, cellTopo = _getTopologyFromShape(b, offset) topoValues = numpy.append(topoValues, cellTopo) offset += nVerts topoInH5 = groupName + "/blk_topology" self._meshH5[topoInH5] = topoValues return self._makeGenericMesh("Blocks", len(blks), self._meshH5[verticesInH5], self._meshH5[topoInH5])
def test_cartesianMesh(self): mesh = utils.createBlockMesh(self.cartesianBlock) self.assertEqual(mesh.vertices.size, 8 * 3) self.assertEqual(mesh.cellTypes[0], 12)
def test_hexMesh(self): mesh = utils.createBlockMesh(self.hexBlock) self.assertEqual(mesh.vertices.size, 12 * 3) self.assertEqual(mesh.cellTypes[0], 16)