Back to index

salome-smesh  6.5.0
Modules | Classes
Defining Algorithms
Creating meshes
Collaboration diagram for Defining Algorithms:

Modules

 Basic meshing algorithms
 Projection Algorithms
 Radial Prism
 Segments around Vertex
 3D extrusion meshing algorithm

Classes

class  smeshDC.Mesh_Algorithm
 The mother class to define algorithm, it is not recommended to use it directly. More...

Class Documentation

class smeshDC::Mesh_Algorithm

The mother class to define algorithm, it is not recommended to use it directly.

For each meshing algorithm, a python class inheriting from class Mesh_Algorithm should be defined. This descendant class sould have two attributes defining the way it is created by class Mesh (see e.g. class StdMeshersDC_Segment in StdMeshersDC.py).

  • meshMethod attribute defines name of method of class Mesh by calling which the python class of algorithm is created. E.g. if in class MyPlugin_Algorithm meshMethod = "MyAlgorithm", then an instance of MyPlugin_Algorithm is created by the following code: my_algo = mesh.MyAlgorithm()
  • algoType defines name of algorithm type and is used mostly to discriminate algorithms that are created by the same method of class Mesh. E.g. if MyPlugin_Algorithm.algoType = "MyPLUGIN" then it's creation code can be: my_algo = mesh.MyAlgorithm(algo="MyPLUGIN")

Definition at line 4035 of file smeshDC.py.

Public Member Functions

def __init__
def FindHypothesis
 Finds a hypothesis in the study by its type name and parameters.
def FindAlgorithm
 Finds the algorithm in the study by its type name.
def GetSubMesh
 If the algorithm is global, returns 0;
else returns the submesh associated to this algorithm.
def GetAlgorithm
 Returns the wrapped mesher.
def GetCompatibleHypothesis
 Gets the list of hypothesis that can be used with this algorithm.
def GetName
 Gets the name of the algorithm.
def SetName
 Sets the name to the algorithm.
def GetId
 Gets the id of the algorithm.
def Create
 Private method.
def Assign
 Private method.
def CompareHyp
def CompareEqualHyp
def Hypothesis
 Private method.
def MainShapeEntry
 Returns entry of the shape to mesh in the study.
def ViscousLayers
 Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build near mesh boundary.
def ReversedEdgeIndices
 Transform a list of ether edges or tuples (edge 1st_vertex_of_edge) into a list acceptable to SetReversedEdges() of some 1D hypotheses.

Public Attributes

 mesh
 geom
 subm
 algo

Constructor & Destructor Documentation

Definition at line 4041 of file smeshDC.py.

04041 
04042     def __init__(self):
04043         self.mesh = None
04044         self.geom = None
04045         self.subm = None
04046         self.algo = None


Member Function Documentation

def smeshDC.Mesh_Algorithm.Assign (   self,
  algo,
  mesh,
  geom 
)

Private method.

Definition at line 4169 of file smeshDC.py.

04169 
04170     def Assign(self, algo, mesh, geom):
04171         if geom is None:
04172             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
04173         self.mesh = mesh
04174         name = ""
04175         if not geom:
04176             self.geom = mesh.geom
04177         else:
04178             self.geom = geom
04179             AssureGeomPublished( mesh, geom )
04180             try:
04181                 name = GetName(geom)
04182                 pass
04183             except:
04184                 pass
04185             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
04186         self.algo = algo
04187         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
04188         TreatHypoStatus( status, algo.GetName(), name, True )
04189         return

Here is the call graph for this function:

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.CompareEqualHyp (   self,
  hyp,
  args 
)

Definition at line 4194 of file smeshDC.py.

04194 
04195     def CompareEqualHyp (self, hyp, args):
04196         return True

Here is the call graph for this function:

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.CompareHyp (   self,
  hyp,
  args 
)

Definition at line 4190 of file smeshDC.py.

04190 
04191     def CompareHyp (self, hyp, args):
04192         print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
04193         return False

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.Create (   self,
  mesh,
  geom,
  hypo,
  so = "libStdMeshersEngine.so" 
)

Private method.

Definition at line 4158 of file smeshDC.py.

04158 
04159     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
04160         if geom is None:
04161             raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
04162         algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
04163         if algo is None:
04164             algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
04165             pass
04166         self.Assign(algo, mesh, geom)
04167         return self.algo

Here is the call graph for this function:

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.FindAlgorithm (   self,
  algoname,
  smeshpyD 
)

Finds the algorithm in the study by its type name.

Finds only the algorithms, which have been created in smeshpyD engine.

Returns:
SMESH.SMESH_Algo

Definition at line 4092 of file smeshDC.py.

04092 
04093     def FindAlgorithm (self, algoname, smeshpyD):
04094         study = smeshpyD.GetCurrentStudy()
04095         if not study: return None
04096         #to do: find component by smeshpyD object, not by its data type
04097         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04098         if scomp is not None:
04099             res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
04100             # Check if the root label of the algorithms exists
04101             if res and hypRoot is not None:
04102                 iter = study.NewChildIterator(hypRoot)
04103                 # Check all published algorithms
04104                 while iter.More():
04105                     algo_so_i = iter.Value()
04106                     attr = algo_so_i.FindAttribute("AttributeIOR")[1]
04107                     if attr is not None:
04108                         anIOR = attr.Value()
04109                         algo_o_i = salome.orb.string_to_object(anIOR)
04110                         if algo_o_i is not None:
04111                             # Check if this is an algorithm
04112                             algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
04113                             if algo_i is not None:
04114                                 # Checks if the algorithm belongs to the current engine
04115                                 if smeshpyD.GetObjectId(algo_i) > 0:
04116                                     # Check if this is the required algorithm
04117                                     if algo_i.GetName() == algoname:
04118                                         # found!!!
04119                                         return algo_i
04120                                     pass
04121                                 pass
04122                             pass
04123                         pass
04124                     iter.Next()
04125                     pass
04126                 pass
04127             pass
04128         return None

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.FindHypothesis (   self,
  hypname,
  args,
  CompareMethod,
  smeshpyD 
)

Finds a hypothesis in the study by its type name and parameters.

Finds only the hypotheses created in smeshpyD engine.

Returns:
SMESH.SMESH_Hypothesis

Definition at line 4050 of file smeshDC.py.

04050 
04051     def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
04052         study = smeshpyD.GetCurrentStudy()
04053         #to do: find component by smeshpyD object, not by its data type
04054         scomp = study.FindComponent(smeshpyD.ComponentDataType())
04055         if scomp is not None:
04056             res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
04057             # Check if the root label of the hypotheses exists
04058             if res and hypRoot is not None:
04059                 iter = study.NewChildIterator(hypRoot)
04060                 # Check all published hypotheses
04061                 while iter.More():
04062                     hypo_so_i = iter.Value()
04063                     attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
04064                     if attr is not None:
04065                         anIOR = attr.Value()
04066                         hypo_o_i = salome.orb.string_to_object(anIOR)
04067                         if hypo_o_i is not None:
04068                             # Check if this is a hypothesis
04069                             hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
04070                             if hypo_i is not None:
04071                                 # Check if the hypothesis belongs to current engine
04072                                 if smeshpyD.GetObjectId(hypo_i) > 0:
04073                                     # Check if this is the required hypothesis
04074                                     if hypo_i.GetName() == hypname:
04075                                         # Check arguments
04076                                         if CompareMethod(hypo_i, args):
04077                                             # found!!!
04078                                             return hypo_i
04079                                         pass
04080                                     pass
04081                                 pass
04082                             pass
04083                         pass
04084                     iter.Next()
04085                     pass
04086                 pass
04087             pass
04088         return None

Here is the caller graph for this function:

Returns the wrapped mesher.

Definition at line 4135 of file smeshDC.py.

04135 
04136     def GetAlgorithm(self):
04137         return self.algo

Gets the list of hypothesis that can be used with this algorithm.

Definition at line 4139 of file smeshDC.py.

04139 
04140     def GetCompatibleHypothesis(self):
04141         mylist = []
04142         if self.algo:
04143             mylist = self.algo.GetCompatibleHypothesis()
04144         return mylist

Here is the caller graph for this function:

Gets the id of the algorithm.

Definition at line 4154 of file smeshDC.py.

04154 
04155     def GetId(self):
04156         return self.algo.GetId()

Gets the name of the algorithm.

Definition at line 4146 of file smeshDC.py.

04146 
04147     def GetName(self):
04148         GetName(self.algo)

Here is the caller graph for this function:

If the algorithm is global, returns 0;
else returns the submesh associated to this algorithm.

Definition at line 4131 of file smeshDC.py.

04131 
04132     def GetSubMesh(self):
04133         return self.subm

def smeshDC.Mesh_Algorithm.Hypothesis (   self,
  hyp,
  args = [],
  so = "libStdMeshersEngine.so",
  UseExisting = 0,
  CompareMethod = "" 
)

Private method.

Definition at line 4199 of file smeshDC.py.

04199 
04200                     UseExisting=0, CompareMethod=""):
04201         hypo = None
04202         if UseExisting:
04203             if CompareMethod == "": CompareMethod = self.CompareHyp
04204             hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
04205             pass
04206         if hypo is None:
04207             hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
04208             a = ""
04209             s = "="
04210             for arg in args:
04211                 argStr = str(arg)
04212                 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
04213                     argStr = arg.GetStudyEntry()
04214                     if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
04215                 if len( argStr ) > 10:
04216                     argStr = argStr[:7]+"..."
04217                     if argStr[0] == '[': argStr += ']'
04218                 a = a + s + argStr
04219                 s = ","
04220                 pass
04221             if len(a) > 50:
04222                 a = a[:47]+"..."
04223             self.mesh.smeshpyD.SetName(hypo, hyp + a)
04224             pass
04225         geomName=""
04226         if self.geom:
04227             geomName = GetName(self.geom)
04228         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
04229         TreatHypoStatus( status, GetName(hypo), geomName, 0 )
04230         return hypo

Here is the call graph for this function:

Here is the caller graph for this function:

Returns entry of the shape to mesh in the study.

Definition at line 4232 of file smeshDC.py.

04232 
04233     def MainShapeEntry(self):
04234         if not self.mesh or not self.mesh.GetMesh(): return ""
04235         if not self.mesh.GetMesh().HasShapeToMesh(): return ""
04236         shape = self.mesh.GetShape()
04237         return shape.GetStudyEntry()

Here is the caller graph for this function:

def smeshDC.Mesh_Algorithm.SetName (   self,
  name 
)

Sets the name to the algorithm.

Definition at line 4150 of file smeshDC.py.

04150 
04151     def SetName(self, name):
04152         self.mesh.smeshpyD.SetName(self.algo, name)


Member Data Documentation

Definition at line 4045 of file smeshDC.py.

Definition at line 4043 of file smeshDC.py.

Definition at line 4042 of file smeshDC.py.

Definition at line 4044 of file smeshDC.py.