Source Code for int2d

Hi everyone,
I’m trying to implement an area integral over specific elements of a mesh. I’m kind of stumped since int2d integrates over the whole mesh. I can’t seem to find the source code for this in the github directory. Is there some way to get this source code?

Alternatively I was thinking about adding the elements to one region and using int2d with that region, but so far, I haven’t found a way to change the region of a single element.

Help would be greatly aprreciated!

Wherever you got the pre-built binaries should have a source code download
option too. If you are stuck on windohs and can’t defenstrate, maybe get cygwin
for some linux like tools.

If you play with this and look at the mesh output the regions are associated with elements
not dofs. The verticies are associated with boundaries although I’m not sure
how that relates to the edges at the end as a corner point is part of two boundaries :slight_smile:

mesh Th=square(5,5);
fespace Vh(Th,P0);
Vh dof;
dof[][14]=1;
Th=change(Th,fregion=(dof>.1)?1:0);
plot(dof,wait=1,fill=1);
for(int i=0; i<4; ++i) dof[][i]=100000;
cout<<" totoal regin  "<<int2d(Th,1)(dof)<<endl;
cout<<" totoal "<<int2d(Th)(dof)<<endl;

dof=region;
plot(dof,wait=1,fill=1);
savemesh(Th,"thmesh.msh");

Hello,

I looks possible to write the int2d as in the following lines of code:

varf Lond(A, w) = int2d(Th)( dx(w)*dx(A) + dy(w)*dy(A) )
	+ int2d(Th)( (Upp+Low)*A*w/lambda^2 ) 		// A/lambda^2, only in SC
	- int2d(Th)( Upp*XU*w )				// X for upper strip
	- int2d(Th)( Low*XL*w )				// X for lower strip
	+ on(OUTER, A = 0);

where XU and XL are constants, A is the vector potential to be solved for, and lambda is a penetration depth in a superconductor. “Upp” is the characteristic function taking the value 1 on a (group of) region(s), 0 elsewhere; and “Low” is the characteristic function taking the value 1 on another (group of) region(s), 0 elsewhere. The may be defined with:

// Define the characteristic function of a first group of regions
func Low=(Th(x,y).region<ne);
// Define the characteristic function of a second group of regions
func Upp=(Th(x,y).region>=ne & Th(x,y).region<2*ne);

where Th is the mesh for the whole system; ne is a region index. In this case, the “Low” group of regions encompasses the regions with indices less than ne; and the “Upp” group of regions encompasses the regions with indices greater or equal to ne.
The 2nd, 3rd and 4th lines of the definition of “Lond” involve int2d over a restricted region.

To find the indices of the regions:
// ------ Define fespace “femp0”
// ------ to allow the definition of “nuReg” taking the value of the index of the region ---------
fespace femp0(Th,P0);
femp0 nuReg=region; // a P0 function to get the region number
// Displays a colour map of the regions
real[int] viso=(0:2*ne+1);
plot(nuReg, wait = true, fill=true, viso=viso, value = true, cmm=“Regions”);

Maybe I don’t get what you’re trying to do, but to me it looks like you’re using the command int2d and the regions have already been defined somewhere else. Therefore I don’t see how this answers my question.

I know the syntax for int2d. The problem I’m having is the fact that I can either use it as int2d(Th)(function), so on the whole mesh, or as int2d(Th, i)(function) where i is a region of the mesh. As far as I could see in the documentation, if I set a region while initialising the mesh, that region is the same for the whole mesh and using the command change would only change the region number for the whole region, not the region number for one element of the mesh.

If it’s unclear what my problem is, please let me know.

Did you try my code/ Characteristic or indicator or phase field there are a lot
of names for making different things but its easy to confuse a region with a dof.
Your integral over single point is pretty simple :slight_smile:

I think it might be helpful, but I’m stuck on how to implenent the whole thing…
I’m trying to calculate the integral over six elements of a function multiplied with the basis function that is one on the vertex which the elements have in common.

so I should be able to run a loop over the elements and change the region of one element per iteration.

What I’m trying to do right now is implement the basis functions for these elements… Is there a shortcut which yields the basis functions phi in freefem? I feel like there should be but I can’t seem to find it.

If I set

mesh Th=square(5,5);
fespace Vh(Th,P1);
Vh u;
u=1;

does u[i] yield the basisfunctions phi_i?

The integral already includes the basis functions but if you want to
add another one I guess you could make a new variable to include
in the integrand and set the dof to 1 at the common vertex ( a delta
function approximation ). Does that help?

so i guess the code above doesn’t really work that way…
delta functions are either 0 or 1, so that would work for P0 elements, don’t I need something like a hat function for P1 elements?

sorry it’s been a long day and i might be a bit slow right now :confused: