Hi Jean,

Minor unrelated note to your snippet of manually written L2 norm: have a 
look at 
https://www.dealii.org/developer/doxygen/deal.II/namespaceUtilities_1_1MPI.html 
which has plenty of template wrappers for MPI functions that can make life 
much much easier, including sending objects that can be serialized
(which is not the case here, but still).

> If you think this is not obvious in the documentation, can 
you point out where you looked? It's something easily fixed. (Want to write 
your first pull request? ;-) ) 

+1

Regards,
Denis.

On Saturday, March 2, 2019 at 4:54:46 AM UTC+1, Jean Ragusa wrote:
>
> Hi,
>
> I have a solution vector with locally owned and locally relevant dofs. I 
> want to compute its L2-norm. Using the l2_norm() on it caused a Trilinos 
> error (I was going to compute the squared of the L2 norm, then do an MPI 
> Allreduce on the resulting values).
>
> So, I decided to code it "by hand" as follows: 
>
> double norm_squared = 0.;
> const unsigned int start_ = (dist_solution.local_range().first), end_ = 
> (dist_solution.local_range().second);
>
> for (unsigned int i = start_; i < end_; ++i)
>    norm_squared += std::pow(dist_solution(i),2);
>
> double norm_global =0.;
> MPI_Allreduce(&norm_squared, &norm_global, 1, MPI_DOUBLE, MPI_SUM, 
> mpi_communicator);
> norm_global = std::sqrt(norm_global);
>
>
> Even though this works, I was wondering if there is a better way to do 
> this? 
>
> Cheers,
> --jean
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to