for(int gg = 0;gg!=nbIntegrationPts;gg++) {
double alpha = vol*t_w;
// evalue exact value
double exact_u = uValue(t_coords(NX),t_coords(NY),t_coords(NZ));
// evalue exact hradient
t_exact_grad = gValue(t_coords(NX),t_coords(NY),t_coords(NZ));
// calculate gradient errro
t_error_grad(i) = t_grad(i)-t_exact_grad(i);
// error
double error = pow(t_u-exact_u,2)+t_error_grad(i)*t_error_grad(i);
// iterate over base functions
data.getFieldData()[0] += alpha*error;
++t_w; // move to next integration point
++t_u; // next value of function at integration point
++t_grad; // next gradient at integration point
++t_coords; // next coordinate at integration point
}