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
JKerMorExport.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
18  :public JaRMoSExport {
29  public:
30 
44  public:
45 
47  this.ModelType= " JKerMor ";
48  }
49 
50 
51  protected:
52 
53 
54  function [sourcebase , sourcefiles ] = typeSpecificExport(f,models.BaseFullModel model,folder) {
55  rm = model;
56 
57  fprintf(f," \t<kermor_model>\n ");
58  fprintf(f," \t\t<T>%17.17f</T>\n ",rm.T);
59  fprintf(f," \t\t<dt>%17.17f</dt>\n ",rm.dt);
60 
61  /* Get system dimension from initial value */
62  mu = [];
63  if ~isempty(rm.ParamSamples)
64  mu = rm.ParamSamples(:,1);
65  end
66  dim = size(rm.System.x0.evaluate(mu),1);
67  fprintf(f," \t<dim>%d</dim>\n ",dim);
68 
69  /* % Export model data */
70  export.Util.saveRealMatrix(rm.V," V.bin ",folder);
71  export.Util.saveRealMatrix(rm.W," W.bin ",folder);
72  /* export.AppExport.saveRealMatrix(rm.W,'G.bin',folder); */
73 
74  /* ODE solver type */
75  stype = " explicit ";
76  if isa(rm.ODESolver," solvers.IImplSolver ")
77  stype = " implicit ";
78  end
79  fprintf(f," \t<solvertype>%s</solvertype>\n ",stype);
80  fprintf(f," \t<outputtodof>TimoOutToDoF</outputtodof>\n ");
81  sources = [" TimoOutToDoF "];
82 
83  /* % Export system data
84  * Parameters */
85  fprintf(f," \t<parameters>\n ");
86  p = rm.FullModel.System.Params;
87  if ~isempty(p)
88  /* pvals = zeros(length(p),2); */
89  for k=1:length(p)
90  fprintf(f," \t\t<param name='%s' min='%17.17f' max='%17.17f' label='%s'/>\n ",...
91  p(k).Name,p(k).MinVal,p(k).MaxVal,p(k).Name);
92  end
93  /* export.AppExport.saveRealMatrix(pvals, 'paramvalues.bin', folder); */
94  end
95  fprintf(f," \t</parameters>\n ");
96 
97  /* Kernel expansion */
98  s = rm.System;
99  cf = s.f;
100  fprintf(f," \t<corefun type='%s'>\n ",class(cf));
101  if isa(cf," kernels.KernelExpansion ")
102  export.Util.saveRealMatrix(cf.Ma," Ma.bin ",folder);
103  export.Util.saveRealMatrix(cf.Centers.xi," xi.bin ",folder);
104  exportKernel(cf.Kernel," kernel.bin ",folder);
105  fprintf(f," \t\t<statekernel>%s</statekernel>\n ",class(cf.Kernel));
106  if isa(cf," kernels.ParamTimeKernelExpansion ")
107  export.Util.saveRealVector(cf.Centers.ti," ti.bin ",folder);
108  exportKernel(cf.TimeKernel," timekernel.bin ",folder);
109  fprintf(f," \t\t<timekernel>%s</timekernel>\n ",class(cf.TimeKernel));
110 
111  export.Util.saveRealMatrix(cf.Centers.mui," mui.bin ",folder);
112  exportKernel(cf.ParamKernel," paramkernel.bin ",folder);
113  fprintf(f," \t\t<paramkernel>%s</paramkernel>\n ",class(cf.ParamKernel));
114  end
115  elseif isa(cf, " dscomponents.LinearCoreFun ")
116  export.Util.saveRealMatrix(cf.A," A.bin ",folder);
117  elseif isa(cf, " dscomponents.AffLinCoreFun ")
118  if isempty(cf.CoeffClass)
119  error(" AffLinCoreFuns must have the CoeffClass value set for export. ");
120  end
121  /* Set path to IAffineCoefficients class to compile */
122  fprintf(f," \t\t<coeffclass>%s</coeffclass>\n ",cf.CoeffClass);
123  sources[end+1] = cf.CoeffClass;
124  export.Util.saveRealMatrix(cf.AffParamMatrix.Matrices," A.bin ",folder);
125  else
126  error(" System function type unknown for export. ");
127  end
128  fprintf(f," \t</corefun>\n ");
129 
130  /* Input */
131  if rm.System.InputCount > 0 && ~isempty(s.B)
132  fprintf(f," \t<inputconv type='%s'>\n ",class(s.B));
133  if isa(s.B," dscomponents.LinearInputConv ")
134  export.Util.saveRealMatrix(s.B.B," B.bin ",folder);
135  elseif isa(s.B," dscomponents.AffLinInputConv ")
136  if isempty(s.B.CoeffClass)
137  error(" AffLinInputConv instances must have the CoeffClass value set for export. ");
138  end
139  /* Set path to IAffineCoefficients class to compile */
140  fprintf(f," \t\t<coeffclass>%s</coeffclass>\n ",s.B.CoeffClass);
141  sources[end+1] = s.B.CoeffClass;
142  export.Util.saveRealMatrix(s.B.Matrices," B.bin ",folder);
143  end
144  fprintf(f," \t</inputconv>\n ");
145  sources[end+1] = " Inputs ";
146  end
147 
148  /* Mass matrix */
149  if ~isempty(s.M)
150  fprintf(f," \t<massmatrix type='%s'>\n ",class(s.M));
151  if isa(s.M," dscomponents.ConstMassMatrix ")
152  export.Util.saveRealMatrix(s.M.M," M.bin ",folder);
153  elseif isa(s.M," dscomponents.AffLinMassMatrix ")
154  if isempty(s.M.CoeffClass)
155  error(" AffLinMassMatrix instances must have the CoeffClass value set for export. ");
156  end
157  /* Set path to IAffineCoefficients class to compile */
158  fprintf(f," \t\t<coeffclass>%s</coeffclass>\n ",s.M.CoeffClass);
159  sources[end+1] = s.M.CoeffClass;
160  export.Util.saveRealMatrix(s.M.Matrices," M.bin ",folder);
161  end
162  fprintf(f," \t</massmatrix>\n ");
163  end
164 
165  /* Output */
166  if ~isempty(s.C)
167  if isa(s.C," dscomponents.LinearOutputConv ")
168  C = s.C.C;
169  if isscalar(C)
170  C = eye(dim);
171  end
172  export.Util.saveRealMatrix(C," C.bin ",folder);
173  elseif isa(s.C," dscomponents.AffLinOutputConv ")
174  error(" Not yet implemented. ");
175  end
176  fprintf(f," \t<outputconvtype>%s</outputconvtype>\n ",class(s.C));
177  end
178 
179  /* Initial value */
180  if isa(s.x0," dscomponents.ConstInitialValue ")
181  export.Util.saveRealVector(s.x0.x0," x0.bin ",folder);
182  elseif isa(s.B," dscomponents.AffineInitialValue ")
183  error(" Not yet implemented. ");
184  end
185  fprintf(f," \t<initialvaluetype>%s</initialvaluetype>\n ",class(s.x0));
186  fprintf(f," \t</kermor_model>\n ");
187 
188  /* Assign source files and base here (from settings; here as
189  * JaRMoSExport does not "know" the KerMor etc) */
190  sourcebase = this.JKerMorSourceDirectory;
191  sourcefiles = sources;
192 
193  function exportKernel(k, file, folder)
194  if isa(k," kernels.GaussKernel ")
195  export.Util.saveRealVector(k.Gamma,file,folder);
196  elseif isa(k," kernels.LinearKernel ")
197  /* do nothing. */
198  end
199  end
200  }
201 
202 
203 };
204 
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
function [ sourcebase , sourcefiles ] = typeSpecificExport(f,models.BaseFullModel model, folder)
Definition: JKerMorExport.m:54
char ModelType
The model type according to the jarmos.ModelType enum.
Definition: JaRMoSExport.m:114
JKerMorExport: Export class for JaRMoS model generation from KerMor models.
Definition: JKerMorExport.m:17
JaRMoSExport: Export base class for JaRMoS Models.
Definition: JaRMoSExport.m:17
char JKerMorSourceDirectory
The directory of JKerMor sources.
Definition: JKerMorExport.m:31
A MatLab character array.