Skip to content

Commit aad7914

Browse files
committed
add virtual topology demo
1 parent 741d41b commit aad7914

File tree

7 files changed

+130
-3
lines changed

7 files changed

+130
-3
lines changed

CAD/OnshapeTutorial/README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Meshing a CAD Geometry with Gmsh
2-
Tested with CGX/CCX 2.10, Gmsh 2.12
2+
Tested with CGX/CCX 2.10, Gmsh 2.13.1
33

44
This demonstrates a possible workflow for a CalculiX analysis of a CAD
55
generated part.
@@ -9,6 +9,9 @@ generated part.
99
* Import and meshing in gmsh, export as .inp file with volume and surface meshes.
1010
In gmsh, define physical surfaces for boundary conditions and export the mesh
1111
with appropriate settings (to ensure that node sets are written)
12+
* There are two versions for gmsh pre-processing:
13+
* `part.geo`: mesh the geometry as it is, leading to small elements at short edges and narrow surfaces
14+
* `partVT.geo`: Compounding lines and geometry before meshing.
1215
* Open the inp file in cgx and remove all surface elements. Eventually extend node sets to
1316
face sets for surface definition or pressure application.
1417
* Write the mesh and required set definitions
@@ -21,6 +24,9 @@ generated part.
2124
| [part.step](part.step) | STEP geometry exported from Onshape |
2225
| [part.geo](part.geo) | Gmsh control file for meshing and model display |
2326
| [run.fbd](run.fbd) | CGX control file for preprocessing, solving and postprocessing |
27+
| [partVT.geo](partVT.geo) | Gmsh control file with geometry cleaning (virtual topology)|
28+
| [runVT.fbd](runVT.fbd) | CGX control file for the VT version|
29+
| [VTdemo.fbd](VTdemo.fbd) | CGX file for the mesh plots (original and VT version) |
2430
| [solve.inp](solve.inp) | CCX input file |
2531

2632
# Run the analysis
@@ -53,6 +59,37 @@ The gmsh geo file can be executed separately if you want to play around with the
5359
> gmsh part.geo
5460
```
5561
The result of the meshing is the file `gmsh.inp`
62+
63+
## Virtual Topology
64+
65+
The CAD model contains short edges and narrow faces, which locally enforce small elements.
66+
67+
Spurious edges and points can be removed by joining and re-parametrization of adjacent lines or surfaces using the commands
68+
```
69+
Compound Line(new#) = {old#1,old#2};
70+
Compound Surface(new#) = {old#1,old#2};
71+
72+
```
73+
The Gmsh command file `partVT.geo` uses these commands to produce a mesh without spurious refinement spots.
74+
75+
There is one limitation: The midside nodes of second order elements don't follow the geometry, the edges of such elements are always straight except at boundaries. In Gmsh 3.0 this is announced to be fixed.
76+
77+
Execute
78+
```
79+
> cgx -b VTdemo.fbd
80+
```
81+
to produce images for comparison of the meshes produced with the original geometry or with the cleaned geometry (virtual topology).
82+
83+
Original geometry (1856 nodes, 998 elements)
84+
85+
<img src="mesh.png" width="400" title="Mesh based on the original geometry">
86+
<img src="mesh1.png" width="400" title="Mesh based on the original geometry">
87+
88+
Virtual topology (1425 nodes, 665 elements):
89+
90+
<img src="VTmesh.png" width="400" title="Mesh based on the modified geometry, no local refinement spot any more">
91+
<img src="VTmesh1.png" width="400" title="Mesh based on the modified geometry, note the straight element edges on the arched surface.">
92+
5693
# Application of Boundary Conditions
5794
After closing the gmsh window, CGX takes over control again and reads `gmsh.inp`.
5895

@@ -67,12 +104,12 @@ Some cleanup is required, because gmsh writes 2D elements for the physical surfa
67104

68105
Remove the 2D elements (we address them by type here):
69106
```
70-
zap +CPS6
107+
(cgx window) zap +CPS6
71108
```
72109
Extend node sets to face sets if required (here we need the set `load` for
73110
pressure application)
74111
```
75-
comp load do
112+
(cgx window) comp load do
76113
```
77114
The following image shows the nodes of the support surface and the faces of the pressure
78115
application surface.
@@ -81,6 +118,7 @@ application surface.
81118

82119
Once the sets are defined, there is no particular challenge any more with setting up the simulation.
83120

121+
84122
# Results
85123

86124
von Mises stress, displaced geometry

CAD/OnshapeTutorial/VTdemo.fbd

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# sys gmsh part.step -clcurv -3 -o gmsh.inp -order 2
2+
sys gmsh part.geo
3+
read gmsh.inp
4+
# remove surface elements
5+
zap +CPS6
6+
plot f all n
7+
view elem
8+
rot y
9+
rot d 20
10+
zoom 2
11+
plus n all
12+
hcpy png
13+
sys mv hcpy_1.png mesh.png
14+
frame
15+
zoom 5
16+
rot y
17+
rot u 20
18+
tra l 30
19+
tra d 30
20+
plot f all n
21+
plus n all
22+
hcpy png
23+
sys mv hcpy_2.png mesh1.png
24+
del mesh
25+
26+
sys gmsh partVT.geo
27+
read gmshVT.inp new
28+
# remove surface elements
29+
zap +CPS6
30+
plot f all n
31+
view elem
32+
frame
33+
rot y
34+
rot d 20
35+
zoom 2
36+
plus n all
37+
hcpy png
38+
sys mv hcpy_3.png VTmesh.png
39+
frame
40+
zoom 5
41+
rot y
42+
rot u 20
43+
tra l 30
44+
tra d 30
45+
plot f all n
46+
plus n all
47+
hcpy png
48+
sys mv hcpy_4.png VTmesh1.png

CAD/OnshapeTutorial/VTmesh.png

16 KB
Loading

CAD/OnshapeTutorial/VTmesh1.png

11.1 KB
Loading

CAD/OnshapeTutorial/mesh.png

17.7 KB
Loading

CAD/OnshapeTutorial/mesh1.png

14.1 KB
Loading

CAD/OnshapeTutorial/partVT.geo

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Merge "part.step";
2+
// Virtual topology to avoid enforcing small elements
3+
Compound Line(1000)={63,64};
4+
Compound Line(1001)={65,66};
5+
Compound Surface(30) = {23,25};
6+
Compound Surface(31) = {9,24,26};
7+
Compound Surface(32) = {21};
8+
Compound Surface(33) = {22};
9+
// Set definitions
10+
Physical Surface("support") = {5};
11+
Physical Surface("load") = {17};
12+
Physical Volume("part") = {1};
13+
// Mesh control and meshing
14+
Mesh.SaveGroupsOfNodes = 1;
15+
Mesh.ElementOrder=2;
16+
Mesh.Optimize=1;
17+
Mesh 3;
18+
Save "gmshVT.inp";
19+
// image
20+
// in script mode, there is bad image quality
21+
Mesh.SurfaceEdges = 1;
22+
Mesh.SurfaceFaces = 1;
23+
Mesh.VolumeEdges = 0;
24+
Mesh.VolumeFaces = 0;
25+
General.Trackball=0;
26+
General.RotationX=-50;
27+
Geometry.HideCompounds = 1;
28+
29+
Save "gmshVT.png";
30+
Save "gmshVT.gif";
31+
Save "gmshVT.pdf";
32+
General.RotationX=-260;
33+
General.RotationY=23;
34+
General.ScaleX = 2.5;
35+
General.ScaleY = 2.5;
36+
General.ScaleZ = 2.5;
37+
General.TranslationX = -40; // X-axis translation (in model units)
38+
General.TranslationY = 10; // Y-axis translation (in model units)
39+
Save "gmshVT-zoom.png";
40+
Save "gmshVT-zoom.gif";
41+
Save "gmshVT-zoom.pdf";

0 commit comments

Comments
 (0)