Hi Chenchen

Just so that I understand: are you currently solving the problem using the same 
approach (i.e. distributing the cells, solving the microscopic problem at each 
quadrature point of the cells). You have the solution and now you want to write 
it into a global history vector? 

When you say it can not save any time - what do you mean? You have a very small 
number of processors (4 I think) and the data you are writing looks small. 
Would you expect to see a speed up?

There might be better ways to write multiple chunks of data into a vector than 
what you have suggested (your approach seems a bit low level). Perhaps someone 
can suggest an alternative strategy? A map between the cell user pointer and 
the data you want to store might be a better idea.


A

> 
> Let's simplify the problem as: 
> First, we have a 1-D macro mesh, and at each element (interval) we have 2 
> quadrature points. On each quadrature point, we generate a new Vector, i.e., 
> solution_x. Then, I want to remember this Vector by writing it into 
> local_quadrature_point_history().
> 
> I have written the following code, expecting that we can divide the entire 
> elements into 4 sub_ranges, and write new Vector to 
> local_quadrature_point_history() in parallel. But it turns out that it cannot 
> save any computational time. Can anyone give me any suggestions? Thank you!
> 
> 
> void Step3::Write_problem_on_cell_range (DoFHandler<1>::cell_iterator  
> &range_begin,
> 
>                                                                      
> DoFHandler<1>::cell_iterator  &range_end)
> 
> {
> 
>     const unsigned int   n_q_points  = quadrature_formula_MACRO.size();
> 
>     static Threads::Mutex mutex;
> 
>     Threads::Mutex::ScopedLock lock (mutex);
> 
>     
>     DoFHandler<1>::cell_iterator cell_MACRO = range_begin, endc_MACRO = 
> range_end;
> 
>     for (; cell_MACRO!=endc_MACRO; ++cell_MACRO)
> 
>     {
> 
>         // build history
> 
>         PointHistory<1> *local_quadrature_points_history_MACRO
> 
>         = reinterpret_cast<PointHistory<1> *>(cell_MACRO->user_pointer());
> 
>         
>         // BEGIN RVE problem
> 
>         for (unsigned int q_index = 0; q_index<n_q_points; ++q_index)
> 
>         {
> 
>             solution_x_RVE[0] = 1;    solution_x_RVE[1] = 2;
> 
>             // Write
> 
>             local_quadrature_points_history_MACRO[q_index].solution_x_RVE_h = 
> solution_x_RVE;
> 
>         }
> 
>     }
> 
> }
> 
> 
> 
> void Step3::Write_problem ()
> 
> {
> 
>     static unsigned int n_virtual_cores = MultithreadInfo::n_threads();
> 
>     Threads::ThreadGroup<void> threads;
> 
>     
> std::vector<std::pair<DoFHandler<1>::cell_iterator,DoFHandler<1>::cell_iterator>
>  >
> 
>     sub_ranges =  Threads::split_range 
> <DoFHandler<1>::cell_iterator>(dof_handler_MACRO.begin_active(),
> 
>                                                                       
> dof_handler_MACRO.end(),
> 
>                                                                       
> n_virtual_cores);
> 
>     
>     for (unsigned int t=0; t<n_virtual_cores; ++t)
> 
>         threads += Threads::new_thread (&Step3::Write_problem_on_cell_range, 
> *this,
> 
>                                                               
> sub_ranges[t].first, sub_ranges[t].second);
> 
>     threads.join_all();
> 
> }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Best,
> 
> Chenchen
> 
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> <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] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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.

Reply via email to