meshworker getting gradient values

20 views
Skip to first unread message

Sudarshan Kumar

unread,
Nov 15, 2016, 4:53:59 PM11/15/16
to deal.II User Group

dim=2

template <int dim>
void Step12<dim>::integrate_cell_term (DoFInfo& dinfo, CellInfo& info)
{
   const FEValuesBase<dim>& fe_v  = info.fe_values();
  
   const std::vector<Tensor<1,dim>>& grad = info.gradients[0][0];

}


When   I call   grad[0][0]   it gives segmentation fault.

Could any one  tell how to access the gradient values?


Help is appreciated.

Thanks a lot

Daniel Arndt

unread,
Nov 16, 2016, 10:33:22 AM11/16/16
to deal.II User Group
Sudarshan,


template <int dim>
void Step12<dim>::integrate_cell_term (DoFInfo& dinfo, CellInfo& info)
{
   const FEValuesBase<dim>& fe_v  = info.fe_values();
   const std::vector<Tensor<1,dim>>& grad = info.gradients[0][0];
}

When   I call   grad[0][0]   it gives segmentation fault.
It seems that you didn't tell your MeshWorker::IntegrationInfoBox object that you want to evaluate gradients of a finite element function on a cell.
To do this, you would use something similar to:

MeshWorker::IntegrationInfoBox<dim> info_box;
const unsigned int n_gauss_points = dof_handler.get_fe().degree+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points, n_gauss_points);
info_box.initialize_update_flags();
dealii::UpdateFlags update_flags = ...
info_box.add_update_flags_all(update_flags);
info_box.cell_selector.add("solution", /*values*/ false, /*gradients*/ true, /*hessians*/ false);

dealii::AnyData src_data ;
src_data.add<const Vector<double> *>(&solution,"solution");
info_box.initialize(fe,mapping,src_data, solution);

If this does not solve your problem, it would be great if you come up with a minimal example showing your problem.

Best,
Daniel

Sudarshan Kumar

unread,
Nov 16, 2016, 10:47:15 AM11/16/16
to deal.II User Group


That  works !  excellent !! .  Thanks  a lot, in  tons.
Reply all
Reply to author
Forward
0 new messages