<s> from SimPEG import Mesh , Utils , np , SolverLU <EOL> def run ( plotIt = True ) : <EOL> sz = [ <NUM_LIT> , <NUM_LIT> ] <EOL> tM = Mesh . TensorMesh ( sz ) <EOL> rM = Mesh . CurvilinearMesh ( Utils . meshutils . exampleLrmGrid ( sz , '<STR_LIT>' ) ) <EOL> def DCfun ( mesh , pts ) : <EOL> D = mesh . faceDiv <EOL> G = D . T <EOL> sigma = <NUM_LIT> * np . ones ( mesh . nC ) <EOL> Msigi = mesh . getFaceInnerProduct ( <NUM_LIT:1.> / sigma ) <EOL> MsigI = Utils . sdInv ( Msigi ) <EOL> A = D * MsigI * G <EOL> A [ - <NUM_LIT:1> , - <NUM_LIT:1> ] /= mesh . vol [ - <NUM_LIT:1> ] <EOL> rhs = np . zeros ( mesh . nC ) <EOL> txind = Utils . meshutils . closestPoints ( mesh , pts ) <EOL> rhs [ txind ] = np . r_ [ <NUM_LIT:1> , - <NUM_LIT:1> ] <EOL> return A , rhs <EOL> pts = np . vstack ( ( np . r_ [ <NUM_LIT> , <NUM_LIT:0.5> ] , np . r_ [ <NUM_LIT> , <NUM_LIT:0.5> ] ) ) <EOL> AtM , rhstM = DCfun ( tM , pts ) <EOL> AinvtM = SolverLU ( AtM ) <EOL> phitM = AinvtM * rhstM <EOL> ArM , rhsrM = DCfun ( rM , pts ) <EOL> AinvrM = SolverLU ( ArM ) <EOL> phirM = AinvrM * rhsrM <EOL> if not plotIt : return <EOL> import matplotlib . pyplot as plt <EOL> import matplotlib <EOL> from matplotlib . mlab import griddata <EOL> fig , axes = plt . subplots ( <NUM_LIT:1> , <NUM_LIT:2> , figsize = ( <NUM_LIT:12> * <NUM_LIT> , <NUM_LIT:4> * <NUM_LIT> ) ) <EOL> label = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> opts = { } <EOL> vmin , vmax = phitM . min ( ) , phitM . max ( ) <EOL> dat = tM . plotImage ( phitM , ax = axes [ <NUM_LIT:0> ] , clim = ( vmin , vmax ) , grid = True ) <EOL> Xi = tM . gridCC [ : , <NUM_LIT:0> ] . reshape ( sz [ <NUM_LIT:0> ] , sz [ <NUM_LIT:1> ] , order = '<STR_LIT:F>' ) <EOL> Yi = tM . gridCC [ : , <NUM_LIT:1> ] . reshape ( sz [ <NUM_LIT:0> ] , sz [ <NUM_LIT:1> ] , order = '<STR_LIT:F>' ) <EOL> PHIrM = griddata ( rM . gridCC [ : , <NUM_LIT:0> ] , rM . gridCC [ : , <NUM_LIT:1> ] , phirM , Xi , Yi , interp = '<STR_LIT>' ) <EOL> axes [ <NUM_LIT:1> ] . contourf ( Xi , Yi , PHIrM , <NUM_LIT:100> , vmin = vmin , vmax = vmax ) <EOL> cb = plt . colorbar ( dat [ <NUM_LIT:0> ] , ax = axes [ <NUM_LIT:0> ] ) ; cb . set_label ( "<STR_LIT>" ) <EOL> cb = plt . colorbar ( dat [ <NUM_LIT:0> ] , ax = axes [ <NUM_LIT:1> ] ) ; cb . set_label ( "<STR_LIT>" ) <EOL> tM . plotGrid ( ax = axes [ <NUM_LIT:0> ] , ** opts ) <EOL> axes [ <NUM_LIT:0> ] . set_title ( '<STR_LIT>' ) <EOL> rM . plotGrid ( ax = axes [ <NUM_LIT:1> ] , ** opts ) <EOL> axes [ <NUM_LIT:1> ] . set_title ( '<STR_LIT>' ) <EOL> for i in range ( <NUM_LIT:2> ) : <EOL> axes [ i ] . set_xlim ( <NUM_LIT> , <NUM_LIT> ) <EOL> axes [ i ] . set_ylim ( <NUM_LIT> , <NUM_LIT> ) <EOL> axes [ i ] . text ( <NUM_LIT:0.> , <NUM_LIT:1.0> , label [ i ] , fontsize = <NUM_LIT:20> ) <EOL> if i == <NUM_LIT:0> : <EOL> axes [ i ] . set_ylabel ( "<STR_LIT:y>" ) <EOL> else : <EOL> axes [ i ] . set_ylabel ( "<STR_LIT:U+0020>" ) <EOL> axes [ i ] . set_xlabel ( "<STR_LIT:x>" ) <EOL> plt . show ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> run ( ) </s>
