Esempio n. 1
0
    def _collect_eq_default(self, model, block, dim, blockNumber, tFuncName):
        # model.equations is a list of equation systems

        # equation = copy(model.equations[block.defaultEquation])
        eSystem = model.equations[block.defaultEquation].copy()
        eParam = Params()

        eParam.equation = eSystem
        eParam.equationNumber = block.defaultEquation
        eParam.eRegion = None
        eParam.dim = dim
        eParam.blockNumber = blockNumber
        eParam.funcName = tFuncName.substitute(
            blockNumber=blockNumber, equationNumber=block.defaultEquation)
        eParam.default = True

        eParam.parsedValues = self._get_eq_cpp(eSystem, eParam)
        eParam.original = [e.sent for e in eSystem.eqs]

        logger.debug("parsedValues")
        logger.debug(eParam.parsedValues)

        logger.debug('blockNumber revSp=%s' % str(blockNumber))
        return (eParam)
Esempio n. 2
0
    def _collect_eq_from_region(self, model, eRegion, dim, blockNumber,
                                tFuncName):
        # equation = copy(model.equations[eRegion.equationNumber])
        eParam = Params()
        eSystem = model.equations[eRegion.equationNumber].copy()

        eParam.equation = eSystem
        eParam.equationNumber = eRegion.equationNumber
        eParam.eRegion = eRegion
        eParam.dim = dim
        eParam.blockNumber = blockNumber
        eParam.funcName = tFuncName.substitute(
            blockNumber=blockNumber, equationNumber=eRegion.equationNumber)

        eParam.default = False

        eParam.parsedValues = self._get_eq_cpp(eSystem, eParam)
        eParam.original = [e.sent for e in eSystem.eqs]

        logger.debug("parsedValues")
        logger.debug(eParam.parsedValues)

        logger.debug('blockNumber eqReg=%s' % str(blockNumber))
        return (eParam)
Esempio n. 3
0
    def make_bound_param(self, model, vertex):
        '''Fill this parameters for block bound border
        (vertex in case of 1d)::

        Collect this parameters for template:

             - ``bParams.dim``
             - ``bParams.values`` -- border_values
             - ``bParams.btype``
             - ``bParams.side_num``
             - ``bParams.boundNumber``
             - ``bParams.equationNumber``
             - ``bParams.equation`` -- system of equations
             - ``bParams.funcName``
             - ``bParams.block``
             - ``bParams.blockNumber``
             - ``bParams.boundName`` -- for comment
             - ``bParams.parsedValues``
             - ``bParams.original`` -- for comment

        This parameters also collected for dom:
    
             - ``bound.side``
             - ``bound.blockNumber``
             - ``bParams.funcName``
        '''
        block = vertex.block
        blockNumber = vertex.block.blockNumber

        # for 1d there is only one side:
        side_num = vertex.sides_nums[0]

        # find equation number for side or use default
        equationNum = vertex.equationNumber
        '''
        regsEqNums = [eqReg.equationNumber
                      for eqReg in block.equationRegions
                      if self.test(block, eqReg, side_num)]
        equationNum = (regsEqNums[0] if len(regsEqNums) > 0
                       else block.defaultEquation)
        '''
        eSystem = model.equations[equationNum].copy()

        # find bound region for side or use default
        boundNumber = vertex.boundNumber
        '''
        regionsForSide = [bRegion
                          for k in block.boundRegions
                          for bRegion in block.boundRegions[k]
                          if bRegion.side_num == side_num]
        '''

        # if exist special region for that side
        # if len(regionsForSide) > 0:
        if boundNumber is not None:
            # region = block.boundsRegions[boundNumber]
            # region = regionsForSide[0]
            # boundNumber = region.boundNumber

            bound = model.bounds[boundNumber]

            args = (model, blockNumber, side_num, boundNumber, equationNum)

            # for Dirichlet bound
            if bound.btype == 0:
                func = self.get_func_for_dirichlet(*args)

            # for Neumann bound
            elif bound.btype == 1:
                func = self.get_func_for_neumann(*args)

            funcName = func[0]
            border_values = list(func[1])
            btype = bound.btype
        else:
            # if not, use default

            args = (eSystem, blockNumber, side_num, equationNum)
            func = self.get_func_default(*args)

            funcName = func[0]
            border_values = func[1]
            btype = 1
            boundNumber = -1

        args = (eSystem, model, blockNumber, btype, side_num, border_values)
        parsed = self.parse_equations(*args)
        # print("bound bug debug:")
        # print(parsed)

        # FOR collect template data:
        bParams = Params()
        bParams.dim = model.dimension
        bParams.values = border_values
        bParams.btype = btype
        bParams.side_num = side_num
        bParams.boundNumber = boundNumber
        bParams.equationNumber = equationNum
        bParams.equation = eSystem
        bParams.funcName = funcName
        bParams.block = block
        bParams.blockNumber = blockNumber
        logger.debug("bParams.funcName")
        logger.debug(bParams.funcName)
        logger.debug("bParams.side_num")
        logger.debug(bParams.side_num)
        # in comment
        bParams.boundName = determineNameOfBoundary(side_num)
        bParams.parsedValues = parsed[0]
        bParams.border_values_parsed = parsed[1]
        bParams.original = [e.sent for e in eSystem.eqs]
        # END FOR

        vertex.fm = bParams
        return (bParams)