def harmonic_map(self, fanme): reader = CCGMeshReader(fname) tmesh = reader.read() mesh = HalfEdgeMesh2d.from_mesh(tmesh, NV=3) mesh.nodedata['rgb'] = tmesh.nodedata['rgb'] cmesh = self.ccgalg.harmonic_map(mesh) cmesh.nodedata['rgb'] = tmesh.nodedata['rgb'] writer = MeshWriter(mesh) writer.write(fname='face3.vtu') writer = MeshWriter(cmesh) writer.write(fname='face2.vtu')
def tri_cut_graph(self, fname, weight=None): data = sio.loadmat(fname) node = np.array(data['node'], dtype=np.float64) cell = np.array(data['elem'] - 1, dtype=np.int_) mesh = TriangleMesh(node, cell) mesh = HalfEdgeMesh2d.from_mesh(mesh, closed=True) mesh.ds.NV = 3 gamma = mesh.tri_cut_graph(weight=weight) writer = MeshWriter(mesh) writer.write(fname='test.vtu') for i, index in enumerate(gamma): writer = MeshWriter(mesh, etype='edge', index=index) writer.write(fname='test' + str(i) + '.vtu')
Tbd = spdiags(bdIdx, 0, gdof, gdof) T = spdiags(1 - bdIdx, 0, gdof, gdof) AA = T @ AA @ T + Tbd FF[isBdDof] = x[isBdDof] x[:] = spsolve(AA, FF) uh[:] = x[:udof] ph[:] = x[udof:-1] bc = np.array([1 / 4, 1 / 4, 1 / 4, 1 / 4], dtype=np.float64) ps = mesh.bc_to_point(bc) V = uh.value(bc) mesh.celldata['ph0'] = ph.copy() mesh.celldata['V0'] = V writer = MeshWriter(mesh) writer.write('test.vtk') if m in {3}: bc = mesh.entity_barycenter('face') isFFace = pde.is_fracture_boundary(bc) fig = plt.figure() axes = fig.gca(projection='3d') mesh.add_plot(axes, cellcolor=x[udof:-1]) if m in {3}: mesh.find_face(axes, index=isFFace, color='r') bc = np.array([1 / 4, 1 / 4, 1 / 4, 1 / 4], dtype=np.float64) ps = mesh.bc_to_point(bc)