コード例 #1
0
ファイル: _swarmabstract.py プロジェクト: sb926/underworld2
 def _setup(self):
     # add coord swarm variable now (if available)
     if self._cself.owningCellVariable:
         self._owningCell = svar.SwarmVariable(
             self, "int", 1, _cself=self._cself.owningCellVariable)
     if self._cself.globalIdVariable:
         self._globalId = svar.SwarmVariable(
             self, "int", 1, _cself=self._cself.globalIdVariable)
     # set this flag
     self._cself.isAdvecting = False
コード例 #2
0
 def _setup(self):
     if self._cself.localCoordVariable:
         self._particleCoordinates = svar.SwarmVariable(
             self,
             "double",
             self.mesh.dim,
             _cself=self._cself.localCoordVariable)
     if self._cself.weightVariable:
         self._weightsVariable = svar.SwarmVariable(
             self, "double", 1, _cself=self._cself.weightVariable)
コード例 #3
0
ファイル: _swarmabstract.py プロジェクト: sb926/underworld2
    def add_variable(self, dataType, count):
        """ 
        Add a variable to each particle in this swarm. Variables can be added
        at any point. Removal of variables is however not currently supported.
        See help(SwarmVariable) for further information.
        
        Parameters
        ----------
        dataType: str
            The data type for the variable. Available types are  "char", 
            "short", "int", "float" or "double".
        count: unsigned
            The number of values to be stored for each particle.
        
        Returns
        -------
        variable: SwarmVariable
            The newly created swarm variable.
            
        >>> # first we need a mesh
        >>> mesh = uw.mesh.FeMesh_Cartesian( elementType='Q1/dQ0', elementRes=(16,16), minCoord=(0.,0.), maxCoord=(1.,1.) )
        >>> # create swarm
        >>> swarm = uw.swarm.Swarm(mesh)
        >>> # add a variable
        >>> svar = swarm.add_variable("char",1)
        >>> # add another
        >>> svar = swarm.add_variable("double",3)
        >>> # add some particles
        >>> swarm.populate_using_layout(uw.swarm.layouts.PerCellGaussLayout(swarm,2))
        >>> # add another variable
        >>> svar = swarm.add_variable("double",5)

        """
        return svar.SwarmVariable(self, dataType, count)
コード例 #4
0
 def _setup(self):
     # add coord swarm variable now (if available)
     if self._cself.owningCellVariable:
         self._owningCell = svar.SwarmVariable(
             self,
             "int",
             1,
             _cself=self._cself.owningCellVariable,
             writeable=False)
     if self._cself.globalIdVariable:
         self._globalId = svar.SwarmVariable(
             self,
             "int",
             1,
             _cself=self._cself.globalIdVariable,
             writeable=False)
コード例 #5
0
 def _setup(self):
     if self._cself.particleCoordVariable:
         self._particleCoordinates = svar.SwarmVariable(
             self,
             "double",
             self.mesh.dim,
             _cself=self._cself.particleCoordVariable)
     self._cself.isAdvecting = True
コード例 #6
0
ファイル: _swarm.py プロジェクト: zhang2018git/underworld2
 def _setup(self):
     if self._cself.particleCoordVariable:
         self._particleCoordinates = svar.SwarmVariable(
             self,
             "double",
             self.mesh.dim,
             _cself=self._cself.particleCoordVariable,
             writeable=False)