1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16+
17+ // clang-format Language: Cpp
18+
1619#pragma once
1720
1821#include " stdexec/__detail/__config.hpp"
2528#include < string_view>
2629#include < memory>
2730#include < vector>
28- #include < string.h >
31+ #include < cstring >
2932
30- #include < math.h >
33+ #include < cmath >
3134
3235#if defined(_NVHPC_CUDA) || defined(__CUDACC__)
3336# define STDEXEC_STDERR
@@ -89,7 +92,7 @@ struct fields_accessor {
8992
9093 float *base_ptr;
9194
92- STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float * get (field_id id) const {
95+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) auto get (field_id id) const -> float * {
9396 return base_ptr + static_cast <int >(id) * cells;
9497 }
9598};
@@ -116,8 +119,15 @@ struct grid_t {
116119 }
117120
118121 [[nodiscard]]
119- fields_accessor accessor () const {
120- return {height / n, width / n, width, height, n, cells, fields_.get ()};
122+ auto accessor () const -> fields_accessor {
123+ return {
124+ .dx = height / n,
125+ .dy = width / n,
126+ .width = width,
127+ .height = height,
128+ .n = n,
129+ .cells = cells,
130+ .base_ptr = fields_.get ()};
121131 }
122132};
123133
@@ -129,7 +139,7 @@ STDEXEC_ATTRIBUTE((host, device)) inline bool
129139 return ((x - object_x) * (x - object_x) + (y - object_y) * (y - object_y) <= os2);
130140}
131141
132- inline float calculate_dt (float dx, float dy) {
142+ inline auto calculate_dt (float dx, float dy) -> float {
133143 const float cfl = 0.3 ;
134144 return cfl * std::min (dx, dy) / C0;
135145}
@@ -177,8 +187,8 @@ struct grid_initializer_t {
177187 }
178188};
179189
180- inline grid_initializer_t grid_initializer (float dt, fields_accessor accessor) {
181- return {dt, accessor};
190+ inline auto grid_initializer (float dt, fields_accessor accessor) -> grid_initializer_t {
191+ return {. dt = dt, . accessor = accessor};
182192}
183193
184194STDEXEC_ATTRIBUTE ((host, device)) inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
@@ -216,7 +226,7 @@ struct h_field_calculator_t {
216226 }
217227};
218228
219- inline h_field_calculator_t update_h (fields_accessor accessor) {
229+ inline auto update_h (fields_accessor accessor) -> h_field_calculator_t {
220230 return {accessor};
221231}
222232
@@ -226,11 +236,11 @@ struct e_field_calculator_t {
226236 fields_accessor accessor;
227237 std::size_t source_position;
228238
229- STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float gaussian_pulse (float t, float t_0, float tau) const {
239+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) auto gaussian_pulse (float t, float t_0, float tau) const -> float {
230240 return exp (-(((t - t_0) / tau) * (t - t_0) / tau));
231241 }
232242
233- STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float calculate_source (float t, float frequency) const {
243+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) auto calculate_source (float t, float frequency) const -> float {
234244 const float tau = 0 .5f / frequency;
235245 const float t_0 = 6 .0f * tau;
236246 return gaussian_pulse (t, t_0, tau);
@@ -264,9 +274,9 @@ struct e_field_calculator_t {
264274 }
265275};
266276
267- inline e_field_calculator_t update_e (float *time, float dt, fields_accessor accessor) {
277+ inline auto update_e (float *time, float dt, fields_accessor accessor) -> e_field_calculator_t {
268278 std::size_t source_position = accessor.n / 2 + (accessor.n * (accessor.n / 2 ));
269- return {dt, time, accessor, source_position};
279+ return {. dt = dt, . time = time, . accessor = accessor, . source_position = source_position};
270280}
271281
272282class result_dumper_t {
@@ -358,7 +368,7 @@ class result_dumper_t {
358368 }
359369};
360370
361- inline result_dumper_t dump_vtk (bool write_results, fields_accessor accessor) {
371+ inline auto dump_vtk (bool write_results, fields_accessor accessor) -> result_dumper_t {
362372 return {write_results, accessor};
363373}
364374
@@ -371,12 +381,12 @@ class time_storage_t {
371381 }
372382
373383 [[nodiscard]]
374- float * get () const {
384+ auto get () const -> float * {
375385 return time_.get ();
376386 }
377387};
378388
379- std::string bin_name (int node_id) {
389+ auto bin_name (int node_id) -> std::string {
380390 return " out_" + std::to_string (node_id) + " .bin" ;
381391}
382392
@@ -418,17 +428,17 @@ void report_performance(
418428 report_performance (cells, iterations, method, elapsed);
419429}
420430
421- bool contains (std::string_view str, char c) {
431+ auto contains (std::string_view str, char c) -> bool {
422432 return str.find (c) != std::string_view::npos;
423433}
424434
425- std::pair<std::string_view, std::string_view> split (std::string_view str, char by = ' =' ) {
435+ auto split (std::string_view str, char by = ' =' ) -> std::pair<std::string_view, std::string_view> {
426436 auto it = str.find (by);
427437 return std::make_pair (str.substr (0 , it), str.substr (it + 1 , str.size () - it - 1 ));
428438}
429439
430440[[nodiscard]]
431- std::map<std::string_view, std::size_t > parse_cmd ( int argc, char *argv[]) {
441+ auto parse_cmd ( int argc, char *argv[]) -> std::map<std::string_view, std::size_t> {
432442 std::map<std::string_view, std::size_t > params;
433443 const std::vector<std::string_view> args (argv + 1 , argv + argc);
434444
@@ -453,10 +463,10 @@ std::map<std::string_view, std::size_t> parse_cmd(int argc, char *argv[]) {
453463}
454464
455465[[nodiscard]]
456- std:: size_t value (
466+ auto value (
457467 const std::map<std::string_view, std::size_t > ¶ms,
458468 std::string_view name,
459- std::size_t default_value = 0 ) {
469+ std::size_t default_value = 0 ) -> std::size_t {
460470 if (params.count (name)) {
461471 return params.at (name);
462472 }
0 commit comments