# Find the lagest function value on the boundary

Hello to all of you FreeFem users,

I want to find the largest value of my PDE solution on the boundary of the domain. I know “u.max” gives the largest value of the u on the mesh, but I don’t know how to modify it to get the largest function value on the boundary of the domain.

Are you looking for something like this?

``````mesh Th = square(10,10);
fespace Vh(Th, P2);
Vh u = x*y;
varf onBoundary(u,v) = on(1, 2, 3, 4, u = 1.0);
real[int] onB = onBoundary(0, Vh, tgv = -1);
u[] .*= onB;
cout << u[].max << endl;
plot(u);
``````

Hello,

To find the largest value of your PDE solution 𝑢u specifically on the boundary of the domain in FreeFem, you can follow these steps:

1. Identify Boundary Elements: Use boundary labels to identify the elements that lie on the boundary.
2. Evaluate Boundary Values: Extract the values of 𝑢u at these boundary elements.
3. Find Maximum: Compute the maximum value among these boundary values.
Thanks

Thanks for your reply! I understand this strategy but I don’t know what is the syntax for them. For example, how to identify the element that lies on the boundary?

Thank you, it works. My understanding of this code is that, when envaluates onBoundary(0,vh, tgv=-1), it returns a vector that is zero on the interior point and is 1 for all boundary points. Therefore, u=u.*onB makes the function value on the interior point to be zero, which stands out from the boundary points. Is that correct understanding? If so I think an addition modification is required if the function value is negative on the boundary. In addition to that, could I ask why tgv is set to be -1 when constructs onB?

Your understanding is correct. No modification is needed if the function value on the boundary is negative. A negative number multiplied by 1 is still negative.

See here for an explanation of `tgv = -1`.