Dear community,

I tried to put adaptive_refinement function into separate files. It works 
pretty well without parallel. But I get a link error when using the 
parallel framework, which said:

undefined reference to `void 
dealii::parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number<1,
 dealii::Vector<float>, 1>(dealii::parallel::distributed::Triangulation<1, 1>&, 
dealii::Vector<float> const&, double, double, unsigned int)'

The weird thing is if I do not use this template class, namely use this 
refinement function directly just like step-40, it runs without that link 
error. However, I really want to separate it so that it can be used in 
different cases.

The following is the code. Any suggestions would be appreciated.

   - grid_handler.h header file: 

template <int dim>class GridHandler {
 public:
  static void adaptive_refinement(const DoFHandler<dim> &dof_handler,
                                  const LA::MPI::Vector &solution,
                                  parallel::distributed::Triangulation<dim>
                                  &triangulation);
}


   - grid_handler.cc source file: 

template<int dim>void
GridHandler<dim>::adaptive_refinement(const DoFHandler<dim> &dof_handler,
                                      const LA::MPI::Vector &solution,
                                      parallel::distributed::Triangulation<dim>
                                      &triangulation) {
  Vector<float> estimated_error_per_cell(triangulation.n_active_cells());

  KellyErrorEstimator<dim>::estimate(dof_handler,
                                     
QGauss<dim-1>(dof_handler.get_fe().degree+2),
                                     typename FunctionMap<dim>::type(),
                                     solution,
                                     estimated_error_per_cell);

  // Refine and Coarsen
  
parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number(triangulation,
                                                                         
estimated_error_per_cell,
                                                                         0.3,
                                                                         
0.03);//  GridRefinement::refine_and_coarsen_fixed_number(triangulation,//      
                                            estimated_error_per_cell,//         
                                         0.3,//                                 
                 0.03);
  triangulation.execute_coarsening_and_refinement();
}
// Explicit instantiationstemplate class GridHandler<1>;template class 
GridHandler<2>;template class GridHandler<3>;

Thank you!

Best,

Qing
​

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to