Problem with AffineConstraints for periodicity and MeshWorker in parallel

40 views
Skip to first unread message

Praveen C

unread,
May 4, 2024, 3:03:21 AM5/4/24
to Deal. II Googlegroup
Hello

In a 2d problem with all periodic bc, I was able to use WorkStream for assembly.

But when I switch to MeshWorker, I get error about constraints (when running in parallel, serial is ok)

An error occurred in line <2248> of file </Users/praveen/Applications/deal.II/9.5.1/install/include/deal.II/lac/affine_constraints.h> in function

    types::global_dof_index dealii::AffineConstraints<>::calculate_line_index(const size_type) const [number = double]

The violated condition was: 

    local_lines.is_element(line_n)

Additional information: 

    The index set given to this constraints object indicates constraints

    for degree of freedom 0 should not be stored by this object, but a

    constraint is being added.


Everything is same, cell worker, copier are same for both WorkStream and MeshWorker, so I cannot see why only MeshWorker gives this problem.


Here is how I setup my constraints


  // Setup affine constraints

  constraints.clear();

  constraints.reinit(locally_relevant_dofs);

  setup_periodic_constraints();

  constraints.close();


//------------------------------------------------------------------------------

template <int dim>

void

CGSEM<dim>::setup_periodic_constraints()

{

  if(parameters.periodic_x == true ||

     parameters.periodic_y == true ||

     parameters.periodic_z == true)

  {

    pcout << "Setup periodic constraints ...\n";

  }

  else

  {

    return;

  }


  typedef typename DoFHandler<dim>::cell_iterator Iter;

  std::vector<GridTools::PeriodicFacePair<Iter>> periodicity_vector;


  // Periodic along x

  if(parameters.periodic_x == true)

    GridTools::collect_periodic_faces(dof_handler,

                                      0,

                                      1,

                                      0,

                                      periodicity_vector);


  // Periodic along y

  if(parameters.periodic_y == true)

    GridTools::collect_periodic_faces(dof_handler,

                                      2,

                                      3,

                                      1,

                                      periodicity_vector);

  // Periodic along z

  if(dim == 3 && parameters.periodic_z == true)

    GridTools::collect_periodic_faces(dof_handler,

                                      4,

                                      5,

                                      2,

                                      periodicity_vector);


  DoFTools::make_periodicity_constraints<dim, dim>(periodicity_vector, constraints);

}


Thanks

praveen


Praveen C

unread,
May 4, 2024, 3:57:04 AM5/4/24
to Deal. II Googlegroup
I am sorry about this post, it was a bug in my code.

I was doing this

MeshWorker::mesh_loop(
  dof_handler.begin_active(),
  dof_handler.end(),
  cell_assembler,
  std::bind(&CGSEM<dim>::copy_local_to_global,this,std::placeholders::_1),
  scratch_data,
  task_data,
  MeshWorker::assemble_own_cells);

which was calling copier on all cells. Using a filtered range on locally owned cells fixed the problem.

Thanks
praveen
Reply all
Reply to author
Forward
0 new messages