Example b2143: One directly coupled ventricle and epicardial iterations

This example demonstrates how to couple a single ventricle by direct assembly while iterating on the epicardial surface to get a continuous solution.


The comfile run by this example is as follows:

#Example b2143
#
# This example demonstrates how to couple a single ventricle
#  by direct assembly while iterating on the epicardial 
#  surface to get a continuous solution.
#

# Problem classes
$TLPL=1 
$BLPL=2 
$TMEM=3 
$EXTC=4 

# Problem regions
$CAVITY=1 
$BLOOD=2 
$BEMHT=3 
$MUSCLE=4 
$GRIDHT=5 

# Iteration variables
$NUM_ITERS=0 
$MAX_ITERS=50 
$FINISHED=0
$POTE_TOL=0.1 
$FLUX_TOL=0.1 
$POTE1=1.0
$FLUX1=1.0
$ALPHA1=0.0 
$ALPHA2=0.5 

# Define problem geometry
fem define para;r;fembem;example
fem define regi;r;fembem;example
fem define node;r;refx4;example reg all
fem define base;r;fembem;example
fem define elem;r;refx4;example reg all
fem define fibr;r;refx4;example reg $GRIDHT
fem define elem;r;test;example fibre reg $GRIDHT

# Define finite difference grid
fem define grid;r;heart;example reg $GRIDHT
fem update grid geometry reg $GRIDHT
fem update grid metric reg $GRIDHT
fem group grid xi2=0 as endocardium reg $GRIDHT
fem group grid xi2=1 as epicardium  reg $GRIDHT
fem group grid external as boundary reg $GRIDHT
fem group grid line 849 xidirn 2 as stimulus reg $GRIDHT

# Create node to grid mapping
fem update node grid grid_reg $GRIDHT bem_reg $BEMHT
fem update node geomet from grid reg $BLOOD

# Define equations
fem define equa;r;torso;example reg $CAVITY,$MUSCLE class $TLPL lock
fem define equa;r;blood;example reg $BLOOD class $BLPL lock
fem define equa;r;heart;example reg $GRIDHT class $TMEM,$EXTC

# Define material parameters
fem define mate;r;torso;example reg $CAVITY,$MUSCLE class $TLPL
fem define mate;r;blood;example reg $BLOOD class $BLPL
fem define mate;r;heart;example reg $GRIDHT class $TMEM,$EXTC
fem define cell;r;heart;example reg $GRIDHT class $TMEM,$EXTC
fem update grid material reg $GRIDHT class $TMEM,$EXTC

# Define initial conditions
fem define init;r;torso;example reg $CAVITY,$MUSCLE class $TLPL
fem define init;r;blood;example reg $BLOOD class $BLPL
fem define init;r;heart;example reg $GRIDHT class $TMEM,$EXTC

# Define torso region coupling
fem define coup;r;torso;example class $TLPL

# Define grid to boundary element coupling
fem up elem region $GRIDHT,$CAVITY class $EXTC,$TLPL grids epicardium

# Define solution parameters
fem define solv;r;heart;example reg $GRIDHT class $TMEM
fem define solv;r;heart2;example reg $GRIDHT class $EXTC
fem define solv;r;torso;example coupled reg $CAVITY,$MUSCLE class $TLPL
fem define solv;r;blood;example reg $BLOOD class $BLPL

# Solve the passive torso problems
fem solve coupled reg $CAVITY,$MUSCLE class $TLPL
fem solve reg $BLOOD class $BLPL 

# Solve the bidomain problem
fem solve activ coupled to 0 reg $GRIDHT,$BLOOD,$CAVITY class $TMEM,$EXTC,$BLPL,$TLPL grid endocardium cptype 3

for $TEN ( 0..0 ) {
  for $UNIT ( 0..0 ) {
    for $DECI ( 0..4 ) {
      for $HUND ( 0,2,4,6,8 ) {

        # Solve a bidomain time step
        fem solve activ coupled transmembrane restart to "$TEN$UNIT".'.'."$DECI$HUND" reg $GRIDHT class $TMEM,$EXTC noupdate
        $NUM_ITERS = 0
        $FINISHED = 0

        # Find a converged epicardial solution
        while( !$FINISHED && $NUM_ITERS<=$MAX_ITERS ) {
          $NUM_ITERS++ 

          fem solve activ coupled extra rest reg $GRIDHT,$BLOOD,$CAVITY cl $TMEM,$EXTC,$BLPL,$TLPL noupdate static alpha $ALPHA1 grid endocardium cptype 3
          fem update init from grid region $CAVITY,$BEMHT,$GRIDHT class $EXTC,$TLPL,$EXTC alpha $ALPHA2
          fem solve coupled reg $CAVITY,$MUSCLE class $TLPL
          fem check conv grid_reg $BEMHT grid_cl $EXTC bem_reg $CAVITY bem_cl $TLPL grid_update_cl $EXTC return POTE1 FLUX1

          $FINISHED = (abs($POTE1)<=$POTE_TOL && abs($FLUX1)<=$FLUX_TOL)
          print("Iteration $NUM_ITERS\n");
        }

        # Update the transmembrane potential field
        fem solve activ coupled trans restart reg $GRIDHT,$BLOOD,$CAVITY class $TMEM,$EXTC,$BLPL,$TLPL update static grid endocardium cptype 3

        if($NUM_ITERS<$MAX_ITERS) {
          print("Solution converged in $NUM_ITERS iterations\n");
        }
        else {
          print("Solution did not converge in $MAX_ITERS iterations\n");
          print("Outside potential $POTE1 Outside flux $FLUX1\n");
        }
      }
    }
  }
}

Additional testing commands:

#Testing example b2143
# Torso cavity
fem list node solu reg 1 class 1
fem list node flux reg 1 class 1

# Ventricle
fem list node solu reg 2 class 2
fem list node flux reg 2 class 2  


Files used by this example are:

Name               Modified     Size

example_b2143.com 28-Jun-2001 4.1k blood.ipequa 26-May-2003 1.2k blood.ipinit 06-Jun-2001 2.1k blood.ipmate 06-Jun-2001 592 blood.ipsolv 13-Apr-2007 1.3k fembem.ipbase 28-Jun-2001 3.2k fembem.ippara 12-Nov-2002 5.9k fembem.ipregi 06-Jun-2001 93 heart.ipcell 06-Jun-2001 2.3k heart.ipequa 26-May-2003 1.5k heart.ipgrid 06-Mar-2003 1.1k heart.ipinit 06-Jun-2001 833 heart.ipmate 06-Jun-2001 1.7k heart.ipsolv 13-Apr-2007 1.9k heart.ipsolv.old 06-Jun-2001 1.5k heart2.ipsolv 13-Apr-2007 1.9k heart2.ipsolv.old 06-Jun-2001 1.5k refx4.ipfibr 28-Jun-2001 2.6k refx4.irelem 28-Jun-2001 160k refx4.irnode 06-Jun-2001 195k test.ipelfb 06-Jun-2001 1.2k test_output.com 06-Jun-2001 186 torso.ipcoup 21-Aug-2002 437 torso.ipcoup.old 06-Jun-2001 411 torso.irequa 26-May-2003 2.5k torso.irinit 28-Jun-2001 3.5k torso.irmate 06-Jun-2001 1.2k torso.irsolv 13-Apr-2007 1.6k

Download the entire example:

Name                                 Modified     Size

examples_b_b2_b21_b214_b2143.tar.gz 14-Apr-2007 406k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:03:50 20163
cm-debugSuccessSat Mar 5 00:17:01 20167
mips-irix
cmSuccessSun Aug 19 02:18:35 200746
cm-debugSuccessWed Aug 15 02:15:12 2007114
cm-debug-clear-mallocSuccessSat Aug 18 02:32:05 2007121
cm-debug-clear-malloc7SuccessMon Aug 20 02:29:31 2007122
cm64SuccessSun Aug 19 02:21:18 200749
cm64-debugSuccessTue Aug 21 02:21:37 2007127
cm64-debug-clear-mallocSuccessThu Apr 1 11:21:17 200458
rs6000-aix
cmSuccessWed Mar 4 01:09:58 20094
cm-debugSuccessMon Mar 2 01:13:51 200921
cm64SuccessWed Mar 4 01:11:06 20094
cm64-debugSuccessTue Mar 3 01:18:54 200923
x86_64-linux
cmSuccessSun Mar 6 00:01:12 20161
cm-debugSuccessSat Mar 5 00:01:56 20164

Testing status by file:


Html last generated: Sun Mar 6 05:51:14 2016

Input last modified: Fri Apr 13 10:39:26 2007


CMISS Help / Examples / b / b2 / b21 / b214 / b2143