Example b2145: Multiple directly assembled ventricles with epicardial iteration

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


The comfile run by this example is as follows:

#Example b2145
#
# This example demonstrates how to couple a multiple ventricular
#  regions by direct assembly while iterating on the epicardial 
#  surface to get a continuous solution.
#


# Problem classes
$CAVITY=1 
$LVENTL=2 
$RVENTL=3 
$BEMHRT=4 
$GRIDHT=5 

# Problem regions
$TLAPLC=1 
$LVECLS=2 
$RVECLS=3 
$GRDCLS=4 
$EXTCLS=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;minimal;example
fem define regi;r;torsoslice;example
fem define node;r;cavity4;example reg $CAVITY
fem define node;r;LV3;example reg $LVENTL
fem define node;r;RV3;example reg $RVENTL
fem define node;r;bemhrt3;example reg $BEMHRT
fem define node;r;gridhtr;example reg $GRIDHT
fem define base;r;linear;example
fem define elem;r;cavity4;example reg $CAVITY
fem define elem;r;LV3;example reg $LVENTL
fem define elem;r;RV3;example reg $RVENTL
fem define elem;r;bemhrt3;example reg $BEMHRT
fem define elem;r;gridhtr;example reg $GRIDHT
fem define fibr;r;gridhtr;example reg $GRIDHT
fem define elem;r;gridhtr;example reg $GRIDHT fibre

# Define finite difference grid
fem define grid;r;gridhtr;example reg $GRIDHT
fem update grid geomet reg $GRIDHT
fem update grid metric reg $GRIDHT
fem group grid xi2=0 elem 11..20,27,28 as LVendo reg $GRIDHT
fem group grid xi2=1 elem 11,13,19,20 as RVendo1 reg $GRIDHT
fem group grid xi2=0 elem 1,3,9,10,21,22,25,26 as RVendo2 reg $GRIDHT
fem group grid grid RVendo1,RVendo2 as RVendo reg $GRIDHT
fem group grid grid LVendo,RVendo as endocardium reg $GRIDHT
fem group grid xi2=1 elem 1..10,21..26 as epicardium  reg $GRIDHT
fem group grid external as boundary reg $GRIDHT
fem group grid line 1845 xidirn 2 as stimulus reg $GRIDHT

# Create node to grid mapping
fem update node grid grid_reg $GRIDHT bem_reg $BEMHRT exclude node 77,78
fem update node geomet from grid reg $BEMHRT except node 77,78

# Define equations
fem define equa;r;cavity;example reg $CAVITY class $TLAPLC lock
fem define equa;r;LV;example reg $LVENTL class $LVECLS lock
fem define equa;r;RV;example reg $RVENTL class $RVECLS lock
fem define equa;r;alto;example reg $GRIDHT class $GRDCLS,$EXTCLS lock

# Define material parameters
fem define mate;r;cavity;example reg $CAVITY class $TLAPLC
fem define mate;r;LV;example reg $LVENTL class $LVECLS
fem define mate;r;RV;example reg $RVENTL class $RVECLS
fem define mate;r;alto;example reg $GRIDHT class $GRDCLS,$EXTCLS
fem define cell;r;alto;example reg $GRIDHT class $GRDCLS,$EXTCLS
fem update grid materi reg $GRIDHT class $GRDCLS,$EXTCLS

# Define initial conditions
fem define init;r;cavity2;example reg $CAVITY class $TLAPLC
fem define init;r;LV;example reg $LVENTL class $LVECLS
fem define init;r;RV;example reg $RVENTL class $RVECLS
fem define init;r;alto;example reg $GRIDHT class $GRDCLS,$EXTCLS

# Define right ventricular normal reversals
fem define norm;r;ventcl;example

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

# Define solution parameters
fem define solv;r;alto;example reg $GRIDHT class $GRDCLS
fem define solv;r;alto;example reg $GRIDHT class $EXTCLS
fem define solv;r;cavity;example reg $CAVITY class $TLAPLC
fem define solv;r;LV;example reg $LVENTL class $LVECLS
fem define solv;r;RV;example reg $RVENTL class $RVECLS

# Solve the passive torso problems
fem solve reg $CAVITY class $TLAPLC
fem solve reg $LVENTL class $LVECLS
fem solve reg $RVENTL class $RVECLS

# Solve the bidomain problem
fem solve activ coupled to 0 reg $GRIDHT,$LVENTL,$RVENTL,$CAVITY class $GRDCLS,$EXTCLS,$LVECLS,$RVECLS,$TLAPLC grid endocardium cptype 5

for $TEN ( 0..0 ) {
  for $UNIT ( 0..0 ) {
    for $DECI ( 0..9 ) {
      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 $GRDCLS,$EXTCLS noupdate
        $NUM_ITERS = 0
        $FINISHED = 0
        while( !$FINISHED && $NUM_ITERS<=$MAX_ITERS ) {
          $NUM_ITERS++ 

          fem solve activ coupled extra rest reg $GRIDHT,$LVENTL,$RVENTL,$CAVITY cl $GRDCLS,$EXTCLS,$LVECLS,$RVECLS,$TLAPLC noupdate static alpha $ALPHA1 grid endocardium cptype 5
          fem update init from grid region $CAVITY,$BEMHRT,$GRIDHT class $EXTCLS,$TLAPLC,$EXTCLS alpha $ALPHA2
          fem solve reg $CAVITY class $TLAPLC
          fem check conv grid_reg $BEMHRT grid_cl $EXTCLS bem_reg $CAVITY bem_cl $TLAPLC grid_update_cl $EXTCLS return POTE1 FLUX1

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

        fem solve activ coupled trans rest reg $GRIDHT,$LVENTL,$RVENTL,$CAVITY class $GRDCLS,$EXTCLS,$LVECLS,$RVECLS,$TLAPLC update static alpha $ALPHA1 grid endocardium cptype 5

        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 b2145
# Torso cavity
fem list node solu reg 1 class 1

# Ventricles
fem list node solu reg 2 class 2
fem list node solu reg 3 class 3


Files used by this example are:

Name               Modified     Size

example_b2145.com 06-Jun-2001 5.0k LV.ipequa 26-May-2003 1.2k LV.ipinit 06-Jun-2001 1.2k LV.ipmate 06-Jun-2001 606 LV.ipsolv 13-Apr-2007 1.2k LV3.ipelem 06-Jun-2001 24k LV3.ipnode 06-Jun-2001 28k RV.ipequa 26-May-2003 1.2k RV.ipinit 06-Jun-2001 1.2k RV.ipmate 06-Jun-2001 606 RV.ipsolv 13-Apr-2007 1.2k RV3.ipelem 06-Jun-2001 24k RV3.ipnode 06-Jun-2001 28k alto.ipcell 06-Jun-2001 1.7k alto.ipequa 26-May-2003 1.4k alto.ipinit 06-Jun-2001 847 alto.ipmate 06-Jun-2001 1.8k alto.ipsolv 13-Apr-2007 1.8k alto.ipsolv.old 06-Jun-2001 1.4k bemhrt3.ipelem 06-Jun-2001 80k bemhrt3.ipnode 06-Jun-2001 94k cavity.ipequa 26-May-2003 1.3k cavity.ipmate 06-Jun-2001 606 cavity.ipsolv 13-Apr-2007 1.5k cavity2.ipinit 06-Jun-2001 1.4k cavity4.ipelem 06-Jun-2001 38k cavity4.ipnode 06-Jun-2001 45k gridhtr.ipelem 06-Jun-2001 7.5k gridhtr.ipelfb 06-Jun-2001 4.3k gridhtr.ipfibr 06-Jun-2001 7.0k gridhtr.ipgrid 06-Mar-2003 561 gridhtr.ipnode 06-Jun-2001 14k linear.ipbase 06-Jun-2001 2.2k minimal.ippara 12-Nov-2002 5.9k test_output.com 06-Jun-2001 152 torsoslice.ipregi 06-Jun-2001 93 ventcl.ipnorm 06-Jun-2001 418

Download the entire example:

Name                                 Modified     Size

examples_b_b2_b21_b214_b2145.tar.gz 14-Apr-2007 504k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:03:37 20164
cm-debugSuccessSat Mar 5 00:16:49 20167
mips-irix
cmSuccessSun Aug 19 02:21:05 200749
cm-debugSuccessWed Aug 15 02:15:11 2007115
cm-debug-clear-mallocSuccessSat Aug 18 02:30:03 2007119
cm-debug-clear-malloc7SuccessMon Aug 20 02:31:29 2007119
cm64SuccessSun Aug 19 02:22:57 200751
cm64-debugSuccessTue Aug 21 02:18:03 2007122
cm64-debug-clear-mallocSuccessThu Apr 1 11:22:20 200456
rs6000-aix
cmSuccessWed Mar 4 01:11:10 20095
cm-debugSuccessMon Mar 2 01:13:57 200921
cm64SuccessWed Mar 4 01:11:30 20094
cm64-debugSuccessTue Mar 3 01:18:23 200921
x86_64-linux
cmSuccessSun Mar 6 00:01:08 20162
cm-debugSuccessSat Mar 5 00:02:01 20163

Testing status by file:


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

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


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