Question for mesh file from Gmsh

Numerical methods and mathematical models of Elmer
Post Reply
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Question for mesh file from Gmsh

Post by sunyuan »

Dear experts

I want to simulate static electric field for some wires, I created 9 wires and 1 boundary volume, then I need to subtract wire volumes to avoid having duplicated interfaces.
I was given a .geo file that shows how-to as below: (part of code)
```
Cylinder(1) = {0,0,0,0,0,12.5,0.0125};
Cylinder(10) = {0,0,-2,0,0,18.5,20};
Physical Volume("wire1", 1) = {1};
Physical Volume("infinity", 10) = {10};
BooleanDifference{ Volume{10}; Delete; }{ Volume{1}; }
Coherence;
```
The BooleanDifference should exclude duplicated interfaces I believe.
Here the question 1: What's the difference if I use `BooleanFragment{ Volume{10}; }{ Volume{1}; }`? Will the difference make E field different?
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Question for mesh file from Gmsh

Post by raback »

You might have better luck asking on Gmsh discussion forum if you do not get an answer here...
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Re: Question for mesh file from Gmsh

Post by sunyuan »

You are definitely right...but I ask here because I asked at Gmsh forum and got no answer for a long time (there are ~20 questions lying there...)
And maybe they don't know about FEM so they don't know if the E field calculation result will change due to such mesh operation
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Question for mesh file from Gmsh

Post by Rich_B »

Hello,

Since you are asking, there must be some motive, such as not getting expected results. Posting working examples is usually helpful.

Have you looked at the gmsh section of GetStartedElmer.pdf? In particular, search for 'Fragments', you will find an example. Please let us know if the section is helpful for you.
gmsh-23.png
gmsh-23.png (47.69 KiB) Viewed 594 times
Rich.
sunyuan
Posts: 16
Joined: 20 Apr 2022, 11:28
Antispam: Yes

Re: Question for mesh file from Gmsh

Post by sunyuan »

Hi,

I have read Gmsh manual and I just read the section you mentioned in GetStartedElmer, seems the difference between BooleanFragment and BooleanDifference is just [Unite operated volumes or not]? For example:
BooleanDifference{ Volume{2}; Delete; }{ Volume{1}; } //Cut Volume 2 with Volume 1 and then have 2 volumes (volume been cut and the volume 1)
BooleanFragment{ Volume{2}; Delete; }{ Volume{1}; Delete;} //Intersect and unite Volume1 and Volume2, then have 1 volume (intersected volume) (and original volumes must be deleted otherwise duplicated interfaces exist)

For the minimal example, I used c++ API for Gmsh, I attached here, can you have a simple look if the .geo file and .cpp file represent the same function? When I ran .cpp one it performs quite different with .geo...

Thank you in advance!
Attachments
prototype.cpp
(1.72 KiB) Downloaded 35 times
prototype.geo
(2.09 KiB) Downloaded 37 times
Gary R
Posts: 162
Joined: 12 Apr 2012, 07:23
Antispam: Yes
Location: Long Beach CA, USA

Re: Question for mesh file from Gmsh

Post by Gary R »

I hope this helps:
I never use gmsh to create a model. I use FreeCAD and export to either a .brep or .step file. I then use gmsh to create the mesh. How does this help? I recently had the same problem as you are having. Some one ( Sorry I couldn't find the post for some reason) clued me in to the use of the "Compound" command. You create each part under its own body and when finished combine them with the compound command. This takes care of all the nasty problems that occur when enclosing one solid inside of the other. It works great. If you have never worked with FreeCAD try opening a new page, switch to the Part Design workbench, hit the body icon to create a body, hit the sketch icon and create your part. Repeat the process as needed. I included a FreeCad file that, I think, does exactly what you want. I had to put the file inside of a .tar archive file to get the web site to accept it. Just unzip the file to access the .FRCD file.

Good luck
Gary R

P.S. Aug 15 2022 - The above is wrong. FreeCAD's compound does not work with gmsh. The boundary between the embedded and surrounding object do not allow any form of information transfer across the boundaries. The fusion function does work but the result will not allow things like assigning different materials to the original parts. Fusion does what the name implies. It produces a single part. Sorry if I led anyone down the primrose path. There may be a way but I haven't found it.
Gary R.
Attachments
FreeCAD.tar.gz
(19.06 KiB) Downloaded 38 times
Last edited by Gary R on 15 Aug 2022, 22:04, edited 1 time in total.
Rich_B
Posts: 421
Joined: 24 Aug 2009, 20:18

Re: Question for mesh file from Gmsh

Post by Rich_B »

Hello,

Working from prototype.geo, here is an estimate of the number of elements in the model, not including any possible coarsening.

Smallest element size, cylinder 1, estimated but probably smaller
r 0.0125
Vol = (r^3)/2 = 9.77E-007

Length/radius ratio, cylinder 1
h 12.5
h/r = 1000

Largest volume size, cylinder 10
R 20
H 18.5
Vol = H*pi*R^2 = 2.32E+004

Divide largest volume by the smallest volume to get estimated number of elements
2.38E+010, which is about 24 billion elements

Rich.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Question for mesh file from Gmsh

Post by kevinarden »

To return to the original question in gmsh BooleanDifference and BooleanFragments are slighty different. However if Volume 2 is completely inside of Volume 1 then Difference and Fragment act the same. If Volume 2 is partially in Volume 1 the Difference and Fragment is slightly different. In both cases there is an object volume being cut by a tool volume. In both cases you have the option of keeping the original object volume or not, and keeping the tool volume or not. In difference, if you delete the original object and tool, you end up with one new volume of the object cut with the tool. If you delete the original object and keep the tool, then you end up with a volume cut by the tool, with the tool still present. In fragment, if you delete the object and tool, you still end up with multiple new volumes, the object cut by the tool, the volume of the tool that intersected the object, and the volume of the tool outside of the object.

The case that seems the most interest in this forum is a large cylinder or sphere to represent air our fluid around a body that the body is completely inside the air/fluid. This is best done with difference, delete the object (original volume that will be cut by the tool), and retain the tool (i.e. uncheck delete tool). This will give you the larger volume cut by the tool and retain the tool. Then use coherence to ensure boundaries are shared. You can then give physical names to the outer volume, the embedded volume, and the boundaries. These will become bodies and boundaries in Elmer.
Post Reply