```
import ExactSol
from dolfin import *
import sympy as sy
import mshr
n = 2**6
domain = mshr.Rectangle(Point(-1., -1.), Point(1., 1.)) - mshr.Rectangle(Point(0., 0.), Point(1., 1.) )
mesh = mshr.generate_mesh(domain, n)
order = 2
Velocity = VectorFunctionSpace(mesh, "CG", order)
Pressure = FunctionSpace(mesh, "CG", order-1)
Magnetic = FunctionSpace(mesh, "N1curl", order-1)
Lagrange = FunctionSpace(mesh, "CG", order-1)
```

    DEBUG:FFC:Reusing form from cache.
    DEBUG:FFC:Reusing form from cache.
    DEBUG:FFC:Reusing form from cache.
    DEBUG:FFC:Reusing form from cache.



```
u0, p0,b0, r0, Laplacian, Advection, gradPres,CurlCurl, gradR, NS_Couple, M_Couple = ExactSol.MHD2D(1,1, mesh)
# plot(interpolate(u0, Velocity), prefix='Velocity').write_png()
# plot(interpolate(b0, Magnetic), prefix='Magnetic').write_png()
plot(interpolate(p0, Pressure),elevate=0.0, prefix='Pressure').write_png()
plot(interpolate(r0, Lagrange), elevate=0.0, prefix='Lagrange').write_png()
```

    
       >>>>>>>>>>>>>>>>>>>>>>>>>>
         MHD 2D Exact Solution:
       >>>>>>>>>>>>>>>>>>>>>>>>>>
    
     ----------------------
       NS Exact Solution:
     ----------------------
      u = ( exp(x)*sin(y) , exp(x)*cos(y) )
    
      p = ( sin(x)*cos(y) )
    
     ---------------------------
       Maxwell Exact Solution:
     ---------------------------
      b = ( exp(x + y)*cos(x) , exp(x + y)*sin(x) - exp(x + y)*cos(x) )
    
      p = ( x*sin(2*pi*x)*sin(2*pi*y) )
    



```

```


```
plot(interpolate(u0, Velocity))
```




    <dolfin.cpp.io.VTKPlotter; proxy of <Swig Object of type 'std::shared_ptr< dolfin::VTKPlotter > *' at 0x10ee79cf0> >




```

x = symbols('x')
y = symbols('y')
```


```
u = sy.sin(x)*sy.exp(y)
v = sy.cos(y)*sy.exp(x)
p = sy.sin(x)*sy.cos(y)
uu = x*y*sy.cos(x)
b = sy.diff(uu,y)
d = -sy.diff(uu,x)
r = x*sy.sin(2*sy.pi*y)*sy.sin(2*sy.pi*x)
u0 = Expression((sy.ccode(u),sy.ccode(v)))
p0 = Expression(sy.ccode(p))
b0 = Expression((sy.ccode(b),sy.ccode(d)))
r0 = Expression(sy.ccode(r).replace('M_PI','pi'))
```


```
plot(interpolate(u0, Velocity))

```




    <dolfin.cpp.io.VTKPlotter; proxy of <Swig Object of type 'std::shared_ptr< dolfin::VTKPlotter > *' at 0x108b375d0> >



b536cc6a7df1c2f7f7394201233fc8e07ec6dafd
ipynb
Jupyter Notebook
MHD/FEniCS/MHD/Stabilised/SaddlePointForm/Test/SplitMatrix/ScottTest/Lshaped/.ipynb_checkpoints/Untitled3-checkpoint.ipynb
wathen/PhD
35524f40028541a4d611d8c78574e4cf9ddc3278
MIT
2020-10-25T13:30:20.000Z
2021-08-10T21:27:30.000Z
MHD/FEniCS/MHD/Stabilised/SaddlePointForm/Test/SplitMatrix/ScottTest/Lshaped/.ipynb_checkpoints/Untitled3-checkpoint.ipynb
wathen/PhD
35524f40028541a4d611d8c78574e4cf9ddc3278
MIT
MHD/FEniCS/MHD/Stabilised/SaddlePointForm/Test/SplitMatrix/ScottTest/Lshaped/.ipynb_checkpoints/Untitled3-checkpoint.ipynb
wathen/PhD
35524f40028541a4d611d8c78574e4cf9ddc3278
MIT
2019-10-28T16:12:13.000Z
2020-01-13T13:59:44.000Z
Qwen/Qwen-72B
1. YES
2. YES