1 # Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # @package HexoticPLUGINBuilder
22 # Python API for the MG-Hexa meshing plug-in module.
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 from salome.smesh.smeshBuilder import AssureGeomPublished
27 # import HexoticPlugin module if possible
35 #----------------------------
36 # Mesh algo type identifiers
37 #----------------------------
39 ## Algorithm type: MG-Hexa hexahedron 3D algorithm, see Hexotic_Algorithm
43 #----------------------------
45 #----------------------------
47 ## Defines a hexahedron 3D algorithm
49 # It is created by calling smeshBuilder.Mesh.Hexahedron( smeshBuilder.MG_Hexa, geom=0 )
50 class Hexotic_Algorithm(Mesh_Algorithm):
52 ## name of the dynamic method in smeshBuilder.Mesh class
54 meshMethod = "Hexahedron"
55 ## type of algorithm used with helper function in smeshBuilder.Mesh class
58 ## doc string of the method in smeshBuilder.Mesh class
60 docHelper = "Creates hexahedron 3D algorithm for volumes"
62 ## Private constructor.
63 # @param mesh parent mesh object algorithm is assigned to
64 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
65 # if it is @c 0 (default), the algorithm is assigned to the main shape
66 def __init__(self, mesh, geom=0):
67 Mesh_Algorithm.__init__(self)
68 if noHexoticPlugin: print "Warning: HexoticPlugin module unavailable"
69 self.Create(mesh, geom, MG_Hexa, "libHexoticEngine.so")
73 ## Defines "SetMinMaxHexes" hypothesis to give two MG-Hexa parameters
74 # @param min minimal level of recursive partitioning on the initial octree cube
75 # @param max maximal level of recursive partitioning on the initial octree cube
76 # @return hypothesis object
77 def SetMinMaxHexes(self, min=3, max=8):
78 self.Parameters().SetHexesMinLevel(min)
79 self.Parameters().SetHexesMaxLevel(max)
80 return self.Parameters()
82 ## Defines "SetMinMaxSize" hypothesis to give two MG-Hexa parameters
83 # @param min minimal element's size
84 # @param max maximal element's size
85 # @return hypothesis object
86 def SetMinMaxSize(self, min, max):
87 self.Parameters().SetMinSize(min)
88 self.Parameters().SetMaxSize(max)
89 return self.Parameters()
92 # @param theObject geometrical object to assign local size to
93 # @param theSize local size on the given object
94 # @return hypothesis object
95 def SetSizeMap(self, theObject, theSize):
96 AssureGeomPublished( self.mesh, theObject )
98 raise ValueError, "The size must be > 0"
99 self.Parameters().SetSizeMap(theObject, theSize)
100 return self.Parameters()
102 ## Unsets a size map : this is meant to be used only by the dump
103 # @param theObject geometrical object to unassign local size
104 # @return hypothesis object
105 def UnsetSizeMap(self, theObject):
106 AssureGeomPublished( self.mesh, theObject )
107 self.Parameters().UnsetSizeMap(theObject)
108 return self.Parameters()
110 ## (OBSOLETE) Defines "MinMaxQuad" hypothesis to give three MG-Hexa parameters
111 # @param min minimal level of recursive partitioning on the initial octree cube
112 # @param max maximal level of recursive partitioning on the initial octree cube
113 # @param quad not documented
114 # @return hypothesis object
115 def MinMaxQuad(self, min=3, max=8, quad=True):
116 print "WARNING: Function MinMaxQuad is deprecated, use SetMinMaxHexes instead"
117 return self.SetMinMaxHexes(min, max)
119 ## Defines "ViscousLayers" hypothesis to give MG-Hexa parameters
120 # @param numberOfLayers number of boundary layers
121 # @param firstLayerSize height of the first layer
122 # @param growth geometric progression for the boundary layer growth
123 # @param direction describes whether the layers grow inwards or outwards.
125 # \c Inward : means the layers grow inwards,
126 # \c Outward : means the layers grow outwards
127 # @param facesWithLayers list of surface references from which the boundary
128 # layers should be grown
129 # @param imprintedFaces list of surface references that can be imprinted by
131 # @return hypothesis object
132 def SetViscousLayers(self, numberOfLayers, firstLayerSize, growth,
133 direction="Inward", facesWithLayers=[], imprintedFaces=[]):
134 self.Parameters().SetNbLayers(numberOfLayers)
135 self.Parameters().SetFirstLayerSize(firstLayerSize)
136 self.Parameters().SetGrowth(growth)
137 if direction == "Inward":
138 self.Parameters().SetDirection(True)
139 elif direction == "Outward":
140 self.Parameters().SetDirection(False)
141 self.Parameters().SetFacesWithLayers(facesWithLayers)
142 self.Parameters().SetImprintedFaces(imprintedFaces)
144 return self.Parameters()
146 ## Defines hypothesis having several parameters
147 # @return hypothesis object
148 def Parameters(self):
150 self.params = self.Hypothesis("MG-Hexa Parameters", [],
151 "libHexoticEngine.so", UseExisting=0)
156 pass # end of Hexotic_Algorithm class