From: Wolfgang Bangerth Date: Wed, 15 Jan 2020 16:18:45 +0000 (-0700) Subject: Simplify description in step-49. X-Git-Tag: v9.2.0-rc1~660^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9335%2Fhead;p=dealii.git Simplify description in step-49. --- diff --git a/examples/step-49/step-49.cc b/examples/step-49/step-49.cc index df07d396f2..fd17e571b7 100644 --- a/examples/step-49/step-49.cc +++ b/examples/step-49/step-49.cc @@ -226,12 +226,17 @@ void grid_4() // and returns a mapped point. In this case, we transform $(x,y) \mapsto // (x,y+\sin(\pi x/5))$. // -// GridTools::transform takes a triangulation and any kind of object that can -// be called like a function as arguments. This function-like argument can be -// the address of a function that takes a point and returns a point, an object -// that has an operator() like the code below, or for example, a -// std::function@(const Point@<2@>)@> object one can -// get as a lambda function. Here we choose the latter option. +// GridTools::transform() takes a triangulation and an argument that +// can be called like a function taking a Point and returning a +// Point. There are different ways of providing such an argument: It +// could be a pointer to a function; it could be an object of a class +// that has an `operator()`; it could be a lambda function; or it +// could be anything that is described via a +// std::function@(const Point@<2@>)@> object. +// +// Decidedly the more modern way is to use a lambda function that +// takes a Point and returns a Point, and that is what we do in the +// following: void grid_5() { Triangulation<2> triangulation; @@ -244,8 +249,8 @@ void grid_5() Point<2>(10.0, 1.0)); GridTools::transform( - [](const Point<2> &in) -> Point<2> { - return {in[0], in[1] + std::sin(numbers::PI * in[0] / 5.0)}; + [](const Point<2> &in) { + return Point<2>(in[0], in[1] + std::sin(numbers::PI * in[0] / 5.0)); }, triangulation); print_mesh_info(triangulation, "grid-5.vtu");