fenics team mailing list archive
-
fenics team
-
Mailing list archive
-
Message #00918
Re: Problems with Example Script
Is it possible that your computer is set up with a different MPI
implementation than OpenMPI as default? Try to run
update-alternatives --display mpi
If your default is not OpenMPI you should run
sudo update-alternatives --config mpi
and select it from the list.
Johannes
Hello Johannes,
Yes, that could be the case
$ update-alternatives --display mpi
mpi - auto mode
link currently points to /usr/include/mpich2
/usr/include/mpich2 - priority 40
slave libmpi++.so: /usr/lib/libmpichcxx.so
slave libmpi.so: /usr/lib/libmpich.so
slave mpic++: /usr/bin/mpic++.mpich2
slave mpic++.1.gz: /usr/share/man/man1/mpic++.mpich2.1.gz
slave mpicc: /usr/bin/mpicc.mpich2
slave mpicc.1.gz: /usr/share/man/man1/mpicc.mpich2.1.gz
slave mpicxx: /usr/bin/mpicxx.mpich2
slave mpicxx.1.gz: /usr/share/man/man1/mpicxx.mpich2.1.gz
slave mpif77: /usr/bin/mpif77.mpich2
slave mpif77.1.gz: /usr/share/man/man1/mpif77.mpich2.1.gz
slave mpif90: /usr/bin/mpif90.mpich2
slave mpif90.1.gz: /usr/share/man/man1/mpif90.mpich2.1.gz
/usr/lib/openmpi/include - priority 40
slave libmpi++.so: /usr/lib/openmpi/lib/libmpi_cxx.so
slave libmpi.so: /usr/lib/openmpi/lib/libmpi.so
slave mpiCC: /usr/bin/mpic++.openmpi
slave mpiCC.1.gz: /usr/share/man/man1/mpiCC.openmpi.1.gz
slave mpic++: /usr/bin/mpic++.openmpi
slave mpic++.1.gz: /usr/share/man/man1/mpic++.openmpi.1.gz
slave mpicc: /usr/bin/mpicc.openmpi
slave mpicc.1.gz: /usr/share/man/man1/mpicc.openmpi.1.gz
slave mpicxx: /usr/bin/mpic++.openmpi
slave mpicxx.1.gz: /usr/share/man/man1/mpicxx.openmpi.1.gz
slave mpif77: /usr/bin/mpif77.openmpi
slave mpif77.1.gz: /usr/share/man/man1/mpif77.openmpi.1.gz
slave mpif90: /usr/bin/mpif90.openmpi
slave mpif90.1.gz: /usr/share/man/man1/mpif90.openmpi.1.gz
Current `best' version is /usr/include/mpich2.
So, it looks like I am using mpich2
and then
$ sudo update-alternatives --config mpi
[sudo] password for lorenzo:
There are 2 choices for the alternative mpi (providing /usr/include/mpi).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/include/mpich2 40 auto mode
1 /usr/include/mpich2 40 manual mode
2 /usr/lib/openmpi/include 40 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/openmpi/include to provide
/usr/include/mpi (mpi) in manual mode.
However, when I try the example script, I now get an error
$ python fenics-test.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
File "fenics-test.py", line 6, in <module>
u0 = Expression("1 + x[0]*x[0] + 2*x[1]*x[1]", V=V)
TypeError: __init__() got an unexpected keyword argument 'V'
where fenics_test.py is reported at the end of the email. What is going
wrong? It seems to me that the script below is the exact copy of the
example.
Can anyone help me out?
Many thanks
Lorenzo
########################################
#########################################
##########################################
#fenics_test.py
from dolfin import *
# Create mesh and define function space
mesh = UnitSquare(6, 4)
V = FunctionSpace(mesh, "CG", 1)
# Define boundary conditions
u0 = Expression("1 + x[0]*x[0] + 2*x[1]*x[1]", V=V)
class Boundary(SubDomain): # define the Dirichlet boundary
def inside(self, x, on_boundary):
return on_boundary
u0_boundary = Boundary()
bc = DirichletBC(V, u0, u0_boundary)
# Define variational problem
v = TestFunction(V)
u = TrialFunction(V)
f = Constant(mesh, -6.0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
# Compute solution
problem = VariationalProblem(a, L, bc)
u = problem.solve()
# Plot solution and mesh
plot(u)
plot(mesh)
# Dump solution to file in VTK format
file = File("poisson.pvd")
file << u
# Hold plot
interactive()
References