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
NeumannPressure.m
Go to the documentation of this file.
1 namespace models{
2 namespace muscle{
3 namespace tests{
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 
31  public:
32 
33  NeumannPressure(version) {
34  if nargin < 1
35  version = 1;
36  end
37  /* Creates a Debug simple muscle model configuration. */
38  this = this@models.muscle.AMuscleConfig;
39  this.addOption(" Version ",version);
40  this.init;
41  }
42 
43 
44  function configureModel(m) {
45  configureModel@models.muscle.AMuscleConfig(this, m);
46 /* sys = m.System;
47  *f = sys.f; */
48  m.T= 100;
49  m.dt= 1;
50  /* Kleine Visko für schnelle einstellung des gleichgewichts */
51  m.DefaultMu(1) = .1;/* 1e-4;
52  * "Passende" Mooney-Rivlin parameter so dass das element nicht
53  * allzu sehr degeneriert */
54 
55  m.DefaultMu([9 10]) = .1;
56  /* Genau lösen! */
57  m.ODESolver.RelTol= 1e-7;
58  m.ODESolver.AbsTol= 1e-7;
59  m.DefaultInput= 1;
60  }
61 
62 
63  function P = getBoundaryPressure(elemidx,faceidx) {
64  P = [];
65  if elemidx == 1 && faceidx == 2
66  P = eye(3);
67  end
68  }
82  function u = getInputs() {
83  u = [this.getAlphaRamp(this.Model.T/2,1)];
84  }
85 
86 
87  protected:
88 
89 
90  function geo = getGeometry() {
91  geo = fem.geometry.RegularHex8Grid([0 1],[0 1],[0 1]);
92  geo = geo.toCube27Node;
93  }
101  function displ_dir = setPositionDirichletBC(displ_dir) {
102  geo = this.FEM.Geometry;
103  displ_dir(1,geo.Elements(1,geo.MasterFaces(1,:))) = true;
104  displ_dir(:,geo.Elements(1,geo.MasterFaces(1,5))) = true;
105  }
106 
107 
108  function anull = seta0(anull) {
109  if this.Options.Version == 2
110  anull(1,:,:) = 1;
111  end
112  }
113 
114 
115  public: /* ( Static ) */
116 
117  static function res = test_NeumannPressure() {
118  for version = 1:2
119  a = models.muscle.tests.NeumannPressure(version);
120  m = a.createModel;
121  if version == 1
122  m.setGaussIntegrationRule(4);
123  end
124 
125  B = m.System.B.getMatrix(1);
126  res = norm(sum(B) - 1) < 1e-10;
127  extfidx = find(B);
128 
129  f1 = m.getPositionDirichletBCFaceIdx(1,1);
130  mu = m.DefaultMu;
131  maxf = [.1 rand(1,5)*.1];
132  for k=1:length(maxf)
133  mu(3) = maxf(k);
134  [t,y] = m.simulate(mu,1);
135  pdf = m.getResidualForces(t,y);
136 /* m.plot(t,y,'DF',pdf,'MR',true,'Pause',2); %,'Lambdas',true
137  * m.plot(t,y,'F',2); */
138 
139  force_l = sum(pdf(f1,:),1);
140 /* figure;
141  * plot(t,force_l); */
142 
143  /* See that the forces at the pulled side match (at the end) */
144  fyend = m.System.f.evaluate(y(:,end),t(end));
145  res = res && norm(maxf(k)*B(extfidx) + fyend(extfidx)) < 1e-10;
146 
147  fprintf(" Ext force on side %g[N] => Force left %gN\n ",...
148  maxf(k),force_l(end));
149  res = res && norm(maxf(k)-force_l(end)) < 1e-8;
150  end
151  end
152  }
153 
154 
155 
156 
157 };
158 }
159 }
160 }
161 
162 
163 
function addOption(name, default, varargin)
Definition: AFEMConfig.m:219
function alpha = getAlphaRamp(ramptime,double alphamax,double starttime)
Creates a linearly increasing scalar function starting at starttime milliseconds ranging from zero to...
static function res = test_NeumannPressure()
Tests the force generated by an isometrically fixed muscle.
double T
The final timestep up to which to simulate.
Definition: BaseModel.m:271
function displ_dir = setPositionDirichletBC(displ_dir)
function P = getBoundaryPressure(elemidx, faceidx)
Determines the neumann forces on the boundary.
function geo = getGeometry()
Single cube with same config as reference element.
Model: Model for a FEM-discretized muscle model.
Definition: Model.m:19