In [1]:
from SimPEG import Mesh, Utils, Solver
%pylab inline
In [98]:
mesh = Mesh.TensorMesh([50,50])
In [99]:
mesh.plotGrid(faces=True, nodes=True, edges=True)
In [100]:
Div = mesh.faceDiv
mesh.setCellGradBC('dirichlet')
Grad = mesh.cellGrad
sigma = np.ones(mesh.nC)*1e-2
Msig = mesh.getFaceInnerProduct(sigma)
In [107]:
A = -Div*Msig*Grad
q = np.zeros(mesh.nC)
inds = Utils.closestPoints(mesh, [np.r_[0.2, 0.5], np.r_[0.8, 0.5]])
q[inds] = [1., -1.]
In [108]:
Ainv = Solver(A)
sol = Ainv*q
In [109]:
mesh.plotImage(sol)
Out[109]:
In [111]:
mesh.plotImage(Grad*sol, vType='F', view='vec', streamOpts={'color':'w'})
Out[111]:
In [ ]: