How to use the pyansys.Archive 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 / tests / plane_182_183 / test_archive_182_183.py View on Github external
def archive():
    filename = os.path.join(testfiles_path, 'archive.cdb')
    return pyansys.Archive(filename)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_read_mesh200():
    archive = pyansys.Archive(os.path.join(testfiles_path, 'mesh200.cdb'))
    assert archive.grid.n_cells == 1000
github akaszynski / pyansys / tests / test_corba.py View on Github external
def test_nodes(cleared, mapdl):
    mapdl.prep7()
    mapdl.cdread('db', pyansys.examples.sector_archive_file)
    archive = pyansys.Archive(pyansys.examples.sector_archive_file, parse_vtk=False)
    mapdl.nwrite('/tmp/ansys/tmp.nodes')
    assert np.allclose(mapdl.nodes, archive.nodes)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_writehex_missing_elem_num(tmpdir, hex_archive):
    grid = hex_archive.grid
    grid.cell_arrays['ansys_elem_num'][:10] = -1
    grid.cell_arrays['ansys_etype'] = np.ones(grid.number_of_cells)*-1
    grid.cell_arrays['ansys_elem_type_num'] = np.ones(grid.number_of_cells)*-1

    filename = str(tmpdir.mkdir("tmpdir").join('tmp.cdb'))
    pyansys.save_as_archive(filename, grid)
    archive_new = pyansys.Archive(filename)

    assert np.allclose(hex_archive.grid.points, archive_new.grid.points)
    assert np.allclose(hex_archive.grid.cells, archive_new.grid.cells)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_read_parm():
    filename = os.path.join(testfiles_path, 'parm.cdb')
    archive = pyansys.Archive(filename)
    with pytest.raises(AttributeError):
        archive.parameters

    archive = pyansys.Archive(filename, read_parameters=True)
    assert len(archive.parameters) == 2
    for parm in archive.parameters:
        assert isinstance(archive.parameters[parm], np.ndarray)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_writehex_missing_node_num(tmpdir, hex_archive):
    hex_archive.grid.point_arrays['ansys_node_num'][:-1] = -1

    temp_archive = str(tmpdir.mkdir("tmpdir").join('tmp.cdb'))
    pyansys.save_as_archive(temp_archive, hex_archive.grid)
    archive_new = pyansys.Archive(temp_archive)

    assert np.allclose(hex_archive.grid.points.shape, archive_new.grid.points.shape)
    assert np.allclose(hex_archive.grid.cells.size, archive_new.grid.cells.size)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_invalid_archive(tmpdir, hex_archive):
    nblock_filename = str(tmpdir.mkdir("tmpdir").join('nblock.cdb'))
    pyansys.write_nblock(nblock_filename, hex_archive.nnum,
                         hex_archive.nodes)

    archive = pyansys.Archive(nblock_filename)
    with pytest.raises(AttributeError):
        archive.grid
github akaszynski / pyansys / pyansys / examples / examples.py View on Github external
def show_hex_archive(off_screen=None):
    """Displays a hex beam mesh"""
    # Load an archive file
    archive = pyansys.Archive(hexarchivefile)
    archive.plot(off_screen=off_screen, color='w', show_edges=True)
    assert archive.grid.n_points
    assert archive.grid.n_cells
github akaszynski / pyansys / pyansys / mapdl.py View on Github external
def _archive(self):
        """Write entire archive to ASCII and read it in as a pyansys.Archive """
        if self._archive_cache is None:
            # temporarily disable log
            prior_log_level = self._log.level
            self._log.setLevel('CRITICAL')

            # write database to an archive file
            arch_filename = os.path.join(self.path, 'tmp.cdb')
            self.cdwrite('db', arch_filename)
            self._archive_cache = pyansys.Archive(arch_filename, parse_vtk=False)
            self._log.setLevel(prior_log_level)
        return self._archive_cache
github akaszynski / pyansys / docs / index_functions.py View on Github external
#==============================================================================
# load a beam and write it
#==============================================================================
import pyansys
from pyansys import examples

# Sample *.cdb
filename = examples.hexarchivefile

# Read ansys archive file
archive = pyansys.Archive(filename)

# Print raw data from cdb
for key in archive.raw:
   print "%s : %s" % (key, archive.raw[key])

# Create a vtk unstructured grid from the raw data and plot it
archive.ParseFEM()
archive.uGrid.Plot()

# write this as a vtk xml file 
archive.save_as_vtk('hex.vtu')


# Load this from vtk
import vtki
grid = vtki.LoadGrid('hex.vtk')