Example a_backup/deforming_heart: Deforming heart, time varying nodes, strain and deformed fibres.

This example shows how to use time to animate a scene graph and to calculate strains and deformed fibres on the prolate heart.

The sequence below illustrates this visualisation. The silver streamlines are aligned with the deforming fibres and the red/blue cones show the three component vectors of the strain tensor (red compression and blue extension).

Screenshot of example a_backup/deforming_heart


The comfile run by this example is as follows:

#Example a/deforming_heart: Deforming heart, time varying nodes, strain and deformed fibres
#
# This example shows how a whole sequence of solutions can be read in at one time and then
# animated.  The viewpoint and scene description can be interactively adjusted while the
# heart is deforming.

#Create some materials
gfx create material bluey ambient 0 0.25 0.5 diffuse 0 0.4 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.3
gfx create material copper ambient 1 0.2 0 diffuse 0.6 0.3 0 emission 0 0 0 specular 0.7 0.7 0.5 alpha 1 shininess 0.3
gfx create material gold ambient 1 0.4 0 diffuse 1 0.7 0 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.8
gfx create material silver ambient 0.4 0.4 0.4 diffuse 0.7 0.7 0.7 emission 0 0 0 specular 0.7 0.7 0.7 alpha 1 shininess 0.6

#Create a strain spectrum
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

#Read in the sequence of nodal positions.
for $i (0..49)
  {
	 $filename = sprintf("heart%04d.exnode", $i);
	 print "Reading $filename time $i\n";
	 gfx read node "$example/$filename" time $i;
  }

#Read in the element description
gfx read elements $example/heart.exelem;

#Create a window and set the viewpoint
gfx create window 1
gfx modify window 1 set perturb_lines
gfx modify window 1 view parallel eye_point -49.8293 -203.894 194.97 interest_point 9.48997 9.25073 -1.96496 up_vector -0.978396 0.111345 -0.174195 view_angle 24.2458 near_clipping_plane 2.96197 far_clipping_plane 1058.51 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1

# create initial lines visualisation
gfx modify g_element "/" general clear;
gfx modify g_element heart general clear;
gfx modify g_element heart lines select_on material gold selected_material default_selected

#Set the timekeeper playing
gfx timekeeper default play speed 50 skip;
gfx create time_editor

# Now we can modify the graphics while the time is running....
gfx modify g_element heart surfaces exterior face xi3_0 select_on material copper selected_material default_selected render_shaded

gfx edit scene

#Read in a reference heart position
gfx read node $example/reference_heart0000.exnode;
gfx read elements $example/reference_heart.exelem;

#Define the rc_equivalents of the prolate spheroidal coordinates
gfx define field rc_reference_coordinates coordinate_transform field reference_coordinates
gfx define field rc_coordinates coordinate_transform field coordinates

#Calculate the strains
gfx define field F gradient coordinate rc_reference_coordinates field rc_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 coordinate_system rectangular_cartesian scale field E2 scale_factors 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5

gfx define field principal_strains eigenvalues field E
gfx define field principal_strain_vectors eigenvectors eigenvalues principal_strains
gfx define field deformed_principal_strain_vectors matrix_multiply number_of_rows 3 fields principal_strain_vectors F_transpose

gfx define field deformed_principal_strain_vector1 composite deformed_principal_strain_vectors.1 deformed_principal_strain_vectors.2 deformed_principal_strain_vectors.3
gfx define field deformed_principal_strain_vector2 composite deformed_principal_strain_vectors.4 deformed_principal_strain_vectors.5 deformed_principal_strain_vectors.6
gfx define field deformed_principal_strain_vector3 composite deformed_principal_strain_vectors.7 deformed_principal_strain_vectors.8 deformed_principal_strain_vectors.9
# since above vectors have the stretch as their magnitude, normalize them:
gfx define field norm_def_principal_strain_vector1 normalise field deformed_principal_strain_vector1
gfx define field norm_def_principal_strain_vector2 normalise field deformed_principal_strain_vector2
gfx define field norm_def_principal_strain_vector3 normalise field deformed_principal_strain_vector3

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

#Calculate the deformed fibre axes
gfx define field fibre_axes fibre_axes coordinate rc_reference_coordinates fibre reference_fibres
gfx define field deformed_fibre_axes matrix_multiply number_of_rows 3 fields fibre_axes F_transpose

gfx define field deformed_fibre composite deformed_fibre_axes.1 deformed_fibre_axes.2 deformed_fibre_axes.3
gfx define field deformed_sheet composite deformed_fibre_axes.4 deformed_fibre_axes.5 deformed_fibre_axes.6
gfx define field norm_def_fibre normalise field deformed_fibre
gfx define field def_fibre_cross cross_product dimension 3 fields norm_def_fibre deformed_sheet
gfx define field norm_def_fibre_cross normalise field def_fibre_cross
gfx define field norm_def_fibre_cross_normal cross_product dimension 3 fields norm_def_fibre norm_def_fibre_cross
gfx define field orthonormal_deformed_fibre_axes composite norm_def_fibre norm_def_fibre_cross_normal norm_def_fibre_cross

#Show deforming fibres and strain vectors
gfx modify g_element heart streamlines xi 0.5,0.5,0.5 ribbon vector deformed_fibre_axes length 10 width 1 no_data select_on material silver selected_material default_selected
gfx modify g_element heart element_points glyph mirror_cone general size "0*1*1" centre 0,0,0 orientation norm_def_principal_strain_vector1 variable_scale principal_strain1 scale_factors "20*0*0" use_elements cell_centres discretization "1*1*1" native_discretization NONE select_on material bluey data principal_strain1 spectrum strain selected_material default_selected
gfx modify g_element heart element_points glyph mirror_cone general size "0*1*1" centre 0,0,0 orientation norm_def_principal_strain_vector2 variable_scale principal_strain2 scale_factors "20*0*0" use_elements cell_centres discretization "1*1*1" native_discretization NONE select_on material bluey data principal_strain2 spectrum strain selected_material default_selected
gfx modify g_element heart element_points glyph mirror_cone general size "0*1*1" centre 0,0,0 orientation norm_def_principal_strain_vector3 variable_scale principal_strain3 scale_factors "20*0*0" use_elements cell_centres discretization "1*1*1" native_discretization NONE select_on material bluey data principal_strain3 spectrum strain selected_material default_selected
#By toggling off the visibility of the different settings you can vastly speed up the frame rate.

if ($TESTING)
{
	gfx write node group heart fields coordinates & fibres output time 24;	
}

Files used by this example are:

Name                        Modified     Size

deforming_heart.com 20-Apr-2012 6.9k COPYRIGHT 19-Apr-2012 504 heart.exelem 20-Apr-2012 733k heart0000.exnode 20-Apr-2012 66k heart0001.exnode 20-Apr-2012 66k heart0002.exnode 20-Apr-2012 66k heart0003.exnode 20-Apr-2012 66k heart0004.exnode 20-Apr-2012 66k heart0005.exnode 20-Apr-2012 66k heart0006.exnode 20-Apr-2012 66k heart0007.exnode 20-Apr-2012 66k heart0008.exnode 20-Apr-2012 66k heart0009.exnode 20-Apr-2012 66k heart0010.exnode 20-Apr-2012 66k heart0011.exnode 20-Apr-2012 66k heart0012.exnode 20-Apr-2012 66k heart0013.exnode 20-Apr-2012 66k heart0014.exnode 20-Apr-2012 66k heart0015.exnode 20-Apr-2012 66k heart0016.exnode 20-Apr-2012 66k heart0017.exnode 20-Apr-2012 66k heart0018.exnode 20-Apr-2012 66k heart0019.exnode 20-Apr-2012 66k heart0020.exnode 20-Apr-2012 66k heart0021.exnode 20-Apr-2012 66k heart0022.exnode 20-Apr-2012 66k heart0023.exnode 20-Apr-2012 66k heart0024.exnode 20-Apr-2012 66k heart0025.exnode 20-Apr-2012 66k heart0026.exnode 20-Apr-2012 66k heart0027.exnode 20-Apr-2012 66k heart0028.exnode 20-Apr-2012 66k heart0029.exnode 20-Apr-2012 66k heart0030.exnode 20-Apr-2012 66k heart0031.exnode 20-Apr-2012 66k heart0032.exnode 20-Apr-2012 66k heart0033.exnode 20-Apr-2012 66k heart0034.exnode 20-Apr-2012 66k heart0035.exnode 20-Apr-2012 66k heart0036.exnode 20-Apr-2012 66k heart0037.exnode 20-Apr-2012 66k heart0038.exnode 20-Apr-2012 66k heart0039.exnode 20-Apr-2012 66k heart0040.exnode 20-Apr-2012 66k heart0041.exnode 20-Apr-2012 66k heart0042.exnode 20-Apr-2012 66k heart0043.exnode 20-Apr-2012 66k heart0044.exnode 20-Apr-2012 66k heart0045.exnode 20-Apr-2012 66k heart0046.exnode 20-Apr-2012 66k heart0047.exnode 20-Apr-2012 66k heart0048.exnode 20-Apr-2012 66k heart0049.exnode 20-Apr-2012 66k heart0050.exnode 20-Apr-2012 66k reference_heart.exelem 20-Apr-2012 734k reference_heart0000.exnode 20-Apr-2012 105k streamline_animation.cmgui 20-Apr-2012 2.9k

Download the entire example:

Name                                      Modified     Size

examples_a_backup_deforming_heart.tar.gz 12-Aug-2014 4.6M

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxSuccessSun Mar 6 00:15:18 20164
cmgui-wx-debugSuccessSun Mar 6 00:16:22 20163
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:20:58 20166
cmgui-wx-debug-valgrindFailureSun Mar 6 01:22:07 201682
last breakSun Mar 6 01:20:00 201682
last successTue Feb 10 01:21:00 201578
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:36 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:06:00 20151
cmgui-wx-debugFailureSun Mar 6 00:01:36 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:07:00 20154
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:43 201610
last breakSun Mar 6 00:02:00 201610
last successWed Jun 3 00:47:00 201565
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:14 20167

Testing status by file:


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

Input last modified: Fri Apr 20 15:57:08 2012


CMISS Help / Examples / a_backup / deforming_heart