@@ -51,8 +51,7 @@ struct deleter_t {
5151};
5252
5353template <class T >
54- STDEXEC_ATTRIBUTE ((host, device))
55- inline std::unique_ptr<T, deleter_t> allocate_on(bool gpu, std::size_t elements = 1 ) {
54+ STDEXEC_ATTRIBUTE ((host, device)) inline std::unique_ptr<T, deleter_t> allocate_on(bool gpu, std::size_t elements = 1 ) {
5655 T *ptr{};
5756
5857#if defined(_NVHPC_CUDA) || defined(__CUDACC__)
@@ -90,8 +89,7 @@ struct fields_accessor {
9089
9190 float *base_ptr;
9291
93- STDEXEC_ATTRIBUTE ((nodiscard, host, device))
94- float *get (field_id id) const {
92+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float *get (field_id id) const {
9593 return base_ptr + static_cast <int >(id) * cells;
9694 }
9795};
@@ -111,9 +109,10 @@ struct grid_t {
111109 grid_t (std::size_t n, bool gpu)
112110 : n(n)
113111 , cells(n * n)
114- , fields_(allocate_on<float >(
115- gpu,
116- static_cast <std::size_t >(cells) * static_cast <int >(field_id::fields_count))) {
112+ , fields_(
113+ allocate_on<float >(
114+ gpu,
115+ static_cast <std::size_t >(cells) * static_cast <int >(field_id::fields_count))) {
117116 }
118117
119118 [[nodiscard]]
@@ -124,8 +123,8 @@ struct grid_t {
124123
125124constexpr float C0 = 299792458 .0f ; // Speed of light [metres per second]
126125
127- STDEXEC_ATTRIBUTE ((host, device))
128- inline bool is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
126+ STDEXEC_ATTRIBUTE ((host, device)) inline bool
127+ is_circle_part(float x, float y, float object_x, float object_y, float object_size) {
129128 const float os2 = object_size * object_size;
130129 return ((x - object_x) * (x - object_x) + (y - object_y) * (y - object_y) <= os2);
131130}
@@ -139,9 +138,7 @@ struct grid_initializer_t {
139138 float dt;
140139 fields_accessor accessor;
141140
142- STDEXEC_ATTRIBUTE ((host, device))
143- void
144- operator ()(std::size_t cell_id) const {
141+ STDEXEC_ATTRIBUTE ((host, device)) void operator ()(std::size_t cell_id) const {
145142 const std::size_t row = cell_id / accessor.n ;
146143 const std::size_t column = cell_id % accessor.n ;
147144
@@ -184,32 +181,26 @@ inline grid_initializer_t grid_initializer(float dt, fields_accessor accessor) {
184181 return {dt, accessor};
185182}
186183
187- STDEXEC_ATTRIBUTE ((host, device))
188- inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
184+ STDEXEC_ATTRIBUTE ((host, device)) inline std::size_t right_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
189185 return col == N - 1 ? cell_id - (N - 1 ) : cell_id + 1 ;
190186}
191187
192- STDEXEC_ATTRIBUTE ((host, device))
193- inline std::size_t left_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
188+ STDEXEC_ATTRIBUTE ((host, device)) inline std::size_t left_nid(std::size_t cell_id, std::size_t col, std::size_t N) {
194189 return col == 0 ? cell_id + N - 1 : cell_id - 1 ;
195190}
196191
197- STDEXEC_ATTRIBUTE ((host, device))
198- inline std::size_t bottom_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
192+ STDEXEC_ATTRIBUTE ((host, device)) inline std::size_t bottom_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
199193 return row == 0 ? cell_id + N * (N - 1 ) : cell_id - N;
200194}
201195
202- STDEXEC_ATTRIBUTE ((host, device))
203- inline std::size_t top_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
196+ STDEXEC_ATTRIBUTE ((host, device)) inline std::size_t top_nid(std::size_t cell_id, std::size_t row, std::size_t N) {
204197 return row == N - 1 ? cell_id - N * (N - 1 ) : cell_id + N;
205198}
206199
207200struct h_field_calculator_t {
208201 fields_accessor accessor;
209202
210- STDEXEC_ATTRIBUTE ((always_inline, host, device))
211- void
212- operator ()(std::size_t cell_id) const {
203+ STDEXEC_ATTRIBUTE ((always_inline, host, device)) void operator ()(std::size_t cell_id) const {
213204 const std::size_t N = accessor.n ;
214205 const std::size_t column = cell_id % N;
215206 const std::size_t row = cell_id / N;
@@ -235,21 +226,17 @@ struct e_field_calculator_t {
235226 fields_accessor accessor;
236227 std::size_t source_position;
237228
238- STDEXEC_ATTRIBUTE ((nodiscard, host, device))
239- float gaussian_pulse (float t, float t_0, float tau) const {
229+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float gaussian_pulse (float t, float t_0, float tau) const {
240230 return exp (-(((t - t_0) / tau) * (t - t_0) / tau));
241231 }
242232
243- STDEXEC_ATTRIBUTE ((nodiscard, host, device))
244- float calculate_source (float t, float frequency) const {
233+ STDEXEC_ATTRIBUTE ((nodiscard, host, device)) float calculate_source (float t, float frequency) const {
245234 const float tau = 0 .5f / frequency;
246235 const float t_0 = 6 .0f * tau;
247236 return gaussian_pulse (t, t_0, tau);
248237 }
249238
250- STDEXEC_ATTRIBUTE ((always_inline, host, device))
251- void
252- operator ()(std::size_t cell_id) const {
239+ STDEXEC_ATTRIBUTE ((always_inline, host, device)) void operator ()(std::size_t cell_id) const {
253240 const std::size_t N = accessor.n ;
254241 const std::size_t column = cell_id % N;
255242 const std::size_t row = cell_id / N;
@@ -364,8 +351,8 @@ class result_dumper_t {
364351
365352 void operator ()(bool update_time = true ) const {
366353 int rank_ = 0 ;
367- const std::string filename = std::string ( " output_ " ) + std::to_string (rank_) + " _ "
368- + std::to_string (0 ) + " .vtk" ;
354+ const std::string filename =
355+ std::string ( " output_ " ) + std::to_string (rank_) + " _ " + std::to_string (0 ) + " .vtk" ;
369356
370357 write_vtk (filename);
371358 }
0 commit comments