Sorry, I misused the Utilities::MPI::sum() function and thought it might 
not work right at first.
Now I use the Utilities::MPI::sum() function to sum up the energy in all 
processors, is that right? 

在 2019年6月4日星期二 UTC+8上午8:50:25,llf m写道:
>
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/6ad0287d-146a-4422-9736-db82e342eb5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to