Boundary condition grouping GMSH

Mesh generators, CAD programs, and other tools
Post Reply
loberd
Posts: 3
Joined: 29 Jun 2022, 16:22
Antispam: Yes

Boundary condition grouping GMSH

Post by loberd »

Hi:
I'm extremely new to Elmer, FEM, and even CAD so I may get the terminology wrong. I'm working on creating a mesh (using GMSH but I'm also playing around with Salome and Netgen) which will have a large number of boundary condition "parts" but only a few different boundaries. I'm trying to figure out the best way to set up my geometries and meshing so I don't have to manually select hundreds of boundaries. How should I set up my geometry and/or mesh to make assigning boundary conditons easy? I've set up a toy example below (a screenshot of the geometry and a STEP file).

In the toy example (toy.step) I have 9 smaller rectangles on a larger rectangle (In my real application there might be closer to 100 of these smaller rectangles). Each of the smaller rectangles will have all of their edges assigned to one of 2 boundary conditions (in my case it's an electrostatic problem); In this toy example lets say all even number smaller rectangles are given boundary condition A and all odd boundary condition B (in my actual use these smaller rectangles are either going to be ground potential or some other potential). How can I set this up so that I don't have to manually select each side of every rectangle? In this example it's just 36 but in the real application it could be upwards of 400 edges. As I said i'm playing around with several mesh generating programs and am leaning towards GMSH but am open to changing.
Attachments
Screenshot 2022-06-29 092509.jpg
(278.28 KiB) Not downloaded yet
toy.step
(135.61 KiB) Downloaded 18 times
raback
Site Admin
Posts: 4423
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Boundary condition grouping GMSH

Post by raback »

Hi

In Salome may you could save the entity names. Then you could directly set names to the entities rather than numbers. The UNV format maintains the names. This way the sif file would stay rather intact. This is at least one possible way.

-Peter
kevinarden
Posts: 1518
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Boundary condition grouping GMSH

Post by kevinarden »

in gmsh there is a geo file that stores all of the commands used to create the mesh, including physical groups, which is the way to group curves to becomeone boundary. A nice feature is that you can edit this text file, or generate it with a code like python, so you don't have to pick each curve in the group. In the toy example all of the inner boxes can be one boundary and the big box one boundary by doing this.

// Gmsh project created on Wed Jun 29 11:27:17 2022
SetFactory("OpenCASCADE");
//+
v() = ShapeFromFile("toy.step");
Physical Curve("small_boxes") = {16, 15, 14, 13, 5, 6, 7, 8, 4, 1, 2, 3, 11, 12, 9, 10, 37, 40, 39, 38, 42, 41, 44, 43, 45, 48, 47, 46, 49, 52, 51, 50, 54, 53, 56, 55};
//+
Physical Curve("big_box") = {18, 19, 20, 17};
kevinarden
Posts: 1518
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Boundary condition grouping GMSH

Post by kevinarden »

In salome groups become single boundaries. In salome I can create a group of the small box curves just be dragging a box around them selecting all of the curves at once.
small_boxes.png
(142.69 KiB) Not downloaded yet
loberd
Posts: 3
Joined: 29 Jun 2022, 16:22
Antispam: Yes

Re: Boundary condition grouping GMSH

Post by loberd »

Thank you so much for your reply. I'm going to try out your solutions as soon as I can. For gmsh i'm working on creating a script to create the geo file as I find the user interface not the best. I'm doing the generation in R instead of python, since the learning curve on gmsh/elmer is steep I don't have the bandwidth to tackle that as well. I know python is much more suited to that and I intend to learn it. Really appreciate the fast and thorough reply. Now time to tackle learning the SIF file...
loberd
Posts: 3
Joined: 29 Jun 2022, 16:22
Antispam: Yes

Re: Boundary condition grouping GMSH

Post by loberd »

kevinarden wrote: 29 Jun 2022, 18:48 in gmsh there is a geo file that stores all of the commands used to create the mesh, including physical groups, which is the way to group curves to becomeone boundary. A nice feature is that you can edit this text file, or generate it with a code like python, so you don't have to pick each curve in the group. In the toy example all of the inner boxes can be one boundary and the big box one boundary by doing this.

// Gmsh project created on Wed Jun 29 11:27:17 2022
SetFactory("OpenCASCADE");
//+
v() = ShapeFromFile("toy.step");
Physical Curve("small_boxes") = {16, 15, 14, 13, 5, 6, 7, 8, 4, 1, 2, 3, 11, 12, 9, 10, 37, 40, 39, 38, 42, 41, 44, 43, 45, 48, 47, 46, 49, 52, 51, 50, 54, 53, 56, 55};
//+
Physical Curve("big_box") = {18, 19, 20, 17};
Kevin:
Thanks for this information. About the same time you posted I found another post (of course I couldn't find it *before* I posted) where they advised that when you export a MSH format to uncheck "Save All Elments" as that kept the "physical group" together upon importing into elmer. I haven't played around with what other things happen when you do that.

And with the Salome solution thanks for that tip as well. I like Salome's UI better than GMSH for geometry but worse for meshing, which shouldn't be suprising as they are each created to solve one of those problems. However, the one thing I find frustrating with Salome is the documentation is very basic where as GMSH has lots of examples not only on their site but on other people's as well.
Post Reply