[Gmsh] Saving msh in several parts defined by lists of physical

Christophe Geuzaine cgeuzaine at uliege.be
Sun Apr 5 08:42:36 CEST 2020


> On 5 Apr 2020, at 00:32, Michel Cassagnes <michelcassagnes11 at gmail.com> wrote:
> 
> Dear all,
> 
> It seems that the option does not exist yet but maybe it has something to do with partitioning. Here is my question :
> 
> I would like to save mesh (in med format) in several parts that are defined by lists of physicals. Some physicals may belong to more than one part.
> 
> What I do for now :
> 1 - I prepare a text file that describes a geometry from a cad software (list of entities, each entity being described by a list of point coordinates, its type and its cad layer)
> 2 - another text file describes the different parts of the geometry, by sets of layer names. Some physicals may belong to several parts.
> 3 - then I make geo files from 1 and 2, each geo file contains all geometry but only physicals which are to be saved as mesh.
> 4 - Gmsh mesh each geo.files (so I repeat exactly the same meshing for each geo file) then I  save only mesh entities with physical tag in med format 
> 
> What I would like to do: Instead of meshing all geo files as in point 3 above:- mesh in only one time the geo file, containing all geometry 
> - then save the mesh in several steps, giving at each step a list of physicals that are to be saved.
> 

Hello Michel,

You can exploit the fact that by default, when physical groups are defined, Gmsh only saves the entities that belong to physical groups. So you can just mesh once, define your physical groups in turn, and save each time. Here's an example:

---
SetFactory("OpenCASCADE");
Box(1) = {0,0,0, 0.1,1,1};
Box(2) = {0.1,0,0, 0.3,1,1};
Box(3) = {0.4,0,0, 0.6,1,1};
BooleanFragments{ Volume{1,2,3}; Delete; }{}

Mesh 3;

Physical Volume("Left", 1) = {1};
Save "m1.med";
Delete Physicals;

Physical Volume("Middle", 2) = {2};
Save "m2.med";
Delete Physicals;

Physical Volume("Right", 3) = {3};
Save "m3.med";
---

Cheers,

Christophe





> Exemple :
> geo file  :
> surfaces : "s1", "s2", "s3"
> points : "p1", "p2"
> 
> meshes to save :
> first med file : 
>     - meshed surfaces : "s1", "s2"
>     - points : "p1"
> second med file :
>     - meshed surfaces : "s2", "s3"
>     - points : "p2"
> 
> I hope it is clear !
> 
> Best regards,
> 
> Michel Cassagnes
> 
> 
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine






More information about the gmsh mailing list