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
20 from smesh import Mesh_Algorithm, AssureGeomPublished
22 # import GHS3DPlugin module if possible
30 # Optimization level of GHS3D
32 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
33 # V4.1 (partialy redefines V3.1). Issue 0020574
34 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
38 ## Tetrahedron GHS3D 3D algorithm
39 # It is created by calling Mesh.Tetrahedron( GHS3D, geom=0 )
41 class GHS3D_Algorithm(Mesh_Algorithm):
43 meshMethod = "Tetrahedron"
46 ## Private constructor.
47 def __init__(self, mesh, geom=0):
48 Mesh_Algorithm.__init__(self)
49 if noGHS3DPlugin: print "Warning: GHS3DPlugin module unavailable"
50 self.Create(mesh, geom, self.algoType, "libGHS3DEngine.so")
53 ## Defines hypothesis having several parameters
57 self.params = self.Hypothesis("GHS3D_Parameters", [],
58 "libGHS3DEngine.so", UseExisting=0)
61 ## To mesh "holes" in a solid or not. Default is to mesh.
63 def SetToMeshHoles(self, toMesh):
64 self.Parameters().SetToMeshHoles(toMesh)
66 ## Set Optimization level:
67 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
68 # Strong_Optimization.
69 # Default is Standard_Optimization
70 def SetOptimizationLevel(self, level):
71 self.Parameters().SetOptimizationLevel(level)
73 ## Maximal size of memory to be used by the algorithm (in Megabytes).
75 def SetMaximumMemory(self, MB):
76 self.Parameters().SetMaximumMemory(MB)
78 ## Initial size of memory to be used by the algorithm (in Megabytes) in
79 # automatic memory adjustment mode.
80 def SetInitialMemory(self, MB):
81 self.Parameters().SetInitialMemory(MB)
83 ## Path to working directory.
85 def SetWorkingDirectory(self, path):
86 self.Parameters().SetWorkingDirectory(path)
88 ## To keep working files or remove them. Log file remains in case of errors anyway.
89 def SetKeepFiles(self, toKeep):
90 self.Parameters().SetKeepFiles(toKeep)
92 ## To set verbose level [0-10]. <ul>
93 #<li> 0 - no standard output,
94 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
95 # indicates when the final mesh is being saved. In addition the software
96 # gives indication regarding the CPU time.
97 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
98 # histogram of the skin mesh, quality statistics histogram together with
99 # the characteristics of the final mesh.</ul>
100 def SetVerboseLevel(self, level):
101 self.Parameters().SetVerboseLevel(level)
103 ## To create new nodes.
104 def SetToCreateNewNodes(self, toCreate):
105 self.Parameters().SetToCreateNewNodes(toCreate)
107 ## To use boundary recovery version which tries to create mesh on a very poor
108 # quality surface mesh.
109 def SetToUseBoundaryRecoveryVersion(self, toUse):
110 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
112 ## Applies finite-element correction by replacing overconstrained elements where
113 # it is possible. The process is cutting first the overconstrained edges and
114 # second the overconstrained facets. This insure that no edges have two boundary
115 # vertices and that no facets have three boundary vertices.
116 def SetFEMCorrection(self, toUseFem):
117 self.Parameters().SetFEMCorrection(toUseFem)
119 ## To removes initial central point.
120 def SetToRemoveCentralPoint(self, toRemove):
121 self.Parameters().SetToRemoveCentralPoint(toRemove)
123 ## To set an enforced vertex.
124 # @param x : x coordinate
125 # @param y : y coordinate
126 # @param z : z coordinate
127 # @param size : size of 1D element around enforced vertex
128 # @param vertexName : name of the enforced vertex
129 # @param groupName : name of the group
130 def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
133 return self.Parameters().SetEnforcedVertex(x, y, z, size)
135 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
138 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
140 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
142 ## To set an enforced vertex given a GEOM vertex, group or compound.
143 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
144 # @param size : size of 1D element around enforced vertex
145 # @param groupName : name of the group
146 def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
147 AssureGeomPublished( self.mesh, theVertex )
149 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
151 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
153 ## To remove an enforced vertex.
154 # @param x : x coordinate
155 # @param y : y coordinate
156 # @param z : z coordinate
157 def RemoveEnforcedVertex(self, x, y, z):
158 return self.Parameters().RemoveEnforcedVertex(x, y, z)
160 ## To remove an enforced vertex given a GEOM vertex, group or compound.
161 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
162 def RemoveEnforcedVertexGeom(self, theVertex):
163 AssureGeomPublished( self.mesh, theVertex )
164 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
166 ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
167 # @param theSource : source mesh which provides constraint elements/nodes
168 # @param elementType : SMESH.ElementType (NODE, EDGE or FACE)
169 # @param size : size of elements around enforced elements. Unused if -1.
170 # @param groupName : group in which enforced elements will be added. Unused if "".
171 def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
174 return self.Parameters().SetEnforcedMesh(theSource, elementType)
176 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
179 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
181 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
183 ## Sets command line option as text.
184 def SetTextOption(self, option):
185 self.Parameters().SetTextOption(option)