quadgrid 0.1
simple cartesian quad grid with particles for c++/octave
Loading...
Searching...
No Matches
particles_imp.h File Reference
#include "counter.h"

Go to the source code of this file.

Classes

class  p2g_helper_t< GVAR_t, PVAR_t, P2C_t >
class  p2gd_helper_t< GVAR_t, PVAR_t, P2C_t, DPROPX_t, DPROPY_t, DPROPAREA_t >
class  g2p_helper_t< GVAR_t, PVAR_t, P2C_t, GRIDM_t >
 Template class for the implementation of the g2p method. More...
class  g2pd_helper_t< GVAR_t, PVAR_t, P2C_t, GRIDM_t >
 Template class for the implementation g2pd method. More...
class  particles_t::update_ptcl_to_grd_host

Functions

template<>
void particles_t::print< particles_t::output_format::octave_ascii > (std::ostream &os) const
template<>
void particles_t::print< particles_t::output_format::json > (std::ostream &os) const
template<>
void particles_t::print< particles_t::output_format::csv > (std::ostream &os) const

Function Documentation

◆ particles_t::print< particles_t::output_format::csv >()

template<>
void particles_t::print< particles_t::output_format::csv > ( std::ostream & os) const

Definition at line 228 of file particles.cpp.

229 {
230
231 os << "\"x\", " << "\"y\"";
232
233 for (auto const & ii : dprops)
234 os << ", \"" << ii.first << "\"";
235
236 for (auto const & ii : iprops)
237 os << ", \"" << ii.first << "\"";
238
239 os << std::endl;
240
241
242 for (idx_t jj = 0; jj < x.size (); ++jj) {
243
244 os << x[jj] << ", " << y[jj];
245
246 for (auto const & ii : dprops)
247 os << ", " << std::setprecision (16) << ii.second[jj];
248
249 for (auto const & ii : iprops)
250 os << ", " << ii.second[jj];
251
252 os << std::endl;
253 }
254}

◆ particles_t::print< particles_t::output_format::json >()

template<>
void particles_t::print< particles_t::output_format::json > ( std::ostream & os) const

Definition at line 221 of file particles.cpp.

222 {
223 nlohmann::json j = *this;
224 os << j;
225}

◆ particles_t::print< particles_t::output_format::octave_ascii >()

template<>
void particles_t::print< particles_t::output_format::octave_ascii > ( std::ostream & os) const

Definition at line 257 of file particles.cpp.

259 {
260
261 os << "# name: x" << std::endl
262 << "# type: matrix" << std::endl
263 << "# rows: 1" << std::endl
264 << "# columns: " << x.size () << std::endl;
265 for (auto const & kk : x) {
266 os << std::setprecision(16) << kk << " ";
267 }
268 os << std::endl;
269
270 os << "# name: y" << std::endl
271 << "# type: matrix" << std::endl
272 << "# rows: 1" << std::endl
273 << "# columns: " << y.size () << std::endl;
274 for (auto const & kk : y) {
275 os << std::setprecision(16) << kk << " ";
276 }
277 os << std::endl;
278
279 os << "# name: dprops" << std::endl
280 << "# type: scalar struct" << std::endl
281 << "# ndims: 2" << std::endl
282 << "1 1" << std::endl
283 << "# length: " << dprops.size () << std::endl;
284
285
286 for (auto const & ii : dprops) {
287 os << "# name: " << ii.first << std::endl
288 << "# type: matrix" << std::endl
289 << "# rows: 1" << std::endl
290 << "# columns: " << ii.second.size () << std::endl;
291 for (auto const & kk : ii.second) {
292 os << std::setprecision(16) << kk << " ";
293 }
294 os << std::endl;
295 }
296 os << std::endl;
297
298 os << "# name: iprops" << std::endl
299 << "# type: scalar struct" << std::endl
300 << "# ndims: 2" << std::endl
301 << "1 1" << std::endl
302 << "# length: " << iprops.size () << std::endl;
303
304 for (auto const & ii : iprops) {
305 os << "# name: " << ii.first << std::endl
306 << "# type: int64 matrix" << std::endl
307 << "# ndims: 2" << std::endl
308 << "1 " << ii.second.size () << std::endl;
309 for (auto const & kk : ii.second) {
310 os << kk << " ";
311 }
312 os << std::endl;
313 }
314 os << std::endl;
315}