I'd like to use the C (!) package cubature in a JIT compiled expression. I can't figure out how to do it. The package documentation reads:
The current version of the code can be downloaded from:
cubature-1.0.2.tgz
a gzipped tar file. This unpacks to a directory containing a README file with instructions and a stand-alone hcubature.c or pcubature.c file (along with a couple of private header files) that you can compile and link into your program for h-adaptive and p-adaptive integration, respectively, and a header file cubature.h that you #include.
In my view, the problem is that this package cannot be "installed".
The package compiles and runs when I use either gcc
or cc
. I ran a few tests to see if I can call it from another file and all works well. Here is a minimal example of my problem in FEniCS.
The following python file pyfile.py
runs well except for a warning (see comment at bottom):
from dolfin import *
loc_file = open( "xpr.cpp" , 'r' )
code = loc_file.read()
xpr = Expression( code )
xpr( (2.,2.) )
and the c++ file is xpr.cpp
:
namespace dolfin {
class Xpr : public Expression
{
public:
Xpr() : Expression() { }
void eval(Array<double>& values, const Array<double>& x) const
{
values[0] = 1;
}
};
}
adding the following line to the beginning of xpr.cpp
makes the compilation fail with a long error message.
#include "cubature.h"
I know this is the line I need because this is how I included the package in my tests that didn't involve python and dolfin.
Any help would be greatly appreciated!
UPDATE: I believe what I need to do is give the Expression the option include_dirs = [ "." ]
and place the compiled cubature files in the same library as my code. I can't figure this out (yet).
PS 1: The warning mentioned above is Automatic determination of degree for Expressions has been deprecated in FEniCS version 2016.1.
I'd love to get rid of it if anyone knows how.
PS 2: Why do I want to use this package? I want to calculate an integral of a function over a computatinal domain. Normally, this can be done via FEniCS. However, the function has a singularity on the boundary, so plan on (adaptively) integrating over every cell, and using that to calculate the domain integral. I think this might help other people who may use FEniCS in thee future. Also, I did try to increase the degree of the expression, but to no avail.