Exercise on 2d meshing

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Exercise on 2d meshing

Post by johnwang »

Hi,

1. Open a New document, Use attached marco to make a triangle with Face. Its name in mode tree is Shape. Save it. I saved it as d:/cfdtest/aFace.FCstd
2. Switch to FEA WB, click A icon to active FEA tool
3. Click to select Shape in mode tree, Mesh tool is activated.
4. Cick Mesh tool (the one using gmsh) . On the mesh window, click Apply to mesh. Click OK to close.
5. In Edit/Preferences/FEA/General, I ticked 'Beside .FCStd file, so I can see my mesh saved at d:/cfdtest/aFace/FEMMeshGmsh. It is called Shape_mesh.UNV. I could convert it to Elmer's mesh format with Elmergrid.exe under win 10. the command in terminal is

Code: Select all

elmergrid 8 2 Shape_mesh.UNV
The Shape_Geometry.brep file is what I draw in FreeCAD. The shape2mesh.geo file is how to mesh in gmsh. Change these two lines

Code: Select all

// save
Mesh.Format = 2;
// Ignore Physical definitions and save all elements;
Mesh.SaveAll = 1;
Save "D:/CFDtest/aFace\FEMMeshGmsh\Shape_Mesh.unv";
to

Code: Select all

// save
Mesh.Format = 1;
// Ignore Physical definitions and save all elements;
Mesh.SaveAll = 1;
Save "D:/CFDtest/aFace\FEMMeshGmsh\Shape_Mesh.msh";
Then double click shape2mesh.geo in the folder, gmsh will generate a Shape_mesh.msh file. This file could be viewed by gmsh by double click. I could also convert it to Elmer's mesh format with Elmergrid.exe under win 10. the command in terminal now is

Code: Select all

elmergrid 14 2 Shape_mesh.msh
At the moment, I have problem to convert both UNV and msh. Convert UNV needs a new developer version of elmergrid.exe. Maybe need to add boundary condition.

Regards,

John
m.jpg
m.jpg (52.77 KiB) Viewed 648 times

Code: Select all

from FreeCAD import Base
import Part

V1=Base.Vector(0,0,0)
V2=Base.Vector(300,0,0)
V3=Base.Vector(150,150,0)

L1=Part.LineSegment(V1,V2)
L2=Part.LineSegment(V2,V3)
L3=Part.LineSegment(V3,V1)

S=Part.Shape([L1,L2,L3])
W=Part.Wire(S.Edges)

F=Part.Face(W)
Part.show(F)
Last edited by johnwang on Fri May 29, 2020 9:56 am, edited 1 time in total.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Exercise on 2d meshing

Post by RatonLaveur »

I have trouble understanding what you are trying to achieve. 2D Elmer cases can already be run all the way from FreeCAD GUI.
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Exercise on 2d meshing

Post by johnwang »

In shape2mesh.geo, change these two lines as:

Code: Select all

// save
Mesh.Format = 'su2';
// Ignore Physical definitions and save all elements;
Mesh.SaveAll = 1;
Save "D:/CFDtest/aFace\FEMMeshGmsh\Shape_Mesh.su2";
I got su2 mesh. Will try to add BCs.

Edit:

It is generated by Mod\Fem\femmesh.py
save.jpg
save.jpg (82.53 KiB) Viewed 521 times
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
Post Reply