Color Contour of Triangulated Data

TRIANGULATION_ORDER6_CONTOUR, a MATLAB program 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 GNU LGPL 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 program which reads a quadratic triangle mesh and displays any associated basis function.

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

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

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

TRIANGULATION_DELAUNAY_DISCREPANCY, a MATLAB program which measures the amount by which a triangulation fails the local Delaunay test;

TRIANGULATION_HISTOGRAM, a MATLAB program which computes histograms of data over a triangulation.

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

TRIANGULATION_ORDER3_CONTOUR, a MATLAB program 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 program 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 program which estimates the integral of a function over a triangulated region.

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

TWOD_PLOTC, a MATLAB program which makes a color contour plot of scalar data defined on a 2D finite element mesh.

VECTOR_MAGNITUDE_GRID, 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 contour plot of the vector magnitude.

Source Code:

Last revised on 10 April 2019.