This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Using integration scheme depending on element location etc

+2 votes

Dear All

I have seen where to definie additional schemes in quadrature_schemes.py
However, I would like to understand whether the selection
of the scheme can be done on a element by element basis, depending
on where the singularities of the potential are etc.

regards

Moritz

asked Jan 30, 2014 by moritzbraun FEniCS User (1,390 points)

1 Answer

+3 votes
from dolfin import *

mesh = UnitSquareMesh(1,1)
V = FunctionSpace(mesh, 'CG', 2)

cf = CellFunction('size_t', mesh)
cf.set_all(0)
cf[0] = 1 
dx = dx[cf]

u, v = TrialFunction(V), TestFunction(V)
# default rule
a = u*v*dx()
# form with default rule on 0 cells and, vertex rule on 1 cells
b = u*v*dx(0, {"quadrature_rule": "default"}) \
  + u*v*dx(1, {"quadrature_rule": "vertex"})

A, B = assemble(a), assemble(b)
print A.array() - B.array()

# now switch quadrature rules
cf.set_all(1)
cf[0] = 0
# form compilation is not required again
B = assemble(b)
print A.array() - B.array()

Form b uses distinct quadrature rules according to value of cell function cf. Your adaptivity comes into play by setting values of cf according to your needs.

answered Jan 30, 2014 by Jan Blechta FEniCS Expert (51,420 points)

Dear Jan

Thanks a lot
This is very useful advice.
I thus need to add another 4 schemes, depending on whcih corner
of the tet sits on the nucleus and
iterate over the cells and check set the scheme
accordingly

Great

regards

Moritz

...