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

Function cart_to_oblate_velocity

examples/pde/bhrt.cpp:366–397  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

364 * @return af::array
365 */
366af::array cart_to_oblate_velocity(const af::array& vel, const af::array& pos) {
367 if (vel.dims() != pos.dims())
368 throw make_error("Arrays must have the same dimensions");
369 else if (pos.dims()[0] != 3)
370 throw make_error("Arrays must have 3 principal coordintes");
371
372 af::array x = pos(0, af::span);
373 af::array y = pos(1, af::span);
374 af::array z = pos(2, af::span);
375
376 auto a = J / M;
377 auto diff = x * x + y * y + z * z - a * a;
378
379 af::array r =
380 af::sqrt((diff + af::sqrt(diff * diff + z * z * a * a * 4.0)) / 2.0);
381 af::array o = af::acos(z / r);
382 af::array p = af::atan2(y, x);
383
384 af::array ux = vel(0, af::span);
385 af::array uy = vel(1, af::span);
386 af::array uz = vel(2, af::span);
387
388 af::array ra = r * r + a * a;
389 af::array ur = ((ux * x + uy * y) * r + uz * ra * z / r) /
390 (r * r + af::pow(a * af::cos(o), 2.0));
391 af::array up = (uy * x - ux * y) / (x * x + y * y);
392 af::array uo = ((ux * x + uy * y) / af::tan(o) - uz * z * af::tan(o)) /
393 (r * r + af::pow(a * af::cos(o), 2.0));
394 af::array transformed_vel = af::join(0, ur, uo, up);
395
396 return transformed_vel;
397}
398
399/**
400 * @brief Transform the position vectors from spherical to cartesian coordinates

Callers 1

Calls 9

make_errorFunction · 0.85
sqrtFunction · 0.85
acosFunction · 0.85
atan2Function · 0.85
powFunction · 0.85
cosFunction · 0.85
tanFunction · 0.85
joinFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected