Hello all,

I am new to libMesh. I am trying to solve a generalized eigen-value problem
for an integral equation. I tried example "Solving a generalized Eigen
Problem" and it works fine.

Next, I modified the assembly routine to have a skeleton like this:

for (const auto & elem : mesh.active_local_element_ptr_range())
    for (const auto & elem_remote : mesh.active_element_ptr_range())

So basically for each local element, I am looping over all the active
elements (local and nonlocal) to assemble the integral equation. I am
pretty confident that I used fe->reinit and other housekeeping stuff
properly.

However, as expected, I encountered the following error from PETSc:

[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: New nonzero at (0,4) caused a malloc

because I didn't augment the sparsity pattern of my matrix.

Next, I added the following lines to suppress the PETSc error:

PetscMatrix<Number> * matrix_A_petsc = dynamic_cast<PetscMatrix<Number>
*>(eigen_system.matrix_A.get());
MatSetOption(matrix_A_petsc->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR,
PETSC_FALSE);

Now my calculation could run to completion, and both the assembled matrix
and the solution are correct.
However, this is undesirable because my "*total number of mallocs used
during MatSetValues calls != 0*" and therefore the assembly process is
unbelievably slow.
I think I have to augment the sparsity correctly to speed up the assembly.

Next, I followed miscellaneous ex9 to augment the sparsity pattern using
the coupling functor. I created a class called AugmentSparsityToDense,
deriving from GhostingFunctor, and its operator() looks like:

void
AugmentSparsityToDense::operator()(const MeshBase::const_element_iterator &
range_begin,
                                   const MeshBase::const_element_iterator &
range_end,
                                   processor_id_type p,
                                   map_type & coupled_elements)
{
  const CouplingMatrix * const null_mat = nullptr;
  for (const auto & elem : as_range(range_begin, range_end))
  {
    coupled_elements.emplace(elem, null_mat);
    for (const auto & elem_remote : as_range(range_begin, range_end))
      coupled_elements.emplace(elem_remote, null_mat);
  }
}

and I attached it to the DofMap using the following lines:

std::shared_ptr<AugmentSparsityToDense> augment_sparsity(new
AugmentSparsityToDense());
eigen_system.get_dof_map().add_coupling_functor(augment_sparsity);

but then I still get the PETSc error:

[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: New nonzero at (0,4) caused a malloc

and when I examine the n_nz and n_oz from DofMap, the sparsity is indeed
not augmented. Can anyone give me some suggestions?

Thanks,
Gary

_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to