triangulation_order6_contour, a MATLAB code which reads datafiles describing a set of nodes, a triangulation of the nodes into six-node triangles, and a scalar evaluated at the nodes. It produces a plot of the triangulation, and several styles of color contour plots of the scalar

This program has a flaw - MATLAB can easily display linear data, so the program essentially divides each quadratic 6-node triangle into smaller 3-node triangles, and lets MATLAB compute and display a surface which is planar over each triangle. This is only an approximation, and if the "fine scale" quadratic behavior of the solution is of interest, it will not show up using this program! To do so well requires computing the underlying quadratic function at numerous sampling points before constructing and displaying the (now much smaller) planar surfaces that approximate the quadratic surface.

The program reads three data files that form a "finite element model" of a scalar quantity defined over a 2D region:

The program automatically displays five plots:

  1. An image of the 3-node triangles created by discarding the midside nodes of the input triangulation;
  2. A color contour plot, using the crude 3-node triangulation, with color constant over a triangle.
  3. An image of the finer 3-node triangles created by breaking the 6-node triangles into 4 3-node triangles.
  4. A color contour plot, using the finer 3-node triangulation, with color constant over a triangle.
  5. A color contour plot, using the finer 3-node triangulation, with color linearly interpolated to make a very nice picture.


triangulation_order6_contour ( 'prefix' )
where prefix is the common filename prefix:


The computer code and data files described and made available on this web page are distributed under the MIT license


triangulation_order6_contour is available in a MATLAB version.

Related Data and Programs:

fem2d, a data directory which contains a description and examples of the 2d fem format.

fem_basis_t6_display, a MATLAB code which reads a quadratic triangle mesh and displays any associated basis function.

levels, a MATLAB code which makes a contour plot, choosing the contour levels using random sampling.

triangulation, a MATLAB code which carries out various operations on order 3 ("linear") or order 6 ("quadratic") triangulations.

triangulation_corner, a MATLAB code which patches triangulations so that no triangle has two sides on the boundary.

triangulation_delaunay_discrepancy, a MATLAB code which measures the amount by which a triangulation fails the local delaunay test;

triangulation_histogram, a MATLAB code which computes histograms of data over a triangulation.

triangulation_mask, a MATLAB code which takes an existing triangulation and deletes triangles and their corresponding nodes as requested by the user.

triangulation_order3_contour, a MATLAB code which handles the case where the triangulation is of order 3.

triangulation_order6, a directory which describes the format for the node and element files describing an order 6 triangulation.


triangulation_orient, a MATLAB code which reads data defining a triangulation, makes sure that every triangle has positive orientation, and if not, writes a corrected triangle file.

triangulation_quad, a MATLAB code which estimates the integral of a function over a triangulated region.

triangulation_refine, a MATLAB code which reads data defining a triangulation, replaces each triangle by four congruent smaller ones, and writes the new triangulation information to a file.

Source Code:

Last revised on 10 April 2019.