Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving functions to Mapdl class #2468

Merged
merged 28 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e251109
Moving parres and inquire
germa89 Nov 2, 2023
2d79df8
Moving lgwrite
germa89 Nov 2, 2023
d595d41
Moving VWRITE
germa89 Nov 2, 2023
cbdbc7d
Moving *USE
germa89 Nov 2, 2023
f50e728
Moving NRM
germa89 Nov 2, 2023
44f9ba7
Moving /COM
germa89 Nov 2, 2023
b42b0ab
Moving LSSOLVE
germa89 Nov 2, 2023
cfc5b07
fixing typo
germa89 Nov 2, 2023
6154655
Disabling Google heading.
germa89 Nov 3, 2023
78122ab
fixing vale version to avoid pipeline unexpected breakdowns.
germa89 Nov 3, 2023
627d423
Undoing changes from main
germa89 Nov 3, 2023
5184e5d
Empty comment to trigger CICD
germa89 Nov 3, 2023
2c00eaf
Empty commit to re-trigger CICD
germa89 Nov 3, 2023
5135802
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 3, 2023
a897585
Fixing tests
germa89 Nov 3, 2023
8f050c8
Merge branch 'feat/moving-functions-to-mapdl-classes' of https://gith…
germa89 Nov 3, 2023
2e27612
Merge branch 'fix/vale-issues' into feat/moving-functions-to-mapdl-cl…
germa89 Nov 3, 2023
ae025a7
fixing indentation
germa89 Nov 3, 2023
079dc4d
Fixing com command
germa89 Nov 6, 2023
47e5500
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 6, 2023
ed6a52c
Fixing typo
germa89 Nov 6, 2023
387df9e
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 6, 2023
6408c53
Improving parres
germa89 Nov 7, 2023
fd77cce
removing files
germa89 Nov 7, 2023
a0164ae
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 7, 2023
d9f5fab
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 7, 2023
ae34972
Fixing call to str (weirrrdd)
germa89 Nov 8, 2023
b7c8f92
Merge branch 'main' into feat/moving-functions-to-mapdl-classes
germa89 Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/ansys/mapdl/core/_commands/apdl/array_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,12 +1479,5 @@ def vwrite(
This command is valid in any processor.

"""
# cannot be in interactive mode
if not self._store_commands:
raise MapdlRuntimeError(
"VWRTIE cannot run interactively. \n\nPlease use "
"``with mapdl.non_interactive:``"
)

command = f"*VWRITE,{par1},{par2},{par3},{par4},{par5},{par6},{par7},{par8},{par9},{par10},{par11},{par12},{par13},{par14},{par15},{par16},{par17},{par18},{par19}"
return self.run(command, **kwargs)
5 changes: 1 addition & 4 deletions src/ansys/mapdl/core/_commands/apdl/macro_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,4 @@ def use(
This command is valid in any processor.
"""
command = f"*USE,{name},{arg1},{arg2},{arg3},{arg4},{arg5},{arg6},{arg7},{arg8},{arg9},{ar10},{ar11},{ar12},{ar13},{ar14},{ag15},{ar16},{ar17},{ar18}"
with self.non_interactive:
self.run(command, **kwargs)

return self._response # returning last response
return self.run(command, **kwargs)
5 changes: 1 addition & 4 deletions src/ansys/mapdl/core/_commands/apdl/matrix_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,8 @@ def nrm(self, name="", normtype="", parr="", normalize="", **kwargs):
to the L1 norm and is applicable to vectors only. The NRMINF option is
the maximum norm and is applicable to either vectors or matrices.
"""
if not parr:
parr = "__temp_par__"
command = f"*NRM,{name},{normtype},{parr},{normalize}"
self.run(command, **kwargs)
return self.parameters[parr]
return self.run(command, **kwargs)

def remove(self, name="", val1="", val2="", val3="", **kwargs):
"""Suppresses rows or columns of a dense matrix or a vector.
Expand Down
86 changes: 2 additions & 84 deletions src/ansys/mapdl/core/_commands/apdl/parameter_definition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import os


class ParameterDefinition:
def afun(self, lab="", **kwargs):
"""Specifies units for angular functions in parameter expressions.
Expand Down Expand Up @@ -432,50 +429,7 @@ def inquire(self, strarray="", func="", arg1="", arg2=""):
>>> mapdl.inquire('', 'RSTFILE')
'file.rst'
"""
func_options = [
"LOGIN",
"DOCU",
"APDL",
"PROG",
"AUTH",
"USER",
"DIRECTORY",
"JOBNAME",
"RSTDIR",
"RSTFILE",
"RSTEXT",
"OUTPUT",
"ENVNAME",
"TITLE",
"EXIST",
"DATE",
"SIZE",
"WRITE",
"READ",
"EXEC",
"LINES",
]

if strarray.upper() in func_options and func.upper() not in func_options:
# Likely you are using the old ``_Mapdl.inquire`` implementation.
raise ValueError(
"Arguments of this method have changed. `Mapdl.inquire` now includes the optional `strarray` parameter "
f"as the first argument. Either use `inquire(func={strarray})`, or `inquire("
", {strarray})`"
)

if func == "":
func = "DIRECTORY"

response = self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}", mute=False)
if func.upper() in [
"ENV",
"TITLE",
]: # the output is multiline, we just need the last line.
response = response.splitlines()[-1]
if "=" in response:
return response.split("=")[1].strip()
return ""
return self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}")

def parres(self, lab="", fname="", ext="", **kwargs):
"""Reads parameters from a file.
Expand Down Expand Up @@ -518,43 +472,7 @@ def parres(self, lab="", fname="", ext="", **kwargs):
>>> mapdl.parres('parm.PARM')

"""
if not fname:
fname = self.jobname

fname = self._get_file_name(
fname=fname, ext=ext, default_extension="parm"
) # Although documentation says `PARM`

if self._mode == "grpc": # grpc mode
if self.is_local:
# It must be a file!
if os.path.isfile(fname):
# And it exist!
filename = os.path.join(os.getcwd(), fname)
elif fname in self.list_files(): #
# It exists in the Mapdl working directory
filename = os.path.join(self.directory, fname)
elif os.path.dirname(fname):
raise ValueError(
f"'{fname}' appears to be an incomplete directory path rather than a filename."
)
else:
# Finally
raise FileNotFoundError(f"Unable to locate filename '{fname}'")

else:
if not os.path.dirname(fname):
# might be trying to run a local file. Check if the
# file exists remotely.
if fname not in self.list_files():
self.upload(fname, progress_bar=False)
else:
self.upload(fname, progress_bar=False)
filename = os.path.basename(fname)
else:
filename = fname

return self.input(filename)
return self.run(f"PARRES, {lab}, {fname}, {ext}")

def parsav(self, lab="", fname="", ext="", **kwargs):
"""Writes parameters to a file.
Expand Down
31 changes: 1 addition & 30 deletions src/ansys/mapdl/core/_commands/session/files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""These SESSION commands are for file operations, such as deleting, copying, and listing."""

import os


class Files:
def anstoasas(self, fname="", key="", **kwargs):
Expand Down Expand Up @@ -505,34 +503,7 @@ def lgwrite(self, fname="", ext="", kedit="", remove_grpc_extra=True, **kwargs):
K,2,2,0,0

"""
# always add extension to fname
if ext:
fname = fname + f".{ext}"

# seamlessly deal with remote instances in gRPC mode
target_dir = None
is_grpc = "Grpc" in type(self).__name__
if is_grpc and fname:
if not self._local and os.path.basename(fname) != fname:
target_dir, fname = os.path.dirname(fname), os.path.basename(fname)

# generate the log and download if necessary
output = self.run(f"LGWRITE,{fname},,,{kedit}", **kwargs)
if not fname:
# defaults to <jobname>.lgw
fname = self.jobname + ".lgw"
if target_dir is not None:
self.download(fname, target_dir=target_dir)

# remove extra grpc /OUT commands
if remove_grpc_extra and is_grpc and target_dir:
filename = os.path.join(target_dir, fname)
with open(filename, "r") as fid:
lines = [line for line in fid if not line.startswith("/OUT")]
with open(filename, "w") as fid:
fid.writelines(lines)

return output
return self.run(f"LGWRITE,{fname},{ext},,{kedit}")

def starlist(self, fname="", ext="", **kwargs):
"""Displays the contents of an external, coded file.
Expand Down
4 changes: 1 addition & 3 deletions src/ansys/mapdl/core/_commands/session/list_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def com(self, comment="", **kwargs):

This command is valid anywhere.
"""
command = "/COM,%s" % (str(comment))
if self.print_com and not self.mute and not kwargs.get("mute", False):
print(command)
command = f"/COM, {comment}"
return self.run(command, **kwargs)

def golist(self, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ def lssolve(self, lsmin="", lsmax="", lsinc="", **kwargs):
>>> mapdl.lssolve(1, 2)

"""
with self.non_interactive:
self.run(f"LSSOLVE,{lsmin},{lsmax},{lsinc}", **kwargs)
return self.last_response
return self.run(f"LSSOLVE,{lsmin},{lsmax},{lsinc}", **kwargs)

def lswrite(self, lsnum="", **kwargs):
"""Writes load and load step option data to a file.
Expand Down
Loading
Loading