## COMSOL Multiphysics Programming Note (I)

15 Apr

fem.equ—contains information about equations on subdomains

fem.bnd—contains information belonging to boundaries

fem.edg—in 3D, this field is related to edges (curves)

fem.pnt—in 2D and 3D, this field corresponds to vertices (points)

fem.ode—specifies ODEs and other scalar equations independent of position

Subdomain groups are defined in the optional field fem.equ.ind. It can be a cell array of numeric vectors or a numeric vector.

fem.equ.ind = { [1 2] [6 3 4] };

Similarly, groupings of boundaries, edges, and vertices can be defined in fem.bnd.ind, fem.edg.ind, and fem.pnt.ind, respectively.

fem.sdim—Space Coordinates sometimes called the independent variables.

fem.sdim = {‘r’ ‘phi’ ‘z’};

Models using a moving mesh require a second set of coordinates to describe the mesh’s motion. The coordinate sets are called frames. To specify two frames, make fem.sdim a cell array of two cell arrays of coordinates, for example, in 2D. One of the frames is the reference frame, the fixed frame where you draw the geometry; the other frame describes the mesh motion.

fem.sdim = {{‘X’ ‘Y’} {‘x’ ‘y’}};

Fem.frame—Frame Names

When there is more than one frame you must give each a name. Do this in the field fem.frame, for example,

fem.frame = {‘ref’ ‘ale’};

fem.sshape—Geometry Shape (first s=space?)

The global coordinates are polynomials in the local element coordinates of a certain degree. This degree, k, can be specified in the field fem.sshape. For instance,

fem.sshape = 2;

gives quadratic shape functions for the global space coordinates. This makes it possible to have curved mesh elements at the boundary and thereby come closer to the true geometric boundary.

fem.mesh = meshinit(fem);
fem.mesh = meshrefine(fem);
meshplot(fem);
fem.mesh = meshinit(fem,’hmax’,0.01); //all mesh-element diameters are less than 0.01

Dependent variables describe the physical quantities that you model.
Independent variables refer to space coordinates.

Finite elements are defined using shape function objects. Their task is to express field variables as linear combinations of certain basis functions (shape functions).

fem.equ.expr = { ‘W’ ‘B*H/2’ ‘div’ ‘ux+vy’ };

defines W = B*H/2, and div = ux+vy on all subdomain groups.

Lagrange interpolation is a special case of Hermite interpolation. In Lagrange interpolation, you obtain shape functions by fitting a curve for the field variables of a problem without concerning its derivatives.