Back to index

salome-geom  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
GEOM_PY.structelem.StructuralElementManager Class Reference

List of all members.

Public Member Functions

def __init__
def createElement

Private Member Functions

def _extractMeshGroups
def _getMeshGroupListFromString

Private Attributes

 _studyEditor

Detailed Description

This class manages the structural elements in the study. It is used to
create a new structural element from a list of commands. The parameter
`studyId` defines the ID of the study in which the manager will create
structural elements. If it is :const:`None` or not specified, it will use
the ID of the current study as defined by
:func:`salome.kernel.studyedit.getActiveStudyId` function.

Definition at line 72 of file __init__.py.


Constructor & Destructor Documentation

def GEOM_PY.structelem.StructuralElementManager.__init__ (   self,
  studyId = None 
)

Definition at line 81 of file __init__.py.

00081 
00082     def __init__(self, studyId = None):
00083         self._studyEditor = getStudyEditor(studyId)


Member Function Documentation

def GEOM_PY.structelem.StructuralElementManager._extractMeshGroups (   self,
  command 
) [private]
This method extracts the names of the mesh groups (i.e. the
geometrical objects used to build the structural element part) in the
command in parameter. It returns a tuple containing the mesh groups as
a list of strings and the other parameters of the command as a new
dictionary.

Definition at line 188 of file __init__.py.

00188 
00189     def _extractMeshGroups(self, command):
00190         """
00191         This method extracts the names of the mesh groups (i.e. the
00192         geometrical objects used to build the structural element part) in the
00193         command in parameter. It returns a tuple containing the mesh groups as
00194         a list of strings and the other parameters of the command as a new
00195         dictionary.
00196         """
00197         (parttype, parameters) = command
00198         newparams = parameters.copy()
00199         groupMailleParam = newparams.pop("Group_Maille", None)
00200         meshGroupParam = newparams.pop("MeshGroups", None)
00201         if groupMailleParam is None and meshGroupParam is None:
00202             logger.warning("No mesh group specified in command %s, this "
00203                            "command will be ignored." % command)
00204             return ([], newparams)
00205         elif groupMailleParam is not None and meshGroupParam is not None:
00206             logger.warning('Both "MeshGroups" and "Group_Maille" specified in'
00207                            ' command %s, only "MeshGroups" will be used.' %
00208                            command)
00209         elif groupMailleParam is not None and meshGroupParam is None:
00210             meshGroupParam = groupMailleParam
00211         
00212         meshGroupList = []
00213         if type(meshGroupParam) == types.StringType:
00214             meshGroupList = self._getMeshGroupListFromString(meshGroupParam)
00215         else:
00216             for item in meshGroupParam:
00217                 meshGroupList += self._getMeshGroupListFromString(item)
00218         
00219         if len(meshGroupList) == 0:
00220             logger.warning("Mesh group list is empty in command %s, this "
00221                            "command will be ignored." % command)
00222 
00223         return (meshGroupList, newparams)
    

Here is the call graph for this function:

This method splits the string in parameter to extract comma separated
names. Those names are returned as a list of strings.

Definition at line 224 of file __init__.py.

00224 
00225     def _getMeshGroupListFromString(self, meshString):
00226         """
00227         This method splits the string in parameter to extract comma separated
00228         names. Those names are returned as a list of strings.
00229         """
00230         meshGroupList = []
00231         list = meshString.split(",")
00232         for item in list:
00233             strippedItem = item.strip()
00234             if len(strippedItem) > 0:
00235                 meshGroupList.append(strippedItem)
00236         return meshGroupList
00237 

Here is the caller graph for this function:

Create a structural element from the list of commands `commandList`.
Each command in this list represent a part of the structural element,
that is a specific kind of shape (circular beam, grid, etc.)
associated with one or several geometrical primitives. A command must
be a tuple. The first element is the structural element part class
name or alias name. The second element is a dictionary containing the
parameters describing the part. Valid class names are all the classes
defined in the module :mod:`~salome.geom.structelem.parts` and inheriting
class :class:`~parts.StructuralElementPart`. There are also several
aliases for backward compatibility. Here is the complete list:

* :class:`~parts.GeneralBeam`
* :class:`~parts.CircularBeam`
* :class:`~parts.RectangularBeam`
* :class:`~parts.ThickShell`
* :class:`~parts.Grid`

* :func:`~parts.VisuPoutreGenerale` (alias for
  :class:`~parts.GeneralBeam`)
* :func:`~parts.VisuPoutreCercle` (alias for
  :class:`~parts.CircularBeam`)
* :func:`~parts.VisuPoutreRectangle` (alias for
  :class:`~parts.RectangularBeam`)
* :func:`~parts.VisuBarreGenerale` (alias for
  :class:`~parts.GeneralBeam`)
* :func:`~parts.VisuBarreRectangle` (alias for
  :class:`~parts.RectangularBeam`)
* :func:`~parts.VisuBarreCercle` (alias for
  :class:`~parts.CircularBeam`)
* :func:`~parts.VisuCable` (alias for :class:`~parts.CircularBeam`)
* :func:`~parts.VisuCoque` (alias for :class:`~parts.ThickShell`)
* :func:`~parts.VisuGrille` (alias for :class:`~parts.Grid`)

* ``Orientation``: This identifier is used to specify the orientation
  of one or several 1D structural element parts (i.e. beams). The
  parameters are described in class
  :class:`~orientation.Orientation1D`.

The valid parameters in the dictionary depend on the type of the
structural element part, and are detailed in the documentation of
the corresponding class. The only parameter that is common to all the
classes is "MeshGroups" (that can also be named "Group_Maille"). It
defines the name of the geometrical object(s) in the study that will
be used as primitives to build the structural element part. This
parameter can be either a list of strings or a single string with
comma separated names.

Definition at line 84 of file __init__.py.

00084 
00085     def createElement(self, commandList):
00086         """
00087         Create a structural element from the list of commands `commandList`.
00088         Each command in this list represent a part of the structural element,
00089         that is a specific kind of shape (circular beam, grid, etc.)
00090         associated with one or several geometrical primitives. A command must
00091         be a tuple. The first element is the structural element part class
00092         name or alias name. The second element is a dictionary containing the
00093         parameters describing the part. Valid class names are all the classes
00094         defined in the module :mod:`~salome.geom.structelem.parts` and inheriting
00095         class :class:`~parts.StructuralElementPart`. There are also several
00096         aliases for backward compatibility. Here is the complete list:
00097         
00098         * :class:`~parts.GeneralBeam`
00099         * :class:`~parts.CircularBeam`
00100         * :class:`~parts.RectangularBeam`
00101         * :class:`~parts.ThickShell`
00102         * :class:`~parts.Grid`
00103 
00104         * :func:`~parts.VisuPoutreGenerale` (alias for
00105           :class:`~parts.GeneralBeam`)
00106         * :func:`~parts.VisuPoutreCercle` (alias for
00107           :class:`~parts.CircularBeam`)
00108         * :func:`~parts.VisuPoutreRectangle` (alias for
00109           :class:`~parts.RectangularBeam`)
00110         * :func:`~parts.VisuBarreGenerale` (alias for
00111           :class:`~parts.GeneralBeam`)
00112         * :func:`~parts.VisuBarreRectangle` (alias for
00113           :class:`~parts.RectangularBeam`)
00114         * :func:`~parts.VisuBarreCercle` (alias for
00115           :class:`~parts.CircularBeam`)
00116         * :func:`~parts.VisuCable` (alias for :class:`~parts.CircularBeam`)
00117         * :func:`~parts.VisuCoque` (alias for :class:`~parts.ThickShell`)
00118         * :func:`~parts.VisuGrille` (alias for :class:`~parts.Grid`)
00119         
00120         * ``Orientation``: This identifier is used to specify the orientation
00121           of one or several 1D structural element parts (i.e. beams). The
00122           parameters are described in class
00123           :class:`~orientation.Orientation1D`.
00124 
00125         The valid parameters in the dictionary depend on the type of the
00126         structural element part, and are detailed in the documentation of
00127         the corresponding class. The only parameter that is common to all the
00128         classes is "MeshGroups" (that can also be named "Group_Maille"). It
00129         defines the name of the geometrical object(s) in the study that will
00130         be used as primitives to build the structural element part. This
00131         parameter can be either a list of strings or a single string with
00132         comma separated names.
00133         """
00134         logger.debug("StructuralElementManager.createElement: START")
00135         logger.debug("Command list: %s" % commandList)
00136 
00137         element = StructuralElement(self._studyEditor.studyId)
00138         orientationCmdList = []
00139         for command in commandList:
00140             (parttype, parameters) = command
00141             if parttype == "Orientation":
00142                 orientationCmdList += [command]
00143             elif parttype not in dir(parts):
00144                 logger.warning('Invalid structural element part name "%s"'
00145                                ' in command %s, this command will be '
00146                                'ignored.' % (parttype, command))
00147             else:
00148                 (meshGroupList, newparams) = self._extractMeshGroups(command)
00149                 for meshGroup in meshGroupList:
00150                     # Get the geometrical primitive object
00151                     groupSObj = self._studyEditor.study.FindObject(meshGroup)
00152                     groupGeomObj = None
00153                     if groupSObj is not None:
00154                         groupGeomObj = \
00155                                 self._studyEditor.getOrLoadObject(groupSObj)
00156                     if groupGeomObj is None:
00157                         logger.error("Can't get geom object corresponding to "
00158                                      'mesh group "%s", structural element '
00159                                      "part %s will not be built." %
00160                                      (groupName, part))
00161                         continue
00162                     
00163                     # Create the part
00164                     try:
00165                         part = parts.__dict__[parttype](
00166                                         self._studyEditor.studyId, meshGroup,
00167                                         groupGeomObj, newparams)
00168                         element.addPart(part)
00169                     except InvalidParameterError, e:
00170                         logger.error("Invalid parameter error: %s" % e)
00171                         raise
00172                     except:
00173                         logger.exception("Can't create structural element"
00174                                          " part with command %s." %
00175                                          str(command))
00176 
00177         # Orientations are parsed after the parts because they must be
00178         # associated with existing parts.
00179         for command in orientationCmdList:
00180             (parttype, parameters) = command
00181             (meshGroupList, orientParams) = self._extractMeshGroups(command)
00182             for meshGroup in meshGroupList:
00183                 element.addOrientation(meshGroup, orientParams)
00184 
00185         element.build()
00186         logger.debug("StructuralElementManager.createElement: END")
00187         return element
    

Here is the call graph for this function:


Member Data Documentation

Definition at line 82 of file __init__.py.


The documentation for this class was generated from the following file: