BoundaryLayer setup for Gmsh 2D and 3D meshing, please help to test

About the development of the FEM module/workbench.

Moderator: bernd

qingfeng.xia
Posts: 145
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

BoundaryLayer setup for Gmsh 2D and 3D meshing, please help to test

Postby qingfeng.xia » Fri Jun 16, 2017 8:38 am

## introduction to boundary layer

precise control of the thickness of the first cell normal to wall, is crucial for turbulence models like k-epsilon, k-omega. This function is required by CFD workbench, but could be useful for other CAE domains. The velocity gradient near wall is so high that near wall mesh need to be very fine to catch flow condition in turbulence boundary layer.

https://en.wikipedia.org/wiki/Boundary_layer
==============================
## solution with Gmsh

I have been thinking about this since last year, just recent I have done some test outside of FreeCAD, as kind of feasibility study.
Box_Geometry.brep
(4.49 KiB) Downloaded 44 times
geo can not been uploaded, but it is on my website
see my webpage http://www.iesensor.com/blog/2017/06/16 ... d-meshing/
gmsh 3d boundarylayer.png
gmsh 3d boundarylayer.png (376.39 KiB) Viewed 2149 times
The boundary layer is hard to see, meshing bisect may illustrate it better. but it do work some single body.

Now I am turning into coding, a new class "FemMeshBoundaryLayer" is added, holding setup information.
this function is built on his work of FemMeshRegion, Thanks for bernd.

Gmsh boundary meshing is not robust like commercial tool like Ansys workbench, so it may fail for complex geometry. but anyway, you can substitute the coarse mesh generated by FEM/CFD workbench with some better one after the initial evaluation in GUI.

Also mentioned, OpenFOAM CFD workbench use cfmesh and snappyHexMesh of OpenFOAM for boundarlyer refinement.
https://github.com/jaheyns/CfdFoam/blob ... rtTools.py

==================================
## basic implementation is done

https://github.com/qingfengxia/FreeCAD.git
* [new branch] boundarylayer -> boundarylayer
https://github.com/qingfengxia/FreeCAD/ ... ndarylayer

only one boundary setting bbject/Field can be applied, but multiple boundary faces can be selected.

2D meshing can get a result and shown up in taskpanel.
Although solid mechanics does not need a boundary layer, but it should not hurt. I can get result, but not sure it is realistic

3D is also possible, but boundary layer can only been viewed in wireframe view mode
3D data file is too big to upload to this forum.

set up boundary mesh parameters could be trick, so try my 2D case first for testing
FreeCAD_gmsh_2d_boundaryLayer_meshing.png
FreeCAD_gmsh_2d_boundaryLayer_meshing.png (312.38 KiB) Viewed 2098 times
FreeCAD _gmsh_3d_ boundary_layer_meshing.png
FreeCAD _gmsh_3d_ boundary_layer_meshing.png (397.27 KiB) Viewed 2098 times
the ends of boundary layer is not good, I am not sure if fan angle could help
-----------------------

## bugs to resolve (solved 2017-07-31)

issue 1: FemMeshBoundaryLayer, properties can not been changed in taskpanel: 2 of then can be updated now, only one left: thickness

> solved, my stupid error after copy and paste

issue 2: in reference box, selected geometry element will not show up until next element is clicked

> user must click "Add reference" button, then click goemetry, it is not bug but I miss out the user manual

issue 3: 3D result can not been shown, error 'FEM: Result node numbers are not equal to FEM Mesh NodeCount.'

> solved, 3D result can be shown properly in result task panel, as the figure attached.
For mesh algorithm, only a few 2DAlgorithms are usable with 3D boundary layer generation, DelQuad/Frontal are tested to be usable!
Only half of faces for 2D meshing can be shown in FreeCAD , but the mesh and result show properly in paraview.

issue 4: Also solve the bug: after femobject renaming, FemMaterialFluid command failed for name mismatching
> fixed
FreeCAD_3D_boundarylayer_result.png
FreeCAD_3D_boundarylayer_result.png (386.48 KiB) Viewed 1835 times
Last edited by qingfeng.xia on Mon Jul 31, 2017 9:57 pm, edited 8 times in total.
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
bernd
Posts: 6137
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing

Postby bernd » Fri Jun 16, 2017 5:37 pm

could someone explain in simple words what a boundary layer is?
User avatar
kkremitzki
Posts: 977
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing

Postby kkremitzki » Fri Jun 16, 2017 8:40 pm

bernd wrote:
Fri Jun 16, 2017 5:37 pm
could someone explain in simple words what a boundary layer is?
A boundary layer is a region between a fluid and a boundary surface where "intermediate" effects rule. For example, if you have a puddle, there is not a discontinuous transition from "all water" to "all air". There is a very small intermediate boundary layer where all the evaporation is occurring, and there's a gradient across this layer from "all water" to "all air".
Like my FreeCAD work? I'd appreciate any level of support via Patreon! Read more about what I do at my blog.
qingfeng.xia
Posts: 145
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing

Postby qingfeng.xia » Sat Jun 17, 2017 10:22 pm

bernd wrote:
Fri Jun 16, 2017 5:37 pm
could someone explain in simple words what a boundary layer is?
CSIR team are working on cfmesh, which I guess deals with same thing, viscous layer.

I have found the gmsh boundary layer can not shown up in FreeCAD even in wireframe mode for cylinder wall. boundary layer can only be viewed by cross section clip in paraview.
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
bernd
Posts: 6137
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing, please help to test

Postby bernd » Sat Jul 01, 2017 1:00 pm

qingfeng.xia
Posts: 145
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing, please help to test

Postby qingfeng.xia » Mon Jul 31, 2017 9:35 am

I am working on this issue now, just finish rebase on 2017-07-31 master.

issues are solved, and PR are sent to upstream master
Last edited by qingfeng.xia on Mon Jul 31, 2017 10:14 pm, edited 1 time in total.
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
qingfeng.xia
Posts: 145
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing

Postby qingfeng.xia » Mon Jul 31, 2017 10:14 pm

How to use this feature:

usage is quite similar with FemMeshRegion, once Gmsh object is created, FemmeshBoundaryLayer object can be added into gmsh object.

boundary layer are attached to the selected Edge (for 2D mesh) or faces for 3D mesh, 3 parameters can be setup to control boundary layers generation.

thickness (normal to the boundary edge/face) for the first layer on the boundary, it must be minimum thickness,
ratio of second layer thickness / first layer thickness, 1.3 - 2 for turbulence boundary layers
how many layers, usually a smooth transition of cell size from boundary to far field is preferred
FreeCAD_boundarylayer_setup_taskpanel.png
FreeCAD_boundarylayer_setup_taskpanel.png (49.73 KiB) Viewed 1832 times
3D test case for cantilever, based on example comes with FreeCAD Femworkbench
FemBLMesh3D.fcstd
(839.86 KiB) Downloaded 36 times
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
Kunda1
Posts: 2981
Joined: Thu Jan 05, 2017 9:03 pm

Re: BoundaryLayer setup for Gmsh 2D and 3D meshing, please help to test

Postby Kunda1 » Tue Aug 22, 2017 4:28 pm

Can we close issue #3111?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features