Yiyang -- it's not easily possible to do it both at the same time
(because DataPostprocessor only creates output, but not do any kind of
integration -- so you are missing some information). But it's easy to do
by hand. For example, for the Laplace equation, you would do something
like this (pseudo-code):
double compute_energy ()
{
FEValues fe_values (...);
std::vector<Tensor<1,dim> > solution_gradients (n_q_points);
double energy = 0;
for (cell=...)
{
fe_values.reinit(cell);
fe_values.get_function_gradients (solution,
solution_gradients);
for (q=0...n_q_points)
energy += solution_gradients[q] * solution_gradients[q] *
fe_values.JxW(q);
}
return energy;
}
Best
W.