input#

Mapdl.input(fname='', ext='', dir_='', line='', log='', *, verbose=False, progress_bar=False, time_step_stream=None, chunk_size=512, orig_cmd='/INP', write_to_log=True, **kwargs)[source]#

Stream a local input file to a remote mapdl instance. Stream the response back and deserialize the output.

Changed in version 0.65: From version 0.65 you can use the APDL commands arguments (ext, dir, line) in within this command. However, the gRPC implementation does not uses the APDL /INPUT command, rather the gRPC input method with the appropriate configuration to replicate /INPUT behaviour.

Parameters:
fnamestr, optional

MAPDL input file to stream to the MAPDL gRPC server. File name and directory path. An unspecified directory path defaults to the Python working directory; in this case, you can use all 248 characters for the file name. The file name defaults to the current Jobname if Ext is specified.

extstr, optional

Filename extension (eight-character maximum).

dirstr, optional

Directory path. The default is the current working directory.

lineint, optional

A value indicating either a line number in the file from which to begin reading the input file. The first line is the zero line (Python convention).

(blank), or 0

Begins reading from the top of the file. Default.

LINE_NUMBER

Begins reading from the specified line number in the file.

logoptional

Not supported in the gRPC implementation.

time_step_streamint, optional

Time to wait between streaming updates to send back chunks from the listener file. Larger values mean more data per chunk and less chunks, but if the command is short, will wait until time_step_stream is finished leading to a long execution time.

Due to stability issues, the default time_step_stream is dependent on verbosity. The defaults are:

  • verbose=True: time_step_stream=500

  • verbose=False: time_step_stream=50

These defaults will be ignored if time_step_stream is manually set.

orig_cmdstr, optional

Original command. There are some cases, were input is used to send the file to the grpc server but then we want to run something different than /INPUT, for example CDREAD.

Returns:
str

Response from MAPDL.

Notes

This method does not use the APDL /INPUT command. However its usage is very similar to it. See Examples section.

If you want to use /INPUT for some reason, although it is not recommended, you can write the desired input file, upload it using Mapdl.upload, and then use run command Mapdl.run('/INPUT,. This does not avoid to use the gRPC input method, but it allows you to use the APDL /INPUT command from the generated input file. See Examples section for more information.

Examples

Load a simple "ds.dat" input file generated from Ansys Workbench.

>>> output = mapdl.input('ds.dat')

Load that same file while streaming the output in real-time.

>>> output = mapdl.input('ds.dat', verbose=True)

Use the default APDL /INPUT command:

>>> with open('myinput.inp','w').write("/finish\n/prep7\n/com, my commands")
>>> with open('inputtrigger.inp','w').write("/input,myinput,inp")
>>> mapdl.upload("myinput.inp")
Uploading myinput.inp: 100%|█████████████████████████████████████████████████| 26.0/26.0 [00:00<00:00, 5.86kB/s]
'myinput.inp'
>>> mapdl.upload("inputtrigger.inp")
Uploading inputtrigger.inp: 100%|████████████████████████████████████████████| 32.0/32.0 [00:00<00:00, 8.92kB/s]
'inputtrigger.inp'
>>> with mapdl.non_interactive:
        mapdl.run("/input,inputtrigger,inp") # This inputs 'myinput.inp'