Hi
I want to solve a elasticity problem with changing the constants including the Elasticity modulus (E) and Poisson ratio (nu) in different steps (Lets say in 3 steps). In this case I have 9 combinations of the E and nu. I can solve such problem with a single core in serial. Here is the minimal work:
from dolfin import *
L = 25.
H = 1.
Nx = 250
Ny = 10
mesh = RectangleMesh(Point(0., 0.), Point(L, H), Nx, Ny, "crossed")
rho_g = 1e-3
f = Constant((0,-rho_g))
E = [Constant(1e5) , Constant(2e5),Constant(3e5)]
nu = [Constant(0.15) , Constant(0.3) , Constant(0.45)]
for i in range(3):
for j in range(3):
mu = E[i]/2/(1+nu[j])
lmbda = E[i]*nu[j]/(1+nu[j])/(1-2*nu[j])
def eps(v):
return sym(grad(v))
def sigma(v):
return lmbda * tr(eps(v)) * Identity(2) + 2.0 * mu * eps(v)
V = VectorFunctionSpace(mesh, 'Lagrange', degree=2)
du = TrialFunction(V)
u_ = TestFunction(V)
a = inner(sigma(du), eps(u_)) * dx
l = inner(f, u_) * dx
def left(x, on_boundary):
return near(x[0], 0.)
bc = DirichletBC(V, Constant((0., 0.)), left)
u = Function(V, name="Displacement")
solve(a == l, u, bc)
displacement = File(str(i)+str(j)+".pvd")
displacement << u
Now I want to solve it in parallel to make it faster. With that being said, I want to use 9 cores and solve each combination separately with the assigned core. I have been using FEniCS for 4 years but as I have never used it in parallel (e.g. using MPI) , I could not figure it out. I would appreciate your time helping me with that.