# Mesh import error: \_split\_fluid

**URL:** <https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173>\
**Category:** General\
**Created:** [7 September 2017 19:48 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173 "2017-09-07T19:48:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dallas\_Nelson](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dallas\_Nelson](https://pyfr.discourse.group/u/Dallas_Nelson)\
**Post date:** [7 September 2017 19:48 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/1 "2017-09-07T19:48:49Z")

</div>

I am trying to import my mesh so I can PyFR however I am being met with the following error.

`christopher@dear5b-cuda:~/PDE_Sim$ pyfr import pde_assem.msh pde_assem.pyfrm`

```auto
Traceback (most recent call last):
File "/home/christopher/miniconda3/bin/pyfr", line 11, in <module>
load_entry_point('pyfr==1.6.0', 'console_scripts', 'pyfr')()
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/ __main__.py", line 110, in main
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/ __main__.py", line 124, in process_import
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py", line 23, in to_pyfrm
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/gmsh.py", line 200, in _to_raw_pyfrm
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py", line 179, in get_connectivity
File "/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py", line 96, in _split_fluid
KeyError: 4

```

I am on a linux system running ubuntu 16.04 but am fairly new to linux and python so its very possible I have made some mistake somewhere or it is something that would be painfully obvious to anyone else.  
My goal is to simulate the mixing of two fluids inside a long cylinder under different injection configurations if that is relevant at all.  
Please let me know if there is any other information I can supply to help get to the bottom of this and thank you for your time.

---

<div class="post-metadata">

**Author:** ![nnunn](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nnunn](https://pyfr.discourse.group/u/nnunn)\
**Post date:** [8 September 2017 21:18 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/2 "2017-09-08T21:18:38Z")

</div>

Hi Dallas – may be an error in the way your mesh file defines the fluid elements.  
If your mesh is generated by gmsh, and if you can send the .geo file, I can take a look.  
Nigel

---

<div class="post-metadata">

**Author:** ![Dallas\_Nelson](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dallas\_Nelson](https://pyfr.discourse.group/u/Dallas_Nelson)\
**Post date:** [8 September 2017 22:10 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/3 "2017-09-08T22:10:52Z")

</div>

The geometry was created in solidworks and exported as a .stl. I then used gmsh to convert it to .msh so my guess is something went wrong in the conversion.  
Here are the steps I used:

> File → Merge → “filename.stl”  
> Geometry → Elementary entities → Add → New → Volume, click on the surface to build the volume  
> Mesh → 3D  
> I will attach the .stl and .geo files  
> Thank you

[PDE Assem2.geo](https://pyfr.discourse.group/uploads/short-url/cj5rvFxBekkrAcDVRAkVPLAYUpC.geo) (110 Bytes)

[PDE Assem2.STL](https://pyfr.discourse.group/uploads/short-url/4NZCQoZC6Hs1VW7IBk8baVqi7yj.STL) (6.22 MB)

---

<div class="post-metadata">

**Author:** ![nnunn](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nnunn](https://pyfr.discourse.group/u/nnunn)\
**Post date:** [9 September 2017 07:40 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/4 "2017-09-09T07:40:27Z")

</div>

Hi Dallas - thanks for sending the .geo and STL geometry files.

Just checking - I see a long, thin tube with 4 holes near one end, plus two cylindrical disks at the other end, punched through with more holes.

- Are you trying to mesh inside the “walls” of the structure, or some volume that encloses the structure?
- What sort of boundary conditions do you need?
- Can your version of gmsh actually create a mesh from that input?

I’m using gmsh 3.02, and can’t get a valid mesh.  
Nigel

---

<div class="post-metadata">

**Author:** ![nnunn](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nnunn](https://pyfr.discourse.group/u/nnunn)\
**Post date:** [9 September 2017 09:03 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/5 "2017-09-09T09:03:21Z")

</div>

PS: Dallas, gmsh can work directly with IGES and STEP formats.

If you can export your SolidWorks geometry in one of these (OpenCascade-friendly) formats, they might work better than an STL approximation.

just a thought - Nigel

---

<div class="post-metadata">

**Author:** ![Ezhilmathi\_Krishnasa](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@Ezhilmathi\_Krishnasa](https://pyfr.discourse.group/u/Ezhilmathi_Krishnasa)\
**Post date:** [9 September 2017 14:17 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/6 "2017-09-09T14:17:43Z")

</div>

Hi Dallas,

Few more things, you need to specify the BC and fluid domain in the msh.

Cheers,  
Mathi

---

<div class="post-metadata">

**Author:** ![Dallas\_Nelson](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dallas\_Nelson](https://pyfr.discourse.group/u/Dallas_Nelson)\
**Post date:** [14 September 2017 18:54 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/7 "2017-09-14T18:54:20Z")

</div>

Thank you for the responses. I have remade my geometry using gmsh so I wont need to worry about converting it. I am not sure how I am supposed to specify the BC and fluid domain though. Are the BC just me calling out the different surfaces and the fluid domain just the volume because thats all I’ve really been able to find online. If so then how do I add a second fluid and specify how each is entering the chamber? Again this stuff might be really obvious and I am just a big ape smashing keys at a computer.

Thank you

---

<div class="post-metadata">

**Author:** ![Dallas\_Nelson](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@Dallas\_Nelson](https://pyfr.discourse.group/u/Dallas_Nelson)\
**Post date:** [14 September 2017 18:57 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/8 "2017-09-14T18:57:47Z")

</div>

Forgot to add that I am still running into a key error and attach files  
christopher@dear5b-cuda:~/PDE\_Sim$ pyfr import PDE\_Assemb.msh PDE\_Assemb.pyfrm  
Traceback (most recent call last):  
File “/home/christopher/miniconda3/bin/pyfr”, line 11, in   
load\_entry\_point(‘pyfr==1.6.0’, ‘console\_scripts’, ‘pyfr’)()  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/ **main**.py”, line 110, in main  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/ **main**.py”, line 124, in process\_import  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py”, line 23, in to\_pyfrm  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/gmsh.py”, line 200, in \_to\_raw\_pyfrm  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py”, line 179, in get\_connectivity  
File “/home/christopher/miniconda3/lib/python3.6/site-packages/pyfr-1.6.0-py3.6.egg/pyfr/readers/base.py”, line 96, in \_split\_fluid  
KeyError: 7

[PDE\_Assemb.geo](https://pyfr.discourse.group/uploads/short-url/TIJsTHgWKZypV7SlxxrTq8jIRS.geo) (1.1 KB)

[PDE\_Assemb.msh](https://pyfr.discourse.group/uploads/short-url/hHBsiGtiTtnAjKFEmr9Q69k4m70.msh) (14.4 KB)

---

<div class="post-metadata">

**Author:** ![nnunn](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nnunn](https://pyfr.discourse.group/u/nnunn)\
**Post date:** [15 September 2017 17:56 UTC](https://pyfr.discourse.group/t/mesh-import-error-split-fluid/173/9 "2017-09-15T17:56:39Z")

</div>

Dallas - nice work with the new boolean cylinders!

I’ve attached an adjusted .geo input (Assemb\_v2.geo) that generates a mesh (44,897 tetrahedra) which PyFR should be able to load.

At the top of the file you can see I use variables {x1, x2, x3} to toggle a shorted barrel length (makes it easier to examine the mesh).

However, given the geometry, I’m not sure which region you intend to be the actual simulation (“fluid”) domain… ?

Loading the attached .geo into gmsh and pressing [Mesh -\> 3d], I see 5 small cylinders labeled “inlet1” : “inlet5” going from (x= -2 : x= 0) through the wide disk, as inlets into the long barrel chamber formed by your “ **inside wall** ” surface.

**Question** : do you want to model the **structure** generated by this geometry, or some volume enclosing this structure? i.e., do you want to simulate the inlet/pipe material, or some fluid flowing through the pipe?

Nigel

[Assemb\_v2.geo](https://pyfr.discourse.group/uploads/short-url/5xEdFBJ1YPotPiCxUCJKXNvi5pz.geo) (1.68 KB)
