Thank you so much, Prof. Bangerth.
On Friday, September 15, 2017 at 11:19:01 AM UTC-5, Wolfgang Bangerth wrote:
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.