Example 33a: Diffusion on a 2D square (using mathML)


The comfile run by this example is as follows:

#Example_334a Diffusion on a 2D square (using mathML)
#Note:
# ! Run under LINUX only
# ! No test example so far because perl interpreter has
#   problems reading in .xml files from directories with
#   both explicit and relative path names

print "$example"
# If the example path is not set, default to current directory
     if (!defined $example) {
         $example = "./";
     }
     # Drop off the trailing / in the example path
     $chopped = chop $example;
     if ($chopped ne "/") {
         $example .= $chopped;
     }
print "$example"
$MODEL="output1";
$results_dir="$example/results";
$Field{'Conc1'} =1;

########################################
### BASIC SETUP                      ###
########################################

fem def para;r;$example/common/parameters reg 1

fem define base;r;$example/bases #linear 2D basis function and 1D basis function

fem define node;r;$example/source #define a square: 1 element with 4 nodes
fem define elem;r;$example/source 

fem define fibr;d reg 1          #default fibre angle
fem define elem;r;$example/source fibre reg 1 

fem def equa;r;$example/equations/time-dependent 
fem def mate;d #note that the .ipmate file is default because
#the parameters will be set by the mathML file  
fem def init;r;$example/equations/parabolic #choose two nodes as source
#and set flux boundary conditions of the others to 0
fem def solv;r;$example/common/time-dependent 
 
# cmgui output
fem export node;"${results_dir}/${MODEL}" as $MODEL      
fem export elem;"${results_dir}/${MODEL}" as $MODEL    

########################################
### SETUP CONCENTRATION FIELDS REG 1 ###
########################################

fem def field;r;source;example
fem def elem;r;source;example field 
fem define label Conc field 1
 
############################
### DEFINE MATHML INPUT  ###
############################

fem define maths electrodiffusion uri electrodiffusion #read in a mathML
#file that provides input parameters for the advection/diffusion equation
#you may play around with the input file (electrodiffusion) to see
#how the parameters affect the solution

fem define label Parabolic equation 1 

#map the mathML variables to CMISS variables
fem define map equation Parabolic variable D_fibre1_1 to maths electrodiffusion variable D_grad2_u1 
fem define map equation Parabolic variable v_fibre1_1 to maths electrodiffusion variable v_grad_u1 
fem define map equation Parabolic variable D_fibre2_1 to maths electrodiffusion variable D_grad2_u2 
fem define map equation Parabolic variable v_fibre2_1 to maths electrodiffusion variable v_grad_u2 
fem define map equation Parabolic variable grad_v_fibre1_1 to maths electrodiffusion variable grad_v_fibre1 
fem define map equation Parabolic variable grad_v_fibre2_1 to maths electrodiffusion variable grad_v_fibre2 
fem define map equation Parabolic variable b_1 to maths electrodiffusion variable b_u 
fem define map equation Parabolic variable a_1 to maths electrodiffusion variable a 
fem define map equation Parabolic variable s_1 to maths electrodiffusion variable s 

#show the mapping on shell output
fem list labels

###############
### SOLVE   ###     
###############

#initialize solve
#'reassemble' necessary for updating during iteration
fem solve equation to 0 reassemble  

fem update field $Field{'Conc1'} substitute solution niy 1 depvar 1

#time loop 
#Note: the solution is stored in the .exnode output file as the 4th ('field1')
#nodal value

foreach $count ( '001'..'100' ) {
      my $time = $count/10;
      fem solve equation to "$time" reassemble        
      fem update field $Field{'Conc1'} substitute solution niy 1 depvar 1 
      fem export node;"$results_dir/output1_$count" #cmgui output     
}

#draw the concentration field reading the diffusion.iphist file

fem def win;c
fem draw nodes
fem draw lines
fem draw field animate history $example/diffusion

#for fancier visuals in cmgui, see draw.com
set output;cmiss_test on
fem list node solution
set output off

Additional testing commands:

fem list node solution

Files used by this example are:

Name              Modified     Size

example_33a.com 17-Aug-2004 3.9k bases.ipbase 11-Aug-2004 1.9k cmiss_test.out 11-Aug-2004 1.0k common/ 13-Apr-2007 - diffusion.iphist 11-Aug-2004 4.3k draw.com 11-Aug-2004 2.8k electrodiffusion 11-Aug-2004 3.2k equations/ 16-Aug-2004 - file.ipnode 11-Aug-2004 705 results/ 16-Aug-2004 - source.ipelem 11-Aug-2004 336 source.ipelfb 11-Aug-2004 225 source.ipelfd 11-Aug-2004 226 source.ipfiel 11-Aug-2004 601 source.ipnode 11-Aug-2004 817 test_output.com 11-Aug-2004 23

Download the entire example:

Name                      Modified     Size

examples_3_33_33a.tar.gz 14-Apr-2007 9.5k

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

Input last modified: Fri Apr 13 10:32:45 2007


CMISS Help / Examples / 3 / 33 / 33a