changeset 1311:b2e84fe336d8 feature/poroelastic

Move common code for displacement and traction BC outside of switch statement
author Martin Almquist <malmquist@stanford.edu>
date Mon, 20 Jul 2020 22:21:57 -0700
parents eb015fe9605b
children 6d64b57caf46
files +scheme/ViscoElastic2d.m
diffstat 1 files changed, 16 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/+scheme/ViscoElastic2d.m	Mon Jul 20 22:06:33 2020 -0700
+++ b/+scheme/ViscoElastic2d.m	Mon Jul 20 22:21:57 2020 -0700
@@ -272,25 +272,25 @@
             eU      = obj.eU;
             eGamma  = obj.eGamma;
 
+            % Get elastic closure and penalty
+            [closure, penalty] = obj.elasticObj.boundary_condition(boundary, bc, tuning);
+            closure = Eu*closure*Eu';
+            penalty = Eu*penalty;
+
+            switch component
+            case 't'
+                dir = obj.getTangent(boundary);
+            case 'n'
+                dir = obj.getNormal(boundary);
+            case 1
+                dir = {1, 0};
+            case 2
+                dir = {0, 1};
+            end
+
             switch type
             case {'F','f','Free','free','traction','Traction','t','T'}
 
-                % Get elastic closure and penalty
-                [closure, penalty] = obj.elasticObj.boundary_condition(boundary, bc, tuning);
-                closure = Eu*closure*Eu';
-                penalty = Eu*penalty;
-
-                switch component
-                case 't'
-                    dir = obj.getTangent(boundary);
-                case 'n'
-                    dir = obj.getNormal(boundary);
-                case 1
-                    dir = {1, 0};
-                case 2
-                    dir = {0, 1};
-                end
-
                 % Add viscous part of closure
                 for i = 1:dim
                     for j = 1:dim
@@ -306,22 +306,6 @@
 
             case {'D','d','dirichlet','Dirichlet','displacement','Displacement'}
 
-                % Get elastic closure and penalty
-                [closure, penalty] = obj.elasticObj.boundary_condition(boundary, bc, tuning);
-                closure = Eu*closure*Eu';
-                penalty = Eu*penalty;
-
-                switch component
-                case 't'
-                    dir = obj.getTangent(boundary);
-                case 'n'
-                    dir = obj.getNormal(boundary);
-                case 1
-                    dir = {1, 0};
-                case 2
-                    dir = {0, 1};
-                end
-
                 % Add penalty to strain rate eq
                 for i = 1:dim
                     for j = 1:dim