Subject: [UFC-dev] quadrature code generation tests in FFC

From: Kristian Oelgaard <[email-masked]>
Date: Mon, 10 Dec 2007 16:22:17 +0100

Hi,

I've added a test module for quadrature code generation in ffc/src/test.
available from

[email-masked]/hg/ffc-test

The question is if it would fit better in the UFC repository (with some
modifications)

Currently:
The basic idea is to compile the forms in ffc/src/demo using both representations
(the quadrature header will have the name *_quad.h)
Then include these two headers in a main file which is individual for all forms.
The main file will evaluate the tensor on one element (or one exterior/interior 
facet) and compare the values of the tensors with a given tolerance.

The main file only uses the UFC specification (I 'borrowed' and extended the
UFC.h/UFC.cpp data structure from DOLFIN) so it can be compiled with
g++ `pkg-config --cflags ufc-1` (name_form)_main.cpp UFC.cpp

It's quite easy to add more tests because the UFC data structure takes care of
almost everything.

Modifications:
Have a more general setup that would take two forms and compute all tensors (and
all facet combinations too) and compare the values and return the error.

Avoid individual main files.

Any opinions/suggestions?

Kristian

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 11 Dec 2007 15:29:26 +0100

> Any opinions/suggestions?

I've played with the same idea, but havent come around to automate it.
One problem is that numbering isn't always the same, but that should
be possible to handle by sorting values or something.

Take a look at the ufcbenchmark module, it uses the adaptive timing
code I got from Anders to time all integrals of a form on reference
cells, and can return the computed element tensors as well. You could
merge your code with this, or replace it if yours is better. My code
doesn't depend on a mesh, I wrote a reference_cell class to fill in a
standard reference cell of any type.

--
Martin

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 13 Dec 2007 09:22:01 +0100

> standard reference cell of any type.

OK, I might not get around to it this side of Christmas though. Just a few
questions. How is the current ufc_benchmark supposed to work? How do I run the
tests? and should the comparison module be set up in a similar fashion?

I have UFC installed locally and when running setup.py I get the error:

swig -c++ -python ufc_benchmark.i
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.5
copying ufc_benchmark.py -> build/lib.linux-i686-2.5
running build_ext
building '_ufc_benchmark' extension
creating build/temp.linux-i686-2.5
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes
-fPIC -I/usr/include/python2.5 -c ufc_benchmark.cpp -o
build/temp.linux-i686-2.5/ufc_benchmark.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for
Ada/C/ObjC but not for C++
In file included from ufc_benchmark.cpp:16:
ufc_data.h:9:17: error: ufc.h: No such file or directory
ufc_data.h:20: error: expected unqualified-id before ‘&’ token
ufc_data.h:20: error: expected ‘,’ or ‘...’ before ‘&’ token
ufc_data.h:20: error: ISO C++ forbids declaration of ‘parameter’ with no type
ufc_data.h:109: error: ISO C++ forbids declaration of ‘form’ with no type
ufc_data.h:109: error: invalid use of ‘::’

I've added 
-I/home/oelgaard/local/include
to the Makefile (compile module / compile wrapper)

so 'make' produces

swig -c++ -python ufc_benchmark.i
g++ -I/usr/include/python2.5 -I/home/oelgaard/local/include -o
ufc_benchmark_wrap.o -c ufc_benchmark_wrap.cxx
g++ -I/home/oelgaard/local/include -c -o ufc_benchmark.o ufc_benchmark.cpp
g++ -shared -o _ufc_benchmark.so ufc_benchmark_wrap.o ufc_benchmark.o
echo Done.
Done.

what else should be modified?

Kristian
> --
> Martin
> _______________________________________________
> UFC-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufc-dev
>

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Thu, 13 Dec 2007 10:08:58 +0100

2007/12/13, Kristian Oelgaard <[email-masked]>:
> ufc_data.h:20: error: expected unqualified-id before '&' token
> ufc_data.h:20: error: expected ',' or '...' before '&' token
> ufc_data.h:20: error: ISO C++ forbids declaration of 'parameter' with no type
> ufc_data.h:109: error: ISO C++ forbids declaration of 'form' with no type
> ufc_data.h:109: error: invalid use of '::'
>
> I've added

Sorry, I guess I just assumed ufc was in the path. One solution would be to use
FLAGS=`pkg-config ufc-1 --cflags`
in the Makefile to get the include path. I don't think there's anything else?

The make procedure should probably be possible to do in setup.py as
well, but I don't know much about distutils so I used make instead.

--
Martin

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 13 Dec 2007 10:39:02 +0100

Quoting Martin Sandve Alnæs <[email-masked]>:

> > > > Then include these two headers in a main file which is individual for
> all
> > > forms.
> > > > The main file only uses the UFC specification (I 'borrowed' and
> extended
> > > the
> > > > It's quite easy to add more tests because the UFC data structure takes
> care
> > > of
> > > > almost everything.
> > > >
> > > > Modifications:
> > > > Have a more general setup that would take two forms and compute all
> tensors
> > > (and

I removed my modifications to the Makefile and added
include_dirs=["/home/oelgaard/local/include"] as argument to the Extension
object in setup.py.

This will compile and install the files

ufc_benchmark-1.0.0.egg-info
_ufc_benchmark.so
ufc_benchmark.py
ufc_benchmark.pyc

in
~/local/lib/python2.5/site-packages

Is this correct? If so, how do I use the module to run the tests?

Kristian