The code is like this:
from dolfin import *
import numpy as np
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
mesh = UnitSquareMesh(mpi_comm_self(),16, 16)
V = FunctionSpace(mesh, "DG", 1)
# Define test and trial functions
v = TestFunction(V)
u = TrialFunction(V)
# Define normal component, mesh size and right-hand side
n = FacetNormal(mesh)
h = CellSize(mesh)
h_avg = (h('+') + h('-'))/2
if(rank==0):
g = Expression('sin(pi*x[0])*sin(pi*x[1])',pi = np.pi )
f = Expression('2*pi*pi*sin(pi*x[0])*sin(pi*x[1])',pi = np.pi)
if(rank==1):
g = Expression('exp(-ll*(x[0]-0.5) )+exp(ll*(x[0]-0.5))',ll=20.0 )
f = Expression('-ll*ll*exp(-ll*(x[0]-0.5))-ll*ll*exp(ll*(x[0]-0.5))',ll=20.0)
alpha = 5.0
gamma = alpha*2
# Define variational problem
The code is as following:
a = dot(grad(v), grad(u))*dx \
- dot(avg(grad(v)), jump(u, n))*dS \
- dot(jump(v, n), avg(grad(u)))*dS \
+ alpha/h_avg*dot(jump(v, n), jump(u, n))*dS \
- dot(grad(v), u*n)*ds \
- dot(v*n, grad(u))*ds \
+ gamma/h*v*u*ds
L = v*f*dx + gamma/h*v*g*ds - dot(grad(v), g*n)*ds
# Compute solution
A = assemble(a)
b = assemble(L)
but when I run : mpirun -np 2 python myprogram.py
there was wrong , I don't know why ? Thanks!