Code covered by the BSD License  

Highlights from
Biohydrodynamics Toolbox

image thumbnail
from Biohydrodynamics Toolbox by Alexandre Munnier
Tool to simulate easily the motion of moving solids or swimming robots in a potential fluid flow.

Fluid's Boundaries
Fluid's Boundaries
Biohydrodynamics Toolbox    

Fluid's Boundaries


The mathematical model BhT is based on involves only integral equations set on the fluid's boundaries for the computation of the fluid's flow. For short, all of the data required to compute bodies' motions is concentrated along the fluid's boundaries. Neither the fluid nor the solids need to be further described once their boundaries have been properly set up.

Two types of boundaries

Fluid's boundaries encountered in BhT can be divided into two types:
    • The moving solids' boundaries (the solids making up articulated bodies),
    • The fixed boundaries (boundaries of fixed immersed obstacles and the boundary of the tank containing the fluid).
Images/bounded_fish.jpg
Fixed boundaries are all of them described in the same fixed reference frame (the main frame in which the bodies' motion will be computed) whereas moving boundaries are attached to, and described in, moving frames.

Example of a M-File 

Any boundary is described by a M-File. Here is an example of a M-File that defines an ellipse-shaped boundary.
function [y,varargout] = bht_ellipse(t,der,settings)
% This function yields a parameterization for an ellipse.
% 't' is a vector whose elements belong to[0,2*pi[.
% 'settings' is a row vector of 5 elements:
% settings(1:2) are the coordinates of the ellipse's center.
% settings(3) is the semi-major axis' length.
% settings(4) is the semi-minor axis' length.
% settings(5) = 1 (counterclockwise orientation) or -1
% (clockwise orientation).

% Depending on the flag 'der', the
% function returns:

% der = 0: the points' coordinates of the parameterization.
% der = 1: the first derivative of the parameterization.
% der = 2: the second derivative of the parameterization.

% Ellipse's size and position.
x1 = settings(1);
x2 = settings(2);
a = settings(3);
b = settings(5)*settings(4);

% Number of points in the parameterization.
n = length(t);

% Reshape vector t (ensure that t has a row vector form)

t = reshape(t,1,n);


% Compute the points' coordinates
if der == 0
  y = [a*cos(t)+x1; b*sin(t)+x2];
elseif der == 1
  y = [-a*sin(t); b*cos(t)]; % the first derivative
elseif der == 2
  y = [-a*cos(t); -b*sin(t)]; % the second derivative
else
  error('der must be 0,1 or 2')
end
For any boundary, the related M-File must have three input variables:
    • t: it is a vector whose elements belong to [0,2*pi[ (boundaries are always parameterized over [0,2*pi[).
    • der: can be 0,1 or 2. Depending on these values, the function returns either the points' coordinates of the parameterization, either the first derivative or the second derivative of the parameterization. 
    • settings: an array of numbers having the size you wish. In our example, it contains the data for the ellipse's center, the semi-major and semi-minor axis lengths and a flag for the orientation. 
Note: any bounday's parameterization must be at least twice continuously differentiable.
First and second derivatives have to be worked out since their expressions must be included in the M-File. Be aware that BhT is not able to detect errors in these formula. Nonetheless, BhT comes with the function bht_boundary_check, a tool that allows to check if the boundaries are well defined.

Clockwise or counterclockwise orientation?

Whether the parameterization is clockwise or counterclockwise oriented depends on how the fluid is situated with respect to the boundary. A clockwise orientation means that the fluid is contained inside the boundary whereas a counterclockwise orientation corresponds to a solid or a fixed obstacle with the fluid outside.

Center of mass

For any solid's boundary, the origin must coincide with the center of mass of the solid. This constraint is not always simple to satisfy. When it is not, the DAT-File compiler bht_data_compile shifts the parameterization points if necessery and display a warning message in the current workspace. However, this change may affect the structure of the articulated body. The function bht_boundary_chek computes and display the center of mass of the solids.

Examples

BhT comes with some built-in boundary M-Files listed here.

See also

Where do the equations of motion used by BhT come from?
Articulated bodies
Writing a DAT-File
bht_boundary_check
2008 - A. Munnier and B. Pincon (Insitut Elie Cartan and INRIA Lorraine, Projet CORIDA, Nancy, France).       

Contact us at files@mathworks.com