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
BurgersF.m
Go to the documentation of this file.
1 namespace models{
2 namespace burgers{
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 BurgersF
39  public:
40 
41  A;
42 
43  Ax;
44 
45 
46  public:
47 
48  BurgersF(sys) {
49  this = this@dscomponents.ACompEvalCoreFun(sys);
50  this.CustomProjection= false;
51  this.TimeDependent= false;
52  }
53 
54 
55  function fx = evaluate(colvec<double> x,unused1) {
56  fx = bsxfun(@times,this.A*x,this.mu(1,:)) - x.*(this.Ax*x);
57  }
58 
59 
60  function evaluateCoreFun() {
61  error(" Evaluate is overridden directly ");
62  }
63 
64 
65  function fx = evaluateMulti(colvec<double> x,unused1,colvec<double> mu) {
66  fx = bsxfun(@times,this.A*x,mu(1,:)) - x.*(this.Ax*x);
67  }
68 
69 
70  function J = getStateJacobian(colvec<double> x,unused1) {
71  hlp = bsxfun(@times,this.Ax,x);
72  hlp = hlp + spdiags(this.Ax*x,0,size(x,1),size(x,1));
73  J = this.mu(1)*this.A - hlp;
74  }
75 
76 
77  function newDim() {
78  m = this.System.Model;
79  n = m.Dimension;
80  dx = (m.Omega(2) - m.Omega(1))/(n+1);
81  e = ones(n,1);
82  d1 = e/(2*dx);
83  d2 = e/(dx^2);
84  this.A= spdiags([d2 -2*d2 d2], -1:1, n, n);
85  this.Ax= spdiags([-d1 0*d1 d1], -1:1, n, n);
86  this.JSparsityPattern= spdiags([e e e], -1:1, n, n);
87  this.xDim= n;
88  this.fDim= n;
89  }
90 
91 
92  function copy = clone() {
93  copy = clone@dscomponents.ACompEvalCoreFun(this, models.burgers.BurgersF(this.System));
94  copy.A= this.A;
95  copy.Ax= this.Ax;
96  }
97 
98 
99  protected:
100 
102  fxj = zeros(length(pts),size(X,2));
103  for idx=1:length(pts)
104  pt = pts(idx);
105  if idx == 1
106  st = 0;
107  else
108  st = ends(idx-1);
109  end
110  /* Select the elements of x that are effectively used in f */
111  xidx = (st+1):ends(idx);
112  x = X(xidx);
113  fxj(idx) = this.mu(1).*(this.A(pt,argidx(xidx))*x) - x(self(xidx)).*(this.Ax(pt,argidx(xidx))*x);
114  end
115  }
140  function fxj = evaluateComponentsMulti(pts,ends,argidx,self,X,unused1,colvec<double> mu) {
141  fxj = zeros(length(pts),size(X,2));
142  for idx=1:length(pts)
143  pt = pts(idx);
144  if idx == 1
145  st = 0;
146  else
147  st = ends(idx-1);
148  end
149  /* Select the elements of x that are effectively used in f */
150  xidx = (st+1):ends(idx);
151  x = X(xidx,:);
152  fxj(idx,:) = mu(1,:).*(this.A(pt,argidx(xidx))*x) - x(self(xidx),:).*(this.Ax(pt,argidx(xidx))*x);
153  end
154  }
155 
156 
157 };
158 }
159 }
160 
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
function evaluateCoreFun()
Definition: BurgersF.m:60
CustomProjection
Set this property if the projection process is customized by overriding the default project method...
Definition: ACoreFun.m:108
logical TimeDependent
Flag that indicates if the ACoreFun is (truly) time-dependent.
Definition: ACoreFun.m:84
Model
The Model this System is attached to.
function fx = evaluateMulti(colvec< double > x, unused1,colvec< double > mu)
Definition: BurgersF.m:65
function newDim()
Definition: BurgersF.m:77
function J = getStateJacobian(colvec< double > x, unused1)
Definition: BurgersF.m:70
function fxj = evaluateComponentsMulti(pts, ends, argidx, self, X, unused1,colvec< double > mu)
Definition: BurgersF.m:140
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
function fxj = evaluateComponents(rowvec< integer > pts,rowvec< integer > ends,rowvec< integer > argidx,rowvec< integer > self,matrix< double > X, unused1)
Evaluates the burgers nonlinearity pointwise.
Definition: BurgersF.m:101
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 copy = clone()
Definition: BurgersF.m:92
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
Definition: ACoreFun.m:127
ACompEvalCoreFun: A normal CoreFun which supports single-component evaluation.
function fx = evaluate(colvec< double > x, unused1)
Definition: BurgersF.m:55