ansys / ansys/pymechanical

Bug located in opening more than one *.mechdb using embedded app

Open
#1,184 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
83
Forks
37
Avg merge
1d 3m
Merged PRs (30d)
26

Description

### 🔍 Before submitting the issue

- [x] I have searched among the existing issues
- [x] I am using a Python virtual environment

### 🐞 Description of the bug

In Linux

when user starts the mechanical in embedded session and any `mechdb` , one can access the `MeshData` without any problems, if user closes it using `app.close()` and opens another `mechdb` and tries to access the `MeshData`, the wrapper is there but it does not contain Mesh, the number of elements and nodes are zero

### 📝 Steps to reproduce

- in any Linux operating system
- use the [cube-hole.mechdb](https://github.com/ansys/pymechanical/blob/main/tests/assets/cube-hole.mechdb)
- create a copy of the above file and name it `dummy.mechdb`
- put following code in a file `test.py`
```
import os
import ansys.mechanical.core as mech
app=None
def test_reopen_access_meshdata():
dir_path = os.path.dirname(__file__)
global app
app = mech.App(version=251)
globals().update(mech.global_variables(app, True))

app.open(os.path.join(dir_path,"cube-hole.mechdb"))
md = app.DataModel.MeshDataByName(app.DataModel.MeshDataNames[0])
orig_node_count = md.NodeCount

app.close()
app.new()
app.open(os.path.join(dir_path,"dummy.mechdb"))

md = app.DataModel.MeshDataByName(app.DataModel.MeshDataNames[0])

assert orig_node_count==md.NodeCount, f"Node count did not match after reopening the mesh data : {orig_node_count} != {md.NodeCount}"

if __name__ == "__main__":
test_reopen_access_meshdata()
app.close()
app.exit()
app._dispose()

```

- now run `mechanical-env python test.py`
- you will see the assertion error

### 💻 Which operating system are you using?

Linux

### 📀 Which ANSYS version are you using?

2025 R1

### 🐍 Which Python version are you using?

3.10

### 📦 Installed packages

```shell
-
```

Contributor guide

Open the contributing guide

Research direction

Start with the supplied test.py reproduction and the cube-hole.mechdb and dummy.mechdb assets. Trace the App lifecycle through close(), new(), open(), and MeshDataByName(), then verify that accessing MeshData after reopening produces the expected node count instead of zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.