Shows how to store real, integer, string and element:xi values at nodes and
data points. Also demonstrates the use of constant and indexed fields, which
provide a mechanism for reducing memory requirements when values can be
categorised by an integer type, eg. cell_type in this case and thus do not
need to be stored at every node.
Also tests writing these special field formats.
# ***** BEGIN LICENSE BLOCK *****
# 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 exnode formats 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 *****
# Set the default tessellation to use 4 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 "4" refinement_factors "1";
{
# Shows how to store real, integer, string and element:xi values at nodes and
# data points. Also demonstrates the use of constant and indexed fields, which
# provide a mechanism for reducing memory requirements when values can be
# categorised by an integer type - cell_type in this case - and thus do not
# need to be stored at every node. Shows how with just element:xi (embedded)
# coordinates defined at data points, any field defined over the element can be
# calculated there.
# define some materials
gfx cre mat copper ambient 1 0.2 0 diffuse 0.6 0.3 0 specular 0.7 0.7 0.5 shininess 0.3;
gfx cre mat gold ambient 1 0.4 0 diffuse 1 0.7 0 specular 0.5 0.5 0.5 shininess 0.8;
# read in the basic cube geometry
gfx read nodes example cube.exnode;
gfx read elements example cube.exelem;
# read in the indexed and constant fields
gfx read nodes example cube_special.exnode;
# Fields defined:
# cell_type=integer from 1 to 3 at each node, used as indexer for other fields
# cell_name=indexed string providing a name for each cell_type - use it as a
# label_field in the graphical element editor
# variable=indexed real, one for each cell_type
# variable_int=indexed integer vector - 3 per cell_type
# constant_string=a string value that is the same at all nodes in the file
# general_string=a name for each node in the file
# vector=constant rectangular cartesian vector at all nodes in the file
# Visualise these fields
gfx modify g_element cube general;
gfx modify g_element cube lines material default;
#gfx modify g_element cube node_points glyph point size "1*1*1" centre 0,0,0 label cell_name no_select material default data cell_type spectrum default;
gfx modify g_element cube node_points glyph arrow_line size "0*1*1" centre 0,0,0 label cell_name orientation vector scale_factors "5*0*0" no_select material default data cell_type spectrum default;
# Now read data points which contain embedded locations in the cube mesh:
gfx read data example cube_element_xi.exdata;
# The above file defines a field 'element_xi' which gives an element:xi position in
# a the host cube mesh, and can only be viewed as a label_field.
# Need to create an embedded field which returns the coordinates field from the
# host mesh at the element_xi location, as if it were defined at the data points:
gfx define field element_xi_coordinate embedded element_xi element_xi field coordinates;
# Visualise the embedded fields
gfx modify g_element xi_points general clear;
gfx modify g_element xi_points data_points coordinate element_xi_coordinate glyph point size "1*1*1" centre 0,0,0 label element_xi no_select material gold;
gfx modify spectrum default autorange;
if ($TESTING) {
# Test I/O of the whole cube
gfx write nodes output_cube.exnode group cube;
gfx read nodes output_cube.exnode;
# Test I/O of individual fields
gfx write nodes output_cube_cell_type.exnode group cube field cell_type;
gfx write nodes output_cube_cell_name.exnode group cube field cell_name;
gfx read nodes output_cube_cell_type.exnode;
gfx read nodes output_cube_cell_name.exnode;
# Test I/O of element_xi/data group
gfx write data output_cube_element_xi.exdata group xi_points field element_xi;
gfx read data output_cube_element_xi.exdata;
# Output vrml
gfx export vrml file output_cube_special.wrl;
} else {
gfx create window 1;
}
}