Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions doc/changelog.d/3773.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: missing pool name in test
10 changes: 7 additions & 3 deletions src/ansys/mapdl/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,15 @@ class ComponentManager:

>>> mapdl.components["mycomp4"] = (1, 2, 3)
/Users/german.ayuso/pymapdl/src/ansys/mapdl/core/component.py:282: UserWarning: Assuming a NODES selection.

This assumes you are doing a NODES selection.
It is recommended you use the following notation to avoid this warning:
\>\>\> mapdl.components['mycomp3'] = 'NODES', (1, 2, 3)

>>> mapdl.components['mycomp3'] = 'NODES', (1, 2, 3)

Alternatively, you disable this warning using:
> mapdl.components.default_entity_warning=False
warnings.warn(

>>> mapdl.components.default_entity_warning=False

You can change the default type by changing
:attr:`Mapdl.components.default_entity <ansys.mapdl.core.Mapdl.components.default_entity>`
Expand Down
27 changes: 14 additions & 13 deletions src/ansys/mapdl/core/mesh_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,8 @@ def nnum_all(self) -> np.ndarray:

nnum = self._mapdl.get_array("NODE", item1="NLIST")
nnum = nnum.astype(np.int32)
if nnum.size == 1:
if nnum[0] == 0:
nnum = np.empty(0, np.int32)
if nnum.size == 1 and nnum[0] == 0:
nnum = np.empty(0, np.int32)

self._ignore_cache_reset = False

Expand All @@ -441,9 +440,8 @@ def enum_all(self) -> np.ndarray:

enum = self._mapdl.get_array("ELEM", item1="ELIST")
enum = enum.astype(np.int32)
if enum.size == 1:
if enum[0] == 0:
enum = np.empty(0, np.int32)
if enum.size == 1 and enum[0] == 0:
enum = np.empty(0, np.int32)

self._ignore_cache_reset = False
return enum
Expand Down Expand Up @@ -551,7 +549,7 @@ def nodes_rotation(self):
"""Returns an array of node rotations"""
return self._mapdl.nlist(kinternal="").to_array()[:, 4:]

def _load_nodes(self, chunk_size=DEFAULT_CHUNKSIZE):
def _load_nodes(self, chunk_size=None):
"""Loads nodes from server.

Parameters
Expand All @@ -565,8 +563,8 @@ def _load_nodes(self, chunk_size=DEFAULT_CHUNKSIZE):
np.ndarray
Numpy array of nodes
"""
if self._chunk_size:
chunk_size = self._chunk_size
if not chunk_size:
chunk_size = self._chunk_size or DEFAULT_CHUNKSIZE

request = anskernel.StreamRequest(chunk_size=chunk_size)
chunks = self._mapdl._stub.Nodes(request)
Expand Down Expand Up @@ -606,7 +604,7 @@ def _elem_off(self):
def _elem_off(self, value):
self._cache_elem_off = value

def _load_elements_offset(self, chunk_size=DEFAULT_CHUNKSIZE):
def _load_elements_offset(self, chunk_size=None):
"""Loads elements from server

Parameters
Expand Down Expand Up @@ -639,8 +637,8 @@ def _load_elements_offset(self, chunk_size=DEFAULT_CHUNKSIZE):
Array of indices indicating the start of each element.

"""
if self._chunk_size:
chunk_size = self._chunk_size
if not chunk_size:
chunk_size = self._chunk_size or DEFAULT_CHUNKSIZE

request = anskernel.StreamRequest(chunk_size=chunk_size)
chunks = self._mapdl._stub.LoadElements(request)
Expand All @@ -664,7 +662,7 @@ def _load_elements_offset(self, chunk_size=DEFAULT_CHUNKSIZE):
elems_[indx_elem] = self.enum
return elems_, offset

def _load_element_types(self, chunk_size=DEFAULT_CHUNKSIZE):
def _load_element_types(self, chunk_size=None):
"""Loads element types from the MAPDL server.

Returns
Expand All @@ -677,6 +675,9 @@ def _load_element_types(self, chunk_size=DEFAULT_CHUNKSIZE):
int
Size of the chunks to request from the server.
"""
if not chunk_size:
chunk_size = self._chunk_size or DEFAULT_CHUNKSIZE

request = anskernel.StreamRequest(chunk_size=chunk_size)
chunks = self._mapdl._stub.LoadElementTypeDescription(request)
data = parse_chunks(chunks, np.int32)
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def __init__(
for i, (ip, port) in enumerate(zip(ips, ports))
]

# Storing
# Storing threads
self._threads = threads

if wait:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ def test_directory_names_custom_string(self, tmpdir):
"ansys.mapdl.core.pool.MapdlPool.__del__",
lambda *args, **kwargs: None,
)
@patch(
"ansys.mapdl.core.pool.MapdlPool.exit",
lambda *args, **kwargs: None,
)
def test_directory_names_function(self, tmpdir):
def myfun(i):
if i == 0:
Expand All @@ -336,7 +340,7 @@ def myfun(i):
names=myfun,
run_location=tmpdir,
additional_switches=QUICK_LAUNCH_SWITCHES,
wait=False,
wait=True,
restart_failed=False,
)

Expand All @@ -345,6 +349,9 @@ def myfun(i):
assert "instance_one" in dirs_path_pool
assert "Other_instance" in dirs_path_pool

pool.exit()
del pool

def test_num_instances(self):
with pytest.raises(ValueError, match="least 1 instance"):
pool = MapdlPool(
Expand Down
Loading