1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # @package HYBRIDPluginBuilder
23 # Python API for the HYBRID meshing plug-in module.
25 from salome.smesh.smesh_algorithm import Mesh_Algorithm
26 from salome.smesh.smeshBuilder import AssureGeomPublished
28 # import HYBRIDPlugin module if possible
36 # Optimization level of HYBRID
38 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
39 # V4.1 (partialy redefines V3.1). Issue 0020574
40 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
42 #----------------------------
43 # Mesh algo type identifiers
44 #----------------------------
46 ## Algorithm type: HYBRID tetrahedron 3D algorithm, see HYBRID_Algorithm
49 ## Tetrahedron HYBRID 3D algorithm
51 # It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.HYBRID, geom=0 )
52 class HYBRID_Algorithm(Mesh_Algorithm):
54 ## name of the dynamic method in smeshBuilder.Mesh class
56 meshMethod = "Tetrahedron"
57 ## type of algorithm used with helper function in smeshBuilder.Mesh class
60 ## doc string of the method in smeshBuilder.Mesh class
62 docHelper = "Creates tetrahedron 3D algorithm for volumes"
64 ## Private constructor.
65 # @param mesh parent mesh object algorithm is assigned to
66 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
67 # if it is @c 0 (default), the algorithm is assigned to the main shape
68 def __init__(self, mesh, geom=0):
69 Mesh_Algorithm.__init__(self)
70 if noHYBRIDPlugin: print "Warning: HYBRIDPlugin module unavailable"
71 self.Create(mesh, geom, self.algoType, "libHYBRIDEngine.so")
75 ## Defines hypothesis having several parameters
76 # @return hypothesis object
79 self.params = self.Hypothesis("HYBRID_Parameters", [],
80 "libHYBRIDEngine.so", UseExisting=0)
86 ## To mesh "holes" in a solid or not. Default is to mesh.
87 # @param toMesh "mesh holes" flag value
88 def SetToMeshHoles(self, toMesh):
89 self.Parameters().SetToMeshHoles(toMesh)
92 ## To make groups of volumes of different domains when mesh is generated from skin.
93 # Default is to make groups.
94 # This option works only (1) for the mesh w/o shape and (2) if GetToMeshHoles() == true
95 # @param toMesh "mesh holes" flag value
96 def SetToMakeGroupsOfDomains(self, toMakeGroups):
97 self.Parameters().SetToMakeGroupsOfDomains(toMakeGroups)
100 ## Set Optimization level:
101 # @param level optimization level, one of the following values
102 # - None_Optimization
103 # - Light_Optimization
104 # - Standard_Optimization
105 # - StandardPlus_Optimization
106 # - Strong_Optimization.
108 # Default is Standard_Optimization
109 def SetOptimizationLevel(self, level):
110 self.Parameters().SetOptimizationLevel(level)
113 ## Set maximal size of memory to be used by the algorithm (in Megabytes).
114 # @param MB maximal size of memory
115 def SetMaximumMemory(self, MB):
116 self.Parameters().SetMaximumMemory(MB)
119 ## Set initial size of memory to be used by the algorithm (in Megabytes) in
120 # automatic memory adjustment mode.
121 # @param MB initial size of memory
122 def SetInitialMemory(self, MB):
123 self.Parameters().SetInitialMemory(MB)
127 ## To mesh Boundary Layers growing inward or outward.
129 # @param inward boolean value
130 def SetBoundaryLayersInward(self, inward):
131 self.Parameters().SetBoundaryLayersInward(inward)
134 ## To mesh with element type Tetra Dominant or hexa Dominant in the boundary layers.
135 # Default is Tetra Dominant.
136 # @param tetraDominant boolean value
137 def SetElemGenTetraDominant(self, tetraDominant);
138 self.Parameters().SetElemGenTetraDominant(tetraDominant)
141 ## To mesh adding extra normals at opening ridges and corners.
143 # @param addMultinormals boolean value
144 def SetAddMultinormals(self, addMultinormals);
145 self.Parameters().SetAddMultinormals(addMultinormals)
148 ## To mesh smoothing normals at closed ridges and corners.
150 # @param smoothNormals boolean value
151 def SetSmoothNormals(self, smoothNormals);
152 self.Parameters().SetSmoothNormals(smoothNormals)
155 ## To set height of the first layer.
157 # @param heightFirstLayer double value
158 def SetHeightFirstLayer(self, heightFirstLayer);
159 self.Parameters().SetHeightFirstLayer(heightFirstLayer)
162 ## To set boundary layers coefficient of geometric progression.
164 # @param boundaryLayersProgression double value
165 def SetBoundaryLayersProgression(self, boundaryLayersProgression);
166 self.Parameters().SetBoundaryLayersProgression(boundaryLayersProgression)
169 ## To set multinormals angle threshold at opening ridges.
171 # @param multinormalsAngle double value
172 def SetMultinormalsAngle(self, multinormalsAngle);
173 self.Parameters().SetMultinormalsAngle(multinormalsAngle)
176 ## To set number of boundary layers.
178 # @param nbOfBoundaryLayers int value
179 def SetNbOfBoundaryLayers(self, nbOfBoundaryLayers);
180 self.Parameters().SetNbOfBoundaryLayers(nbOfBoundaryLayers)
183 ## Set path to working directory.
184 # @param path working directory
185 def SetWorkingDirectory(self, path):
186 self.Parameters().SetWorkingDirectory(path)
189 ## To keep working files or remove them.
190 # @param toKeep "keep working files" flag value
191 def SetKeepFiles(self, toKeep):
192 self.Parameters().SetKeepFiles(toKeep)
195 ## Remove or not the log file (if any) in case of successful computation.
196 # The log file remains in case of errors anyway. If
197 # the "keep working files" flag is set to true, this option
199 # @param toRemove "remove log on success" flag value
200 def SetRemoveLogOnSuccess(self, toRemove):
201 self.Parameters().SetRemoveLogOnSuccess(toRemove)
204 ## Print the the log in a file. If set to false, the
205 # log is printed on the standard output
206 # @param toPrintLogInFile "print log in a file" flag value
207 def SetPrintLogInFile(self, toPrintLogInFile):
208 self.Parameters().SetStandardOutputLog(not toPrintLogInFile)
211 ## Set verbosity level [0-10].
212 # @param level verbosity level
213 # - 0 - no standard output,
214 # - 2 - prints the data, quality statistics of the skin and final meshes and
215 # indicates when the final mesh is being saved. In addition the software
216 # gives indication regarding the CPU time.
217 # - 10 - same as 2 plus the main steps in the computation, quality statistics
218 # histogram of the skin mesh, quality statistics histogram together with
219 # the characteristics of the final mesh.
220 def SetVerboseLevel(self, level):
221 self.Parameters().SetVerboseLevel(level)
224 ## To create new nodes.
225 # @param toCreate "create new nodes" flag value
226 def SetToCreateNewNodes(self, toCreate):
227 self.Parameters().SetToCreateNewNodes(toCreate)
230 ## To use boundary recovery version which tries to create mesh on a very poor
231 # quality surface mesh.
232 # @param toUse "use boundary recovery version" flag value
233 def SetToUseBoundaryRecoveryVersion(self, toUse):
234 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
237 ## Applies finite-element correction by replacing overconstrained elements where
238 # it is possible. The process is cutting first the overconstrained edges and
239 # second the overconstrained facets. This insure that no edges have two boundary
240 # vertices and that no facets have three boundary vertices.
241 # @param toUseFem "apply finite-element correction" flag value
242 def SetFEMCorrection(self, toUseFem):
243 self.Parameters().SetFEMCorrection(toUseFem)
246 ## To remove initial central point.
247 # @param toRemove "remove initial central point" flag value
248 def SetToRemoveCentralPoint(self, toRemove):
249 self.Parameters().SetToRemoveCentralPoint(toRemove)
252 ## To set an enforced vertex.
253 # @param x : x coordinate
254 # @param y : y coordinate
255 # @param z : z coordinate
256 # @param size : size of 1D element around enforced vertex
257 # @param vertexName : name of the enforced vertex
258 # @param groupName : name of the group
259 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
262 return self.Parameters().SetEnforcedVertex(x, y, z, size)
264 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
268 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
270 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
274 ## To set an enforced vertex given a GEOM vertex, group or compound.
275 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
276 # @param size : size of 1D element around enforced vertex
277 # @param groupName : name of the group
278 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
279 AssureGeomPublished( self.mesh, theVertex )
281 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
283 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
286 ## To remove an enforced vertex.
287 # @param x : x coordinate
288 # @param y : y coordinate
289 # @param z : z coordinate
290 def RemoveEnforcedVertex(self, x, y, z):
291 return self.Parameters().RemoveEnforcedVertex(x, y, z)
293 ## To remove an enforced vertex given a GEOM vertex, group or compound.
294 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
295 def RemoveEnforcedVertexGeom(self, theVertex):
296 AssureGeomPublished( self.mesh, theVertex )
297 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
299 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
300 # @param theSource : source mesh which provides constraint elements/nodes
301 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
302 # @param size : size of elements around enforced elements. Unused if -1.
303 # @param groupName : group in which enforced elements will be added. Unused if "".
304 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
307 return self.Parameters().SetEnforcedMesh(theSource, elementType)
309 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
313 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
315 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
319 ## Sets command line option as text.
320 # @param option command line option
321 def SetTextOption(self, option):
322 self.Parameters().SetTextOption(option)
325 pass # end of HYBRID_Algorithm class