Ted,
you think of this in a much too complicated way :-)
> Is there a better/more efficient way to calculate the integral( dot
> (grad u, grad r) ) dx?
Yes (an outline, template arguments and other things left to be filled in
as an exercise). Note that r=sqrt((x-a)*(x-a)) and so
grad r = (x-a) / r = (x-a) / sqrt((x-a)*(x-a))
Then:
QGauss quadrature (fe_degree);
FEValues fe_values (fe, quadrature,
update_gradients | update_q_points | update_JxW_values);
vector<Tensor<1,dim> > gradients (quadrature.n_q_points);
double integral = 0;
for (cell=...)
{
fe_values.reinit (cell);
fe_values.get_function_gradients (solution, gradients);
for (q=0; q<n_q_points; ++q)
integral += gradients[q] *
(fe_values.quadrature_point(q) - a) /
fe_values.quadrature_point(q).distance (a) *
fe_values.JxW(q);
}
Does this help?
Best
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.tamu.edu/~bangerth/
_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii