VMTK and OpenFoam

739 views
Skip to first unread message

nacholarrabide

unread,
Jan 16, 2015, 3:56:13 PM1/16/15
to vmtk-...@googlegroups.com
Dear all, 

I am trying to get some CFD simulations running on OpenFOAM. I used some in-hose software to get a proper surface in stl format. So far, I tried different paths to go from the surface to the tetrahedral mesh, which I input to OpenFOAM 1.6 (I use some extension packages only available in this version).

So far, all the roads reached a dead end. Surely most of you have already done CFD from VMTK and solved some (or all) of these problems, so any help is greatly appreciated. The stl is already cleaned up, just in case, I do a vmtk surface remesh to improve the mesh a bit further and set the edge size that I want. I use VMTK (1.2) from Python (2.7.3) under Ubuntu 12.04. 

These are the paths and the problems encountered so far:

 - Load an STL in VMTK -> use vmtkMeshGenerator to generate the mesh -> use vmtkmeshwriter to output the mesh in "fluent" format-> convert to OpenFOAM using the "fluent3DMeshToFoam" app

Seems to work, but the foam mesh that "fluent3DMeshToFoam" outputs is a mess (I check that using "foamToVTK" app). Also, by looking at the vmtk generated ".msh" file and comparing to a similar one generated from the same stl with Netgen, it seems like a tag is missing (something like "(0 "Nodes:")" in line 5). Am I messing up or missing a step in between? Is this expected?

 - Load an STL in VMTK -> use vmtkMeshGenerator to generate the mesh -> use vmtkmeshwriter to output the mesh in "fluent" format-> convert to OpenFOAM using Netgen export utility
 
Netgen will not open the file, same question as before, Am I messing up or missing a step in between?

If someone has gone through this or a similar path to do CFD with OpenFOAM from VMTK, any suggestion? is anyone currently using the fluent format in the vmtk mesh writer? is there any other format more suitable to connect both?

Best,

Nacho

Luca Antiga

unread,
Jan 21, 2015, 9:40:40 AM1/21/15
to vmtk-...@googlegroups.com
Hi Nacho,
good to hear from you. I personally haven’t used OpenFOAM with vmtk, but we’ve been generating meshes in Fluent format in the past and they worked (in Fluent).
Note that the Fluent exporter in vmtk only supports linear tets. Are you using prismatic boundary layers by any chance?

Luca

--
You received this message because you are subscribed to the Google Groups "vmtk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vmtk-users+...@googlegroups.com.
To post to this group, send email to vmtk-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Luca Antiga, PhD
Co-founder and Principal Scientist, OROBIX Srl
via Gabriele Camozzi 144, 24121 Bergamo, Italy

twitter: @lantiga
mobile: +39.347.43.16.596

"This message originates from OROBIX Srl and its contents and attachments are privileged and confidential and are intended only for the individual(s) or entity(ies) named above. This message should not be forwarded, distributed or disclosed. Any unauthorized use, dissemination and duplication is strictly prohibited and may be unlawful. All personal messages express views solely of the sender, which are not to be attributed to OROBIX Srl, and may not be copied or distributed without this disclaimer. If you are not the intended recipient or received this message in error, please delete this message and notify the sender by reply e-mail. Opinions, conclusions and other information in this message that do not relate to the official business of OROBIX Srl shall be understood as neither given nor endorsed by it."

Ignacio Larrabide

unread,
Jan 21, 2015, 3:05:20 PM1/21/15
to vmtk-...@googlegroups.com
Hi Luca, 

many thanks for the reply. Still fighting with this. I convert all prisms to linear tets before saving the mesh, at some point I notice that prism elements could not be saved. The issue is somewhere else. Was there any significant change in the meshing filters from version 0.9 to 1.2? 

Best,

Nacho


Ignacio Larrabide, DSc

Luca Antiga

unread,
Jan 21, 2015, 3:29:43 PM1/21/15
to vmtk-...@googlegroups.com
Hi Nacho,
no fundamental changes from 0.9 to 1.2, but there has to be something I’m missing. 
You may already have tried, but can you try with an all-tet mesh (i.e. not a mesh with boundary layer converted to tets)?

Luca

Ignacio Larrabide

unread,
Jan 21, 2015, 3:38:37 PM1/21/15
to vmtk-...@googlegroups.com

Thanks for the speedy reply! I tried also that, but with the same result. I'll send a py script and sample data later so we can discuss on something concrete. Talk to you soon.

Nacho

Luca Antiga

unread,
Jan 21, 2015, 3:41:45 PM1/21/15
to vmtk-...@googlegroups.com
Great, that would work.
I’ll be traveling tomorrow, so it’s unlikely I’ll be able to take a look before Friday.
Cheers

Luca

nacholarrabide

unread,
Jan 21, 2015, 5:40:44 PM1/21/15
to vmtk-...@googlegroups.com
Hi again,

here is the python script (with some comments where I get unexpected results) and the input (vessel.vtk) and script outputs (vesselVolMesh.vtu in vtk format and vesselVolMesh.msh.tar.gs the compressed mesh in fluent format).

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
from vmtk import vmtkscripts

# read the mesh
sr = vmtkscripts.vmtkSurfaceReader()
sr.InputFileName = "vessel.vtk"
sr.Execute()

# create the centerline and add the extensions to the inlets
ce = vmtkscripts.vmtkCenterlines()
ce.Surface = sr.Surface
ce.SeedSelectorName = 'openprofiles' # a window opens and asks for the ids 
                                     # of the inlet and outlet profile IDs, can this be
                                     # done automatic? 
ce.Execute()

fe = vmtkscripts.vmtkFlowExtensions()
fe.Surface = sr.Surface
fe.Centerlines = ce.Centerlines
fe.ExtensionMode = 'boundarynormal'
#fe.TransitionRatio = 4  # not sure what this parameter is.
fe.ExtensionRadius = 10 # seems to be working, but I'm not sue on what this radius means, 
fe.ExtensionLength = 12 # what length is this one? 10 diameters? 10 radius? measured where?
                        # I used a value that worked, but it is not clear what this value is
                        # Also: can I set different lengths in different in/outputs?
fe.Interactive = 0
fe.Execute()

# create the volume mesh and boundary layer
mg = vmtkscripts.vmtkMeshGenerator()
mg.Surface = fe.Surface
mg.TargetEdgeLength = 0.8 # coarse example, just to get a result fast
mg.SkipCapping = 1
mg.SkipRemeshing = 0
mg.BoundaryLayer = 1
mg.NumberOfSublayers = 3 # only 2 layers are generated, Am I missing something?
mg.SubLayerRatio = 0.7
mg.RemeshCapsOnly = 0
mg.BoundaryLayerOnCaps = 0
mg.Tetrahedralize = 1
mg.Execute()

# save the mesh to fluent format (to convert to OpenFOAM later on) and to vtk to inspect in paraview.
mw = vmtkscripts.vmtkMeshWriter()
mw.Mesh = mg.Mesh
mw.OutputFileName = "vesselVolMesh.msh"
mw.Format = "fluent"
mw.Execute()

mw2 = vmtkscripts.vmtkMeshWriter()
mw2.Mesh = mg.Mesh
mw2.OutputFileName = "vesselVolMesh.vtu"
mw2.Format = "vtk"
mw2.Execute()
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Many thanks for your feedback.

Nacho 
vessel.vtk

Nacho Larrabide

unread,
Jan 22, 2015, 2:55:42 PM1/22/15
to vmtk-...@googlegroups.com
Dear Luca and all, 

I have completely wiped out my old verion of VMTK (0.9) and re-installed the vmtk version I had and installer the latest 1.2 stable release from the python egg. I believe something probably changed in the last couple of versions in the writers. After a couple of tests, it seems that the fluent output is correct for OpenFOAM to convert it correctly. As soon as I have a clean working python script, I will share it. Still, I'm continue to struggle with some of the issues I mention as comments in the python script (mainly related to the meshgenerator parameters). 

Any ideas?

Many thanks,

Nacho
Ignacio Larrabide, DSc
mailto:ignacio.larrabide@gmail.com

Simone Manini

unread,
Jan 23, 2015, 3:59:31 AM1/23/15
to vmtk-...@googlegroups.com, vmtk-...@googlegroups.com
Dear Nacho,
the new boundary layer algorithm was introduced in the 1.2 binary version of VMTK.
With previous versions you were able only to add maximum 2 sublayers.

With vmtk 1.2 you can use:

-sublayers parameter in order to choose how many sublayers will be created
-sublayerratio parameter to set the ratio between one layer and its neighbour.
-thicknessfactor parameter to set the thickness of the first internal layer.

Remember to set -boundarylayeroncaps 0.


Regarding flow extensions:

By using -adaptivelength 1 you enable computing length of each flowextension proportional to the mean profile radius. The proportionality factor is set through extensionratio.
I suggest using this modality instead of  -extensionlength which is a fixed length.


Last but not least, if you want to automatically add seeds without interactively place them, you need to pass to the script the coordinates ( or point ids ) of the seeds with the flag -seedselector:

idlist: list of surface point ids (specified as argument to -sourceids and -targetids); 
pointlist: list of surface points (specified as argument to -sourcepoints and -targetpoints)


Best regards 
Simone


Simone Manini, Eng
Project Manager, OROBIX Srl
via Camozzi 144, 24121 Bergamo, Italy

orobix:  www.orobix.com
web:     daron1337.github.io
twitter:  @daron1337
phone:  +39 035 0273786
             +39 035 0170561

"This message originates from Orobix Srl and its contents and attachments are privileged and confidential and are intended only for the individual(s) or entity(ies) named above. This message should not be forwarded, distributed or disclosed. Any unauthorized use, dissemination and duplication is strictly prohibited and may be unlawful. All personal messages express views solely of the sender, which are not to be attributed to Orobix Srl, and may not be copied or distributed without this disclaimer. If you are not the intended recipient or received this message in error, please delete this message and notify the sender by reply e-mail. Opinions, conclusions and other information in this message that do not relate to the official business of Orobix Srl shall be understood as neither given nor endorsed by it."


<vessel.vtk>

Ignacio Larrabide

unread,
Jan 23, 2015, 8:00:20 AM1/23/15
to vmtk-...@googlegroups.com
Hi Simone, 

many thanks for the reply. Just to clarify, I'm using vmtkscripts through python. Some comments inline:

On Fri, Jan 23, 2015 at 5:59 AM, Simone Manini <simone...@orobix.com> wrote:
Dear Nacho,
the new boundary layer algorithm was introduced in the 1.2 binary version of VMTK.
With previous versions you were able only to add maximum 2 sublayers.

With vmtk 1.2 you can use:

-sublayers parameter in order to choose how many sublayers will be created
 
The python parameter associated to this variable is  NumberOfSublayers, I set it to three, but only 2 layers (the default) come out. I tried going rirectly to the py source and changing the default value directly at the /vmtk-1.2-py2.7-linux-x86_64.egg/vmtk/vmtkmeshgenerator.py like this:

self.NumberOfSubLayers = 3

which is far from clean, but it worked. What could be going wrong? the rest of parameters are working fine for the mesh generator.

-sublayerratio parameter to set the ratio between one layer and its neighbour.

Ok
 
-thicknessfactor parameter to set the thickness of the first internal layer.

Ok
 

Remember to set -boundarylayeroncaps 0.


Regarding flow extensions:

By using -adaptivelength 1 you enable computing length of each flowextension proportional to the mean profile radius. The proportionality factor is set through extensionratio.
I suggest using this modality instead of  -extensionlength which is a fixed length.

Great, much better now!! I had the same problem than before with vmtkmeshgenerator and the number of sublayers. It "sorted out" the same way. Any ideas on why the parameter setting is not persistent?

As a suggestion (and I don't want to be picky) but sometimes is not clear from the documentation what each parameter does and quite some trial error follows.



Last but not least, if you want to automatically add seeds without interactively place them, you need to pass to the script the coordinates ( or point ids ) of the seeds with the flag -seedselector:

idlist: list of surface point ids (specified as argument to -sourceids and -targetids); 
pointlist: list of surface points (specified as argument to -sourcepoints and -targetpoints)


I see, perfect.

Many thanks,

Nacho

Simone Manini

unread,
Jan 26, 2015, 4:15:33 AM1/26/15
to vmtk-...@googlegroups.com, vmtk-...@googlegroups.com

Dear Nacho,

The python parameter associated to this variable is  NumberOfSublayers, I set it to three, but only 2 layers (the default) come out. I tried going rirectly to the py source and changing the default value directly at the /vmtk-1.2-py2.7-linux-x86_64.egg/vmtk/vmtkmeshgenerator.py like this:

self.NumberOfSubLayers = 3

which is far from clean, but it worked. What could be going wrong? the rest of parameters are working fine for the mesh generator.

Looking at the code there’s nothing wrong, we wil try to take a look deeper and we will let you know


Simone


Luca Antiga

unread,
Jan 29, 2015, 10:35:36 AM1/29/15
to vmtk-...@googlegroups.com
Hi Nacho,
I believe the problem is that in your Python script you’re setting 

mg.NumberOfSublayers = 3

instead of

mg.NumberOfSubLayers = 3

The same way Python gives you freedom, it happily lets you shoot yourself in the foot :-)

Luca
  

Ignacio Larrabide

unread,
Jan 29, 2015, 10:56:07 AM1/29/15
to vmtk-...@googlegroups.com
%$#@*&, indeed, it was that.

Thanks, a lot. If you would like to have a few scripts to make explicit the connection between VMTK and OpenFOAM, let me know. I'm happy to contribute with a sample, if that helps.

Best,

Nacho

Luca Antiga

unread,
Jan 29, 2015, 11:34:05 AM1/29/15
to vmtk-...@googlegroups.com
Hey Nacho,
that would actually be great!

Luca

Ignacio Larrabide

unread,
Feb 10, 2015, 9:23:09 AM2/10/15
to vmtk-...@googlegroups.com
Dear all, 

I continue to work on the mesh generation for CFD with OpenFOAM. I'm almost there, but...  I'm using one of the example datasets provided with one of the tutorials (ParentVesselReconstruction, datasets id1_model.vtp and id2_model.vtp). I have the whole pipeline working now, but I get some anoying inconsistence in the final fluent mesh. The script looks like this:

# The mesh generation process might need adjusting the target edge length for your
# geometry. 
from vmtk import vmtkscripts

# read the mesh
sr = vmtkscripts.vmtkSurfaceReader()
#sr.InputFileName = "vmtk/id2_model.vtp"
sr.InputFileName = "vmtk/id1_model.vtp"
sr.Execute()

sn = vmtkscripts.vmtkSurfaceNormals()
sn.Surface = sr.Surface
sn.Execute()

# define the edge length
edgeLength = 0.5

# remesh the surface before further processing
srm = vmtkscripts.vmtkSurfaceRemeshing()
srm.Surface = sn.Surface
srm.ElementSizeMode = "edgelength"
srm.TargetEdgeLength = edgeLength
srm.NumberOfIterations = 5
#srm.ExcludeEntityIds = [1]
srm.Execute()

# create the centerline and add the extensions to the inlets
ce = vmtkscripts.vmtkCenterlines()
ce.Surface = srm.Surface
ce.SeedSelectorName = 'openprofiles' 
ce.Execute()

# create flow extensions
fe = vmtkscripts.vmtkFlowExtensions()
fe.Surface = srm.Surface
#fe.Centerlines = ce.Centerlines
fe.ExtensionMode = 'boundarynormal'
fe.ExtensionRadius = 2  
fe.AdaptiveExtensionLength = 1
fe.Interactive = 0
fe.Execute()

# remesh the surface before further processing
srm2 = vmtkscripts.vmtkSurfaceRemeshing()
srm2.Surface = fe.Surface
srm2.ElementSizeMode = "edgelength"
srm2.TargetEdgeLength = edgeLength
srm2.NumberOfIterations = 5
#srm2.ExcludeEntityIds = [1]
srm2.Execute()

# create the volume mesh and boundary layer
mg = vmtkscripts.vmtkMeshGenerator()
mg.Surface = srm2.Surface
mg.TargetEdgeLength = edgeLength
#mg.SkipCapping = 0
mg.SkipRemeshing = 1
mg.BoundaryLayer = 1
#mg.NumberOfSublayers = 2 
mg.SubLayerRatio = 0.7
mg.BoundaryLayerThicknessFactor = 0.5
#mg.RemeshCapsOnly = 1
mg.BoundaryLayerOnCaps = 0
mg.Tetrahedralize = 1
mg.Execute()

# Scale the mesh to meters
ms = vmtkscripts.vmtkMeshScaling()
ms.Mesh = mg.Mesh
ms.ScaleFactor = 0.001
ms.Execute()

# save the mesh to fluent format (to convert to OpenFOAM later on) and to vtk to inspect in paraview.
mw = vmtkscripts.vmtkMeshWriter()
mw.Mesh = ms.Mesh
mw.OutputFileName = "vmtk/id2_model_volMesh.msh"
mw.Format = "fluent"
mw.Execute()

mw2 = vmtkscripts.vmtkMeshWriter()
mw2.Mesh = ms.Mesh
mw2.OutputFileName = "vmtk/id2_model_volMesh.vtu"
mw2.Format = "vtk"
mw2.Execute()

It all works fine, but in the final fluent mesh, by the end of the file, I get the following "Zones":

[...]
(0 "Zones:")
(45 (2 fluid blood)())
(45 (3 wall surface3)())
(45 (4 interior default-interior)())
EOF

This means (apparently) the the domain only has one "surface" region (named surface3), where I should get four (4) additional regions, one for each inlet/outlet. I already the surface in the input of the mesh generator and all the groups (CellEntityIds) are there, and python exits with a nasty crash. This only happens with these two models (id1_model.vtp and id2_model.vtp), but it does not with other models I've tried. Any clues?

Best,

Nacho

Luca Antiga

unread,
Feb 14, 2015, 7:02:45 PM2/14/15
to vmtk-...@googlegroups.com
Hi Nacho,
not sure it's the actual problem, but you should inform the mesh writer about the CellEntityIdsArrayName. This way the Fluent writer can pick up the different entities at the endcaps.
Best,

Luca
twitter: @lantiga
mobile: +39.347.43.16.596
office: +39 035.027.37.86

Veeturi Sricharan

unread,
Jun 30, 2017, 2:20:14 PM6/30/17
to vmtk-users
Hi Luca,

I believe if you tetrahedralize the mesh, fluent can support it. I've tried that and have been able to import it into Fluent.

zbysze...@gmail.com

unread,
Oct 14, 2017, 12:03:40 PM10/14/17
to vmtk-users
Hello!

I'm wondering whether you managed to run a simulation with OpenFOAM on the mesh generated by the VMTK software. Recently, I created a simple geometry of the blood vessel (almost straight pipe) and converted it to the OpenFoam format. However, when I checked the mesh correctness, I obtained some errors, like too high non-orthogonality values or under-determined cells. Therefore, the simulation doesn't want to converge and results are wrong. I checked numerous edgelengths when generating the mesh in VMTK, however, all configurations led to wrong meshes.

Zibi

Roxie Xueke Yu

unread,
Dec 3, 2018, 4:02:41 AM12/3/18
to vmtk-users
Hello Zibi,

I wonder if you have solved the problem? I'm currently inspecting the possibility of using VMTK for OpenFOAM simulations, and would really like any suggestions that you could give me.
Thanks in advance.

Roxie
Reply all
Reply to author
Forward
0 new messages