]> SALOME platform Git repositories - plugins/hybridplugin.git/blob - src/GHS3DPlugin/GHS3DPluginBuilder.py
Salome HOME
0022172: [CEA 790] create the groups corresponding to domains
[plugins/hybridplugin.git] / src / GHS3DPlugin / GHS3DPluginBuilder.py
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ##
21 # @package GHS3DPluginBuilder
22 # Python API for the GHS3D meshing plug-in module.
23
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 from salome.smesh.smeshBuilder import AssureGeomPublished
26
27 # import GHS3DPlugin module if possible
28 noGHS3DPlugin = 0
29 try:
30     import GHS3DPlugin
31 except ImportError:
32     noGHS3DPlugin = 1
33     pass
34
35 # Optimization level of GHS3D
36 # V3.1
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
40
41 #----------------------------
42 # Mesh algo type identifiers
43 #----------------------------
44
45 ## Algorithm type: GHS3D tetrahedron 3D algorithm, see GHS3D_Algorithm
46 GHS3D = "GHS3D_3D"
47
48 ## Tetrahedron GHS3D 3D algorithm
49 #  
50 #  It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.GHS3D, geom=0 )
51 class GHS3D_Algorithm(Mesh_Algorithm):
52
53     ## name of the dynamic method in smeshBuilder.Mesh class
54     #  @internal
55     meshMethod = "Tetrahedron"
56     ## type of algorithm used with helper function in smeshBuilder.Mesh class
57     #  @internal
58     algoType   = GHS3D
59     ## doc string of the method in smeshBuilder.Mesh class
60     #  @internal
61     docHelper  = "Creates tetrahedron 3D algorithm for volumes"
62
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")
71         self.params = None
72         pass
73
74     ## Defines hypothesis having several parameters
75     #  @return hypothesis object
76     def Parameters(self):
77         if not self.params:
78             self.params = self.Hypothesis("GHS3D_Parameters", [],
79                                           "libGHS3DEngine.so", UseExisting=0)
80             pass
81         return self.params
82
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)
87         pass
88
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)
95         pass
96
97     ## Set Optimization level:
98     #  @param level optimization level, one of the following values
99     #  - None_Optimization
100     #  - Light_Optimization
101     #  - Standard_Optimization
102     #  - StandardPlus_Optimization
103     #  - Strong_Optimization.
104     #  .
105     #  Default is Standard_Optimization
106     def SetOptimizationLevel(self, level):
107         self.Parameters().SetOptimizationLevel(level)
108         pass
109
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)
114         pass
115
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)
121         pass
122
123     ## Set path to working directory.
124     #  @param path working directory
125     def SetWorkingDirectory(self, path):
126         self.Parameters().SetWorkingDirectory(path)
127         pass
128
129     ## To keep working files or remove them. Log file remains in case of errors anyway.
130     #  @param toKeep "keep working files" flag value
131     def SetKeepFiles(self, toKeep):
132         self.Parameters().SetKeepFiles(toKeep)
133         pass
134
135     ## Set verbosity level [0-10].
136     #  @param level verbosity level
137     #  - 0 - no standard output,
138     #  - 2 - prints the data, quality statistics of the skin and final meshes and
139     #    indicates when the final mesh is being saved. In addition the software
140     #    gives indication regarding the CPU time.
141     #  - 10 - same as 2 plus the main steps in the computation, quality statistics
142     #    histogram of the skin mesh, quality statistics histogram together with
143     #    the characteristics of the final mesh.
144     def SetVerboseLevel(self, level):
145         self.Parameters().SetVerboseLevel(level)
146         pass
147
148     ## To create new nodes.
149     #  @param toCreate "create new nodes" flag value
150     def SetToCreateNewNodes(self, toCreate):
151         self.Parameters().SetToCreateNewNodes(toCreate)
152         pass
153
154     ## To use boundary recovery version which tries to create mesh on a very poor
155     #  quality surface mesh.
156     #  @param toUse "use boundary recovery version" flag value
157     def SetToUseBoundaryRecoveryVersion(self, toUse):
158         self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
159         pass
160
161     ## Applies finite-element correction by replacing overconstrained elements where
162     #  it is possible. The process is cutting first the overconstrained edges and
163     #  second the overconstrained facets. This insure that no edges have two boundary
164     #  vertices and that no facets have three boundary vertices.
165     #  @param toUseFem "apply finite-element correction" flag value
166     def SetFEMCorrection(self, toUseFem):
167         self.Parameters().SetFEMCorrection(toUseFem)
168         pass
169
170     ## To remove initial central point.
171     #  @param toRemove "remove initial central point" flag value
172     def SetToRemoveCentralPoint(self, toRemove):
173         self.Parameters().SetToRemoveCentralPoint(toRemove)
174         pass
175
176     ## To set an enforced vertex.
177     #  @param x            : x coordinate
178     #  @param y            : y coordinate
179     #  @param z            : z coordinate
180     #  @param size         : size of 1D element around enforced vertex
181     #  @param vertexName   : name of the enforced vertex
182     #  @param groupName    : name of the group
183     def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""):
184         if vertexName == "":
185             if groupName == "":
186                 return self.Parameters().SetEnforcedVertex(x, y, z, size)
187             else:
188                 return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName)
189             pass
190         else:
191             if groupName == "":
192                 return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName)
193             else:
194                 return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName)
195             pass
196         pass
197
198     ## To set an enforced vertex given a GEOM vertex, group or compound.
199     #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
200     #  @param size         : size of 1D element around enforced vertex
201     #  @param groupName    : name of the group
202     def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""):
203         AssureGeomPublished( self.mesh, theVertex )
204         if groupName == "":
205             return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
206         else:
207             return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName)
208         pass
209
210     ## To remove an enforced vertex.
211     #  @param x            : x coordinate
212     #  @param y            : y coordinate
213     #  @param z            : z coordinate
214     def RemoveEnforcedVertex(self, x, y, z):
215         return self.Parameters().RemoveEnforcedVertex(x, y, z)
216
217     ## To remove an enforced vertex given a GEOM vertex, group or compound.
218     #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
219     def RemoveEnforcedVertexGeom(self, theVertex):
220         AssureGeomPublished( self.mesh, theVertex )
221         return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
222
223     ## To set an enforced mesh with given size and add the enforced elements in the group "groupName".
224     #  @param theSource    : source mesh which provides constraint elements/nodes
225     #  @param elementType  : SMESH.ElementType (NODE, EDGE or FACE)
226     #  @param size         : size of elements around enforced elements. Unused if -1.
227     #  @param groupName    : group in which enforced elements will be added. Unused if "".
228     def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""):
229         if size < 0:
230             if groupName == "":
231                 return self.Parameters().SetEnforcedMesh(theSource, elementType)
232             else:
233                 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
234             pass
235         else:
236             if groupName == "":
237                 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
238             else:
239                 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
240             pass
241         pass
242
243     ## Sets command line option as text.
244     #  @param option command line option
245     def SetTextOption(self, option):
246         self.Parameters().SetTextOption(option)
247         pass
248     
249     pass # end of GHS3D_Algorithm class