def BoundaryIndices(mesh): dim = mesh.geometry().dim() if dim == 3: EdgeBoundary = BoundaryEdge(mesh) EdgeBoundary = np.sort(EdgeBoundary)[::2] else: B = BoundaryMesh(mesh,"exterior",False) EdgeBoundary = B.entity_map(1).array() MagneticBoundary = np.ones(mesh.num_edges()) MagneticBoundary[EdgeBoundary.astype("int32")] = 0 Magnetic = spdiags(MagneticBoundary,0,mesh.num_edges(),mesh.num_edges()) B = BoundaryMesh(mesh,"exterior",False) NodalBoundary = B.entity_map(0).array()#.astype("int","C") LagrangeBoundary = np.ones(mesh.num_vertices()) LagrangeBoundary[NodalBoundary] = 0 Lagrange = spdiags(LagrangeBoundary,0,mesh.num_vertices(),mesh.num_vertices()) if dim == 3: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary,LagrangeBoundary),axis=1) else: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary),axis=1) Velocity = spdiags(VelocityBoundary,0,dim*mesh.num_vertices(),dim*mesh.num_vertices()) return [Velocity, Magnetic, Lagrange]
def BoundaryIndices(mesh): dim = mesh.geometry().dim() if dim == 3: EdgeBoundary = BoundaryEdge(mesh) EdgeBoundary = np.sort(EdgeBoundary)[::2] else: B = BoundaryMesh(mesh, "exterior", False) EdgeBoundary = B.entity_map(1).array() MagneticBoundary = np.ones(mesh.num_edges()) MagneticBoundary[EdgeBoundary.astype("int32")] = 0 Magnetic = spdiags(MagneticBoundary, 0, mesh.num_edges(), mesh.num_edges()) B = BoundaryMesh(mesh, "exterior", False) NodalBoundary = B.entity_map(0).array() #.astype("int","C") LagrangeBoundary = np.ones(mesh.num_vertices()) LagrangeBoundary[NodalBoundary] = 0 Lagrange = spdiags(LagrangeBoundary, 0, mesh.num_vertices(), mesh.num_vertices()) if dim == 3: VelocityBoundary = np.concatenate( (LagrangeBoundary, LagrangeBoundary, LagrangeBoundary), axis=1) else: VelocityBoundary = np.concatenate((LagrangeBoundary, LagrangeBoundary), axis=1) Velocity = spdiags(VelocityBoundary, 0, dim * mesh.num_vertices(), dim * mesh.num_vertices()) return [Velocity, Magnetic, Lagrange]
def BoundaryIndices(W): mesh = W[0].mesh() dim = mesh.geometry().dim() if dim == 3: EdgeBoundary = BoundaryEdge(mesh) EdgeBoundary = np.sort(EdgeBoundary)[::2] else: B = BoundaryMesh(mesh, "exterior", False) EdgeBoundary = B.entity_map(1).array() MagneticBoundary = np.ones(mesh.num_edges()) MagneticBoundary[EdgeBoundary.astype("int32")] = 0 Magnetic = spdiags(MagneticBoundary, 0, mesh.num_edges(), mesh.num_edges()) B = BoundaryMesh(mesh, "exterior", False) NodalBoundary = B.entity_map(0).array() #.astype("int","C") LagrangeBoundary = np.ones(mesh.num_vertices()) LagrangeBoundary[NodalBoundary] = 0 Lagrange = spdiags(LagrangeBoundary, 0, mesh.num_vertices(), mesh.num_vertices()) if W[0].__str__().find( "Bubble") == -1 and W[0].__str__().find("CG1") != -1: if dim == 3: VelocityBoundary = np.concatenate( (LagrangeBoundary, LagrangeBoundary, LagrangeBoundary), axis=1) else: VelocityBoundary = np.concatenate( (LagrangeBoundary, LagrangeBoundary), axis=1) Velocity = spdiags(VelocityBoundary, 0, dim * mesh.num_vertices(), dim * mesh.num_vertices()) else: LagrangeBoundary = np.ones(W[0].dim() / 2) LagrangeBoundary[NodalBoundary] = 0 if dim == 3: VelocityBoundary = np.concatenate( (LagrangeBoundary, LagrangeBoundary, LagrangeBoundary), axis=1) else: VelocityBoundary = np.concatenate( (LagrangeBoundary, LagrangeBoundary), axis=1) Velocity = spdiags(VelocityBoundary, 0, W[0].dim(), W[0].dim()) return [Velocity, Magnetic, Lagrange]
def BoundaryIndices(W): mesh = W[0].mesh() dim = mesh.geometry().dim() if dim == 3: EdgeBoundary = BoundaryEdge(mesh) EdgeBoundary = np.sort(EdgeBoundary)[::2] else: B = BoundaryMesh(mesh,"exterior",False) EdgeBoundary = B.entity_map(1).array() MagneticBoundary = np.ones(mesh.num_edges()) MagneticBoundary[EdgeBoundary.astype("int32")] = 0 Magnetic = spdiags(MagneticBoundary,0,mesh.num_edges(),mesh.num_edges()) B = BoundaryMesh(mesh,"exterior",False) NodalBoundary = B.entity_map(0).array()#.astype("int","C") LagrangeBoundary = np.ones(mesh.num_vertices()) LagrangeBoundary[NodalBoundary] = 0 Lagrange = spdiags(LagrangeBoundary,0,mesh.num_vertices(),mesh.num_vertices()) if W[0].__str__().find("Bubble") == -1 and W.sub(0).__str__().find("CG1") != -1: if dim == 3: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary,LagrangeBoundary),axis=1) else: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary),axis=1) Velocity = spdiags(VelocityBoundary,0,dim*mesh.num_vertices(),dim*mesh.num_vertices()) else: LagrangeBoundary = np.ones(W[0].dim()/2) LagrangeBoundary[NodalBoundary] = 0 if dim == 3: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary,LagrangeBoundary),axis=1) else: VelocityBoundary = np.concatenate((LagrangeBoundary,LagrangeBoundary),axis=1) Velocity = spdiags(VelocityBoundary,0,W[0].dim(),W[0].dim()) return [Velocity, Magnetic, Lagrange]