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
43 Decrease_Collision_Mode, Stop_Collision_Mode = 0,1
45 # Boundary Layers growing inward or outward.
46 Layer_Growth_Inward, Layer_Growth_Outward = 0,1
48 # Mesh with element type Tetra Dominant or hexa Dominant in the remaining volume (outside layers).
49 Generation_Tetra_Dominant, Generation_Hexa_Dominant = 0,1
51 #----------------------------
52 # Mesh algo type identifiers
53 #----------------------------
55 ## Algorithm type: HYBRID tetrahedron 3D algorithm, see HYBRID_Algorithm
58 ## Tetrahedron HYBRID 3D algorithm
60 # It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.HYBRID, geom=0 )
61 class HYBRID_Algorithm(Mesh_Algorithm):
63 ## name of the dynamic method in smeshBuilder.Mesh class
65 meshMethod = "Tetrahedron"
66 ## type of algorithm used with helper function in smeshBuilder.Mesh class
69 ## doc string of the method in smeshBuilder.Mesh class
71 docHelper = "Creates tetrahedron 3D algorithm for volumes"
73 ## Private constructor.
74 # @param mesh parent mesh object algorithm is assigned to
75 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
76 # if it is @c 0 (default), the algorithm is assigned to the main shape
77 def __init__(self, mesh, geom=0):
78 Mesh_Algorithm.__init__(self)
79 if noHYBRIDPlugin: print "Warning: HYBRIDPlugin module unavailable"
80 self.Create(mesh, geom, self.algoType, "libHYBRIDEngine.so")
84 ## Defines hypothesis having several parameters
85 # @return hypothesis object
88 self.params = self.Hypothesis("HYBRID_Parameters", [],
89 "libHYBRIDEngine.so", UseExisting=0)
95 ## To mesh "holes" in a solid or not. Default is to mesh.
96 # @param toMesh "mesh holes" flag value
97 def SetToMeshHoles(self, toMesh):
98 self.Parameters().SetToMeshHoles(toMesh)
101 ## To make groups of volumes of different domains when mesh is generated from skin.
102 # Default is to make groups.
103 # This option works only (1) for the mesh w/o shape and (2) if GetToMeshHoles() == true
104 # @param toMesh "mesh holes" flag value
105 def SetToMakeGroupsOfDomains(self, toMakeGroups):
106 self.Parameters().SetToMakeGroupsOfDomains(toMakeGroups)
109 ## Set Optimization level:
110 # @param level optimization level, one of the following values
111 # - None_Optimization
112 # - Light_Optimization
113 # - Standard_Optimization
114 # - StandardPlus_Optimization
115 # - Strong_Optimization.
117 # Default is Standard_Optimization
118 def SetOptimizationLevel(self, level):
119 self.Parameters().SetOptimizationLevel(level)
122 ## Set maximal size of memory to be used by the algorithm (in Megabytes).
123 # @param MB maximal size of memory
124 def SetMaximumMemory(self, MB):
125 self.Parameters().SetMaximumMemory(MB)
128 ## Set initial size of memory to be used by the algorithm (in Megabytes) in
129 # automatic memory adjustment mode.
130 # @param MB initial size of memory
131 def SetInitialMemory(self, MB):
132 self.Parameters().SetInitialMemory(MB)
136 ## Set Collision Mode:
137 # @param mode Collision Mode, one of the following values
138 # - Decrease_Collision_Mode
139 # - Stop_Collision_Mode
141 # Default is Decrease_Collision_Mode
142 def SetCollisionMode(self, mode):
143 self.Parameters().SetCollisionMode(mode)
146 ## To mesh Boundary Layers growing inward or outward.
147 # @param mode, one of the following values
148 # - Layer_Growth_Inward
149 # - Layer_Growth_Outward
151 # Default is Layer_Growth_Inward
152 def SetBoundaryLayersGrowth(self, mode):
153 self.Parameters().SetBoundaryLayersGrowth(mode)
156 ## To mesh with element type Tetra Dominant or hexa Dominant in the remaining volume (outside layers).
157 # @param mode, one of the following values
158 # - Generation_Tetra_Dominant
159 # - Generation_Hexa_Dominant
161 # Default is Generation_Tetra_Dominant
162 def SetElementGeneration(self, mode);
163 self.Parameters().SetElementGeneration(mode)
166 ## To mesh adding extra normals at opening ridges and corners.
168 # @param addMultinormals boolean value
169 def SetAddMultinormals(self, addMultinormals);
170 self.Parameters().SetAddMultinormals(addMultinormals)
173 ## To mesh smoothing normals at closed ridges and corners.
175 # @param smoothNormals boolean value
176 def SetSmoothNormals(self, smoothNormals);
177 self.Parameters().SetSmoothNormals(smoothNormals)
180 ## To set height of the first layer.
182 # @param heightFirstLayer double value
183 def SetHeightFirstLayer(self, heightFirstLayer);
184 self.Parameters().SetHeightFirstLayer(heightFirstLayer)
187 ## To set boundary layers coefficient of geometric progression.
189 # @param boundaryLayersProgression double value
190 def SetBoundaryLayersProgression(self, boundaryLayersProgression);
191 self.Parameters().SetBoundaryLayersProgression(boundaryLayersProgression)
194 ## To set multinormals angle threshold at opening ridges.
196 # @param multinormalsAngle double value
197 def SetMultinormalsAngle(self, multinormalsAngle);
198 self.Parameters().SetMultinormalsAngle(multinormalsAngle)
201 ## To set number of boundary layers.
203 # @param nbOfBoundaryLayers int value
204 def SetNbOfBoundaryLayers(self, nbOfBoundaryLayers);
205 self.Parameters().SetNbOfBoundaryLayers(nbOfBoundaryLayers)
208 ## Set path to working directory.
209 # @param path working directory
210 def SetWorkingDirectory(self, path):
211 self.Parameters().SetWorkingDirectory(path)
214 ## To keep working files or remove them.
215 # @param toKeep "keep working files" flag value
216 def SetKeepFiles(self, toKeep):
217 self.Parameters().SetKeepFiles(toKeep)
220 ## Remove or not the log file (if any) in case of successful computation.
221 # The log file remains in case of errors anyway. If
222 # the "keep working files" flag is set to true, this option
224 # @param toRemove "remove log on success" flag value
225 def SetRemoveLogOnSuccess(self, toRemove):
226 self.Parameters().SetRemoveLogOnSuccess(toRemove)
229 ## Print the the log in a file. If set to false, the
230 # log is printed on the standard output
231 # @param toPrintLogInFile "print log in a file" flag value
232 def SetPrintLogInFile(self, toPrintLogInFile):
233 self.Parameters().SetStandardOutputLog(not toPrintLogInFile)
236 ## Set verbosity level [0-10].
237 # @param level verbosity level
238 # - 0 - no standard output,
239 # - 2 - prints the data, quality statistics of the skin and final meshes and
240 # indicates when the final mesh is being saved. In addition the software
241 # gives indication regarding the CPU time.
242 # - 10 - same as 2 plus the main steps in the computation, quality statistics
243 # histogram of the skin mesh, quality statistics histogram together with
244 # the characteristics of the final mesh.
245 def SetVerboseLevel(self, level):
246 self.Parameters().SetVerboseLevel(level)
249 ## To create new nodes.
250 # @param toCreate "create new nodes" flag value
251 def SetToCreateNewNodes(self, toCreate):
252 self.Parameters().SetToCreateNewNodes(toCreate)
255 ## To use boundary recovery version which tries to create mesh on a very poor
256 # quality surface mesh.
257 # @param toUse "use boundary recovery version" flag value
258 def SetToUseBoundaryRecoveryVersion(self, toUse):
259 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
262 ## Applies finite-element correction by replacing overconstrained elements where
263 # it is possible. The process is cutting first the overconstrained edges and
264 # second the overconstrained facets. This insure that no edges have two boundary
265 # vertices and that no facets have three boundary vertices.
266 # @param toUseFem "apply finite-element correction" flag value
267 def SetFEMCorrection(self, toUseFem):
268 self.Parameters().SetFEMCorrection(toUseFem)
271 ## To remove initial central point.
272 # @param toRemove "remove initial central point" flag value
273 def SetToRemoveCentralPoint(self, toRemove):
274 self.Parameters().SetToRemoveCentralPoint(toRemove)
277 ## To set an enforced vertex.
278 # @param x : x coordinate
279 # @param y : y coordinate
280 # @param z : z coordinate
281 # @param size : size of 1D element around enforced vertex
282 # @param vertexName : name of the enforced vertex
283 # @param groupName : name of the group
284 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
287 return self.Parameters().SetEnforcedVertex(x, y, z, size)
289 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
293 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
295 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
299 ## To set an enforced vertex given a GEOM vertex, group or compound.
300 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
301 # @param size : size of 1D element around enforced vertex
302 # @param groupName : name of the group
303 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
304 AssureGeomPublished( self.mesh, theVertex )
306 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
308 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
311 ## To remove an enforced vertex.
312 # @param x : x coordinate
313 # @param y : y coordinate
314 # @param z : z coordinate
315 def RemoveEnforcedVertex(self, x, y, z):
316 return self.Parameters().RemoveEnforcedVertex(x, y, z)
318 ## To remove an enforced vertex given a GEOM vertex, group or compound.
319 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
320 def RemoveEnforcedVertexGeom(self, theVertex):
321 AssureGeomPublished( self.mesh, theVertex )
322 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
324 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
325 # @param theSource : source mesh which provides constraint elements/nodes
326 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
327 # @param size : size of elements around enforced elements. Unused if -1.
328 # @param groupName : group in which enforced elements will be added. Unused if "".
329 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
332 return self.Parameters().SetEnforcedMesh(theSource, elementType)
334 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
338 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
340 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
344 ## Sets command line option as text.
345 # @param option command line option
346 def SetTextOption(self, option):
347 self.Parameters().SetTextOption(option)
350 pass # end of HYBRID_Algorithm class