Thanks, this looks much prettier! 在 2018年3月27日星期二 UTC-7下午5:04:18,Jean-Paul Pelteret写道: > > Dear Weixiong, > > There’s an interpolation function that should do this for you: > > https://dealii.org/8.5.1/doxygen/deal.II/namespaceVectorTools.html#a5e3af70a47cedfaf361cf5c621e94e3d > The associated interpolation matrix is (I’m pretty sure) built using > > https://dealii.org/8.5.1/doxygen/deal.II/namespaceFETools.html#ab1e885987df913c64885ece9034b5c44 > > I hope this helps. If be interested to know if this gives you the same > result as your hand computation. > > Best, > Jean-Paul > > > On 28 Mar 2018, at 01:10, Weixiong Zheng <zwxn...@gmail.com <javascript:>> > wrote: > > I put my non-smart solution here in case if there's no easy way of doing > it in deal.II and someone else needs it. > > // The vector I want to output is the solution for vector-valued problem. > // I want to output the cell-average value for the 0th component. > Vector<double> modi (solu); > Quadrature<dim> qq(fe.get_unit_support_points()); > FEValues<dim> fv(fe, qq, update_values | update_quadrature_points); > std::vector<bool> selected_dofs (dof_handler.n_dofs()); > > // comp[0] is the 0th component of std::vector<FEValuesExtractors::Scalar> > for the system > DoFTools::extract_dofs(dof_handler, fe.component_mask(comp[0]), > selected_dofs); > std::vector<types::global_dof_index> local_to_global_dof (fe.dofs_per_cell > ); > > > // modify the 0th component > for (typename DoFHandler<dim>::active_cell_iterator > cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) { > fv.reinit(cell); > std::vector<double> local_sol(qq.size()); > fv[comp[0]].get_function_values(solu_out,local_sol); > double avg = std::accumulate(local_sol.begin(), local_sol.end(), 0.) / > local_sol.size(); > cell->get_dof_indices (local_to_global_dof); > for (auto i=0; i<fe.dofs_per_cell; ++i) { > if (selected_dofs[local_to_global_dof[i]]) { > solu_out[local_to_global_dof[i]] = avg; > } > } > } > > > If anyone has any smarter idea, please let me know and thanks in advance. > Weixiong > > 在 2018年3月27日星期二 UTC-7下午2:35:37,Weixiong Zheng写道: >> >> Hi >> >> I am trying to output an cell average solution for a code using DG >> bilinear element in 2D. Is there a trivial way to project DG-1 to DG-0? Or >> is there any function I can call to output the solution at some specfic >> points, say the center point of the cell? >> >> Thanks >> > > -- > 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+un...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > >
-- 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.