How to use the pyansys.save_as_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 / 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_write_non_ansys_grid(tmpdir):
    grid = pv.UnstructuredGrid(pyvista_examples.hexbeamfile)
    del grid.point_arrays['sample_point_scalars']
    del grid.cell_arrays['sample_cell_scalars']
    archive_file = str(tmpdir.mkdir("tmpdir").join('tmp.cdb'))
    pyansys.save_as_archive(archive_file, grid)
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_writehex(tmpdir, hex_archive):
    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, 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_write_lin_archive(tmpdir, celltype, all_solid_cells_archive_linear):
    linear_grid = all_solid_cells_archive_linear.grid

    mask = linear_grid.celltypes == celltype
    assert mask.any()
    linear_grid = linear_grid.extract_cells(mask)

    tmp_archive_file = str(tmpdir.mkdir("tmpdir").join('tmp.cdb'))

    pyansys.save_as_archive(tmp_archive_file, linear_grid)
    new_archive = pyansys.Archive(tmp_archive_file)
    assert new_archive.quality > 0
    assert np.allclose(linear_grid.celltypes, new_archive.grid.celltypes)
github akaszynski / pyansys / examples / 01-mapdl-examples / pyvista_mesh.py View on Github external
import pyvista as pv
import pyansys

# launch MAPDL and run a modal analysis
os.environ['I_MPI_SHM_LMT'] = 'shm'  # necessary for Ubuntu
mapdl = pyansys.launch_mapdl(loglevel='WARNING', override=True)

# Create a simple plane mesh centered at (0, 0, 0) on the XY plane
mesh = pv.Plane(i_resolution=100, j_resolution=100)

mesh.plot(color='w', show_edges=True)

###############################################################################
# Write the mesh to an archive file
archive_filename = os.path.join(mapdl.path, 'tmp.cdb')
pyansys.save_as_archive(archive_filename, mesh)


###############################################################################
# mapdl = pyansys.launch_mapdl(prefer_pexpect=True, override=True)

# Read in the archive file
response = mapdl.cdread('db', archive_filename)
mapdl.prep7()
print(mapdl.shpp('SUMM'))

# specify shell thickness
mapdl.sectype(1, "shell")
mapdl.secdata(0.01)
mapdl.emodif('ALL', 'SECNUM', 1)

# specify material properties
github akaszynski / pyansys / _downloads / 81a5e2e588577f9490a1e42b8ead946f / pyvista_mesh.py View on Github external
import pyvista as pv
import pyansys

# launch MAPDL and run a modal analysis
os.environ['I_MPI_SHM_LMT'] = 'shm'  # necessary for Ubuntu
mapdl = pyansys.launch_mapdl(loglevel='WARNING', override=True)

# Create a simple plane mesh centered at (0, 0, 0) on the XY plane
mesh = pv.Plane(i_resolution=100, j_resolution=100)

mesh.plot(color='w', show_edges=True)

###############################################################################
# Write the mesh to an archive file
archive_filename = os.path.join(mapdl.path, 'tmp.cdb')
pyansys.save_as_archive(archive_filename, mesh)


###############################################################################
# mapdl = pyansys.launch_mapdl(prefer_pexpect=True, override=True)

# Read in the archive file
response = mapdl.cdread('db', archive_filename)
mapdl.prep7()
print(mapdl.shpp('SUMM'))

# specify shell thickness
mapdl.sectype(1, "shell")
mapdl.secdata(0.01)
mapdl.emodif('ALL', 'SECNUM', 1)

# specify material properties