← Back to team overview

dolfin team mailing list archive

Re: [Question #156272]: Computing numerical integral of a function on a cell

 

Question #156272 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/156272

    Status: Open => Answered

Marie Rognes proposed the following answer:

Define a DG0 function space on your mesh, and define a test function v on this function space. (The  DG0 basis functions will be 1 in one of the cells and 0 on all the rest). Assemble the form density*v*dx to yield a vector, where each entry corresponds to the integral of 'density' over a cell. 

In other words

density = ...
DG0 = FunctionSpace(mesh, "DG", 0)
v = TestFunction(DG0)
L = density*v*dx
b = assemble(L)

Could this be what you are looking for?

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.