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
JaRMoSExport.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 handle {
48  public:
49 
114  char ModelType = "Unknown";
124  char Short = "";
134  public:
135 
136  function exportModel(models.ReducedModel model,char folder) {
137 
138  /* % Use last folder if KerMor is around */
139  if nargin == 2
140  initialdir = ;
141  if ~isempty(which(" KerMor "))
142  a = KerMor.App;
143  initialdir = getpref(a.getPrefTag," LASTDIR "," . ");
144  end
145  folder = uigetdir(initialdir);
146  if ~isempty(which(" KerMor "))
147  setpref(a.getPrefTag," LASTDIR ",folder);
148  end
149  end
150 
151  /* % Validations */
152  if exist(folder," dir ") ~= 7
153  try
154  mkdir(folder);
155  catch ME
156  mexc = MException(" JaRMoSExport:nodir "," Directory '%s' did not exist and could not be created. ", folder);
157  mexc.addCause(ME);
158  mexc.throw();
159  end
160  end
161 
162  /* % Create Model XML */
163  f = fopen(fullfile(folder," model.xml ")," w+ ");
164  fprintf(f," <?xml version='1.0' encoding='utf-8'?>\n ");
165  fprintf(f," <model type='%s' machformat='be'>\n ",this.ModelType);
166  fprintf(f," \t<description>\n ");
167  fprintf(f," \t\t<short>%s</short>\n ",this.Short);
168  fprintf(f," \t\t<created>%s</created>\n ",datestr(now," yyyy-mm-dd "));
169  /* get image
170  * [fn,fo] = rm.createImage;
171  * copyfile(fullfile(fo,fn),fullfile(folder,fn));
172  * fprintf(f,'\t\t<image>%s</image>\n',fn); */
173  fprintf(f," \t</description>\n ");
174 
175  [sourcebase, sourcefiles] = this.typeSpecificExport(f, model, folder);
176 
177  /* % Java sources compilation */
178  if ~isempty(sourcefiles)
179  if isempty(sourcebase)
180  error(" No project java sources directory set. Aborting. ");
181  end
182  j = export.Java;
183  j.TargetFolder= folder;
184  j.Package= this.JavaExportPackage;
185  j.JProjectSource= sourcebase;
186  j.AdditionalClassPath= [this.JaRMoSBaseSource];
187  j.Sources= sourcefiles;
188  j.CreateAndroid= true;
189  j.exportFunctions;
190  end
191 
192  fprintf(f," <numDoFfields>%d</numDoFfields>\n ",this.DoFFields);
193 
194  /* % Model geometry */
195  if ~isempty(this.GeometryExportCallback)
196  fprintf(f," <geometry>\n ");
197  this.GeometryExportCallback(f, folder, this);
198  fprintf(f," </geometry>\n ");
199  end
200  /* % Logical model solution fields */
201  fi = this.LogicalFields;
202  if ~isempty(fi)
203  fprintf(f," <visual><fields>\n ");
204  for idx=1:length(fi)
205  mapping = " VERTEX ";
206  if isfield(fi(idx)," Mapping ") && ~isempty(fi(idx).Mapping)
207  mapping = fi(idx).Mapping;
208  end
209  if ~isempty(fi(idx).Name)
210  fprintf(f," \t<field type='%s' mapping='%s'>%s</field>\n ",...
211  fi(idx).Type,mapping,fi(idx).Name);
212  else
213  fprintf(f," \t<field type='%s' mapping='%s'/>\n ",...
214  fi(idx).Type,mapping);
215  end
216  end
217  fprintf(f," </fields></visual>\n ");
218  end
219  if ~isempty(this.JavaExportPackage)
220  fprintf(f," <package>%s</package>\n ",this.JavaExportPackage);
221  end
222  fprintf(f," </model>\n ");
223  fclose(f);
224  }
234  protected: /* ( Abstract ) */
235 
236  virtual function [sourcebase , sourcefiles ] = typeSpecificExport(f,models.BaseFullModel model,settings,folder) = 0;
237 
238 
239 
240 };
241 
function exportModel(models.ReducedModel model,char folder)
Exports the given model for use in JaRMoS to the given folder.
Definition: JaRMoSExport.m:136
char JaRMoSBaseSource
The JaRMoSBase java sources directory. Required if any java classes are to by compiled.
Definition: JaRMoSExport.m:103
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
integer DoFFields
The number of degrees of freedom-fields this system computes as output.
Definition: JaRMoSExport.m:50
char ModelType
The model type according to the jarmos.ModelType enum.
Definition: JaRMoSExport.m:114
An integer value.
The KerMor reduced model class.
Definition: ReducedModel.m:18
A MatLab function handle.
Matlab's base handle class (documentation generation substitute)
JaRMoSExport: Export base class for JaRMoS Models.
Definition: JaRMoSExport.m:17
virtual function [ sourcebase , sourcefiles ] = typeSpecificExport(f,models.BaseFullModel model, settings, folder)
char Short
Short description for the model.
Definition: JaRMoSExport.m:124
function_handle GeometryExportCallback
A callback for geometry export of the JaRMoS-Model.
Definition: JaRMoSExport.m:78
struct LogicalFields
Returns the field descriptions for each logical solution field.
Definition: JaRMoSExport.m:62
char JavaExportPackage
The package of any java classes associated with this model when exported to JaRMoS.
Definition: JaRMoSExport.m:92
Global configuration class for all KerMor run-time settings.
Definition: KerMor.m:17
static function KerMor theinstance = App()
The singleton KerMor instance.
Definition: KerMor.m:910
A MatLab struct.
A MatLab character array.