48 #if defined (HAVE_CONFIG_H)
81 signed long idx, idy, idz;
94 return (
id <
N - 1 ?
id :
N - 2);
114 bilinear (
const double u11,
const double u21,
const double u12,
115 const double u22,
const double x,
const double y)
117 return (u11 * (1-
x) * (1-y) +
138 return ( (((X.
idx >= 0) && (X.
idx < cols-1)) ||
139 ((X.
idx == cols-1) && (X.
fcx == 0.0))) &&
140 (((X.
idy >= 0) && (X.
idy < rows-1)) ||
141 ((X.
idy == rows-1) && (X.
fcy == 0.0))) );
164 V.x =
bilinear (u(idy, idx), u(idy, idx+1), u(idy+1, idx),
165 u(idy+1, idx+1), fcx, fcy);
166 V.y =
bilinear (v(idy, idx), v(idy, idx+1), v(idy+1, idx),
167 v(idy+1, idx+1), fcx, fcy);
186 const double x =
V.x * tx(idx);
187 const double y =
V.y * ty(idy);
188 const double n = 1.0 / sqrt (
x*
x + y*y);
199 ((
V.x == 0) && (
V.y == 0)));
206 const double zeta,
const double xi,
210 Vector2 V0, V1, S0, X1, Xnxt, S1;
231 X1 =
add2d (X0f, S0);
244 0.5 * (S0.
y + S1.
y)};
245 Xnxt =
add2d (X0f, S);
252 buffer(i, 0) = Xnxt.
x;
253 buffer(i, 1) = Xnxt.
y;
255 if (i + 1 >= maxnverts)
263 trilinear (
const double u111,
const double u211,
const double u121,
264 const double u221,
const double u112,
const double u212,
265 const double u122,
const double u222,
266 const double x,
const double y,
const double z)
268 return (u111 * (1-
x) * (1-y) * (1-z) +
269 u211 *
x * (1-y) * (1-z) +
270 u121 * (1-
x) * y * (1-z) +
271 u221 *
x * y * (1-z) +
272 u112 * (1-
x) * (1-y) * z +
273 u212 *
x * (1-y) * z +
274 u122 * (1-
x) * y * z +
294 return ( (((X.
idx >= 0) && (X.
idx < nx-1)) ||
295 ((X.
idx == nx-1) && (X.
fcx == 0.0))) &&
296 (((X.
idy >= 0) && (X.
idy < ny-1)) ||
297 ((X.
idy == ny-1) && (X.
fcy == 0.0))) &&
298 (((X.
idz >= 0) && (X.
idz < nz-1)) ||
299 ((X.
idz == nz-1) && (X.
fcz == 0.0))) );
318 double fcx, fcy, fcz;
325 V.x =
trilinear (u(idy, idx, idz), u(idy, idx+1, idz),
326 u(idy+1, idx, idz), u(idy+1, idx+1, idz),
327 u(idy, idx, idz+1), u(idy, idx+1, idz+1),
328 u(idy+1, idx, idz+1), u(idy+1, idx+1, idz+1),
330 V.y =
trilinear (v(idy, idx, idz), v(idy, idx+1, idz),
331 v(idy+1, idx, idz), v(idy+1, idx+1, idz),
332 v(idy, idx, idz+1), v(idy, idx+1, idz+1),
333 v(idy+1, idx, idz+1), v(idy+1, idx+1, idz+1),
336 w(idy+1, idx, idz),
w(idy+1, idx+1, idz),
337 w(idy, idx, idz+1),
w(idy, idx+1, idz+1),
338 w(idy+1, idx, idz+1),
w(idy+1, idx+1, idz+1),
356 const double x =
V.x * tx(idx);
357 const double y =
V.y * ty(idy);
358 const double z =
V.z * tz(idz);
359 const double n = 1.0 / sqrt (
x*
x + y*y + z*z);
372 ((
V.x == 0) && (
V.y == 0) && (
V.z == 0)));
379 const double zeta,
const double xi,
const double rho,
383 Vector3 V0, V1, S0, X1, Xnxt, S1;
404 X1 =
add3d (X0f, S0);
419 0.5 * (S0.
z + S1.
z)};
420 Xnxt =
add3d (X0f, S);
427 buffer(i, 0) = Xnxt.
x;
428 buffer(i, 1) = Xnxt.
y;
429 buffer(i, 2) = Xnxt.
z;
431 if (i + 1 >= maxnverts)
443 const int nargin = args.
length ();
447 const Matrix U = args(0).matrix_value ();
448 const Matrix V = args(1).matrix_value ();
449 const RowVector TX = args(2).row_vector_value ();
450 const RowVector TY = args(3).row_vector_value ();
451 const double zeta = args(4).double_value ();
452 const double xi = args(5).double_value ();
453 const double h = args(6).double_value ();
460 Matrix buffer (maxnverts, 2);
462 euler2d (cols, rows, U,
V, TX, TY, zeta,
xi, h, maxnverts,
474 const int nargin = args.
length ();
481 const RowVector TX = args(3).row_vector_value ();
482 const RowVector TY = args(4).row_vector_value ();
483 const RowVector TZ = args(5).row_vector_value ();
484 const double zeta = args(6).double_value ();
485 const double xi = args(7).double_value ();
486 const double rho = args(8).double_value ();
487 const double h = args(9).double_value ();
491 const int ndims = dims.
ndims ();
493 error (
"%s: dimension must be 3", fcn);
496 Matrix buffer (maxnverts, 3);
498 euler3d (dims(1), dims(0), dims(2), U,
V, W, TX, TY, TZ, zeta,
xi, rho,
499 h, maxnverts, buffer, &nverts);
506 DEFUN (__streameuler2d__, args, ,
521 DEFUN (__streameuler3d__, args, ,
octave_idx_type columns(void) const
octave_idx_type rows(void) const
Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type length(void) const
Array< octave_value > array_value(void) const
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Z
F77_RET_T const F77_INT & N
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)
std::complex< T > floor(const std::complex< T > &x)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
static const double xi[33]
static void handle_border(octave_idx_type *id2, double *fc2, const octave_idx_type id1, const double fc1, const octave_idx_type N)
static bool is_in_definition_set2d(const Cell2 X, const octave_idx_type cols, const octave_idx_type rows)
static Cell2 vector_to_cell2d(const Vector2 X)
static octave_value streameuler3d_internal(const octave_value_list &args, const char *fcn)
static void euler3d(const octave_idx_type nx, const octave_idx_type ny, const octave_idx_type nz, const NDArray &u, const NDArray &v, const NDArray &w, const RowVector &tx, const RowVector &ty, const RowVector &tz, const double zeta, const double xi, const double rho, const double h, const octave_idx_type maxnverts, Matrix &buffer, octave_idx_type *nverts)
static Cell3 vector_to_cell3d(const Vector3 X)
static void number_to_fractional(signed long *id, double *fc, const double u)
static bool is_in_definition_set3d(const Cell3 X, const octave_idx_type nx, const octave_idx_type ny, const octave_idx_type nz)
static octave_value streameuler2d_internal(const octave_value_list &args)
static octave_idx_type handle_border_index(const octave_idx_type id, const octave_idx_type N)
static bool is_singular2d(const Vector2 V)
static Vector3 add3d(const Cell3 X, const Vector3 Y)
static Vector2 add2d(const Cell2 X, const Vector2 Y)
static Vector2 vector_interpolation2d(const Cell2 X, const Matrix &u, const Matrix &v, const octave_idx_type cols, const octave_idx_type rows)
static Vector3 vector_interpolation3d(const Cell3 X, const NDArray &u, const NDArray &v, const NDArray &w, const octave_idx_type nx, const octave_idx_type ny, const octave_idx_type nz)
static Vector3 calculate_step_vector3d(const Cell3 X, const Vector3 V, const RowVector &tx, const RowVector &ty, const RowVector &tz, const octave_idx_type nx, const octave_idx_type ny, const octave_idx_type nz, const double h)
static double trilinear(const double u111, const double u211, const double u121, const double u221, const double u112, const double u212, const double u122, const double u222, const double x, const double y, const double z)
static Vector2 calculate_step_vector2d(const Cell2 X, const Vector2 V, const RowVector &tx, const RowVector &ty, const octave_idx_type cols, const octave_idx_type rows, const double h)
static bool is_singular3d(const Vector3 V)
static double bilinear(const double u11, const double u21, const double u12, const double u22, const double x, const double y)
static void euler2d(const octave_idx_type cols, const octave_idx_type rows, const Matrix &u, const Matrix &v, const RowVector &tx, const RowVector &ty, const double zeta, const double xi, const double h, const octave_idx_type maxnverts, Matrix &buffer, octave_idx_type *nverts)