Beispiel #1
0
def loadP2(p, t, n, f):
    #Compute the matrix with node-edge indices
    emi = msh.edgeIndex(p, t)[1]
    # Sum up the matrix element mass weighted with the T matrices (the conecction)
    return sum(
        map(
            lambda K: (TP2(t, emi, K).transpose().dot(
                elemLoadP2(np.array([p[i - 1] for i in t[K]]), n, f))),
            range(0, len(t))))
Beispiel #2
0
def massP2(p,t):
  #Compute the matrix with node-edge indices
  emi=msh.edgeIndex(p,t)[1]
  # Sum up the matrix element mass weighted with the T matrices (the conecction)
  # in lil_matrix format
  massm=sum(map(lambda K:(TP2(t,emi,K).transpose()
  	.dot(elemMassP2(np.array([p[i-1] for i in t[K]]))))
  .dot(TP2(t,emi,K).toarray()),range(0,len(t))))
  return sparse.lil_matrix(massm)
Beispiel #3
0
def massP2(p, t):
    #Compute the matrix with node-edge indices
    emi = msh.edgeIndex(p, t)[1]
    # Sum up the matrix element mass weighted with the T matrices (the conecction)
    # in lil_matrix format
    massm = sum(
        map(
            lambda K: (TP2(t, emi, K).transpose().dot(
                elemMassP2(np.array([p[i - 1] for i in t[K]])))).dot(
                    TP2(t, emi, K).toarray()), range(0, len(t))))
    return sparse.lil_matrix(massm)
Beispiel #4
0
  # determine actual max. mesh width
  mmw[j] = msh.max_mesh_width(p,t);

  # LINEAR FINITE ELEMENTS
  # Compute the discretized system:
  A_lin = FEM.stiffness(p, t);          # stiffness-matrix
  M_lin = FEM.mass(p, t);               # mass-matrix
  F_lin = FEM.load(p, t, 3, f);         # load-vector

  # Solve the discretized system (A + M)u = F:
  A_lin = A_lin.tocsr();                # conversion from lil to csr format
  M_lin = M_lin.tocsr();
  u_lin = spsolve(A_lin + M_lin, F_lin);

  eIndex = msh.edgeIndex(p,t)
  N = p.shape[0];

  # Computing the discretized system:
  A = FEM.stiffnessP2(p,t,eIndex)
  M = FEM.massP2(p,t,eIndex)
  F = FEM.loadP2(p,t,eIndex,f,3)

  # Solving the discretized system (A + M)u = F:
  A = A.tocsr();
  M = M.tocsr();
  u = spsolve(A + M, F);
  # print np.shape(u), 'N= ', N
  #u = u[0:N];

  # Exact solution of the problem:
Beispiel #5
0
def loadP2(p,t,n,f):
  #Compute the matrix with node-edge indices
  emi=msh.edgeIndex(p,t)[1]
  # Sum up the matrix element mass weighted with the T matrices (the conecction)
  return sum(map(lambda K:(TP2(t,emi,K).transpose()
  	.dot(elemLoadP2(np.array([p[i-1] for i in t[K]]),n,f))),range(0,len(t))))