Example #1
0
    def __call__( self, diff_var = None, chunk_size = None, **kwargs ):
        force, virtual = self.get_args( **kwargs )
        ap, vg = virtual.get_approximation( self.get_current_group(), 'Volume' )
        n_el, n_qp, dim, n_ep = ap.get_v_data_shape( self.integral_name )
        vdim = virtual.field.dim[0]
        
        if diff_var is None:
            shape = (chunk_size, 1, vdim * n_ep, 1)
            mode = 0
        else:
            raise StopIteration

        cache = self.get_cache( 'mat_in_qp', 0 )
        mat = fix_scalar_constant( force, nm.float64 )
        if mat is None:
            mat = nm.asarray( force, dtype = nm.float64 )
            if mat.ndim == 1:
                mat = nm.ascontiguousarray( mat[...,nm.newaxis] )
        else:
            try:
                mat = mat[...,nm.newaxis,nm.newaxis]
            except TypeError: # Old numpy...
                mat = nm.array( mat, ndmin = 2 )

        mat_qp = cache( 'matqp', self.get_current_group(), 0,
                       mat = mat, ap = ap,
                       assumed_shapes = [(n_el, n_qp, vdim, 1)],
                       mode_in = None )
#        print mat_qp
        bf = ap.get_base( 'v', 0, self.integral_name )
        for out, chunk in self.char_fun( chunk_size, shape ):
            status = self.function( out, bf, mat_qp, vg, chunk )
            yield out, chunk, status
Example #2
0
    def get_fargs( self, diff_var = None, chunk_size = None, **kwargs ):
        mat, virtual, state = self.get_args( **kwargs )
        ap, vg = virtual.get_approximation( self.get_current_group(), 'Volume' )

        self.set_data_shape( ap )
        shape, mode = self.get_shape( diff_var, chunk_size )

        vec = self.get_vector( state )
        mat_arg = fix_scalar_constant( mat, nm.float64 )
        if mat_arg is None:
            mat_arg = fix_scalar_in_el( mat, self.data_shape[0], nm.float64 )
            self.function = terms.dw_st_pspg_p
        else:
            self.function = terms.dw_laplace

        if state.is_real():
            fargs = vec, 0, mat_arg, vg, ap.econn
        else:
            ac = nm.ascontiguousarray
            fargs = [(ac( vec.real ), 0, mat_arg, vg, ap.econn),
                     (ac( vec.imag ), 0, mat_arg, vg, ap.econn)]
            mode += 1j
            
        return fargs, shape, mode