KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SubElemInhomogMaterial.m
Go to the documentation of this file.
1 namespace models{
2 namespace muscle{
3 namespace examples{
4 
5 
6 /* (Autoinserted by mtoc++)
7  * This source code has been filtered by the mtoc++ executable,
8  * which generates code that can be processed by the doxygen documentation tool.
9  *
10  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
11  * Except for the comments, the function bodies of your M-file functions are untouched.
12  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
13  * attached source files that are highly readable by humans.
14  *
15  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
16  * the correct locations in the source code browser.
17  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
18  */
19 
28  public:
29 
31  this = this@models.muscle.AMuscleConfig(varargin[:]);
32  this.addOption(" Flip ",1);
33  this.init;
34 
35  this.VelocityBCTimeFun= general.functions.ConstantUntil(20);
36  }
44  function configureModel(m) {
45  configureModel@models.muscle.AMuscleConfig(this, m);
46 
47  m.T= 40;
48  m.dt= .5;
49  m.ODESolver.RelTol= 1e-6;
50  m.ODESolver.AbsTol= 1e-3;
51  m.DefaultMu(2) = 0;
52  }
53 
54 
55  function tmr = getTendonMuscleRatio(points) {
56  tmr = zeros(1,size(points,2));
57 /* tmr(:)=1; */
58  switch this.Options.Flip
59  case 3
60  tmr(points(3,:)<.5 & points(1,:)>.5) = 1;
61  tmr(points(3,:)>2.5 & points(1,:)<.5) = 1;
62  case 2
63  tmr(points(2,:)<.5 & points(3,:)>.5) = 1;
64  tmr(points(2,:)>2.5 & points(3,:)<.5) = 1;
65  otherwise
66  tmr(points(1,:)<.5 & points(3,:)>.5) = 1;
67  tmr(points(1,:)>2.5 & points(3,:)<.5) = 1;
68  end
69  }
81  protected:
82 
83 
84  function geo = getGeometry() {
85  xr = linspace(0,3,this.Options.GeoNr+1);
86  switch this.Options.Flip
87  case 3
88  geo = fem.geometry.RegularHex8Grid([0 1],[0 1], xr);
89  case 2
90  geo = fem.geometry.RegularHex8Grid([0 1],xr,[0 1]);
91  otherwise
92  geo = fem.geometry.RegularHex8Grid(xr,[0 1],[0 1]);
93  end
94  geo = geo.toCube27Node;
95  }
103  function displ_dir = setPositionDirichletBC(displ_dir) {
104  geo = this.FEM.Geometry;
105  switch this.Options.Flip
106  case 3
107  displ_dir(:,geo.Elements(1,geo.MasterFaces(5,:))) = true;
108  /* displ_dir([2 3],geo.Elements(this.Options.GeoNr,geo.MasterFaces(6,:))) = true; */
109  case 2
110  displ_dir(:,geo.Elements(1,geo.MasterFaces(3,:))) = true;
111  /* displ_dir([2 3],geo.Elements(this.Options.GeoNr,geo.MasterFaces(4,:))) = true; */
112  otherwise
113  displ_dir(:,geo.Elements(1,geo.MasterFaces(1,:))) = true;
114  /* displ_dir([2 3],geo.Elements(this.Options.GeoNr,geo.MasterFaces(2,:))) = true; */
115  end
116 
117  }
118 
119 
120  function [velo_dir , velo_dir_val ] = setVelocityDirichletBC(velo_dir,velo_dir_val) {
121  geo = this.FEM.Geometry;
122  switch this.Options.Flip
123  case 3
124  velo_dir(3,geo.Elements(this.Options.GeoNr,geo.MasterFaces(6,:))) = true;
125  case 2
126  velo_dir(2,geo.Elements(this.Options.GeoNr,geo.MasterFaces(4,:))) = true;
127  otherwise
128  velo_dir(1,geo.Elements(this.Options.GeoNr,geo.MasterFaces(2,:))) = true;
129  end
130  velo_dir_val(velo_dir) = .02;
131  }
142  function anull = seta0(anull) {
143  anull(this.Options.Flip,:,:) = 1;
144  }
145 
146 
147  public: /* ( Static ) */
148 
149  static function res = test_SubElem(gn) {
150  if nargin < 1
151  gn = 3;
152  end
153  /* % */
154  v = zeros(3,1);
155  o = ones(3,1);
156  for fl = 1:3
157  c = models.muscle.examples.SubElemInhomogMaterial(" GeoNr ",gn," Flip ",fl);
158  m = c.createModel;
159  m.setGaussIntegrationRule(6);
160  [t,y] = m.simulate;
161  df = m.getResidualForces(t,y);
162  idx = m.getPositionDirichletBCFaceIdx(1,1+(fl-1)*2);
163  force = sum(df(idx,end));
164  fprintf(" Flip %d - Forces at pos dirichlet side at end: %g\n ",fl,force);
165  v(fl) = force;
166  m.plot(t,y," DF ",df," F ",2);
167  end
168  err = tril(v*o" -(v*o ")^t)
169  rel1 = err ./ (v*o^t)
170  rel2 = err ./ (v*o" ) "
171  res = all(abs(rel1(:)) < 1e-4) && all(abs(rel2(:)) < 1e-4)
172  }
173 
174 
175 
176 };
177 }
178 }
179 }
180 
181 
182 
function addOption(name, default, varargin)
Definition: AFEMConfig.m:219
SubElemInhomogMaterial(varargin)
Creates a Debug simple muscle model configuration.
function geo = getGeometry()
Single cube with same config as reference element.
function displ_dir = setPositionDirichletBC(displ_dir)
* fl(l)
A variable number of input arguments.
Speed test * all(1:3)
VelocityBCTimeFun
Velocity conditions application function.
Definition: AFEMConfig.m:65
function [ velo_dir , velo_dir_val ] = setVelocityDirichletBC(velo_dir, velo_dir_val)
Determines the dirichlet velocities.
function tmr = getTendonMuscleRatio(points)
Returns the [0,1] ratio between tendon and muscle at all specified points.