Spatial Co-ordinate of Maximum Value of Variable

Say I have the following code:

int nn = 50;
mesh Th = square(nn, nn);
fespace Vh(Th, P1);
Vh u;
u = sin(x);

I can get the maximum value of ‘u’ by:
real maxValueU = u[].max;

How do I get the values of x and y coordinates where maximum value of ‘u’ occurs?

yes but be careful because the max could be not unique.unc

the method imax give the dof number

int dofmaxValueU = u[].imax;

Now for P1 finite element the dof are vertices with same numbering so

Th(dofmaxValueU).x
Th(dofmaxValueU).y

given the coordinate.