[SOLVED] Gmsh: mesh size dependent upon surface or volume

Mesh generators, CAD programs, and other tools

[SOLVED] Gmsh: mesh size dependent upon surface or volume

Postby CrocoDuck » 16 Jun 2016, 12:03

Hi there!

I have a complex domain which requires few regions to be meshed with higher density. On COMSOL I was used to apply a mesh size correcting factor to the target surfaces. Gmsh seems powerful enough to allow this sort of things to be done. I tried to follow the instruction into these messages but I doesn't seem to work when I import the geometry from brep files.

Any of you guys ever needed to differentiate the mesh size in the domain? Have you been able to achieve it with Gmsh? If not, what do you use to do that?
Last edited by CrocoDuck on 16 Jun 2016, 14:21, edited 1 time in total.
CrocoDuck
 
Posts: 40
Joined: 12 May 2016, 13:15

Re: Gmsh: mesh size dependent upon surface or volume

Postby CrocoDuck » 16 Jun 2016, 14:18

Oh well, I started noticing a trend in my posts... At first it does not work. Seek for help. Then out of nowhere it starts working. Weird.

Well, I tried this few times until it worked... Not sure what made it work but I am solving on the new mesh now.

  • Open Gmsh and import the brep file
  • Set your Global Mesh parameters
  • Go to Mesh > Define > Size Fields.
  • You could see a warning message requiring you to pick a choice here or at some point. It asks if you want to save the file as .geo first. I did not save the file as .geo here: it makes few surfaces to disappear! I chosen "keep file as it is" or similar.
  • New > MathEval. In the Field F put your refined mesh size.
  • New > Restrict. List all the numbers of the entities you want to be refined with the number in MathEval. I selected the faces I was interested in and the lines around them. List is comma separated: 1, 3, 4, ... You can set the viewing options to display entity numbers.
  • Build the mesh. Profit.

EDIT: If you need to assign more than one different size here an example on how to proceed:

Lets say the surface 1 3 need mesh size 0.2 and surface 2 needs mesh size 0.1

Do as above and set MathEval to 0.2 first. Then use Restrict to select all the surfaces needing refinement: 1, 2, 3.

Then, set up a new MathEval to 0.1. Setup now a new Restrict with the surface needing 0.1: 2.

Finally, set up a Min Field. List the Restrict fields numbers in the Field List (2, 4 in my case). Set this field as background field. There can be only one background field and the background field is the one used to calculate the mesh sizes. This way, for each face the minimum mesh size assigned is taken. Meaning that the mesh sizes will be: 1 - 0.2, 2 - 0.1, 3 - 0.2, as we wanted.

You can also do the other way around using the Max Field in the last step. Min and Max appear the only fields that can be used on Restrict, according to the documentation.
CrocoDuck
 
Posts: 40
Joined: 12 May 2016, 13:15


Return to External tools

Who is online

Users browsing this forum: No registered users and 2 guests

cron