Dear Boron,

As a new user, I’d like to welcome to the forum and deal.II!

Am I correct that you only see this issue when executing your program in 
parallel? I think that the problem results from the way that you initialise the 
solution vector. That is, this line:

> present_solution.reinit(locally_owned_dofs, mpi_communicator);


This is perfectly fine in many situations. However, in order to compute the 
solution values and gradients at quadrature points in a cell all degrees of 
freedom belonging to that cell must be accessible from the solution vector. 
Since this vector “ present_solution.reinit" does not contain the ghost DoFs, 
there will eventually be a cell that has its DoFs split between processes and 
not all values will be immediately accessible on a process. The way to fix this 
issue would be to initialise an intermediate vector that also holds ghost 
values, copy the distributed solution to the ghosted one, and then proceed with 
all cell-based calculations using the ghosted vector. That would be done 
something like this:

  // At the beginning of assemble_system()
  PETScWrappers::MPI::Vector present_solution_ghosted;
  present_solution_ghosted.reinit(locally_owned_dofs, locally_relevant_dofs , 
mpi_communicator);
  …
  // On a cell
   fe_values.get_function_values(present_solution_ghosted, old_solution);  

A tutorial that shows how to get the locally_relevant_dofs is step-40 
<https://www.dealii.org/9.0.0/doxygen/deal.II/step_40.html>.

I hope that this helps you solve the problem.
Best,
Jean-Paul  

> On 21 Feb 2019, at 11:02, mboron1...@gmail.com wrote:
> 
> Dear all,
> I am Boron. I am a new to DEALII. I am currently trying to write a parallel 
> code in DEALII for solving nonlinear Poisson's equation. The file is also 
> attahed below. My doubt is "How do we pass history variable while 
> constructing the cell_matrix?"
> A code snippet is (Line No 211-225) :
> 
> for (; cell!=endc; ++cell)
>         {
>         if (cell->subdomain_id() == this_mpi_process)
>         {
>             cell_matrix = 0; 
>             cell_rhs = 0;
> 
>             fe_values.reinit (cell);
> 
>             fe_values.get_function_values(present_solution, old_solution);    
>             fe_values.get_function_gradients(present_solution, 
> old_solution_gradients);
>             for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
>             {            
>                 // BUILD ELEMENTAL CELL MATRIX @ EACH GAUSS POINT
>             }
> 
> In the above code snippet, the line 
> 'fe_values.get_function_values(present_solution, old_solution);  ' throws an 
> error. Is there a way to pass only the vectors relevant to the corresponding 
> subdomains in DEALII?
> 
> 
> -- 
> 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 dealii+unsubscr...@googlegroups.com 
> <mailto:dealii+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> <NonLinearPoissonParallel.cc>

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