Region based current definition


I am looking to define a current for certain regions in my mesh in a very similar example to the magnetostatics simulation.

However, the code seems to only produce the current int he thicker parts of my magnet. And not the thinner layers. I suspect that this is because a lot of my nodes are on the border of the magnet and the thin layers don’t have any nodes strictly inside this border.

One can see how the current is non-zero (coloured) int he preview screenshot and compare it to the geometry of the magnet from the GMSH screenshot.

How can I rectify my code so that the region considered is also considering the border so that my thin layers also have a non-zero current?

Paraview picture:

GMSH pictures:

I apologies, but I do not understand you problem,

but some basic remark;

the region is only defined on Tetra in 3d not on vertex.
and to define some data on boundary you have to use label


sorry, I can rephrase my question.

Parts of my mesh are 3D but very thin, such that my 3D mesh has points that are on the boundary, but not inside the region. And then, when I try to define data based on region, none of my points in the thin parts of my mesh have that data defined.

I have tried to define the data using labels using something like Th(x,y,z).label == 3, but I get compile errors. 3 is the tag assigned to one of my physical surfaces, defined in Gmsh.

I hope that clarifies my issue

Sorry, the label works only on integral part and in on part.

Know, even if you have no point inside the mesh3 Th the region exist

take a point (xx,yy,zz) inside a tetra and
int reg=Th(xx,yy,zz).region give the region number and you can use after in 3d integral like in
real volreg=int3d(Th,reg)(1.)