7(std::map<std::string, std::vector<double>> & vars,
8 std::initializer_list<str>
const & pvarnames,
9 std::initializer_list<str>
const & gvarnames,
11 using strlist = std::initializer_list<str>
const &;
13 (vars, pvarnames, gvarnames, apply_mass, OP);
16template<
typename GT,
typename PT>
19(std::map<std::string, std::vector<double>> & vars,
26 double N = 0.0, xx = 0.0, yy = 0.0;
29 for (std::size_t ivar = 0; ivar < std::size(gvarnames); ++ivar) {
30 auto & gvar = vars[
getkey(gvarnames, ivar)];
31 auto const & dprop =
dprops.at (
getkey(pvarnames, ivar));
35 if (
grd_to_ptcl.count (icell->get_global_cell_idx ()) > 0)
37 ii <
grd_to_ptcl.at (icell->get_global_cell_idx ()).size ();
39 idx =
grd_to_ptcl.at (icell->get_global_cell_idx ())[ii];
43 for (
idx_t inode = 0; inode < 4; ++inode) {
44 N = icell->shp(xx, yy, inode);
46 OP (gvar[icell->gt(inode)],
54 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar)
55 for (
idx_t ii = 0; ii <
M.size (); ++ii) {
56 vars[
getkey(gvarnames, ivar)][ii] /=
M[ii];
64(std::map<std::string, std::vector<double>> & vars,
65 std::initializer_list<str>
const & pxvarnames,
66 std::initializer_list<str>
const & pyvarnames,
67 std::string
const &area,
68 std::initializer_list<str>
const & gvarnames,
70 using strlist = std::initializer_list<str>
const &;
71 p2gd<strlist, strlist>
72 (vars, pxvarnames, pyvarnames, area, gvarnames, apply_mass, OP);
76template<
typename GT,
typename PT>
79(std::map<std::string, std::vector<double>> & vars,
80 PT
const & pxvarnames,
81 PT
const & pyvarnames,
82 std::string
const &area,
87 double xx = 0.0, yy = 0.0, Nx = 0.0, Ny = 0.0;
90 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
91 auto & gvar = vars[
getkey(gvarnames, ivar)];
92 auto const & dpropx =
dprops.at (
getkey(pxvarnames, ivar));
93 auto const & dpropy =
dprops.at (
getkey(pyvarnames, ivar));
94 auto const & dproparea =
dprops.at (area);
98 if (
grd_to_ptcl.count (icell->get_global_cell_idx ()) > 0)
100 ii <
grd_to_ptcl.at (icell->get_global_cell_idx ()).size ();
103 idx =
grd_to_ptcl.at (icell->get_global_cell_idx())[ii];
107 for (
idx_t inode=0; inode<4; ++inode) {
109 Nx = icell->shg (xx, yy, 0, inode);
110 Ny = icell->shg (xx, yy, 1, inode);
113 OP (gvar[icell->gt(inode)],
114 (Nx * dpropx[idx] + Ny * dpropy[idx]) * dproparea[idx]);
122 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar)
123 for (
idx_t ii = 0; ii <
M.size (); ++ii) {
124 vars[
getkey(gvarnames, ivar)][ii] /=
M[ii];
129template<
typename str>
132(
const std::map<std::string, std::vector<double>> & vars,
133 std::initializer_list<str>
const & gvarnames,
134 std::initializer_list<str>
const & pvarnames,
136 using strlist = std::initializer_list<str>
const &;
137 g2p<strlist, strlist> (vars, gvarnames,
138 pvarnames, apply_mass, OP);
141template<
typename GT,
typename PT>
144(
const std::map<std::string, std::vector<double>>& vars,
145 GT
const & gvarnames,
146 PT
const & pvarnames,
150 double N = 0.0, xx = 0.0, yy = 0.0;
153 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
155 auto const & gvar = vars.at (
getkey (gvarnames, ivar));
159 if (
grd_to_ptcl.count (icell->get_global_cell_idx ()) > 0)
161 ii <
grd_to_ptcl.at (icell->get_global_cell_idx ()).size ();
164 idx =
grd_to_ptcl.at(icell->get_global_cell_idx ())[ii];
168 for (
idx_t inode = 0; inode < 4; ++inode) {
170 icell->shp(xx, yy, inode) *
M[icell->gt(inode)] :
171 icell->shp(xx, yy, inode);
173 OP (dprop [idx], N * gvar[icell->gt(inode)]);
180template<
typename str>
183(
const std::map<std::string, std::vector<double>>& vars,
184 std::initializer_list<str>
const & gvarnames,
185 std::initializer_list<str>
const & pxvarnames,
186 std::initializer_list<str>
const & pyvarnames,
188 using strlist = std::initializer_list<str>
const &;
189 g2pd<strlist, strlist> (vars, gvarnames, pxvarnames,
190 pyvarnames, apply_mass, OP);
193template<
typename GT,
typename PT>
196(
const std::map<std::string, std::vector<double>>& vars,
197 GT
const & gvarnames,
198 PT
const & pxvarnames,
199 PT
const & pyvarnames,
203 double Nx = 0.0, Ny = 0.0, xx = 0.0, yy = 0.0;
206 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
212 auto const & gvar = vars.at (
getkey (gvarnames, ivar));
213 if (
grd_to_ptcl.count (icell->get_global_cell_idx ()) > 0)
215 ii <
grd_to_ptcl.at (icell->get_global_cell_idx ()).size ();
218 idx =
grd_to_ptcl.at(icell->get_global_cell_idx ())[ii];
222 for (
idx_t inode = 0; inode < 4; ++inode) {
224 icell->shg(xx, yy, 0, inode) *
M[icell->gt(inode)] :
225 icell->shg(xx, yy, 0, inode);
227 icell->shg(xx, yy, 1, inode) *
M[icell->gt(inode)] :
228 icell->shg(xx, yy, 1, inode);
230 OP (dpropx[idx], Nx * gvar[icell->gt(inode)]);
231 OP (dpropy[idx], Ny * gvar[icell->gt(inode)]);
242particles_t::print<particles_t::output_format::octave_ascii>
243(std::ostream & os)
const;
247particles_t::print<particles_t::output_format::json>
248(std::ostream & os)
const;
252particles_t::print<particles_t::output_format::csv>
253(std::ostream & os)
const;
Definition: quadgrid_cpp.h:15
cell_iterator begin_cell_sweep()
Definition: quadgrid_cpp_imp.h:4
cell_iterator end_cell_sweep()
Definition: quadgrid_cpp.h:308
std::function< double &(double &, const double &)> assignment_t
datatype for assignment operators
Definition: particles.h:14
void p2gd(std::map< std::string, std::vector< double > > &vars, PT const &pxvarnames, PT const &pyvarnames, std::string const &area, GT const &gvarnames, bool apply_mass=false, assignment_t OP=ASSIGNMENT_OPS::PLUS_EQ) const
Definition: particles_imp.h:79
void g2p(const std::map< std::string, std::vector< double > > &vars, bool apply_mass=false, assignment_t OP=ASSIGNMENT_OPS::PLUS_EQ)
Definition: particles.h:331
std::map< idx_t, std::vector< idx_t > > grd_to_ptcl
grid/particles connectivity.
Definition: particles.h:53
void g2pd(const std::map< std::string, std::vector< double > > &vars, GT const &gvarnames, PT const &pxvarnames, PT const &pyvarnames, bool apply_mass=false, assignment_t OP=ASSIGNMENT_OPS::PLUS_EQ)
Definition: particles_imp.h:196
const quadgrid_t< std::vector< double > > & grid
refernce to a grid object.
Definition: particles.h:54
static const std::string & getkey(std::map< std::string, std::vector< double > > const &varnames, std::size_t ivar)
Definition: particles.h:258
std::map< std::string, std::vector< double > > dprops
double type quantities associated with the particles.
Definition: particles.h:50
std::vector< double > x
x coordinate of particle positions.
Definition: particles.h:43
quadgrid_t< std::vector< double > >::idx_t idx_t
datatype for indexing into vectors of properties
Definition: particles.h:40
std::vector< double > y
y coordinate of particle positions.
Definition: particles.h:44
std::vector< double > M
Mass matrix to be used for transfers if required.
Definition: particles.h:52
void p2g(std::map< std::string, std::vector< double > > &vars, bool apply_mass=false) const
Map particle variables to the grid.
Definition: particles.h:283