Example a_backup/analytic_isosurfaces: Visualise iso-surfaces of scalar analytic functions.

Generate iso-surfaces of scalar fields defined by analytic functions of the coordinate components and time.

This example defines analytic functions in terms of "coordinates" field components x, y, z and timekeeper time t, and displays isosurfaces of set values of these fields. The resulting isosurfaces can be animated with time using the time slider.

Note: The mesh in this example uses all the main 3-D element shapes: cube, tetrahedron and the three orientations of triangle*line or wedge elements to test correct isosurfaces generation in each shape.

Screenshot of example a_backup/analytic_isosurfaces

The comfile run by this example is as follows:

# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
# The Original Code is CMISS Analytic Isosurfaces example.
# The Initial Developer of the Original Code is
# Auckland Uniservices Ltd, Auckland, New Zealand.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# ***** END LICENSE BLOCK *****

gfx read nodes $example/allshapes.exnode;
gfx read elements $example/allshapes.exelem;

# define scalar field:
#   fun1 = z + 0.1*sin(magnitude(-0.75*x,-0.75*y)*t)
# where:
#   x,y,z = components of "coordinates" field
#   t = current timekeeper time

gfx define field allshapes/xy composite coordinates.x coordinates.y;
gfx define field allshapes/oxy offset field xy offsets -0.75 -0.75;
gfx define field allshapes/moxy magnitude field oxy;
gfx define field allshapes/t coordinate_system rectangular_cartesian time_value;
gfx define field allshapes/moxyt multiply_components fields moxy t;
gfx define field allshapes/sin_moxyt sin field moxyt;
gfx define field allshapes/ssin_moxyt scale field sin_moxyt scale_factors 0.1;
gfx define field allshapes/fun1 add fields coordinates.z ssin_moxyt;

# define scalar field:
#   fun2 = fun1*sin(4*z)

gfx define field allshapes/sz scale field coordinates.z scale_factors 4;
gfx define field allshapes/sin_sz sin field sz;
gfx define field allshapes/fun2 multiply_components fields fun1 sin_sz;

# create some nice materials:

gfx create material bluey normal_mode ambient 0.1 0.2 0.35 diffuse 0.2 0.4 0.7 emission 0 0 0 specular 0.3 0.3 0.3 alpha 1 shininess 0.2;
gfx create material bone normal_mode ambient 0.7 0.7 0.6 diffuse 0.9 0.9 0.7 emission 0 0 0 specular 0.1 0.1 0.1 alpha 1 shininess 0.2;
gfx create material canary normal_mode ambient 0.45 0.45 0 diffuse 0.9 0.9 0 emission 0 0 0 specular 0.2 0.2 0.2 alpha 1 shininess 0.2;

# Set up graphical renditions, notably isosurfaces of fun1 = 0.2 and fun2 = 0.42:

gfx modify g_element allshapes general clear;
gfx modify g_element allshapes lines coordinate coordinates select_on material default selected_material default_selected;
gfx modify g_element allshapes node_points coordinate coordinates glyph sphere general size "0.08*0.08*0.08" centre 0,0,0 font default select_on material canary selected_material default_selected;
gfx modify g_element allshapes iso_surfaces coordinate coordinates iso_scalar fun1 iso_values 0.2 use_elements select_on material bluey selected_material default_selected render_shaded;
gfx modify g_element allshapes iso_surfaces coordinate coordinates iso_scalar fun2 iso_values 0.42 use_elements select_on material bone selected_material default_selected render_shaded;

# Set the default tessellation to use 16 segments in each element direction.
# This command does not exist on older versions of cmgui. It is safe to ignore errors.
gfx define tessellation default minimum_divisions "16" refinement_factors "1";
# Following does the equivalent on older versions of cmgui
gfx modify g_element allshapes general element_discretization "16";

# set the range of the timekeeper so the time slider can animate the isosurface
# set an interesting initial time

gfx timekeeper default min 0 max 20 set_time 10.5;

if ($TESTING) {
	gfx define tessellation default minimum_divisions "10";
	# test output using a distorted model since it gives more consistent results
	# given numerical differences between different binaries (mostly commonly
	# manifested as different pairs of triangles from a quadrilateral division)
	gfx read nodes $example/allshapes_distorted.exnode;
	gfx export vrml file analytic_isosurfaces_distorted.wrl;
} else {
	gfx create window 1;
	gfx modify window 1 view perspective eye_point 4.99717 5.45307 4.39887 interest_point 0.633125 0.636193 0.397697 up_vector -0.375514 -0.366798 0.851146 view_angle 31.6892 near_clipping_plane 0.076326 far_clipping_plane 27.2763;

Files used by this example are:

Name                        Modified     Size

analytic_isosurfaces.com 20-Apr-2012 5.1k COPYRIGHT 20-Apr-2012 504 allshapes.exelem 20-Apr-2012 10k allshapes.exnode 20-Apr-2012 1.1k allshapes_distorted.exnode 20-Apr-2012 1.1k

Download the entire example:

Name                                           Modified     Size

examples_a_backup_analytic_isosurfaces.tar.gz 12-Aug-2014 426k

Testing status by version:

StatusTestedReal time (s)
cmgui-wxSuccessSun Mar 6 00:06:21 20161
cmgui-wx-debugSuccessSun Mar 6 00:06:22 20160
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:06:22 20161
cmgui-wx-debug-valgrindSuccessSun Mar 6 00:32:27 201618
cmgui-wxSuccessThu Jan 7 00:01:25 20160
cmgui-wx-debugSuccessThu Jan 7 00:01:26 20160
cmgui-wx-debug-memorycheckSuccessThu Jan 7 00:01:26 20160
cmgui-wx-debug-valgrindFailureSun Mar 6 00:04:01 201617
last breakSun Mar 6 00:03:00 201617
last successWed Jun 3 00:15:00 201516
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:04:49 201615

Testing status by file:

Html last generated: Sun Mar 6 05:50:52 2016

Input last modified: Fri Apr 20 15:56:24 2012

CMISS Help / Examples / a_backup / analytic_isosurfaces