message: fuse DG and CG loops for global restriction assembly
diff: @@ -2065,9 +2065,11 @@ SparseMatrix* FiniteElementSpace::DerefinementMatrix(int old_ndofs,
  MFEM_ASSERT(dtrans.embeddings.Size() == old_elem_dof->Size(), "");
  - if (FEColl()->GetContType() == FiniteElementCollection::DISCONTINUOUS)
  - {
  + bool is_dg = FEColl()->GetContType() == FiniteElementCollection::DISCONTINUOUS;
  + Array<int> mark(R->Height());
  + mark = 0;
  + int num_marked = 0;
  for (int k = 0; k < dtrans.embeddings.Size(); k++)
  {
  const Embedding &emb = dtrans.embeddings[k];
  @@ -2087,49 +2089,16 @@ SparseMatrix* FiniteElementSpace::DerefinementMatrix(int old_ndofs,
  if (!std::isfinite(lR(i, 0))) { continue; }
  int r = DofToVDof(dofs[i], vd);
  + int m = (r >= 0) ? r : (-1 - r);
  lR.GetRow(i, row);
  + if (is_dg || !mark[m])
  + {
  for (int j = 0; j < old_vdofs.Size(); j++)
  {
  R->Set(r, old_vdofs[j], row[j]);
  }
  - }
  - }
  - }
  - }
  - else
  - {
  -
  - Array<int> mark(R->Height());
  - mark = 0;
  -
  - int num_marked = 0;
  - for (int k = 0; k < dtrans.embeddings.Size(); k++)
  - {
  - const Embedding &emb = dtrans.embeddings[k];
  - Geometry::Type geom = mesh->GetElementBaseGeometry(emb.parent);
  - DenseMatrix &lR = localR[geom](emb.matrix);
  -
  - elem_dof->GetRow(emb.parent, dofs);
  - old_elem_dof->GetRow(k, old_dofs);
  -
  - for (int vd = 0; vd < vdim; vd++)
  - {
  - old_dofs.Copy(old_vdofs);
  - DofsToVDofs(vd, old_vdofs, old_ndofs);
  -
  - for (int i = 0; i < lR.Height(); i++)
  - {
  - if (!std::isfinite(lR(i, 0))) { continue; }
  -
  - int r = DofToVDof(dofs[i], vd);
  - int m = (r >= 0) ? r : (-1 - r);
  -
  - if (!mark[m])
  - {
  - lR.GetRow(i, row);
  - R->SetRow(r, old_vdofs, row);
  mark[m] = 1;
  num_marked++;
  }
  @@ -2137,11 +2106,12 @@ SparseMatrix* FiniteElementSpace::DerefinementMatrix(int old_ndofs,
  }
  }
  + if (!is_dg)
  + {
  MFEM_VERIFY(num_marked == R->Height(),
  "internal error: not all rows of R were set.");
  }
  -
  R->Finalize(); // no-op if fixed width
  return R;
  }
  