Example a/large_strain: Large strain tensor visualisation in a deforming cube

Uses the gradient computed field to extract the deformation gradient 'F' from deformed and undeformed coordinates of the cube. From this, the Lagrangian / Green's Strain Tensor E is calculated, then the eigenvalues and eigenvectors of it are determined. Each eigenvector/eigenvalue pair is viewed with the mirror_cone glyph which points inwards where there is compression (ie. a negative eigenvalue). Furthermore, colour is also added to indicate compression/tension. The strains are visualised at evenly spaced element points over the cube.

Screenshot of example a/large_strain


The comfile run by this example is as follows:

# Large strain tensor visualisation in a deforming cube
# -----------------------------------------------------
#
# Create some materials for use later.
#
gfx create material bluey ambient 0 0.25 0.5 diffuse 0 0.4 1 specular 0.5 0.5 0.5 shininess 0.3
gfx create material gold ambient 1 0.4 0 diffuse 1 0.7 0 specular 0.5 0.5 0.5 shininess 0.8
gfx create material jade ambient 0.1 0.56 0 diffuse 0.1 0.39 0 emission 0 0 0 specular 0.8 0.8 0.8 alpha 1 shininess 0.8
gfx create material blue ambient 0 0 0 diffuse 0 0.2 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.3
gfx create material green ambient 0 1 0 diffuse 0 1 0 emission 0 0 0 specular 0 0 0 alpha 1 shininess 0
gfx create material red ambient 1 0 0 diffuse 1 0 0 emission 0 0 0 specular 0 0 0 alpha 1 shininess 0
#
# Read in the undeformed cube with the undeformed_coordinates field defined:
#
gfx read nodes example undeformed_cube.exnode
gfx read elements example undeformed_cube.exelem
#
# Read in the deformed cube with the deformed_coordinates field defined:
#
gfx read nodes example deformed_cube.exnode
gfx read elements example deformed_cube.exelem
#
# Define fields necessary to show the strains.
#
# Define F = dx/dX, where X are undeformed coordinates, x are deformed coordinates.
# The 9 values are returned in the order dx/dX dx/dY dx/dZ dy/X etc., ie. across
# the rows of a 3 x 3 matrix first to present a single vector.
# Then:
#   C = F_transpose . F     = right Cauchy-Green deformation tensor
#   E = 0.5*(C - Identity3) = Lagrangian / Greens [finite] strain tensor
#
gfx define field F gradient coordinate undeformed_coordinates field deformed_coordinates
gfx define field F_transpose transpose source_number_of_rows 3 field F
gfx define field Identity3 composite 1 0 0 0 1 0 0 0 1
gfx define field C matrix_multiply number_of_rows 3 fields F_transpose F
gfx define field E2 add fields C Identity3 scale_factors 1 -1
gfx define field E scale field E2 scale_factors 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5
#
# Obtain the principal strains and their direction vectors by performing
# an eigenanalysis on E.
#
gfx define field principal_strains eigenvalues field E
gfx define field principal_strain_vectors coordinate_system rectangular_cartesian eigenvectors eigenvalues principal_strains
#
# The above vectors mark the orientation of the principal strains in the
# undeformed configuration, where the first 3 values in the 9-component field
# are the components of the first eigenvector in the principal_strains field,
# and so on. We convert to deformed directions by post-multiplying them by
# F_transpose. This scales the vectors by the stretches in the principal
# directions, which are the ratios of final length to initial length. The
# deformed principal strain directions remain orthogonal by definition.
#
gfx define field deformed_principal_strain_vectors coordinate_system rectangular_cartesian matrix_multiply number_of_rows 3 fields principal_strain_vectors F_transpose
#
# Extract individual eigenvalues and eigenvectors for display.
#
gfx define field principal_strain1 composite principal_strains.1
gfx define field principal_strain2 composite principal_strains.2
gfx define field principal_strain3 composite principal_strains.3
gfx define field principal_strain_vector1 coordinate_system rectangular_cartesian composite principal_strain_vectors.1 principal_strain_vectors.2 principal_strain_vectors.3
gfx define field principal_strain_vector2 coordinate_system rectangular_cartesian composite principal_strain_vectors.4 principal_strain_vectors.5 principal_strain_vectors.6
gfx define field principal_strain_vector3 coordinate_system rectangular_cartesian composite principal_strain_vectors.7 principal_strain_vectors.8 principal_strain_vectors.9
gfx define field deformed_principal_strain_vector1 coordinate_system rectangular_cartesian composite deformed_principal_strain_vectors.1 deformed_principal_strain_vectors.2 deformed_principal_strain_vectors.3
gfx define field deformed_principal_strain_vector2 coordinate_system rectangular_cartesian composite deformed_principal_strain_vectors.4 deformed_principal_strain_vectors.5 deformed_principal_strain_vectors.6
gfx define field deformed_principal_strain_vector3 coordinate_system rectangular_cartesian composite deformed_principal_strain_vectors.7 deformed_principal_strain_vectors.8 deformed_principal_strain_vectors.9
#
# Normalise the deformed principal strain vectors to remove stretches.
#
gfx define field norm_def_principal_strain_vector1 coordinate_system rectangular_cartesian normalise field deformed_principal_strain_vector1
gfx define field norm_def_principal_strain_vector2 coordinate_system rectangular_cartesian normalise field deformed_principal_strain_vector2
gfx define field norm_def_principal_strain_vector3 coordinate_system rectangular_cartesian normalise field deformed_principal_strain_vector3
#
# Invent a fibre (material) coordinate system with the fibre direction along xi1
# with the sheets extending across xi2. The first 3 components of the fibre_axes
# field is the fibre direction vector, next the sheet, then the sheet normal.
# The fibre_axes field represents the fibre axes in the undeformed configuration
# and its contents are three orthonormal axis vectors.
#
gfx define field fibres coordinate_system fibre composite 0 0 1.5708
gfx define field fibre_axes coordinate_system rectangular_cartesian fibre_axes coordinate undeformed_coordinates fibre fibres
#
# The deformed fibre axes are evaluated by post-multiplying the fibre_axes matrix by
# F_transpose. In general, the deformed_fibre_axes will be neither unit length nor
# orthogonal to each other. Also extract the individual fibre, sheet and normal
# directions of the deformed fibres axes for visualisation later.
#
gfx define field deformed_fibre_axes coordinate_system rectangular_cartesian matrix_multiply number_of_rows 3 fields fibre_axes F_transpose
gfx define field deformed_fibre coordinate_system rectangular_cartesian composite deformed_fibre_axes.1 deformed_fibre_axes.2 deformed_fibre_axes.3
gfx define field deformed_sheet coordinate_system rectangular_cartesian composite deformed_fibre_axes.4 deformed_fibre_axes.5 deformed_fibre_axes.6
gfx define field deformed_normal coordinate_system rectangular_cartesian composite deformed_fibre_axes.7 deformed_fibre_axes.8 deformed_fibre_axes.9
#

# Set up the rendition of the cube to show the deformed fibre axes:
#
# Clear all settings and use the deformed_coordinates as the default coordinate field for all settings
gfx modify g_element cube general clear circle_discretization 6 default_coordinate deformed_coordinates element_discretization "4*4*4" native_discretization none
# Lines
gfx modify g_element cube lines select_on material default selected_material default_selected
# Nodes drawn as small spheres
gfx modify g_element cube node_points glyph sphere general size "0.05*0.05*0.05" centre 0,0,0 select_on material default selected_material default_selected
# Fibre direction in red
gfx modify g_element cube element_points glyph arrow_line general size "0*0.1*0.1" centre 0,0,0 orientation deformed_fibre scale_factors "0.2*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material red selected_material default_selected
# Sheet direction in green
gfx modify g_element cube element_points glyph arrow_line general size "0*0.1*0.1" centre 0,0,0 orientation deformed_sheet scale_factors "0.2*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material green selected_material default_selected
# Sheet normal in blue
gfx modify g_element cube element_points glyph arrow_line general size "0*0.1*0.1" centre 0,0,0 orientation deformed_normal scale_factors "0.2*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material blue selected_material default_selected
#
# (Note we could have used the "axes" glyph combined with the
# deformed_fibre_axes field to show all three axes in one hit, but this cannot
# be output to VRML for testing once the axes become non-orthogonal.)
#
# Create the graphics window, switch to node tool and enable node editing
#
if (!$TESTING)
{
	gfx create window 1
}
#
# Now switch the graphics window to the node tool and enable node editing
#
if (!$TESTING)
{
	gfx modify window 1 set node_tool
	gfx node_tool edit motion_update
}
#
# Click and drag nodes to see the axes move.
# Note that you can hold down the Ctrl key and use the mouse to transform
# the view while still using the node tool.
#
# Since the deformed coordinates are currently the same as the undeformed state,
# the axes are aligned with the global x, y and z.
#
# Re-read in the original, generally deformed cube. Write to VRML if testing.
#
gfx read node example deformed_cube.exnode
if ($TESTING)
{
	gfx export vrml file deformed_cube_fibres.wrl
}
#
# Read in a deformed state that matches the undeformed state. Fibre, sheet and
# normal vectors should align with the global x,y and z directions.
#
gfx read node example deformed_cube3.exnode
#

# Now set the rendition of the cube to show strains:
#
# Define a spectrum that is red when negative (for showing compression strains)
# and bright blue when positive (for extension).
#
gfx create spectrum strain
gfx modify spectrum strain clear overwrite_colour
gfx modify spectrum strain linear reverse range -1 0 extend_below red colour_range 1 1 ambient diffuse component 1
gfx modify spectrum strain linear reverse range 0 1 extend_above blue colour_range 1 1 ambient diffuse component 1
gfx modify spectrum strain linear reverse range 0 1 extend_above green colour_range 0.5 0.5 ambient diffuse component 1
#
# Make the deformed coordinates the default coordinates for the cube, and
# display lines and node points (to edit). At any time in the future you
# can override the coordinate field in any settings for the cube in the
# graphical element editor to show the undeformed state.
#
gfx modify g_element cube general clear circle_discretization 6 default_coordinate deformed_coordinates element_discretization "4*4*4" native_discretization none
gfx modify g_element cube lines select_on material default selected_material default_selected
gfx modify g_element cube node_points glyph sphere general size "0.05*0.05*0.05" centre 0,0,0 select_on material default selected_material default_selected
#
# Also show undeformed lines to see what you are deforming from.
#
gfx modify g_element cube lines coordinate undeformed_coordinates select_on material jade selected_material default_selected
#
# Display eigenvalue/vector sets 1, 2 and 3. Each command ensures the strains
# are shown at the deformed coordinates and oriented with the normalised
# deformed principal strain vectors. The corresponding principal strain
# eigenvalue is supplied as the variable_scale field. This, in combination with
# the mirrow glyph (a cone in this place) allows negative values to cause the
# glyph to point inwards, thus indicating compressive strains.
#
# Strain glyphs are shown at 3 x 3 x 3 locations throughout the cube and each
# vector is coloured by the principal_strain value with the strain spectrum.
# The base "size" of 0*0.02*0.02 indicates that the cones are 0.02 units in
# diameter but have no base length. Scale factors 0.5*0*0 make the glyph half
# as long as the magnitude of the variable_scale (since no scaling is coming
# from the normalised vectors). Their length is thus proportional to the
# principal strain in that direction.
#
gfx modify g_element cube element_points coordinate deformed_coordinates glyph mirror_cone size "0*0.02*0.02" centre 0,0,0 orientation norm_def_principal_strain_vector1 variable_scale principal_strain1 scale_factors "0.5*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material bluey data principal_strain1 spectrum strain selected_material default_selected
gfx modify g_element cube element_points coordinate deformed_coordinates glyph mirror_cone size "0*0.02*0.02" centre 0,0,0 orientation norm_def_principal_strain_vector2 variable_scale principal_strain2 scale_factors "0.5*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material bluey data principal_strain2 spectrum strain selected_material default_selected
gfx modify g_element cube element_points coordinate deformed_coordinates glyph mirror_cone size "0*0.02*0.02" centre 0,0,0 orientation norm_def_principal_strain_vector3 variable_scale principal_strain3 scale_factors "0.5*0*0" use_elements cell_centres discretization "3*3*3" native_discretization NONE select_on material bluey data principal_strain3 spectrum strain selected_material default_selected
#
# Read in a deformed state that matches the undeformed state. Check that
# strains are zero.
#
gfx read node example deformed_cube3.exnode
#
# Read in a generally deformed cube and inspect strains.
#
gfx read node example deformed_cube.exnode
#
# Rotate the cube around to view the strains. Inwardly-pointing red cones
# show compression, while outwardly pointing blue cones mark extension.
#
# Since node tool / node editing are enabled in the graphics window,
# you can click on nodes and drag them to new positions and watch the
# strains update on the fly. By dragging over more than one node you can
# multi-select with a rubber band; hold down the shift key when editing more
# than one node at a time. The shift key is also used to add or remove a node
# from the current selection.
#
# Write the principal strains at the centre of the undeformed cube.
#
gfx modify g_element cube element_points coordinate undeformed_coordinates glyph point general size "0*0.02*0.02" centre 0,0,0 label principal_strains use_elements cell_centres discretization "1*1*1" native_discretization NONE select_on material default selected_material default_selected
#
# Re-read in the original, generally deformed cube. Write to VRML if testing.
#
gfx read node example deformed_cube.exnode
if ($TESTING)
{
	gfx export vrml file deformed_cube.wrl
}
#
# Read in a rotated, uniformly deformed cube. The deformed cube is:
#   50% longer in xi1  (stretch = 1.50, strain =  0.625  )
#   25% thinner in xi2 (stretch = 0.75, strain = -0.21875)
#   10% thinner in xi3 (stretch = 0.90, strain = -0.095  )
# where large strain = 0.5*(stretch*stretch - 1.0). Write to VRML if testing.
#
gfx read node example deformed_cube2.exnode
if ($TESTING)
{
	gfx export vrml file deformed_cube2.wrl
}
#
# Re-read in the generally deformed cube so that this example ends with it displayed.
#
gfx read node example deformed_cube.exnode

Files used by this example are:

Name                    Modified     Size

large_strain.com 17-Mar-2014 14k COPYRIGHT 17-Mar-2014 504 deformed_cube.exelem 17-Mar-2014 3.4k deformed_cube.exnode 17-Mar-2014 683 deformed_cube2.exnode 17-Mar-2014 683 deformed_cube3.exnode 17-Mar-2014 683 undeformed_cube.exelem 17-Mar-2014 3.4k undeformed_cube.exnode 17-Mar-2014 685

Download the entire example:

Name                            Modified     Size

examples_a_large_strain.tar.gz 09-Mar-2016 158k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxFailureSun Mar 6 00:05:39 20161
last breakThu Sep 11 00:02:00 20141
cmgui-wx-debugFailureSun Mar 6 00:05:41 20161
last breakThu Sep 11 00:02:00 20140
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:05:41 20161
last breakThu Sep 11 00:02:00 20141
cmgui-wx-debug-valgrindFailureSun Mar 6 00:42:45 201626
last breakTue Feb 24 00:09:00 201530
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:31 20161
last breakThu Sep 11 00:03:00 20141
cmgui-wx-debugFailureSun Mar 6 00:01:32 20161
last breakThu Sep 11 00:03:00 20141
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:32 20161
last breakThu Sep 11 00:03:00 20140
cmgui-wx-debug-valgrindFailureSun Mar 6 00:04:42 201624
last breakSun Mar 6 00:04:00 201624
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:05:37 201623

Testing status by file:


Html last generated: Wed Mar 9 16:02:19 2016

Input last modified: Wed Mar 9 15:49:34 2016


CMISS Help / Examples / a / large_strain