48#if defined (HAVE_CONFIG_H)
96 return (
id <
N - 1 ?
id :
N - 2);
116bilinear (
const double u11,
const double u21,
const double u12,
117 const double u22,
const double x,
const double y)
119 return (u11 * (1-
x) * (1-y) +
140 return ( (((X.
idx >= 0) && (X.
idx < cols-1)) ||
141 ((X.
idx == cols-1) && (X.
fcx == 0.0))) &&
142 (((X.
idy >= 0) && (X.
idy < rows-1)) ||
143 ((X.
idy == rows-1) && (X.
fcy == 0.0))) );
166 V.x =
bilinear (u(idy, idx), u(idy, idx+1), u(idy+1, idx),
167 u(idy+1, idx+1), fcx, fcy);
168 V.y =
bilinear (v(idy, idx), v(idy, idx+1), v(idy+1, idx),
169 v(idy+1, idx+1), fcx, fcy);
188 const double x =
V.x * tx(idx);
189 const double y =
V.y * ty(idy);
190 const double n = 1.0 / sqrt (
x*
x + y*y);
201 ((
V.x == 0) && (
V.y == 0)));
208 const double zeta,
const double xi,
212 Vector2 V0, V1, S0, X1, Xnxt, S1;
233 X1 =
add2d (X0f, S0);
246 0.5 * (S0.
y + S1.
y)};
247 Xnxt =
add2d (X0f, S);
254 buffer(i, 0) = Xnxt.
x;
255 buffer(i, 1) = Xnxt.
y;
257 if (i + 1 >= maxnverts)
265trilinear (
const double u111,
const double u211,
const double u121,
266 const double u221,
const double u112,
const double u212,
267 const double u122,
const double u222,
268 const double x,
const double y,
const double z)
270 return (u111 * (1-
x) * (1-y) * (1-z) +
271 u211 *
x * (1-y) * (1-z) +
272 u121 * (1-
x) * y * (1-z) +
273 u221 *
x * y * (1-z) +
274 u112 * (1-
x) * (1-y) * z +
275 u212 *
x * (1-y) * z +
276 u122 * (1-
x) * y * z +
296 return ( (((X.
idx >= 0) && (X.
idx < nx-1)) ||
297 ((X.
idx == nx-1) && (X.
fcx == 0.0))) &&
298 (((X.
idy >= 0) && (X.
idy < ny-1)) ||
299 ((X.
idy == ny-1) && (X.
fcy == 0.0))) &&
300 (((X.
idz >= 0) && (X.
idz < nz-1)) ||
301 ((X.
idz == nz-1) && (X.
fcz == 0.0))) );
320 double fcx, fcy, fcz;
327 V.x =
trilinear (u(idy, idx, idz), u(idy, idx+1, idz),
328 u(idy+1, idx, idz), u(idy+1, idx+1, idz),
329 u(idy, idx, idz+1), u(idy, idx+1, idz+1),
330 u(idy+1, idx, idz+1), u(idy+1, idx+1, idz+1),
332 V.y =
trilinear (v(idy, idx, idz), v(idy, idx+1, idz),
333 v(idy+1, idx, idz), v(idy+1, idx+1, idz),
334 v(idy, idx, idz+1), v(idy, idx+1, idz+1),
335 v(idy+1, idx, idz+1), v(idy+1, idx+1, idz+1),
338 w(idy+1, idx, idz),
w(idy+1, idx+1, idz),
339 w(idy, idx, idz+1),
w(idy, idx+1, idz+1),
340 w(idy+1, idx, idz+1),
w(idy+1, idx+1, idz+1),
358 const double x =
V.x * tx(idx);
359 const double y =
V.y * ty(idy);
360 const double z =
V.z * tz(idz);
361 const double n = 1.0 / sqrt (
x*
x + y*y + z*z);
373 ((
V.x == 0) && (
V.y == 0) && (
V.z == 0)));
380 const double zeta,
const double xi,
const double rho,
384 Vector3 V0, V1, S0, X1, Xnxt, S1;
405 X1 =
add3d (X0f, S0);
420 0.5 * (S0.
z + S1.
z)};
421 Xnxt =
add3d (X0f, S);
428 buffer(i, 0) = Xnxt.
x;
429 buffer(i, 1) = Xnxt.
y;
430 buffer(i, 2) = Xnxt.
z;
432 if (i + 1 >= maxnverts)
444 const int nargin = args.
length ();
448 const Matrix U = args(0).matrix_value ();
449 const Matrix V = args(1).matrix_value ();
450 const RowVector TX = args(2).row_vector_value ();
451 const RowVector TY = args(3).row_vector_value ();
452 const double zeta = args(4).double_value ();
453 const double xi = args(5).double_value ();
454 const double h = args(6).double_value ();
461 Matrix buffer (maxnverts, 2);
463 euler2d (cols, rows, U,
V, TX, TY, zeta,
xi, h, maxnverts,
475 const int nargin = args.
length ();
482 const RowVector TX = args(3).row_vector_value ();
483 const RowVector TY = args(4).row_vector_value ();
484 const RowVector TZ = args(5).row_vector_value ();
485 const double zeta = args(6).double_value ();
486 const double xi = args(7).double_value ();
487 const double rho = args(8).double_value ();
488 const double h = args(9).double_value ();
492 const int ndims = dims.
ndims ();
494 error (
"%s: dimension must be 3", fcn);
497 Matrix buffer (maxnverts, 3);
499 euler3d (dims(1), dims(0), dims(2), U,
V, W, TX, TY, TZ, zeta,
xi, rho,
500 h, maxnverts, buffer, &nverts);
507DEFUN (__streameuler2d__, args, ,
522DEFUN (__streameuler3d__, args, ,
octave_idx_type rows(void) const
octave_idx_type columns(void) const
OCTAVE_API 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.
Array< octave_value > array_value(void) const
octave_idx_type length(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 & N
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_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)