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
CoreFun3D.m
Go to the documentation of this file.
1 namespace models{
2 namespace pcd{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
19 class CoreFun3D
20  :public models.pcd.BaseCoreFun {
41  public: /* ( setObservable ) */
42 
55  private:
56 
57  A;
58 
59 
60  nodes;
61 
62 
63  g;
64 
65 
66  public:
67 
68 
69  CoreFun3D(dynsys) {
70  this = this@models.pcd.BaseCoreFun(dynsys);
71  }
72 
73 
74  function copy = clone() {
75  copy = models.pcd.CoreFun3D(this.sys);
76 
77  /* Call superclass method */
78  copy = clone@models.pcd.BaseCoreFun(this, copy);
79 
80  /* copy reference!
81  *copy.sys = this.sys; % already done in constructor */
82  copy.A= this.A;
83  copy.dim= this.dim;
84  copy.g= this.g;
85  copy.nodes= this.nodes;
86  }
87 
88 
89  function newSysDimension() {
90 
91  /* Create diffusion matrix */
92  n = prod(this.System.Dims);
93  this.nodes= this.System.geo.Points;
94  this.fDim= 4*n;
95  this.xDim= 4*n;
96  }
103  function fx = evaluateCoreFun(colvec<double> x,double t) {
104  fx = zeros(size(x));
105 
106  m = this.nodes;
107  s = this.System;
108  n = this.xDim;
109  g = s.geo;
110 
111  /* Uncomment if reaction coeffs become real params again */
112  mu = [s.ReacCoeff; this.mu];
113 
114  /* Extract single functions */
115  xa = x(1:m);
116  xan = xa.^n;
117  ya = x(m+1:2*m);
118  xi = x(2*m+1:3*m);
119  yi = x(3*m+1:end);
120 
121  /* % Compile boundary conditions
122  * Determine the points on each side that are affected of
123  * boundary conditions (constant over each simulation as mu is
124  * fixed then) */
125  h = s.h;
126  a = s.Omega;
127  xr = a(1,2)-a(1,1);
128  yr = a(2,2)-a(2,1);
129  zr = a(3,2)-a(3,1);
130  rb = zeros(m,1);
131  ud = (t < this.tDecaySecs) + (t >= this.tDecaySecs)*max(0,2-.5*t);
132 
133  /* % Front & back (only x/y coords relevant) */
134  [i,j] = ind2sub(g.Dims,g.F); /* #ok<*PROP> */
135 
136  xd = abs((i-1)*h-.5*xr);
137  yd = abs((j-1)*h-.5*yr);
138  rbp = xd < xr*mu(9)/2 & yd < yr*mu(9)/2;
139  rbF = sub2ind(g.Dims, i(rbp), j(rbp), ones(size(i(rbp))));
140  rbp = xd < xr*mu(10)/2 & yd < yr*mu(10)/2;
141  rbBa = sub2ind(g.Dims, i(rbp), j(rbp), ones(size(i(rbp)))*g.Dims(3));
142  rb(rbF) = (xi(rbF)*mu(15)*ud)/h;
143  rb(rbBa) = rb(rbBa) + (xi(rbBa)*mu(16)*ud)/h;
144 
145  /* % Left & Right (only x/z coords relevant) */
146  [i,~,k] = ind2sub(g.Dims,g.L);
147  xd = abs((i-1)*h-.5*xr);
148  zd = abs((k-1)*h-.5*zr);
149  rbp = xd < xr*mu(11)/2 & zd < zr*mu(11)/2;
150  rbL = sub2ind(g.Dims, i(rbp), ones(size(i(rbp))), k(rbp));
151  rbp = xd < xr*mu(12)/2 & zd < zr*mu(12)/2;
152  rbR = sub2ind(g.Dims, i(rbp), ones(size(i(rbp)))*g.Dims(2), k(rbp));
153  rb(rbL) = rb(rbL) + (xi(rbL)*mu(17)*ud)/h;
154  rb(rbR) = rb(rbR) + (xi(rbR)*mu(18)*ud)/h;
155 
156  /* % Top & Bottom (only y/z coords relevant) */
157  [i,j,k] = ind2sub(g.Dims,g.T);
158  yd = abs((j-1)*h-.5*yr);
159  zd = abs((k-1)*h-.5*zr);
160  rbp = yd < yr*mu(13)/2 & zd < zr*mu(13)/2;
161  rbT = sub2ind(g.Dims, ones(size(i(rbp))), j(rbp), k(rbp));
162  rbp = yd < yr*mu(14)/2 & zd < zr*mu(14)/2;
163  rbBo = sub2ind(g.Dims, ones(size(i(rbp)))*g.Dims(1), j(rbp), k(rbp));
164  rb(rbT) = rb(rbT) + (xi(rbT)*mu(19)*ud)/h;
165  rb(rbBo) = rb(rbBo) + (xi(rbBo)*mu(20)*ud)/h;
166 
167  /* % Actual evaluation
168  * Xa */
169  fx(1:m) = mu(1)*xi.*ya - mu(3)*xa + rb;
170  /* Ya */
171  fx(m+1:2*m) = mu(2)*yi.*xan - mu(4)*ya;
172  /* Xi */
173  fx(2*m+1:3*m) = -mu(1)*xi.*ya - mu(5)*xi + mu(7) - rb;
174  /* Yi */
175  fx(3*m+1:end) = -mu(2)*yi.*xan - mu(6)*yi + mu(8);
176  }
187  protected:
188 
189  function fxj = evaluateComponents(pts,ends,unused1,unused2,X,double t) {
190  error(" Not yet implemented ");
191  }
192 
193 
194 };
195 }
196 }
197 
198 
199 
The core nonlinear function of the PCD model in 3D.
Definition: CoreFun3D.m:19
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
function newSysDimension()
This fcn is called before each simulation is started.
Definition: CoreFun3D.m:89
function fxj = evaluateComponents(pts, ends, unused1, unused2, X,double t)
Definition: CoreFun3D.m:189
integer xDim
The current state space dimension of the function's argument .
Definition: ACoreFun.m:151
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
Definition: ACoreFun.m:193
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
Definition: ACoreFun.m:208
#define X(i, j)
function fx = evaluateCoreFun(colvec< double > x,double t)
Allocate result vector.
Definition: CoreFun3D.m:103
function copy = clone()
Definition: CoreFun3D.m:74
tDecaySecs
The number of seconds after which the neumann conditions decease.
Definition: CoreFun3D.m:43