parameters: (mat, boundaryPairs, time=0.0, userData={},
                      nodePairs=None,
                      dofOffset=0, nCoeff=1, dofPerCoeff=None)
return_statement: return uDirVal
docstring: Get map of index: dirichlet value
  
      Apply Dirichlet boundary condition to the system matrix S and rhs vector.
      The right hand side values for h can be given for each boundary
      element individually by setting proper boundary pair arguments.
  
      .. math::
          u(\textbf{r}, t) = h
          \quad\text{for}\quad\textbf{r}\quad\text{on}\quad\delta\Omega=\Gamma_{\text{Dirichlet}}
  
      Parameters
      ----------
      mat: :gimliapi:`GIMLI::RSparseMatrix`
          System matrix of the system equation.
      boundaryPair: list()
          List of pairs [:gimliapi:`GIMLI::Boundary`, h].
          The value :math:`h` will assigned to the nodes of the boundaries.
          Later assignment overwrites prior.
  
          :math:`h` need to be a scalar value (float or int) or
          a value generator function that will be executed at runtime.
          See :py:mod:`pygimli.solver.solver.parseArgToBoundaries`
          and :ref:`tut:modelling_bc` for example syntax,
      nodePairs: list() | callable
          List of pairs [nodeID, uD].
          The value uD will assigned to the nodes given there ids.
          This node value settings will overwrite any prior settings due to
          boundaryPair.
      time: float
          Will be forwarded to value generator.
      userData: class
          Will be forwarded to value generator.
      dofOffset: int[0]
          Offset for matrix index.
docstring_summary: Get map of index: dirichlet value
docstring_tokens: Get map of index : dirichlet value
function: def getDirichletMap(mat, boundaryPairs, time=0.0, userData={},
                      nodePairs=None,
                      dofOffset=0, nCoeff=1, dofPerCoeff=None):
      """Get map of index: dirichlet value
  
      Apply Dirichlet boundary condition to the system matrix S and rhs vector.
      The right hand side values for h can be given for each boundary
      element individually by setting proper boundary pair arguments.
  
      .. math::
          u(\textbf{r}, t) = h
          \quad\text{for}\quad\textbf{r}\quad\text{on}\quad\delta\Omega=\Gamma_{\text{Dirichlet}}
  
      Parameters
      ----------
      mat: :gimliapi:`GIMLI::RSparseMatrix`
          System matrix of the system equation.
      boundaryPair: list()
          List of pairs [:gimliapi:`GIMLI::Boundary`, h].
          The value :math:`h` will assigned to the nodes of the boundaries.
          Later assignment overwrites prior.
  
          :math:`h` need to be a scalar value (float or int) or
          a value generator function that will be executed at runtime.
          See :py:mod:`pygimli.solver.solver.parseArgToBoundaries`
          and :ref:`tut:modelling_bc` for example syntax,
      nodePairs: list() | callable
          List of pairs [nodeID, uD].
          The value uD will assigned to the nodes given there ids.
          This node value settings will overwrite any prior settings due to
          boundaryPair.
      time: float
          Will be forwarded to value generator.
      userData: class
          Will be forwarded to value generator.
      dofOffset: int[0]
          Offset for matrix index.
      """
      if not hasattr(boundaryPairs, '__getitem__'):
          raise BaseException("Boundary pairs need to be a list of "
                              "[boundary, value]")
  
      #uDirNodes = []   ## []
      uDirVal = dict() ## {nID: val}
  
      def _genVecUd(n, ud, dofOffset, nCoeff=1, dofPerCoeff=None):
          ret = {}
          if callable(ud):
              pg.error("callable node pairs need to be implemented.")
  
          if isinstance(n, pg.core.Node):
              idx = dofOffset + n.id()
          else:
              idx = dofOffset + n
  
          if hasattr(ud, '__iter__'):
              # vector valued problem
              if dofPerCoeff is None:
                  if mat.shape[0] % len(ud) != 0:
                      print(mat)
                      print(mat.shape, len(ud))
                      pg.error("Matrix size missmatch for vector valued problem")
                  else:
                      dofPerCoeff = mat.shape[0] // len(ud)
  
              if nCoeff == 1:
                  nCoeff = len(ud)
  
              for i in range(nCoeff):
                  if ud[i] is not None:
                      ret[idx +  i * dofPerCoeff] = ud[i]
          else:
              if nCoeff > 1:
                  print('nCoeff:', nCoeff, 'ud:', ud, 'idx:',idx)
                  pg.error('number of coefficents > 1 but u dirichlet is scalar.')
  
              if ud is not None:
                  ret[idx] = ud
          return ret
  
      for pair in boundaryPairs:
          ent = pair[0]
          val = pair[1]
          # print('**', ent, val)
          uD = generateBoundaryValue(ent, val, time, userData, nCoeff=nCoeff)
          # print('\t', uD)
  
          if uD is not None:
  
              if isinstance(ent, pg.core.Node):
                  uDirVal.update(_genVecUd(ent, uD, dofOffset))
              else:
                  if isinstance(uD, float):
                      pg.critical(uD)
                      uD = [uD] * ent.nodeCount()
                  if len(uD) == ent.nodeCount():
                      # print('uD', uD, nCoeff, dofPerCoeff)
                      for i, n in enumerate(ent.nodes()):
                          uDirVal.update(_genVecUd(n, uD[i], dofOffset,
                                                   nCoeff=nCoeff, dofPerCoeff=dofPerCoeff))
                  else:
                      pg.error('Dirichlet values per boundary need to have '
                               'length of boundary.nodeCount()')
  
      if nodePairs is not None:
          #print("nodePairs", nodePairs)
  
          if len(nodePairs) == 2 and isinstance(nodePairs[0], int):
              # assume a single Node [NodeId, val]
              nodePairs = [nodePairs]
  
          for [n, val] in nodePairs:
              uDirVal.update(_genVecUd(n, val, dofOffset,
                             nCoeff=nCoeff, dofPerCoeff=dofPerCoeff))
  
      return uDirVal
function_tokens: def getDirichletMap ( mat , boundaryPairs , time = 0.0 , userData = { } , nodePairs = None , dofOffset = 0 , nCoeff = 1 , dofPerCoeff = None ) : if not hasattr ( boundaryPairs , '__getitem__' ) : raise BaseException ( "Boundary pairs need to be a list of " "[boundary, value]" ) #uDirNodes = []   ## [] uDirVal = dict ( ) ## {nID: val} def _genVecUd ( n , ud , dofOffset , nCoeff = 1 , dofPerCoeff = None ) : ret = { } if callable ( ud ) : pg . error ( "callable node pairs need to be implemented." ) if isinstance ( n , pg . core . Node ) : idx = dofOffset + n . id ( ) else : idx = dofOffset + n if hasattr ( ud , '__iter__' ) : # vector valued problem if dofPerCoeff is None : if mat . shape [ 0 ] % len ( ud ) != 0 : print ( mat ) print ( mat . shape , len ( ud ) ) pg . error ( "Matrix size missmatch for vector valued problem" ) else : dofPerCoeff = mat . shape [ 0 ] // len ( ud ) if nCoeff == 1 : nCoeff = len ( ud ) for i in range ( nCoeff ) : if ud [ i ] is not None : ret [ idx + i * dofPerCoeff ] = ud [ i ] else : if nCoeff > 1 : print ( 'nCoeff:' , nCoeff , 'ud:' , ud , 'idx:' , idx ) pg . error ( 'number of coefficents > 1 but u dirichlet is scalar.' ) if ud is not None : ret [ idx ] = ud return ret for pair in boundaryPairs : ent = pair [ 0 ] val = pair [ 1 ] # print('**', ent, val) uD = generateBoundaryValue ( ent , val , time , userData , nCoeff = nCoeff ) # print('\t', uD) if uD is not None : if isinstance ( ent , pg . core . Node ) : uDirVal . update ( _genVecUd ( ent , uD , dofOffset ) ) else : if isinstance ( uD , float ) : pg . critical ( uD ) uD = [ uD ] * ent . nodeCount ( ) if len ( uD ) == ent . nodeCount ( ) : # print('uD', uD, nCoeff, dofPerCoeff) for i , n in enumerate ( ent . nodes ( ) ) : uDirVal . update ( _genVecUd ( n , uD [ i ] , dofOffset , nCoeff = nCoeff , dofPerCoeff = dofPerCoeff ) ) else : pg . error ( 'Dirichlet values per boundary need to have ' 'length of boundary.nodeCount()' ) if nodePairs is not None : #print("nodePairs", nodePairs) if len ( nodePairs ) == 2 and isinstance ( nodePairs [ 0 ] , int ) : # assume a single Node [NodeId, val] nodePairs = [ nodePairs ] for [ n , val ] in nodePairs : uDirVal . update ( _genVecUd ( n , val , dofOffset , nCoeff = nCoeff , dofPerCoeff = dofPerCoeff ) ) return uDirVal