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 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(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 WebcutTool(body_list_in, tool_ID, delete=False): import cubit print("body_list_in: ", body_list_in) print("tool_ID: ", tool_ID) ### delete group 'webcut_group' if it exists cubit.delete_group(cubit.get_id_from_name('webcut_group')) ### webcut cmd = 'webcut volume ' for i in body_list_in: cmd += '%i ' % i cmd += 'tool volume %i group_results' % tool_ID cubit.cmd(cmd) ### identify the grain and the outside ### I need a list of the volume IDs in webcut_group, but cubit.get_group_volumes returns a t-uple tmp_IDs = cubit.get_id_from_name('webcut_group') webcut_group_IDs = [vol_id for vol_id in cubit.get_group_volumes(tmp_IDs)] webcut_group_IDs.append(tool_ID) ovlp = cubit.get_overlapping_volumes(webcut_group_IDs) ### ovlp now contains the overlap and the tool ### remove tool_id to get tool_list_out tmp_list = [vol_id for vol_id in ovlp if not vol_id == tool_ID] tool_list_out = tmp_list # just so that I can make a call with tool_ID = tool_list_out ### remove tool_list_out and tool_ID from ovlp body_list_out = [ vol_id for vol_id in webcut_group_IDs if vol_id not in ovlp ] print("body_list_out: ", body_list_out) ### delete the tool of requested if delete: cubit.cmd('delete volume %i' % tool_ID) ### Be nice and clean up cubit.delete_group(cubit.get_id_from_name('webcut_group')) return body_list_out, tool_list_out
def getSelectedVolumes(): """ Return the CUBIT indices of the selected volumes. Parameters: None Return: cubit_ids """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) idxs = cubit.get_group_volumes(group_id) cubit.delete_group(group_id) return idxs
def getSelectedVolumes(): """ Return the CUBIT indices of mouse selected volumes. Parameters: None Return: cubit_ids """ group_id = cubit.create_new_group() cubit.silent_cmd("group %i add selection" % (group_id)) idxs = cubit.get_group_volumes(group_id) cubit.delete_group(group_id) return idxs
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