def getNodesBoundInSelectedVols(target_list): """ Return nodes bound in selected CUBIT volumes. Parameters: * target_list List of indices of target nodes Return: List of indices of nodes bound by the volumes """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) in_list = [] for v in target_list: cords = cubit.get_nodal_coordinates(v) for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] status = body.point_containment(cords) if status == 1 or status == 2: in_list.append(v) break cubit.delete_group(group_id) return in_list
def getNodesBoundInSelectedVols(mesh, scale=1e-6): """ Return nodes bound in selected CUBIT volumes. Parameters: * mesh Associated Tetmesh object created in STEPS * scale LENGTH scale from the CUBIT gemoetry to real geometry. e.g. a radius of 10 in CUBIT to a radius of 1 micron in STEPS, scale is 1e-7. By default the scale is 1e-6, i.e. 1 unit in CUBIT equals 1 micron in STEPS. Return: list of STEPS indices of vertex nodes """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) nverts = mesh.nverts in_list = [] for v in range(nverts): cords = mesh.getVertex(v) cords = [x / scale for x in cords] for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] status = body.point_containment(cords) if status == 1 or status == 2: in_list.append(v) break cubit.delete_group(group_id) return in_list
def getNodesBoundInSelectedVols(target_list): """ Return nodes bound in mouse selected CUBIT volumes. Parameters: * target_list List of indices of target nodes Return: List of indices of nodes bound by the volumes """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) in_list = [] for v in target_list: cords = cubit.get_nodal_coordinates(v) for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] status = body.point_containment(cords) if status == 1 or status == 2: in_list.append(v) break cubit.delete_group(group_id) return in_list
def getSelectedNodes(): """ Return the CUBIT indices of the selected vertex nodes. Parameters: None Return: cubit_ids """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) idxs = cubit.get_group_nodes(group_id) cubit.delete_group(group_id) return idxs
def getSelectedTets(): """ Return the CUBIT indices of mouse selected tetrahedrons. Parameters: None Return: cubit_ids """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) idxs = cubit.get_group_tets(group_id) cubit.delete_group(group_id) return idxs
def getSelectedTris(tri_proxy): """ Return the STEPS indices and CUBIT indices of the selected triangles. Parameters: * tri_proxy Triangle element proxy generated by STEPS mesh importing function Return: (steps_ids, cubit_ids) """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) cubit_ids = cubit.get_group_tris(group_id) steps_ids = [tri_proxy.getSTEPSID(id) for id in cubit_ids] cubit.delete_group(group_id) return (steps_ids, cubit_ids)
def getTrisBoundInSelectedVols(mesh, scale=1e-6): """ Return triangles bound in selected CUBIT volumes. Parameters: * mesh Associated Tetmesh object created in STEPS * scale LENGTH scale from the CUBIT gemoetry to real geometry. e.g. a radius of 10 in CUBIT to a radius of 1 micron in STEPS, scale is 1e-7. By default the scale is 1e-6, i.e. 1 unit in CUBIT equals 1 micron in STEPS. Return: list of STEPS indices of triangles """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) ntris = mesh.ntris in_list = [] for t in range(ntris): verts = mesh.getTri(t) with_in = True cords = [] for v in verts: c = mesh.getVertex(v) c = [x / scale for x in c] cords.append(c) for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] within = True for cord in cords: status = body.point_containment(cord) if status == 0: within = False break if within: in_list.append(t) break cubit.delete_group(group_id) return in_list
def getTrisBoundInSelectedVols(target_list): """ Return triangles bound in selected CUBIT volumes. Parameters: * target_list List of indices of target triangles Return: List of indices of triangles bound by the volumes """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) in_list = [] for t in target_list: verts = cubit.get_connectivity("tri", t) with_in = True cords = [] for v in verts: c = cubit.get_nodal_coordinates(v) cords.append(c) for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] within = True for cord in cords: status = body.point_containment(cord) if status == 0: within = False break if within: in_list.append(t) break cubit.delete_group(group_id) return in_list
def getTrisOverlapSelectedVols(target_list): """ Return triangles overlap with mouse selected CUBIT volumes. Parameters: * target_list List of indices of target triangles Return: List of indices of triangles overlap with the volumes """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) volume_ids = cubit.get_group_volumes(group_id) in_list = [] for t in target_list: verts = cubit.get_connectivity("tri", t) cords = [] for v in verts: c = cubit.get_nodal_coordinates(v) cords.append(c) for vol_id in volume_ids: volume = cubit.volume(vol_id) body = volume.bodies()[0] within = False for cord in cords: status = body.point_containment(cord) if status == 1: within = True break if within: in_list.append(t) break cubit.delete_group(group_id) return in_list