mesh = 0
editor = 0
- def __init__(self, smeshpyD, geompyD, obj=0, name=0):
+ def __init__(self, smeshpyD, geompyD, obj=0, name=0, parallel=False):
"""
Constructor
else:
geo_name = "%s_%s to mesh"%(self.geom.GetShapeType(), id(self.geom)%100)
geompyD.addToStudy( self.geom, geo_name )
- self.SetMesh( self.smeshpyD.CreateMesh(self.geom) )
+ if parallel and isinstance(self, ParallelMesh):
+ self.SetMesh( self.smeshpyD.CreateParallelMesh(self.geom) )
+ else:
+ self.SetMesh( self.smeshpyD.CreateMesh(self.geom) )
elif isinstance(obj, SMESH._objref_SMESH_Mesh):
self.SetMesh(obj)
Surcharge on Mesh for parallel computation of a mesh
"""
- def __init__(self, smeshpyD, geompyD, geom, param, nbThreads, name=0):
+ def __split_geom(self, geompyD, geom):
"""
- Create a parallel mesh.
+ Splitting geometry into n solids and a 2D/1D compound
Parameters:
geom: geometrical object for meshing
- param: full mesh parameters
- nbThreads: Number of threads for parallelisation.
- name: the name for the new mesh.
- Returns:
- an instance of class :class:`ParallelMesh`.
"""
-
- if not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
- raise ValueError("geom argument must be a geometry")
-
- if not isinstance(param, NETGENPlugin._objref_NETGENPlugin_Hypothesis):
- raise ValueError("param must come from NETGENPlugin")
-
- if nbThreads < 1:
- raise ValueError("Number of threads must be stricly greater than 1")
-
# Splitting geometry into 3D elements and all the 2D/1D into one compound
object_solids = geompyD.ExtractShapes(geom, geompyD.ShapeType["SOLID"],
True)
isolid += 1
geompyD.addToStudyInFather( geom, solid, 'Solid_{}'.format(isolid) )
solids.append(solid)
+ # If geom is a solid ExtractShapes will return nothin in that case geom is the solids
+ if isolid == 0:
+ solids = [geom]
faces = []
iface = 0
all_faces = geompyD.MakeGlueFaces(all_faces, 1e-07)
geompyD.addToStudy(all_faces, 'global2D')
- super(ParallelMesh, self).__init__(smeshpyD, geompyD, geom, name)
+ return all_faces, solids
+
+ def __init__(self, smeshpyD, geompyD, geom, param, nbThreads, name=0):
+ """
+ Create a parallel mesh.
+
+ Parameters:
+ geom: geometrical object for meshing
+ param: full mesh parameters
+ nbThreads: Number of threads for parallelisation.
+ name: the name for the new mesh.
+
+ Returns:
+ an instance of class :class:`ParallelMesh`.
+ """
+
+ if not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
+ raise ValueError("geom argument must be a geometry")
+
+ if not isinstance(param, NETGENPlugin._objref_NETGENPlugin_Hypothesis):
+ raise ValueError("param must come from NETGENPlugin")
+
+ if nbThreads < 1:
+ raise ValueError("Number of threads must be stricly greater than 1")
+
+ all_faces, solids = self.__split_geom(geompyD, geom)
+
+ super(ParallelMesh, self).__init__(smeshpyD, geompyD, geom, name, parallel=True)
self.mesh.SetNbThreads(nbThreads)