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

Volume of a mesh and subdomains in c++

0 votes

How can I find the volume of a dynamic mesh. I'm try to find the volume of a mesh at different time steps. I've define my UFL file as:

element = FiniteElement("Lagrange", tetrahedron, 3)

v = Coefficient(element)
M = 1*dx

FFC gives the error "*** FFC: Expecting a UFL form file (.ufl)."

asked Jun 16, 2014 by gennadiy FEniCS Novice (590 points)

How do I translate this for use in C++ via a UFL file:

assemble(1*dx(mesh)) # Volume of entire mesh
assemble(1*dx(0, domain=mesh, subdomain_data=cell_function)) # volume of subdomain 0

2 Answers

0 votes
 
Best answer

You could do something like:

a = CellVolume(tetrahedron)

A = a * dx

forms = [A]

Compile that UFL, and then in c++ assemble A into a double to get the total volume.

answered Jun 23, 2014 by Charles FEniCS User (4,220 points)
selected Jul 4, 2014 by gennadiy
0 votes

Hi gennadiy, It seems like the error is indicating that your UFL file didn't have the .ufl extension. Can you post the full file, including the name?

Dave

answered Jun 20, 2014 by david.bernstein FEniCS User (2,000 points)

Hi David,

I managed to compile a UFL file as:

Volume.ufl

v = Constant("tetrahedron")
M = v*dx

Then I can supply the constant v as 1 from the C++ file. If I change the UFL to the below, it doesn't compile:

Volume.ufl

M = 1*dx

It gives the error

Compiling form Volume

Compiler stage 1: Analyzing form(s)

*** FFC: 'NoneType' object has no attribute 'label'
*** FFC: To get more information about this error, rerun FFC with --verbose.

...