Version: 8.5.0
 All Classes Namespaces Files Functions Variables Pages
Python Interface
Note
The former name of MG-Hexa mesher is Hexotic and names of the corresponding classes and modules still include "Hexotic".

Python package HexoticPLUGINBuilder defines HexoticPLUGINBuilder.Hexotic_Algorithm class providing access to the MG-Hexa meshing algorithm and its parameters.

You can get an instance of this class by calling smeshBuilder.Mesh.Hexahedron(algo=smeshBuilder.MG_Hexa) or smeshBuilder.Mesh.Hexahedron(algo=smeshBuilder.Hexotic). This call creates an algorithm (if not yet exist), assigns it to the mesh and returns an instance of HexoticPLUGINBuilder.Hexotic_Algorithm to the caller.

The class of algorithm has methods to set up meshing parameters.

Below you can see examples of usage of this class for hexahedral mesh generation.

  1. Construction of Mesh using MG-Hexa algorithm
  2. Effect of the sub-domain mode
    1. Sub-domain mode = 1
    2. Sub-domain mode = 2
    3. Sub-domain mode = 3
    4. Sub-domain mode = 4

Construction of Mesh using MG-Hexa algorithm

Example of mesh generation with MG-Hexa algorithm:

1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
25 
26 from salome.smesh import smeshBuilder
27 smesh = smeshBuilder.New(salome.myStudy)
28 
29 
30 # create a sphere
31 sphere = geompy.MakeSphereR(100.)
32 geompy.addToStudy(sphere, "sphere")
33 
34 # create a mesh on the sphere
35 mghexaMesh = smesh.Mesh(sphere,"sphere: MG-CADSurf and MG-Hexa mesh")
36 
37 # create a MG-CADSurf algorithm for faces
38 MG_CADSurf = mghexaMesh.Triangle(algo=smeshBuilder.MG_CADSurf)
39 MG_CADSurf.SetGeometricMesh( 1 )
40 
41 # create a MG-Hexa algorithm for volumes
42 MG_Hexa = mghexaMesh.Hexahedron(algo=smeshBuilder.MG_Hexa)
43 
44 ## compute the mesh
45 #mghexaMesh.Compute()
46 
47 # Change the level of subdivision
48 MG_Hexa.SetMinMaxHexes(4, 8)
49 
50 ## compute the mesh
51 #mghexaMesh.Compute()
52 
53 # Local size
54 
55 # Get the sphere skin
56 faces = geompy.SubShapeAll(sphere, geompy.ShapeType["FACE"])
57 
58 # Set a local size on the face
59 MG_Hexa.SetMinMaxSize(10, 20)
60 MG_Hexa.SetSizeMap(faces[0], 10)
61 
62 # compute the mesh
63 mghexaMesh.Compute()
64 
65 # End of script

Download this script

hexotic_basic_subdivisions_4_8.png
Left: MG-Hexa mesh without hypothesis, right: MG-Hexa mesh with an hypothesis defined by minl=4 and maxl=8

Example of mesh generation with MG-Hexa algorithm and viscous layers parameters:

1 # Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 theStudy = salome.myStudy
23 
24 from salome.geom import geomBuilder
25 geompy = geomBuilder.New(salome.myStudy)
26 
27 import SMESH, SALOMEDS
28 from salome.smesh import smeshBuilder
29 smesh = smeshBuilder.New(salome.myStudy)
30 
31 # Create geometry
32 Box_1 = geompy.MakeBoxDXDYDZ(50, 50, 50)
33 geompy.addToStudy( Box_1, 'Box_1' )
34 
35 # Create mesh
36 Mesh_mghexa_vl = smesh.Mesh(Box_1, "Mesh_mghexa_vl")
37 
38 Regular_1D = Mesh_mghexa_vl.Segment()
39 Local_Length_1 = Regular_1D.LocalLength(8.66025,None,1e-07)
40 
41 MEFISTO_2D = Mesh_mghexa_vl.Triangle(algo=smeshBuilder.MEFISTO)
42 
43 MG_Hexa = Mesh_mghexa_vl.Hexahedron(algo=smeshBuilder.MG_Hexa)
44 MG_Hexa_Parameters = MG_Hexa.Parameters()
45 MG_Hexa.SetViscousLayers(5,5,3,smeshBuilder.Inward,[13,23])
46 MG_Hexa_Parameters.SetMinSize( 2 )
47 MG_Hexa_Parameters.SetMaxSize( 4 )
48 MG_Hexa_Parameters.SetHexesMinLevel( 2 )
49 MG_Hexa_Parameters.SetHexesMaxLevel( 4 )
50 
51 # Compute
52 Mesh_mghexa_vl.Compute()
53 
54 # End of script

Download this script

hexotic_vl_example.png
Left: MG-Hexa mesh without viscous layers parameters, right: MG-Hexa mesh with viscous layers parameters

Local size

hexotic_local_size_example.png
Example of use of a local size on the skin of a sphere

Back to top

Effect of the sub-domain mode

This example illustrates the sub-domain mode of MG-Hexa.

Sub-domain mode = 1

Example of sub-domain mode 1 with MG-Hexa algorithm:

1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
25 
26 import SMESH, SALOMEDS
27 from salome.smesh import smeshBuilder
28 smesh = smeshBuilder.New(salome.myStudy)
29 
30 
31 # Create geometry: a box cut by a holed sphere
32 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
33 Sphere_1 = geompy.MakeSphereR(75)
34 Sphere_2 = geompy.MakeSphereR(25)
35 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
36 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
37 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
38 geompy.addToStudy( Box_1, 'Box_1' )
39 geompy.addToStudy( Sphere_1, 'Sphere_1' )
40 geompy.addToStudy( Sphere_2, 'Sphere_2' )
41 geompy.addToStudy( Cut_1, 'Cut_1' )
42 geompy.addToStudy( Cut_2, 'Cut_2' )
43 
44 # Create filters
45 # aFilter1: elements inside small sphere
46 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
47 # aFilter2: elements inside big sphere and not inside small sphere
48 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
49  smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
50 # aFilter3: elements not inside big sphere
51 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
52 
53 # Create mesh of Cut_2 with sd mode 1
54 print "Create mesh of Cut_2 with sd mode 1"
55 Mesh_mghexa_sd1 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd1")
56 
57 # Create the 2D algo: MG-CADSurf with geometrical mesh
58 Mesh_mghexa_sd1.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
59 
60 # Create the 3D algo: MG-Hexa with:
61 # - minl = 4
62 # - maxl = 8
63 # - sd = 1
64 Mesh_mghexa_sd1.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
65 
66 # Create the groups on filters
67 g1 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
68 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
69 g2 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
70 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
71 g3 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
72 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
73 
74 # Compute
75 Mesh_mghexa_sd1.Compute()
76 
77 # End of script

Download this script

hexotic_sd_mode_1.png
MG-Hexa mesh of a box cut by a holed sphere ( sd = 1 )

Back to top

Sub-domain mode = 2

Example of sub-domain mode 2 with MG-Hexa algorithm:

1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
25 
26 import SMESH, SALOMEDS
27 from salome.smesh import smeshBuilder
28 smesh = smeshBuilder.New(salome.myStudy)
29 
30 # Create geometry: a box cut by a holed sphere
31 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
32 Sphere_1 = geompy.MakeSphereR(75)
33 Sphere_2 = geompy.MakeSphereR(25)
34 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
35 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
36 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
37 geompy.addToStudy( Box_1, 'Box_1' )
38 geompy.addToStudy( Sphere_1, 'Sphere_1' )
39 geompy.addToStudy( Sphere_2, 'Sphere_2' )
40 geompy.addToStudy( Cut_1, 'Cut_1' )
41 geompy.addToStudy( Cut_2, 'Cut_2' )
42 
43 # Create filters
44 # aFilter1: elements inside small sphere
45 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
46 # aFilter2: elements inside big sphere and not inside small sphere
47 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
48  smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
49 # aFilter3: elements not inside big sphere
50 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
51 
52 # Create mesh of Cut_2 with sd mode 2
53 print "Create mesh of Cut_2 with sd mode 2"
54 Mesh_mghexa_sd2 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd2")
55 
56 # Create the 2D algo: MG-CADSurf with geometrical mesh
57 Mesh_mghexa_sd2.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
58 
59 # Create the 3D algo: MG-Hexa with:
60 # - minl = 4
61 # - maxl = 8
62 # - sd = 2
63 Mesh_mghexa_sd2.Hexahedron(smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 2 )
64 
65 # Create the groups on filters
66 g1 = Mesh_mghexa_sd2.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
67 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
68 g2 = Mesh_mghexa_sd2.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
69 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
70 g3 = Mesh_mghexa_sd2.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
71 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
72 
73 # Compute
74 Mesh_mghexa_sd2.Compute()
75 
76 # End of script
77 

Download this script

hexotic_sd_mode_2.png
MG-Hexa mesh of a box cut by a holed sphere ( sd = 2 )

Back to top

Sub-domain mode = 3

Example of sub-domain mode 3 with MG-Hexa algorithm:

1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
25 
26 import SMESH, SALOMEDS
27 from salome.smesh import smeshBuilder
28 smesh = smeshBuilder.New(salome.myStudy)
29 
30 # Create geometry: a box cut by a holed sphere
31 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
32 Sphere_1 = geompy.MakeSphereR(75)
33 Sphere_2 = geompy.MakeSphereR(25)
34 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
35 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
36 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
37 geompy.addToStudy( Box_1, 'Box_1' )
38 geompy.addToStudy( Sphere_1, 'Sphere_1' )
39 geompy.addToStudy( Sphere_2, 'Sphere_2' )
40 geompy.addToStudy( Cut_1, 'Cut_1' )
41 geompy.addToStudy( Cut_2, 'Cut_2' )
42 
43 # Create filters
44 # aFilter1: elements inside small sphere
45 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
46 # aFilter2: elements inside big sphere and not inside small sphere
47 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
48  smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
49 # aFilter3: elements not inside big sphere
50 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
51 
52 # Create mesh of Cut_2 with sd mode 3
53 print "Create mesh of Cut_2 with sd mode 3"
54 Mesh_mghexa_sd3 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd3")
55 
56 # Create the 2D algo: MG-CADSurf with geometrical mesh
57 Mesh_mghexa_sd3.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
58 
59 # Create the 3D algo: MG-Hexa with:
60 # - minl = 4
61 # - maxl = 8
62 # - sd = 3
63 Mesh_mghexa_sd3.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 3 )
64 
65 # Create the groups on filters
66 g1 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
67 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
68 g2 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
69 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
70 g3 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
71 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
72 
73 # Compute
74 Mesh_mghexa_sd3.Compute()
75 
76 # End of script
77 

Download this script

hexotic_sd_mode_3.png
MG-Hexa mesh of a box cut by a holed sphere ( sd = 3 )

Back to top

Sub-domain mode = 4

Example of sub-domain mode 4 with MG-Hexa algorithm:

1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 
20 import salome
21 salome.salome_init()
22 
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
25 
26 from salome.smesh import smeshBuilder
27 smesh = smeshBuilder.New(salome.myStudy)
28 
29 # Create geometry: a box cut by a plane
30 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
31 Translation_1 = geompy.MakeTranslation(Box_1, 0, 200, 0)
32 Partition_1 = geompy.MakePartition([Box_1, Translation_1])
33 geompy.addToStudy( Box_1, 'Box_1' )
34 geompy.addToStudy( Translation_1, 'Translation_1' )
35 geompy.addToStudy( Partition_1, 'Partition_1' )
36 
37 # Create mesh of Partition_1 with sd mode 4 (default sd mode in SALOME)
38 Mesh_mghexa_sd4 = smesh.Mesh(Partition_1, "Mesh_mghexa_sd4")
39 Mesh_mghexa_sd4.Triangle(smeshBuilder.MG_CADSurf)
40 Mesh_mghexa_sd4.Hexahedron(smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 4 )
41 
42 # Compute
43 Mesh_mghexa_sd4.Compute()
44 
45 # End of script

Download this script

hexotic_sd_mode_4.png
MG-Hexa mesh of a box cut by a plane ( On the left, sd = 3: the internal surface is ignored ; on the right sd = 4: all sub-domains are meshed )

Back to top