How to use the pyansys.misc.vtk_cell_info function in pyansys

To help you get started, we’ve selected a few pyansys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akaszynski / pyansys / pyansys / rst.py View on Github external
'the version of this result file is <18.2')

        if isinstance(node_components, str):
            node_components = [node_components]

        mask = np.zeros(grid.n_points, np.bool)
        for component in node_components:
            component = component.upper()
            if component not in grid.point_arrays:
                raise KeyError('Result file does not contain node ' +
                               'component "%s"' % component)

            mask += grid.point_arrays[component].view(np.bool)

        # need to extract the mesh
        cells, offset = vtk_cell_info(grid)
        if sel_type_all:
            cell_mask = cells_with_all_nodes(offset, cells, grid.celltypes,
                                             mask.view(np.uint8))
        else:
            cell_mask = cells_with_any_nodes(offset, cells, grid.celltypes,
                                             mask.view(np.uint8))

        if not cell_mask.any():
            raise RuntimeError('Empty component')
        reduced_grid = grid.extract_cells(cell_mask)

        if not reduced_grid.n_cells:
            raise RuntimeError('Empty mesh due to component selection\n' +
                               'Try "sel_type_all=False"')

        ind = reduced_grid.point_arrays['vtkOriginalPointIds']
github akaszynski / pyansys / pyansys / rst.py View on Github external
# element header
        rnum = self.parse_step_substep(rnum)
        ele_ind_table, nodstr, etype, ptr_off = self._element_solution_header(rnum)

        result_type = result_type.upper()
        if self._resultheader['rstsprs'] == 0 and result_type == 'ENS':
            nitem = 11
        elif result_type in ELEMENT_RESULT_NCOMP:
            nitem = ELEMENT_RESULT_NCOMP[result_type]
        else:
            nitem = 1

        result_index = ELEMENT_INDEX_TABLE_KEYS.index(result_type)

        # Element types for nodal averaging
        cells, offset = vtk_cell_info(self.grid)
        data, ncount = _binary_reader.read_nodal_values(self.filename,
                                                        self.grid.celltypes,
                                                        ele_ind_table,
                                                        offset,
                                                        cells,
                                                        nitem,
                                                        self.grid.number_of_points,
                                                        nodstr,
                                                        etype,
                                                        self.geometry.etype,
                                                        result_index,
                                                        ptr_off)

        if result_type == 'ENS' and nitem != 6:
            data = data[:, :6]