Skip to content

Commit 10b2e1b

Browse files
clatapiepyansys-ci-botgerma89
authored
fix: command conversion (#4126)
* fix: ``clear``, ``file`` and ``mrep`` * chore: adding changelog file 4126.miscellaneous.md [dependabot-skip] * chore: adding changelog file 4126.miscellaneous.md [dependabot-skip] * fix: refactor file and clear methods in _MapdlCommandExtended for improved functionality --------- Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: German <[email protected]>
1 parent 1412986 commit 10b2e1b

File tree

17 files changed

+156
-105
lines changed

17 files changed

+156
-105
lines changed

doc/changelog.d/4126.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix: command conversion

src/ansys/mapdl/core/_commands/apdl/matrix_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ def free(self, name: str = "", val1: str = "", **kwargs):
896896
897897
.. _a-FREE_notes:
898898
899-
A ``/CLEAR`` command will automatically delete all the current APDL Math objects.
899+
A :ref:`clear` command will automatically delete all the current APDL Math objects.
900900
"""
901901
command = f"*FREE,{name},{val1}"
902902
return self.run(command, **kwargs)

src/ansys/mapdl/core/_commands/apdl/parameter_definition.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ def get(
10801080
- Description
10811081
* - MAT
10821082
- ``Sect1``
1083-
- ``Item2`` = 0 or blank; ``IT2NUM`` = ``Sect2``. Material ID to be used for general contact between ``Sect1`` and ``Sect2``. Alternative get function: SECTOMAT( ``Sect1``, ``Sect2`` ).
1083+
- ``Item2`` = 0 or blank; ``IT2NUM`` = ``Sect2``. Material ID to be used for general contact between ``Sect1`` and ``Sect2`` . Alternative get function: SECTOMAT( ``Sect1``, ``Sect2`` ).
10841084
* - REAL
10851085
- ``Sect1``
10861086
- ``Item2`` = 0 or blank; ``IT2NUM`` = ``Sect2``. Real constant ID to be used for general contact between ``Sect1`` and ``Sect2`` . Alternative get function: SECTOREAL( ``Sect1``, ``Sect2`` ).
@@ -3017,11 +3017,11 @@ def inquire(self, strarray: str = "", func: str = "", **kwargs):
30173017
30183018
* ``JOBNAME`` - Returns the current ``Jobname``.
30193019
3020-
* ``RSTDIR`` - Returns rst directory ( ``FILE`` command).
3020+
* ``RSTDIR`` - Returns rst directory ( :ref:`file` command).
30213021
3022-
* ``RSTFILE`` - Returns rst file name ( ``FILE`` command).
3022+
* ``RSTFILE`` - Returns rst file name ( :ref:`file` command).
30233023
3024-
* ``RSTEXT`` - Returns rst file extension ( ``FILE`` command).
3024+
* ``RSTEXT`` - Returns rst file extension ( :ref:`file` command).
30253025
30263026
* ``PSEARCH`` - Returns path used for "unknown command" macro ( :ref:`psearch` command).
30273027

src/ansys/mapdl/core/_commands/aux15/iges.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def ioptn(self, lab: str = "", val1: str = "", **kwargs):
147147
Attempts to read in B-spline curve or surface entities of degree higher than 20 may result in error
148148
messages.
149149
150-
If you issue the ``/CLEAR`` command, the :ref:`ioptn` settings return to their defaults.
150+
If you issue the :ref:`clear` command, the :ref:`ioptn` settings return to their defaults.
151151
152152
For MERG,YES, merging of coincident geometry items is performed automatically when the :ref:`igesin`
153153
command is issued (that is, an internal :ref:`nummrg`,KP command is issued). The model is merged
@@ -164,7 +164,7 @@ def ioptn(self, lab: str = "", val1: str = "", **kwargs):
164164
165165
The :ref:`ioptn` command should be issued before the :ref:`igesin` command. You cannot change these
166166
options after your model has been imported or created. If you must change the options: Clear the
167-
database ( ``/CLEAR`` ) or exit and restart the program.
167+
database ( :ref:`clear` ) or exit and restart the program.
168168
169169
Set the correct options.
170170

src/ansys/mapdl/core/_commands/aux2/binary_file_manipulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ def psmat(
280280
.. _PSMAT_notes:
281281
282282
This command is used to copy a matrix from the assembled global matrix file ( :file:`.FULL` file) as
283-
specified on the ``FILE`` command and write it in a postscript format to a new file named ``Fname``.
284-
``Ext`` (defaults to :file:`Jobname.PS` ). The matrix is symbolized by a grid in which the black or
285-
colored squares represent the nonzero coefficients of the matrix. The :file:`.FULL` file must be
286-
available for this command to work properly.
283+
specified on the :ref:`file` command and write it in a postscript format to a new file named
284+
``Fname``. ``Ext`` (defaults to :file:`Jobname.PS` ). The matrix is symbolized by a grid in which
285+
the black or colored squares represent the nonzero coefficients of the matrix. The :file:`.FULL`
286+
file must be available for this command to work properly.
287287
288288
If the matrix is large, it may be difficult to display the postscript file. In this case, use
289289
``Color`` = BLACK to reduce the postscript file size.

src/ansys/mapdl/core/_commands/database/set_up.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,53 @@
2323

2424
class SetUp:
2525

26+
def clear(self, read: str = "", **kwargs):
27+
r"""Clears the database.
28+
29+
Mechanical APDL Command: `/CLEAR <https://ansyshelp.ansys.com/Views/Secured/corp/v232/en//ans_cmd/Hlp_C_CLEAR.html>`_
30+
31+
Parameters
32+
----------
33+
read : str
34+
File read option:
35+
36+
* ``START`` - Reread :file:`start.ans` file (default).
37+
38+
* ``NOSTART`` - Do not reread :file:`start.ans` file.
39+
40+
Notes
41+
-----
42+
43+
.. _s-CLEAR_notes:
44+
45+
The :ref:`clear` command resets the database to the conditions present at the beginning of the
46+
problem.
47+
48+
The command is typically used between multiple analyses in the same run, or between passes of a
49+
multipass analysis (such as between substructure generation, use, and expansion passes).
50+
51+
The command sets the import and Boolean options back to the default, deletes all items from the
52+
database, and sets memory values to zero for items derived from database information. (All files
53+
remain intact.) The command also resets the jobname to match the currently open session :file:`.LOG`
54+
and :file:`.ERR` files, returning the jobname to its original value or to the most recent value
55+
specified via :ref:`filname` with ``KEY`` = 1.
56+
57+
After the database is cleared, the :file:`start.ans` file is reread (by default) unless ``Read`` =
58+
NOSTART.
59+
60+
Additional commands cannot be stacked (via the $ separator) on the same line as the :ref:`clear`
61+
command.
62+
63+
Use caution when placing the :ref:`clear` command within branching constructs (for example, those
64+
using ``*DO`` or ``*IF`` commands), as the command deletes all parameters including the looping
65+
parameter for do-loops. (To preserve your iteration parameter, issue a :ref:`parsav` command prior
66+
to :ref:`clear`, then follow :ref:`clear` with a :ref:`parres` command.)
67+
68+
This command is valid in any processor. Issuing this command at any point clears the database.
69+
"""
70+
command = f"/CLEAR,{read}"
71+
return self.run(command, **kwargs)
72+
2673
def resume(
2774
self,
2875
fname: str = "",

src/ansys/mapdl/core/_commands/graphics/set_up.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ def mrep(
11031103
of the graphics command macro, following the last graphics command within the macro, to enable the
11041104
replot or zoom feature.
11051105
"""
1106-
command = f"/MREP,{name},{arg1},{arg2},{arg3},,{arg4},{arg5},{arg6},{arg7},{arg8},{arg9},{arg10},{arg11},{arg12},{arg13},{arg14},{arg15},{arg16},{arg17},{arg18}"
1106+
command = f"/MREP,{name},{arg1},{arg2},{arg3},{arg4},{arg5},{arg6},{arg7},{arg8},{arg9},{arg10},{arg11},{arg12},{arg13},{arg14},{arg15},{arg16},{arg17},{arg18}"
11071107
return self.run(command, **kwargs)
11081108

11091109
def noerase(self, **kwargs):

src/ansys/mapdl/core/_commands/post1/load_case_calculations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def lcdef(
9999
----------
100100
lcno : str
101101
Arbitrary pointer number (1-99) to be assigned to the load case specified by ``LSTEP``,
102-
``SBSTEP`` and by the ``FILE`` command. Defaults to 1 + previous value.
102+
``SBSTEP`` and by the :ref:`file` command. Defaults to 1 + previous value.
103103
104104
lstep : str
105105
Load step number to be defined as the load case. Defaults to one.

src/ansys/mapdl/core/_commands/post1/set_up.py

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,63 @@ def dnsol(
572572
command = f"DNSOL,{node},{item},{comp},{v1},{v2},{v3},{v4},{v5},{v6},{datakey}"
573573
return self.run(command, **kwargs)
574574

575+
def file(self, fname: str = "", ext: str = "", **kwargs):
576+
r"""Specifies the data file where results are to be found.
577+
578+
Mechanical APDL Command: `FILE <https://ansyshelp.ansys.com/Views/Secured/corp/v232/en//ans_cmd/Hlp_C_FILE.html>`_
579+
580+
Parameters
581+
----------
582+
fname : str
583+
File name and directory path (248 characters maximum, including the characters needed for the
584+
directory path). An unspecified directory path defaults to the working directory; in this case,
585+
you can use all 248 characters for the file name. The file name defaults to :file:`Jobname`.
586+
587+
ext : str
588+
Filename extension (eight-character maximum). If ``Fname`` is blank, the extension defaults to
589+
RST (for structural, fluid, or coupled-field analyses), to RTH (for thermal or electrical
590+
analyses), or to RMG (for magnetic analyses). For postprocessing contact results corresponding
591+
to the initial contact state in POST1, use the RCN extension. For postprocessing modal
592+
coordinates results in POST1, use the RDSP or RFRQ extension.
593+
594+
Notes
595+
-----
596+
597+
.. _FILE_notes:
598+
599+
Specifies the Mechanical APDL data file where the results are to be found for postprocessing.
600+
601+
Issuing the :ref:`file` command with ``Ext`` = RSDP or RFRQ in POST1 specifies the :file:`.rsdp` or
602+
:file:`.rfrq` file used by the :ref:`prmc` and :ref:`plmc` commands. (See :ref:`POST1 example
603+
below.) <FILE_POST1example>`
604+
605+
**Example Usage**
606+
607+
.. _FILE_examples:
608+
609+
.. _FILE_POST1example:
610+
611+
POST1
612+
^^^^^
613+
614+
.. code:: apdl
615+
616+
/POST1
617+
FILE,,rdsp !Choose file Jobname.rdsp from a previous MSUP transient solution
618+
PRMC,2,1 !Plot Modal coordinates from rdsp file (loadstep and substep specified as arguments)
619+
FILE,,rst !Choose file Jobname.rst
620+
SET,1,1 !Load results from chosen.rst file into database
621+
PRNSOL,u,x !Plot Nodal displacements (loadstep and substep specified using the SET command)
622+
FINISH !Exit POST1
623+
624+
.. _FILE_POST26example:
625+
626+
POST26
627+
^^^^^^
628+
"""
629+
command = f"FILE,{fname},{ext}"
630+
return self.run(command, **kwargs)
631+
575632
def hrcplx(
576633
self,
577634
loadstep: str = "",
@@ -811,8 +868,8 @@ def rescombine(
811868
:ref:`reswrite` to write the data set into a new results file. The new results file will essentially
812869
contain the current set of results data for the entire (that is, global) model.
813870
814-
Upon completion of a :ref:`rescombine` operation, the current file for postprocessing ( ``FILE`` )
815-
is set to the last local results file specified via :ref:`rescombine`. For example, if reading in
871+
Upon completion of a :ref:`rescombine` operation, the current file for postprocessing ( :ref:`file`
872+
) is set to the last local results file specified via :ref:`rescombine`. For example, if reading in
816873
four local results files, the results file for POST1 is specified as :file:`Jobname3.RST` when
817874
:ref:`rescombine` is complete. Therefore, be aware that some downstream postprocessing actions (such
818875
as :ref:`set` ) may be operating on only this one local results file.

src/ansys/mapdl/core/_commands/post1/special_purpose.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def cmsfile(
318318
If ``CmsKey`` = ON (default), output from the command appears as: ``ADD CMS FILE =`` filename.rst
319319
``CmsKey`` = OFF, output from the command appears as: ``ADD FILE =`` filename.rst
320320
321-
If ``Option`` = DELETE or CLEAR, you must clear the database ( ``/CLEAR`` ), then re-enter the
321+
If ``Option`` = DELETE or CLEAR, you must clear the database ( :ref:`clear` ), then re-enter the
322322
postprocessor ( :ref:`post1` ) and issue a :ref:`set` command for the change to take effect on
323323
subsequent plots.
324324
@@ -2020,8 +2020,8 @@ def plmc(
20202020
:ref:`outres` command description.
20212021
20222022
For a cyclic harmonic mode-superposition analysis, use the :ref:`cycfiles` command to identify the
2023-
:file:`.rfrq` None and modal :file:`.rst` None file. For other analyses, use the ``FILE`` command to
2024-
specify the :file:`.rdsp` or :file:`.rfrq` file.
2023+
:file:`.rfrq` None and modal :file:`.rst` None file. For other analyses, use the :ref:`file` command
2024+
to specify the :file:`.rdsp` or :file:`.rfrq` file.
20252025
20262026
You may limit the plot to display only those modes in a certain harmonic index range. The modes
20272027
having the same harmonic index are each plotted in a unique color. If there are less than 10
@@ -3016,8 +3016,8 @@ def prmc(
30163016
:ref:`outres` command description.
30173017
30183018
For a cyclic harmonic mode-superposition analysis, use the :ref:`cycfiles` command to identify the
3019-
:file:`.rfrq` None and modal :file:`.rst` None files. For other analyses, use the ``FILE`` command
3020-
to specify the :file:`.rdsp` or :file:`.rfrq` file.
3019+
:file:`.rfrq` None and modal :file:`.rst` None files. For other analyses, use the :ref:`file`
3020+
command to specify the :file:`.rdsp` or :file:`.rfrq` file.
30213021
30223022
This information can also be obtained from the optional :file:`Jobname.mcf` text file (see the
30233023
:ref:`trnopt` and :ref:`hropt` commands), and it can be plotted using the :ref:`plmc` command. For

0 commit comments

Comments
 (0)