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

Why? calculation of integrals using tags from gmsh file fails in a subdomain

0 votes

Hello Fenics Users
So my problem is as follow :
I have a domain (let say a square) and two sub domains (spheres) inside,
I need to calculate the integrals overs theses sub-domains as well as on the boundaries.
I used to generate the mesh file .msh the software 'gmsh', an to convert it to xml files I use the commande line dolfin-convert square.msh square.xml
mesh generation using gmsh

the numbers appearing in the image are physical tags
and here is the part where their assignment in the .geo file is done
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Physical Surface(1) = {1};
Physical Surface(2) = {2};
Physical Surface(3) = {3};

// Mark physical entities
Physical Line(1) = {4};
Physical Line(2) = {3};
Physical Line(3) = {2};
Physical Line(4) = {1};
Physical Line(5) = {15, 13, 12, 16};
Physical Line(6) = {21, 17, 18, 20};
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
now I define the mesh and what's coming with

mesh = Mesh("%s.xml" %(meshfilename))
# define boundary conditions, measure, and outward normals to cells 
boundaries=MeshFunction("size_t",mesh,"%s_facet_region.xml" %(meshfilename))
ds = Measure("ds")[boundaries]  
outnormal = FacetNormal(mesh) # outward normals to cells 

when I do integrals calculations only these tests worked
f=interpolate(Expression('x[0]*x[0]'),V)

assemble(f*ds(1)) 
assemble(f*ds(2)) 
assemble(f*ds(3))
assemble(f*ds(4))

but these in the interior circles give zero ???

assemble(f*ds(5)) 
assemble(f*ds(6)) 
assemble(f*dx(1))
assemble(f*dx(2))
assemble(f*dx(3))

any help would be appreciated, thank you in advance

asked Sep 20, 2016 by Amexsa FEniCS Novice (350 points)

1 Answer

+1 vote

Hi,
did you try to use the measure dS to integrate over internal facets? (see the measure.py file as reference).

answered Sep 21, 2016 by hernan_mella FEniCS Expert (19,460 points)

Hi,
I tried it like this and it worked

ds_int = Measure("dS")[boundaries]

this line enabled me to integrate over internal facets like this

assemble(f*dS(5))
assemble(f*dS(6))

For external facets I still can use

ds = Measure("ds")[boundaries]

until now half of the problem is solved, the rest now is about sub domains, how can I manipulate them, in other words how to :
- define local Finite Element spaces

- assemble local matrices

- define measures

- do integrations over these sub domains.

Could you please just point me into the right direction again?

I think I found an answer for the last questions, obviously I had to use the generated xml file containing physical_region

then we can define measure in the interior domains this way

subdomains = MeshFunction("size_t", mesh,"%s_physical_region.xml" %(meshfilename))
boundaries = MeshFunction("size_t",mesh,"%s_facet_region.xml" %(meshfilename))

ds = Measure("ds")[boundaries]  
outnormal = FacetNormal(mesh) # outward normals to cells
ds_int = Measure("dS")[boundaries]
dx_int = Measure("dx")[subdomains]
...