예제 #1
0
def assembleobsop(bc, V, Points):
    """
    Short version of assembleobervationoperator that only assembles the
    observation operator Dr at the receivers
    Inputs:
        bc = boundary condition as assembled by DirichletBC
        V = Function space as assembled by FunctionSpace
        Points = points where observation should be made
    """

    v = TestFunction(V); f = Constant('0'); L = f*v*dx; 
    b = assemble(L); bc.apply(b); 
    # Observation points
    Nr = len(Points)
    Dobs = np.zeros(Nr*b.size(), float) 
    Dobs = Dobs.reshape((Nr, b.size()), order='C')
#    Dobs = lil_matrix((Nr, b.size()), dtype='float')
    ii = 0
    for obs in Points:
        delta = PointSource(V, list2point(obs))
        bs = b.copy(); delta.apply(bs); bs = bs.array()
        Dobs[ii,:] = bs.transpose()
        ii += 1

    return csr_matrix(Dobs)
예제 #2
0
def generate_sources(V, b, Data):
    Bsource = []
    for source in Data['sources']:
            delta = PointSource(V, list2point(source))
            bs = b.copy(); delta.apply(bs); 
            Bsource.append(bs)

    return Bsource