Package: mapdl-archive
Read blocked Ansys MAPDL archive files written from MAPDL usingCDWRITE.This is effectivelypymapdl-readerwithout the binary reader. It’s been isolated to allow greater flexibility in development.InstallationInstallation through pip:pip install mapdl-archiveExamplesLoad and Plot an MAPDL Archive FileANSYS archive files containing solid elements (both legacy and
modern), can be loaded using Archive and then converted to a VTK
object.frommapdl_archiveimportArchive,examples# Sample *.cdbfilename=examples.hexarchivefile# Read ansys archive filearchive=Archive(filename)# Print raw data from cdbforkeyinarchive.raw:print("%s:%s"%(key,archive.raw[key]))# Create an unstructured grid from the raw data and plot itgrid=archive.parse_vtk(force_linear=True)grid.plot(color='w',show_edges=True)# write this as a vtk xml filegrid.save('hex.vtu')# or as a vtk binarygrid.save('hex.vtk')You can then load this vtk file usingPyVistaorVTK.importpyvistaaspvgrid=pv.UnstructuredGrid('hex.vtu')grid.plot()Reading ANSYS ArchivesMAPDL archive*.cdband*.datfiles containing elements (both
legacy and modern) can be loaded using Archive and then converted to avtkobject:importmapdl_archivefrommapdl_archiveimportexamples# Read a sample archive filearchive=mapdl_archive.Archive(examples.hexarchivefile)# Print various raw data from cdbprint(archive.nnum,archive.nodes)# access a vtk unstructured grid from the raw data and plot itgrid=archive.gridarchive.plot(color='w',show_edges=True)You can also optionally read in any stored parameters within the
archive file by enabling theread_parametersparameter.importmapdl_archivearchive=mapdl_archive.Archive('mesh.cdb',read_parameters=True)# parameters are stored as a dictionaryarchive.parametersWriting MAPDL ArchivesUnstructured grids generated using VTK can be converted to ANSYS APDL archive
files and loaded into any version of ANSYS usingmapdl_archive.save_as_archivein Python followed byCDREADin MAPDL.
The following example using the built-in archive file demonstrates this
capability.importpyvistaaspvfrompyvistaimportexamplesimportmapdl_archive# load in a vtk unstructured gridgrid=pv.UnstructuredGrid(examples.hexbeamfile)script_filename='/tmp/grid.cdb'mapdl_archive.save_as_archive(script_filename,grid)# Optionally read in archive in PyMAPDL and generate cell shape# quality reportfromansys.mapdl.coreimportlaunch_mapdlmapdl=launch_mapdl()mapdl.cdread('db',script_filename)mapdl.prep7()mapdl.shpp('SUMM')Resulting ANSYS quality report:------------------------------------------------------------------------------
           <<<<<<          SHAPE TESTING SUMMARY           >>>>>>
           <<<<<<        FOR ALL SELECTED ELEMENTS         >>>>>>
------------------------------------------------------------------------------
                   --------------------------------------
                   |  Element count        40 SOLID185  |
                   --------------------------------------

 Test                Number tested  Warning count  Error count    Warn+Err %
 ----                -------------  -------------  -----------    ----------
 Aspect Ratio                 40              0             0         0.00 %
 Parallel Deviation           40              0             0         0.00 %
 Maximum Angle                40              0             0         0.00 %
 Jacobian Ratio               40              0             0         0.00 %
 Warping Factor               40              0             0         0.00 %

 Any                          40              0             0         0.00 %
------------------------------------------------------------------------------Supported ElementsAt the moment, only solid elements are supported by thesave_as_archivefunction, to include:vtk.VTK_TETRAvtk.VTK_QUADRATIC_TETRAvtk.VTK_PYRAMIDvtk.VTK_QUADRATIC_PYRAMIDvtk.VTK_WEDGEvtk.VTK_QUADRATIC_WEDGEvtk.VTK_HEXAHEDRONvtk.VTK_QUADRATIC_HEXAHEDRONLinear element types will be written as SOLID185, quadratic elements
will be written as SOLID186, except for quadratic tetrahedrals, which
will be written as SOLID187.License and AcknowledgmentsThemapdl-archivelibrary is licensed under the MIT license.