How can I get the jump in my solution if my solution vector is distributed?

35 views
Skip to first unread message

Abbas

unread,
Apr 20, 2023, 7:07:09 AM4/20/23
to deal.II User Group
I am trying to querry for the jump in  my solution with "get_jump_in_function_values"  . My solution vector is PETSc distributed. When I run a code that's like the one below:

template <int dim>
void output_jumps<dim>::interface_jump()
{

QGauss<dim - 1> face_quadrature_formula(degree + 1);

FEInterfaceValues<dim> fe_iv(fe,
face_quadrature_formula,
UpdateFlags(update_values |
update_gradients |
update_quadrature_points |
update_normal_vectors |
update_JxW_values));

const unsigned int n_face_q_points = face_quadrature_formula.size();

std::vector<Tensor<2, dim>> gradu(n_face_q_points);

typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end();


const FEValuesExtractors::Vector displacements(0);


for (; cell != endc; ++cell)
if (cell->is_locally_owned())
for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
if (cell->face(face)->user_flag_set())
{
// I want to visit the face only once
cell->face(face)->clear_user_flag();

auto cellnb = cell->neighbor(face);
int nface_number = cell->neighbor_face_no(face);

fe_iv.reinit(cell, face, numbers::invalid_unsigned_int, cellnb, nface_number, numbers::invalid_unsigned_int);

// This line breaks running code in parallel
fe_iv[displacements].get_jump_in_function_values(current_solution, jumpu);
}
}

I get the error: 
    "You tried to access element 512 of a distributed vector, but only
    elements in range [0,511] are stored locally and can be accessed."

How can I access the ghost entries to calculate the jump in my solution?

Bruno Turcksin

unread,
Apr 20, 2023, 2:54:44 PM4/20/23
to deal.II User Group
Hello,

You are using a non-ghosted vector. You need to created a ghosted vector and they assign the non-ghosted vector to the ghosted one.

Best,

Bruno

Abbas

unread,
Apr 21, 2023, 4:10:35 AM4/21/23
to deal.II User Group
It works now!!
Thanks

Abbas

Reply all
Reply to author
Forward
0 new messages