1 # Copyright (C) 2007-2012 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 GHS3DPluginDC
22 # Python API for the GHS3D meshing plug-in module.
24 from smesh_algorithm import Mesh_Algorithm
25 from smesh import AssureGeomPublished
27 # import GHS3DPlugin module if possible
35 # Optimization level of GHS3D
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: GHS3D tetrahedron 3D algorithm, see GHS3D_Algorithm
48 ## Tetrahedron GHS3D 3D algorithm
50 # It can be created by calling smesh.Mesh.Tetrahedron( smesh.GHS3D, geom=0 )
51 class GHS3D_Algorithm(Mesh_Algorithm):
53 ## name of the dynamic method in smesh.Mesh class
55 meshMethod = "Tetrahedron"
56 ## type of algorithm used with helper function in smesh.Mesh class
59 ## doc string of the method in smesh.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 noGHS3DPlugin: print "Warning: GHS3DPlugin module unavailable"
70 self.Create(mesh, geom, self.algoType, "libGHS3DEngine.so")
74 ## Defines hypothesis having several parameters
75 # @return hypothesis object
78 self.params = self.Hypothesis("GHS3D_Parameters", [],
79 "libGHS3DEngine.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 ## Set Optimization level:
90 # @param level optimization level, one of the following values
92 # - Light_Optimization
93 # - Standard_Optimization
94 # - StandardPlus_Optimization
95 # - Strong_Optimization.
97 # Default is Standard_Optimization
98 def SetOptimizationLevel(self, level):
99 self.Parameters().SetOptimizationLevel(level)
102 ## Set maximal size of memory to be used by the algorithm (in Megabytes).
103 # @param MB maximal size of memory
104 def SetMaximumMemory(self, MB):
105 self.Parameters().SetMaximumMemory(MB)
108 ## Set initial size of memory to be used by the algorithm (in Megabytes) in
109 # automatic memory adjustment mode.
110 # @param MB initial size of memory
111 def SetInitialMemory(self, MB):
112 self.Parameters().SetInitialMemory(MB)
115 ## Set path to working directory.
116 # @param path working directory
117 def SetWorkingDirectory(self, path):
118 self.Parameters().SetWorkingDirectory(path)
121 ## To keep working files or remove them. Log file remains in case of errors anyway.
122 # @param toKeep "keep working files" flag value
123 def SetKeepFiles(self, toKeep):
124 self.Parameters().SetKeepFiles(toKeep)
127 ## Set verbosity level [0-10].
128 # @param level verbosity level
129 # - 0 - no standard output,
130 # - 2 - prints the data, quality statistics of the skin and final meshes and
131 # indicates when the final mesh is being saved. In addition the software
132 # gives indication regarding the CPU time.
133 # - 10 - same as 2 plus the main steps in the computation, quality statistics
134 # histogram of the skin mesh, quality statistics histogram together with
135 # the characteristics of the final mesh.
136 def SetVerboseLevel(self, level):
137 self.Parameters().SetVerboseLevel(level)
140 ## To create new nodes.
141 # @param toCreate "create new nodes" flag value
142 def SetToCreateNewNodes(self, toCreate):
143 self.Parameters().SetToCreateNewNodes(toCreate)
146 ## To use boundary recovery version which tries to create mesh on a very poor
147 # quality surface mesh.
148 # @param toUse "use boundary recovery version" flag value
149 def SetToUseBoundaryRecoveryVersion(self, toUse):
150 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
153 ## Applies finite-element correction by replacing overconstrained elements where
154 # it is possible. The process is cutting first the overconstrained edges and
155 # second the overconstrained facets. This insure that no edges have two boundary
156 # vertices and that no facets have three boundary vertices.
157 # @param toUseFem "apply finite-element correction" flag value
158 def SetFEMCorrection(self, toUseFem):
159 self.Parameters().SetFEMCorrection(toUseFem)
162 ## To remove initial central point.
163 # @param toRemove "remove initial central point" flag value
164 def SetToRemoveCentralPoint(self, toRemove):
165 self.Parameters().SetToRemoveCentralPoint(toRemove)
168 ## To set an enforced vertex.
169 # @param x : x coordinate
170 # @param y : y coordinate
171 # @param z : z coordinate
172 # @param size : size of 1D element around enforced vertex
173 # @param vertexName : name of the enforced vertex
174 # @param groupName : name of the group
175 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
178 return self.Parameters().SetEnforcedVertex(x, y, z, size)
180 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
184 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
186 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
190 ## To set an enforced vertex given a GEOM vertex, group or compound.
191 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
192 # @param size : size of 1D element around enforced vertex
193 # @param groupName : name of the group
194 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
195 AssureGeomPublished( self.mesh, theVertex )
197 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
199 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
202 ## To remove an enforced vertex.
203 # @param x : x coordinate
204 # @param y : y coordinate
205 # @param z : z coordinate
206 def RemoveEnforcedVertex(self, x, y, z):
207 return self.Parameters().RemoveEnforcedVertex(x, y, z)
209 ## To remove an enforced vertex given a GEOM vertex, group or compound.
210 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
211 def RemoveEnforcedVertexGeom(self, theVertex):
212 AssureGeomPublished( self.mesh, theVertex )
213 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
215 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
216 # @param theSource : source mesh which provides constraint elements/nodes
217 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
218 # @param size : size of elements around enforced elements. Unused if -1.
219 # @param groupName : group in which enforced elements will be added. Unused if "".
220 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
223 return self.Parameters().SetEnforcedMesh(theSource, elementType)
225 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
229 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
231 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
235 ## Sets command line option as text.
236 # @param option command line option
237 def SetTextOption(self, option):
238 self.Parameters().SetTextOption(option)
241 pass # end of GHS3D_Algorithm class