MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sph_to_cart_velocity

Function sph_to_cart_velocity

examples/pde/bhrt.cpp:246–268  ·  view source on GitHub ↗

* @brief Transform the velocity vectors from cartesian to spherical coordinates * * @param vel * @param pos * @return af::array */

Source from the content-addressed store, hash-verified

244 * @return af::array
245 */
246af::array sph_to_cart_velocity(const af::array& vel, const af::array& pos) {
247 if (vel.dims() != pos.dims())
248 throw make_error("Arrays must have the same dimensions");
249 else if (pos.dims()[0] != 3)
250 throw make_error("Arrays must have 3 principal coordintes");
251
252 af::array r = pos(0, af::span);
253 af::array o = pos(1, af::span);
254 af::array p = pos(2, af::span);
255
256 af::array ur = vel(0, af::span);
257 af::array uo = vel(1, af::span);
258 af::array up = vel(2, af::span);
259
260 af::array ux = (ur * af::sin(o) + uo * r * af::cos(o)) * af::cos(p) -
261 up * r * af::sin(o) * af::sin(p);
262 af::array uy = (ur * af::sin(o) + uo * r * af::cos(o)) * af::sin(p) +
263 up * r * af::sin(o) * af::cos(p);
264 af::array uz = ur * af::cos(o) - uo * r * af::sin(o);
265 af::array transformed_vel = af::join(0, ux, uy, uz);
266
267 return transformed_vel;
268}
269
270/**
271 * @brief Transform the position vectors from cartesian to oblate coordinates

Callers 1

generate_imageFunction · 0.85

Calls 5

make_errorFunction · 0.85
sinFunction · 0.85
cosFunction · 0.85
joinFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected