1 # Copyright (C) 2007-2016 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 GHS3DPluginBuilder
22 # Python API for the MG-Tetra meshing plug-in module.
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 from salome.smesh.smeshBuilder import AssureGeomPublished
27 # import GHS3DPlugin module if possible
35 # Optimization level of MG-Tetra
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: MG-Tetra tetrahedron 3D algorithm, see GHS3D_Algorithm
49 ## Tetrahedron MG-Tetra 3D algorithm
51 # It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.MG_Tetra, geom=0 )
52 class GHS3D_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 noGHS3DPlugin: print "Warning: GHS3DPlugin module unavailable"
71 self.Create(mesh, geom, self.algoType, "libGHS3DEngine.so")
75 ## Defines hypothesis having several parameters
76 # @return hypothesis object
79 self.params = self.Hypothesis("MG-Tetra Parameters", [],
80 "libGHS3DEngine.so", UseExisting=0)
84 ## To mesh "holes" in a solid or not. Default is to mesh.
85 # @param toMesh "mesh holes" flag value
86 def SetToMeshHoles(self, toMesh):
87 self.Parameters().SetToMeshHoles(toMesh)
90 ## To make groups of volumes of different domains when mesh is generated from skin.
91 # Default is to make groups.
92 # This option works only (1) for the mesh w/o shape and (2) if GetToMeshHoles() == true
93 # @param toMakeGroups "Make groups of domains" flag value
94 def SetToMakeGroupsOfDomains(self, toMakeGroups):
95 self.Parameters().SetToMakeGroupsOfDomains(toMakeGroups)
98 ## Set Optimization level:
99 # @param level optimization level, one of the following values
100 # - None_Optimization
101 # - Light_Optimization
102 # - Standard_Optimization
103 # - StandardPlus_Optimization
104 # - Strong_Optimization.
106 # Default is Standard_Optimization
107 def SetOptimizationLevel(self, level):
108 self.Parameters().SetOptimizationLevel(level)
111 ## Set maximal size of memory to be used by the algorithm (in Megabytes).
112 # @param MB maximal size of memory
113 def SetMaximumMemory(self, MB):
114 self.Parameters().SetMaximumMemory(MB)
117 ## Set initial size of memory to be used by the algorithm (in Megabytes) in
118 # automatic memory adjustment mode.
119 # @param MB initial size of memory
120 def SetInitialMemory(self, MB):
121 self.Parameters().SetInitialMemory(MB)
124 ## Set path to working directory.
125 # @param path working directory
126 def SetWorkingDirectory(self, path):
127 self.Parameters().SetWorkingDirectory(path)
130 ## To keep working files or remove them.
131 # @param toKeep "keep working files" flag value
132 def SetKeepFiles(self, toKeep):
133 self.Parameters().SetKeepFiles(toKeep)
136 ## Remove or not the log file (if any) in case of successful computation.
137 # The log file remains in case of errors anyway. If
138 # the "keep working files" flag is set to true, this option
140 # @param toRemove "remove log on success" flag value
141 def SetRemoveLogOnSuccess(self, toRemove):
142 self.Parameters().SetRemoveLogOnSuccess(toRemove)
145 ## Print the the log in a file. If set to false, the
146 # log is printed on the standard output
147 # @param toPrintLogInFile "print log in a file" flag value
148 def SetPrintLogInFile(self, toPrintLogInFile):
149 self.Parameters().SetStandardOutputLog(not toPrintLogInFile)
152 ## Set verbosity level [0-10].
153 # @param level verbosity level
154 # - 0 - no standard output,
155 # - 2 - prints the data, quality statistics of the skin and final meshes and
156 # indicates when the final mesh is being saved. In addition the software
157 # gives indication regarding the CPU time.
158 # - 10 - same as 2 plus the main steps in the computation, quality statistics
159 # histogram of the skin mesh, quality statistics histogram together with
160 # the characteristics of the final mesh.
161 def SetVerboseLevel(self, level):
162 self.Parameters().SetVerboseLevel(level)
165 ## To create new nodes.
166 # @param toCreate "create new nodes" flag value
167 def SetToCreateNewNodes(self, toCreate):
168 self.Parameters().SetToCreateNewNodes(toCreate)
171 ## To use boundary recovery version which tries to create mesh on a very poor
172 # quality surface mesh.
173 # @param toUse "use boundary recovery version" flag value
174 def SetToUseBoundaryRecoveryVersion(self, toUse):
175 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
178 ## Applies finite-element correction by replacing overconstrained elements where
179 # it is possible. The process is cutting first the overconstrained edges and
180 # second the overconstrained facets. This insure that no edges have two boundary
181 # vertices and that no facets have three boundary vertices.
182 # @param toUseFem "apply finite-element correction" flag value
183 def SetFEMCorrection(self, toUseFem):
184 self.Parameters().SetFEMCorrection(toUseFem)
187 ## To remove initial central point.
188 # @param toRemove "remove initial central point" flag value
189 def SetToRemoveCentralPoint(self, toRemove):
190 self.Parameters().SetToRemoveCentralPoint(toRemove)
193 ## To set an enforced vertex.
194 # @param x : x coordinate
195 # @param y : y coordinate
196 # @param z : z coordinate
197 # @param size : size of 1D element around enforced vertex
198 # @param vertexName : name of the enforced vertex
199 # @param groupName : name of the group
200 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
203 return self.Parameters().SetEnforcedVertex(x, y, z, size)
205 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
209 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
211 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
215 ## To set an enforced vertex given a GEOM vertex, group or compound.
216 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
217 # @param size : size of 1D element around enforced vertex
218 # @param groupName : name of the group
219 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
220 AssureGeomPublished( self.mesh, theVertex )
222 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
224 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
227 ## To remove an enforced vertex.
228 # @param x : x coordinate
229 # @param y : y coordinate
230 # @param z : z coordinate
231 def RemoveEnforcedVertex(self, x, y, z):
232 return self.Parameters().RemoveEnforcedVertex(x, y, z)
234 ## To remove an enforced vertex given a GEOM vertex, group or compound.
235 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
236 def RemoveEnforcedVertexGeom(self, theVertex):
237 AssureGeomPublished( self.mesh, theVertex )
238 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
240 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
241 # @param theSource : source mesh which provides constraint elements/nodes
242 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
243 # @param size : size of elements around enforced elements. Unused if -1.
244 # @param groupName : group in which enforced elements will be added. Unused if "".
245 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
248 return self.Parameters().SetEnforcedMesh(theSource, elementType)
250 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
254 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
256 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
260 ## Sets command line option as text.
261 # @param option command line option
262 def SetTextOption(self, option):
263 self.Parameters().SetAdvancedOption(option)
266 ## Sets command line option as text.
267 # @param option command line option
268 def SetAdvancedOption(self, option):
269 self.Parameters().SetAdvancedOption(option)
272 pass # end of GHS3D_Algorithm class