Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize step-14 #15259

Open
kronbichler opened this issue May 23, 2023 · 0 comments
Open

Modernize step-14 #15259

kronbichler opened this issue May 23, 2023 · 0 comments

Comments

@kronbichler
Copy link
Member

I've been using the step-14 tutorial program for teaching. Working with it, I found several components where I think we have much better solutions now, so we might think about replacing them. Let me list the items I would change:

  • The evaluation of a point value should replace https://github.com/dealii/dealii/blob/69c845d78c33419aa6b1f3037930709ed4ca79da/examples/step-14/step-14.cc#LL130C1-L143C1 by VectorTools::point_value with the comment that there are even more efficient strategies with some GridTools::Cache or RemotePointEvaluation - maybe also directly show VectorTools::point_values().
  • Similarly, for
    void PointXDerivativeEvaluation<dim>::operator()(
    const DoFHandler<dim> &dof_handler,
    const Vector<double> & solution) const
    {
    we should use modern facilities, such as VectorTools::point_gradients().
  • The computation of the right-hand side,
    PointValueEvaluation<dim>::assemble_rhs(const DoFHandler<dim> &dof_handler,
    Vector<double> & rhs) const
    {
    // So, first set everything to zeros...
    rhs.reinit(dof_handler.n_dofs());
    // ...then loop over cells and find the evaluation point among the
    // vertices (or very close to a vertex, which may happen due to floating
    // point round-off):
    for (const auto &cell : dof_handler.active_cell_iterators())
    for (const auto vertex : cell->vertex_indices())
    if (cell->vertex(vertex).distance(evaluation_point) <
    cell->diameter() * 1e-8)
    {
    // Ok, found, so set corresponding entry, and leave function
    // since we are finished:
    rhs(cell->vertex_dof_index(vertex, 0)) = 1;
    return;
    }
    we could use FEPointEvaluation in conjunction with find_active_cell_around_point.

Note that there might be some educational value in the old way, but I think one stumbles over these things so often that one should not teach a way that we would not recommend at all. Besides these rather isolated bullet points, there might be more things to consider, such as computing the interface jumps with mesh_loop or similar facilities, but I do not consider myself enough expert to do that. I would personally do things in yet another way via FEEvaluation/FEFaceEvaluation, but that is a personal flavor that should not guide the tutorial here.

Any other ideas we should collect? Or opinions that some of the things should not be changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant