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

Function oblate_to_cart_velocity

examples/pde/bhrt.cpp:330–357  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

328 * @return af::array
329 */
330af::array oblate_to_cart_velocity(const af::array& vel, const af::array& pos) {
331 if (vel.dims() != pos.dims())
332 throw make_error("Arrays must have the same dimensions");
333 else if (pos.dims()[0] != 3)
334 throw make_error("Arrays must have 3 principal coordintes");
335
336 af::array r = pos(0, af::span);
337 af::array o = pos(1, af::span);
338 af::array p = pos(2, af::span);
339
340 af::array ur = vel(0, af::span);
341 af::array uo = vel(1, af::span);
342 af::array up = vel(2, af::span);
343
344 double a = J / M;
345 af::array ra = af::sqrt(r * r + a * a);
346
347 af::array ux =
348 (ur * r * af::sin(o) / ra + uo * ra * af::cos(o)) * af::cos(p) -
349 up * r * af::sin(o) * af::sin(p);
350 af::array uy =
351 (ur * r * af::sin(o) / ra + uo * ra * af::cos(o)) * af::sin(p) +
352 up * r * af::sin(o) * af::cos(p);
353 af::array uz = ur * af::cos(o) - uo * r * af::sin(o);
354 af::array transformed_vel = af::join(0, ux, uy, uz);
355
356 return transformed_vel;
357}
358
359/**
360 * @brief Transform the velocity vectors from cartesian to oblate coordinates

Callers 1

generate_imageFunction · 0.85

Calls 6

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

Tested by

no test coverage detected