1 # Copyright (C) 2007-2013 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.
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 HYBRIDPluginBuilder
22 # Python API for the HYBRID meshing plug-in module.
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 from salome.smesh.smeshBuilder import AssureGeomPublished
27 # import HYBRIDPlugin module if possible
35 # Optimization level of HYBRID
37 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
38 # V4.1 (partialy redefines V3.1). Issue 0020574
39 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
41 #----------------------------
42 # Mesh algo type identifiers
43 #----------------------------
45 ## Algorithm type: HYBRID tetrahedron 3D algorithm, see HYBRID_Algorithm
48 ## Tetrahedron HYBRID 3D algorithm
50 # It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.HYBRID, geom=0 )
51 class HYBRID_Algorithm(Mesh_Algorithm):
53 ## name of the dynamic method in smeshBuilder.Mesh class
55 meshMethod = "Tetrahedron"
56 ## type of algorithm used with helper function in smeshBuilder.Mesh class
59 ## doc string of the method in smeshBuilder.Mesh class
61 docHelper = "Creates tetrahedron 3D algorithm for volumes"
63 ## Private constructor.
64 # @param mesh parent mesh object algorithm is assigned to
65 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
66 # if it is @c 0 (default), the algorithm is assigned to the main shape
67 def __init__(self, mesh, geom=0):
68 Mesh_Algorithm.__init__(self)
69 if noHYBRIDPlugin: print "Warning: HYBRIDPlugin module unavailable"
70 self.Create(mesh, geom, self.algoType, "libHYBRIDEngine.so")
74 ## Defines hypothesis having several parameters
75 # @return hypothesis object
78 self.params = self.Hypothesis("HYBRID_Parameters", [],
79 "libHYBRIDEngine.so", UseExisting=0)
83 ## To mesh "holes" in a solid or not. Default is to mesh.
84 # @param toMesh "mesh holes" flag value
85 def SetToMeshHoles(self, toMesh):
86 self.Parameters().SetToMeshHoles(toMesh)
89 ## To make groups of volumes of different domains when mesh is generated from skin.
90 # Default is to make groups.
91 # This option works only (1) for the mesh w/o shape and (2) if GetToMeshHoles() == true
92 # @param toMesh "mesh holes" flag value
93 def SetToMakeGroupsOfDomains(self, toMakeGroups):
94 self.Parameters().SetToMakeGroupsOfDomains(toMakeGroups)
97 ## Set Optimization level:
98 # @param level optimization level, one of the following values
100 # - Light_Optimization
101 # - Standard_Optimization
102 # - StandardPlus_Optimization
103 # - Strong_Optimization.
105 # Default is Standard_Optimization
106 def SetOptimizationLevel(self, level):
107 self.Parameters().SetOptimizationLevel(level)
110 ## Set maximal size of memory to be used by the algorithm (in Megabytes).
111 # @param MB maximal size of memory
112 def SetMaximumMemory(self, MB):
113 self.Parameters().SetMaximumMemory(MB)
116 ## Set initial size of memory to be used by the algorithm (in Megabytes) in
117 # automatic memory adjustment mode.
118 # @param MB initial size of memory
119 def SetInitialMemory(self, MB):
120 self.Parameters().SetInitialMemory(MB)
123 ## Set path to working directory.
124 # @param path working directory
125 def SetWorkingDirectory(self, path):
126 self.Parameters().SetWorkingDirectory(path)
129 ## To keep working files or remove them.
130 # @param toKeep "keep working files" flag value
131 def SetKeepFiles(self, toKeep):
132 self.Parameters().SetKeepFiles(toKeep)
135 ## Remove or not the log file (if any) in case of successful computation.
136 # The log file remains in case of errors anyway. If
137 # the "keep working files" flag is set to true, this option
139 # @param toRemove "remove log on success" flag value
140 def SetRemoveLogOnSuccess(self, toRemove):
141 self.Parameters().SetRemoveLogOnSuccess(toRemove)
144 ## Print the the log in a file. If set to false, the
145 # log is printed on the standard output
146 # @param toPrintLogInFile "print log in a file" flag value
147 def SetPrintLogInFile(self, toPrintLogInFile):
148 self.Parameters().SetStandardOutputLog(not toPrintLogInFile)
151 ## Set verbosity level [0-10].
152 # @param level verbosity level
153 # - 0 - no standard output,
154 # - 2 - prints the data, quality statistics of the skin and final meshes and
155 # indicates when the final mesh is being saved. In addition the software
156 # gives indication regarding the CPU time.
157 # - 10 - same as 2 plus the main steps in the computation, quality statistics
158 # histogram of the skin mesh, quality statistics histogram together with
159 # the characteristics of the final mesh.
160 def SetVerboseLevel(self, level):
161 self.Parameters().SetVerboseLevel(level)
164 ## To create new nodes.
165 # @param toCreate "create new nodes" flag value
166 def SetToCreateNewNodes(self, toCreate):
167 self.Parameters().SetToCreateNewNodes(toCreate)
170 ## To use boundary recovery version which tries to create mesh on a very poor
171 # quality surface mesh.
172 # @param toUse "use boundary recovery version" flag value
173 def SetToUseBoundaryRecoveryVersion(self, toUse):
174 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
177 ## Applies finite-element correction by replacing overconstrained elements where
178 # it is possible. The process is cutting first the overconstrained edges and
179 # second the overconstrained facets. This insure that no edges have two boundary
180 # vertices and that no facets have three boundary vertices.
181 # @param toUseFem "apply finite-element correction" flag value
182 def SetFEMCorrection(self, toUseFem):
183 self.Parameters().SetFEMCorrection(toUseFem)
186 ## To remove initial central point.
187 # @param toRemove "remove initial central point" flag value
188 def SetToRemoveCentralPoint(self, toRemove):
189 self.Parameters().SetToRemoveCentralPoint(toRemove)
192 ## To set an enforced vertex.
193 # @param x : x coordinate
194 # @param y : y coordinate
195 # @param z : z coordinate
196 # @param size : size of 1D element around enforced vertex
197 # @param vertexName : name of the enforced vertex
198 # @param groupName : name of the group
199 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
202 return self.Parameters().SetEnforcedVertex(x, y, z, size)
204 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
208 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
210 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
214 ## To set an enforced vertex given a GEOM vertex, group or compound.
215 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
216 # @param size : size of 1D element around enforced vertex
217 # @param groupName : name of the group
218 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
219 AssureGeomPublished( self.mesh, theVertex )
221 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
223 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
226 ## To remove an enforced vertex.
227 # @param x : x coordinate
228 # @param y : y coordinate
229 # @param z : z coordinate
230 def RemoveEnforcedVertex(self, x, y, z):
231 return self.Parameters().RemoveEnforcedVertex(x, y, z)
233 ## To remove an enforced vertex given a GEOM vertex, group or compound.
234 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
235 def RemoveEnforcedVertexGeom(self, theVertex):
236 AssureGeomPublished( self.mesh, theVertex )
237 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
239 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
240 # @param theSource : source mesh which provides constraint elements/nodes
241 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
242 # @param size : size of elements around enforced elements. Unused if -1.
243 # @param groupName : group in which enforced elements will be added. Unused if "".
244 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
247 return self.Parameters().SetEnforcedMesh(theSource, elementType)
249 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
253 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
255 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
259 ## Sets command line option as text.
260 # @param option command line option
261 def SetTextOption(self, option):
262 self.Parameters().SetTextOption(option)
265 pass # end of HYBRID_Algorithm class