Thank you so much! I did all of this and it works now. I had tried the dof 
index before, but I think the output to a vtu file was wrong, so now I have 
fixed that too.

Much appreciated,
Giselle

On Monday, December 18, 2023 at 4:55:25 p.m. UTC-5 Wolfgang Bangerth wrote:

>
> On 12/18/23 13:23, Giselle Sosa Jones wrote:
> > // Initialize vector
> > dof_handler_dg0.distribute_dofs(fe_dg0);
> > const std::vector<IndexSet> locally_owned_dofs_per_proc_dg0 =
> > DoFTools::locally_owned_dofs_per_subdomain(dof_handler_dg0);
> > locally_owned_dofs_dg0 = 
> locally_owned_dofs_per_proc_dg0[this_mpi_process];
> > vec.reinit(locally_owned_dofs_dg0, mpi_communicator);
> > 
> > // Calculate values
> > for (const auto &cell : dof_handler_dg0.active_cell_iterators())
> > {
> > double val;
> > if(cell->subdomain_id() == this_mpi_process)
> > {
> > val = compute_value<dim>(cell);
> >                 vec[cell->active_cell_index()] = val;
> > }
> >        vec.compress(VectorOperation::insert);
> > }
>
> Gisella:
> There are potentially three problems with this code, though I don't know 
> how many of these are actual ones :-)
>
> 1/ You treat the 'vec' vector as one associated with degrees of freedom, 
> but you index into it with an active_cell_index. This isn't right. You 
> need to index into it with the DoF index on this cell. I'm pretty sure 
> this is already going to fix your issue.
>
> 2/ You want to do the vec.compress() call only once after assembly, not 
> once per cell. In fact, I'm surprised this works the way you have it: 
> compress() is a *collective* cell in which all processes must 
> participate (or you will get a deadlock), but different processes will 
> have different numbers of active cells, so they will call this function 
> a different number of times.
>
> 3/ DataOut::add_data_vector() has a discussion that explains the 'type' 
> argument, see
>
> https://dealii.org/developer/doxygen/deal.II/classDataOut__DoFData.html#ac43d3b1f6e67424f36e474627fe8e401
> You may want to read through that and perhaps provide an explicit value 
> for the third argument (if you aren't already).
>
> 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 dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/9f6f852d-db5a-48c8-878f-34781b6fa474n%40googlegroups.com.

Reply via email to