Skip to content

Commit 6c95168

Browse files
authored
add in name property (#646)
1 parent 9ff41ff commit 6c95168

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

ansys/mapdl/core/mapdl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ def __init__(self, loglevel='DEBUG', use_vtk=True, log_apdl=False,
179179

180180
self._post = PostProcessing(self)
181181

182+
@property
183+
def _name(self): # pragma: no cover
184+
"""Implemented by child class"""
185+
raise NotImplementedError("Implemented by child class")
186+
182187
@property
183188
def queries(self):
184189
"""Get instance of Query class containing inline functions of APDL.

ansys/mapdl/core/mapdl_console.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ def kill(self):
221221
except:
222222
self._log.warning("Unable to kill process %d", self._process.pid)
223223
self._log.debug("Killed process %d", self._process.pid)
224+
225+
@property
226+
def _name(self):
227+
"""Instance unique identifier."""
228+
return f"Console_PID_{self._process.pid}"

ansys/mapdl/core/mapdl_corba.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,12 @@ def __init__(self, loglevel='INFO', log_apdl='w', use_vtk=True,
182182

183183
# critical for collection
184184
INSTANCES.append(weakref.ref(self))
185+
self._corba_key = None
185186

186187
def _launch(self, start_parm, verbose):
188+
"""Launch CORBA."""
187189
corba_key = launch_corba(verbose=verbose, **start_parm)
190+
self._corba_key = corba_key
188191

189192
orb = CORBA.ORB_init()
190193
self._server = orb.string_to_object(corba_key)
@@ -379,3 +382,8 @@ def _close_output(self):
379382
if self._outfile:
380383
self._outfile.close()
381384
self._outfile = None
385+
386+
@property
387+
def _name(self):
388+
"""Instance unique identifier."""
389+
return f"CORBA_PID_{self._corba_key}"

ansys/mapdl/core/mapdl_grpc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,3 +1768,8 @@ def cmatrix(
17681768
# otherwise, simply run cmatrix as we're already in
17691769
# non-interactive and there's no output to return
17701770
super().cmatrix(symfac, condname, numcond, grndkey, capname, **kwargs)
1771+
1772+
@property
1773+
def _name(self):
1774+
"""Instance unique identifier."""
1775+
return f"GRPC_{self._ip}:{self._port}"

tests/test_mapdl.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def make_block(mapdl, cleared):
108108
mapdl.vmesh("ALL")
109109

110110

111+
@pytest.mark.skip_grpc
112+
def test_internal_name_grpc(mapdl):
113+
assert str(mapdl._ip) in mapdl._name
114+
assert str(mapdl._port) in mapdl._name
115+
assert 'GRPC' in mapdl._name
116+
117+
111118
def test_jobname(mapdl, cleared):
112119
jobname = "abcdefg"
113120
assert mapdl.jobname != jobname

0 commit comments

Comments
 (0)