Skip to content

Add support for "ALL" option inside cdread method #4610

Description

@vadcard

Description of the feature

For now, the option "ALL" for mapdl.cdread() is not supported. It is required when restarting from a previously generated file with mapdl.cdwrite with option "ALL" (both geometry as IGES and model information as .cdb). An example is given in the script attached.

from ansys.mapdl.core import launch_mapdl, Mapdl
def cdreadall(cdb_name):
    mapdl.aux15()
    mapdl.run(f"IGES,{cdb_name},'iges','',,,1")
    mapdl.finish()
    mapdl.input(cdb_name, "cdb")
    mapdl.prep7()
    mapdl.run('/rmtmp')
    
if __name__ == "__main__":
    ansys_exec = r"C:\Program Files\ANSYS Inc\v261\ansys\bin\winx64\ANSYS261.exe"
    mapdl = launch_mapdl(exec_file=ansys_exec, nproc=2, override=True)
    
    mapdl.prep7()
    mapdl.block(0, 1, 0, 1, 0, 1)
    
    mapdl.et(1, "SOLID185")
    mapdl.type(1)
    mapdl.vmesh("ALL")
    mapdl.cdwrite("ALL","file","cdb")
    mapdl.allsel()
    mapdl.finish()
    print('=== using mapdl.cdread to load the file ===')
    try:
        mapdl.cdread("ALL","file","cdb")
        print('== cdread load successful ==')
    except Exception as e:
        print('== cdread load failed ==')
        print(e)
    
    print('==== loading three times in a row to test file locking ====')
    print('== attempting first load ==')
    mapdl.clear("NOSTART")  
    cdreadall("file") 
    print('== first load successful ==')
    print('== attempting second load ==')
    mapdl.clear("NOSTART")
    cdreadall("file") 
    print('== second load successful ==')
    print('== attempting third load ==')
    mapdl.clear("NOSTART")
    cdreadall("file")
    print('== third load successful ==')
    mapdl.exit(force=True)

Steps for implementing the feature

As the CDREAD,ALL,file,cdb command in MAPDL calls the following commands in the background through a temp file :

/AUX15
IGES,'file','iges','',,,1
FINISH
/INPUT,'file','cdb',''
/PREP7   
/RMTMP      ! CLOSE AND DELETE THIS FILE

Adding the following PyMAPDL commands should be enough to support the "ALL" option inside the mapdl.cdread wrapper function :

  mapdl.aux15()
  mapdl.run(f"IGES,{cdb_name},'iges','',,,1")
  mapdl.finish()
  mapdl.input(cdb_name, "cdb")
  mapdl.prep7()
  mapdl.run('/rmtmp')

Useful links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove any current implemented feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions