Dear Wolfgang,
how to do this in distributed parallel mode( to sum up the energy in all 
processors)?
as the vector and matrix has the "compress(...::add)" function,
what about a scalar?

在 2017年9月16日星期六 UTC+8上午12:19:01,Wolfgang Bangerth写道:
>
> On 09/15/2017 08:32 AM, Yiyang Zhang wrote: 
> > For example, consider the sine-Gordon equation, which is in Step-25. 
> > With the help of the DataPostprocessor class, we can output a plot for 
> > the energy density. 
> > But then, how could we calculate the total energy? 
> > 
> > The best scenario would be computing the energy density and total energy 
> > at the same time... 
>
> 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. 
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/c43bc0d6-0f93-437d-925c-2a0bb5ec87ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to