Subject: [Fenics] Problems with Example Script

From: Lorenzo Isella <[email-masked]>
Date: Fri, 14 May 2010 16:06:24 +0200

Dear All,
I have recently installed fenics on my machine (Ubuntu 9.10 amd64 
architecture), following the instructions at

http://www.fenics.org/wiki/Download

However, when I try running the first example script from the excellent 
tutorial

http://www.fenics.org/pub/documents/fenics/tutorial/fenics-tutorial.pdf

which I paste at the end of the email (saved as fenics-test.py), this is 
the output I get

$ python fenics-test.py
Fatal error in MPI_Comm_size: Invalid communicator, error stack:
MPI_Comm_size(111): MPI_Comm_size(comm=0x227101c0, size=0x7fff9ea355ec) 
failed
MPI_Comm_size(69).: Invalid communicator

I am using a multicore machine and it looks like that something related 
to MPI is a problem.
I am not really knowledgeable about parallelization and I am not 
interested (as for now) in running fenics in parallel, but I simply 
would like to be able to play a bit with this example script.
Any help is really appreciated.
Cheers

Lorenzo

####################################################

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()

---

From: Anders Logg <[email-masked]>
Date: Fri, 14 May 2010 17:08:18 +0200

This looks like a problem with your MPI/DOLFIN installation, not the
script itself.

What happens when you write

  python -c "import dolfin"

?

--
Anders

On Fri, May 14, 2010 at 04:06:24PM +0200, Lorenzo Isella wrote:
> However, when I try running the first example script from the
> excellent tutorial
>
> which I paste at the end of the email (saved as fenics-test.py),
> this is the output I get
>
>
> $ python fenics-test.py
> MPI_Comm_size(111): MPI_Comm_size(comm=0x227101c0,
> size=0x7fff9ea355ec) failed
> I am using a multicore machine and it looks like that something
> related to MPI is a problem.
> _______________________________________________
> Mailing list: https://launchpad.net/~fenics
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~fenics
> More help   : https://help.launchpad.net/ListHelp

---

From: Lorenzo Isella <[email-masked]>
Date: Mon, 17 May 2010 09:30:58 +0200

>   python -c "import dolfin"

Hi Anders,
Thanks for helping. Here is the output you wanted

$ python -c "import dolfin"
Fatal error in MPI_Comm_size: Invalid communicator, error stack:
MPI_Comm_size(111): MPI_Comm_size(comm=0xb5d0e1c0, size=0x7fff07719fbc) 
failed
MPI_Comm_size(69).: Invalid communicator

but unfortunately, it still sounds Greek to me.
Any help is really appreciated.
Cheers

Lorenzo

---

From: Anders Logg <[email-masked]>
Date: Mon, 17 May 2010 10:01:30 +0200

On Mon, May 17, 2010 at 09:30:58AM +0200, Lorenzo Isella wrote:
> MPI_Comm_size(111): MPI_Comm_size(comm=0xb5d0e1c0,
> size=0x7fff07719fbc) failed

To me too. Hopefully someone else has an idea what goes wrong.

--
Anders

---

From: Johannes Ring <[email-masked]>
Date: Tue, 18 May 2010 09:23:06 +0200

Hi Lorenzo,

> MPI_Comm_size(69).: Invalid communicator

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

---

From: Lorenzo Isella <[email-masked]>
Date: Tue, 18 May 2010 10:45:32 +0200

> and select it from the list.

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 *

u0_boundary = Boundary()

---

From: Johannes Ring <[email-masked]>
Date: Tue, 18 May 2010 10:57:26 +0200

>  Selection    Path                      Priority   Status

Looks good.

> wrong? It seems to me that the script below is the exact copy of the

I think this script is a bit too old for your copy of DOLFIN (version
0.9.7). I guess the tutorial you posted in your first post, that is

is not the latest copy of the FEniCS tutorial. However, I'm not sure
where to obtain the latest copy. Anyone else?

Johannes

---

From: Johan Hake <[email-masked]>
Date: Tue, 18 May 2010 09:11:21 -0700

> where to obtain the latest copy. Anyone else?

Not sure of this either, but just remove: ", V=V", in the instantiation of the 
Expresssion and you should be fine.

Johan

---

From: Lorenzo Isella <[email-masked]>
Date: Mon, 28 Jun 2010 12:39:57 +0200

Apologies for the tremendous delay but I have been unwell.
After a fresh installation of ubuntu 10.04 and fenics, I still have
troubles in running the script.
Any suggestions?
Cheers

Lorenzo

---

From: Johannes Ring <[email-masked]>
Date: Mon, 28 Jun 2010 13:21:25 +0200

Hi Lorenzo,

> troubles in running the script.

Did you try what Johan was suggesting? You will also need to remove
the "mesh" argument from the call to Constant in line 15.

Johannes

---

From: Lorenzo Isella <[email-masked]>
Date: Mon, 28 Jun 2010 15:05:18 +0200

Hi Johannes,
I had missed that.
Just for the record, the snippet at the end of the email now works as it
is supposed to.
Last question about the example script: did anyone find a more
up-to-date version of the tutorial you can download at

http://www.fenics.org/pub/documents/fenics/tutorial/fenics-tutorial.pdf  ?

Cheers

Lorenzo

##########################################################

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]")

u0_boundary = Boundary()
f = Constant( -6.0)

---

From: Anders Logg <[email-masked]>
Date: Mon, 28 Jun 2010 17:25:28 +0200

> http://www.fenics.org/pub/documents/fenics/tutorial/fenics-tutorial.pdf  ?

I don't think there's an updated tutorial but it will be available in
the "near" future, both as part of the FEniCS book and online in HTML
format.

--
Anders