NSASM is a library of C routines which carry out the finite element assembly of the jacobian matrix used in a Newton iteration to solve the steady state incompressible Navier Stokes equations in a 2D region.
The finite element approximation uses the P2-P1 triangular element, also known as the Taylor-Hood element. The velocities are approximated quadratically, and the pressures linearly.
The sparse matrix format used is known as the compressed column format, in which the nonzero entries and their row indices are stored in order by columns.
The software assumes that a suitable mesh has been set up for the region, with arrays P and T defining that mesh, that an array defining the boundary constraints has been set up, and that an initial estimate of the flow has been made available.
The software is designed to be called, via MATLAB's MEX facility, with the linear system solved by SUPER_LU. Thus, the Newton iteration could have the following form:
for ii = 1 : 8
[ K, L ] = nsasm ( p, t, np0, e, u, mu );
du = - lusolve ( K, L );
u = u + du;
disp ( sprintf ( '%20.10g %20.10g', norm ( L, inf ), norm ( du, inf ) ) );
end
The software makes some particular assumptions about the numbering of nodes, variables, and local element nodes
(Indexing of nodes) It is assumed that the mesh was generated by starting with a set of nodes, triangulating them, and then computing the midsides of the triangles and adding these midsides to the list of nodes. In particular, the program therefore assumes that the numbering of the nodes reflects this process, so that all vertex nodes are numbered first, followed by the midside nodes.
(Indexing of global variables) It is assumed that every node has an associated horizontal velocity variable "U", that every node has an associated vertical velocity variable "V", and that only vertex nodes or "pressure nodes" have an associated pressure variable "P". The variables are stored in a single vector, first all the U's, then all the V's, then the P's. Thus variable 1 is the value of U at node 1, variable NP+1 is the value of V at node 1, and variable 2*NP+1 is the value of P at node 1.
Notice that there are even more global variables than you might think, since the boundary conditions and other constraints are handled by adding a Lagrange multiplier for each one. Thus the number of variables is actually 2*NP+NP0+NE.
(Numerical codes for U,V,P) In the E vector used to define constraints, the numeric codes 0, 1 and 2 are used for U, V and P variables respectively.
(Local numbering of nodes) When listing the 6 nodes that make up a triangle, the ordering should be as follows:
N3
|\
| \
| \
N5 N4
| \
| \
| \
N1--N6--N2
Pay attention! I haven't seen anyone else who follows this
peculiar convention.
[ K, L ] = nsasm ( p, t, np0, e, u, mu );
BUMP is an executable FORTRAN90 program which solves a fluid flow problem in a channel including a bump which obstructs and redirects the flow.
DIRECTION_ARROWS_GRID is a MATLAB program which reads files of node and velocity data, and, using interpolation, creates a velocity direction plot with arrows place on a uniform grid of the user's specification.
DISTMESH is a MATLAB program which computes an unstructured mesh.
FEM1D, is an executable FORTRAN77 program which applies the finite element method, with piecewise linear basis functions, to a two point boundary value problem;
FREE_FEM_NAVIER_STOKES is a MATLAB program for solving the steady incompressible Navier Stokes equations on an arbitrary triangulated region, using the finite element method.
MATLAB_C contains some demonstrations of how a MATLAB procedure can invoke an underlying C function.
SPARSE describes MATLAB's sparse function, which can be used to define or access a sparse matrix.
SUPERLU is a library of C routines which can carry out a fast direct solution of large sparse linear systems.
VECTOR_PLOT is an executable FORTRAN90 program that can plot the velocity field and the velocity direction field.
VECTOR_STREAM_GRID is a MATLAB program which reads node and vector data from a file, computes an interpolatory function, evaluates on a uniform grid of points specified by the user, and displays a streamline plot of the vector field.
VELOCITY_ARROWS. is a MATLAB program that can plot the velocity field.
VELOCITY_ARROWS_GRID is a MATLAB program which reads files of node and velocity data, and, using interpolation, creates a vector plot with arrows place on a uniform grid of the user's specification.
Per-Olof Persson, whose web site is: http://math.mit.edu/~persson/.
NSASM_INTERFACE is a MATLAB script that reads a set of point, element, and constraint files, and calls NSASM to determine the stiffness matrix and right hand side.
The BIG test defines a relatively large sparse matrix, with 2049 nodes, 960 elements, 1287 constraints, NP0 = 545, MU = 500.
The SMALL test defines a small sparse matrix, with 25 nodes, 8 elements, 33 constraints, NP0 = 9, MU = 100.
You can go up one level to the C source codes.