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
JRBExport.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 
17 class JRBExport
18  :public JaRMoSExport {
35  public:
36 
37  Version = 0;
48  TargetFolder = "/home/dwirtz/aghwww/romsim/rbm_advec";
57  JRBSource = "/home/dwirtz/aghhome/Software/Eclipse/JRB/src";
66  Params = "[]";
93  ForWebFolder = true;
108  public:
109 
110 
111 
112 #if 0 //mtoc++: 'set.TargetFolder'
113 function TargetFolder(value) {
114  if isempty(value)
115  error(" Target folder value must not be empty. ");
116  end
117  /* Strip trailing slash if set */
118  if value(end) == " / " || value(end) == " \ "
119  value = value(1:end-1);
120  end
121  if exist(value," dir ") ~= 7
122  if 1 ~= mkdir(value)
123  error(" Could not create directory '%s' ", value);
124  end
125  end
126  this.TargetFolder= value;
127  }
128 
129 #endif
130 
131 
132 
133 #if 0 //mtoc++: 'set.Version'
134 function Version(value) {
135  if ~any(value == [0 1])
136  error(" Only 0 for 'jrb' and 1 for 'rbappmit' versions allowed. ");
137  end
138  this.Version= value;
139  }
140 
141 #endif
142 
143 
144  function export_file(matfile) {
145  S = load(matfile);
146  this.export(S.model, S.detailed_data);
147  }
157  function export(model,det) {
158 
159  /* % Validity checks */
160  fprintf(" Starting model export to %s ...\n ",this.TargetFolder);
161 
162  /* % Re-create the model and reduced data; should not be too costly */
163  model_data = gen_model_data(model);
164  red = gen_reduced_data(model, det);
165 
166  /* % Start the model.xml file with description etc */
167  f = this.startExportXML(model);
168 
169  /* % Export model data, depending on format */
170  if this.Version == 0
171  this.export_JRB(model, model_data, det, red, f);
172  elseif this.Version == 1
173  fprintf(f," <rbappmit_model />\n ");
174  this.export_rbappmit(model, model_data, det, red);
175  end
176 
177  /* % Export affine functions */
178  this.exportAffineFunctions(f);
179 
180  /* % Export grid (no matter which version - always the rb one for our models) */
181  this.exportGeometry(model_data.grid, f);
182 
183  fprintf(f," \t<visual>\n ");
184  fprintf(f," \t\t<plotSteps>%d</plotSteps>\n ",model.nt+1);
185  fprintf(f," \t</visual>\n ");
186 
187  this.endExportXML(f);
188 
189  /* % Add folder name to models.txt if it is a web export. */
190  if this.ForWebFolder
191  [parent, foldername] = fileparts(this.TargetFolder);
192  mtxt = fullfile(parent, " models.txt ");
193  fid = fopen(mtxt," a+ ");
194  ln = fgetl(fid);
195  exists = false;
196  while ischar(ln)
197  if strcmp(ln,foldername)
198  exists = true;
199  end
200  ln = fgetl(fid);
201  end
202  if ~exists
203  fprintf(fid," %s\n ",foldername);
204  end
205  fclose(fid);
206  end
207  }
219  private:
220 
221 
222  function f = startExportXML(models.BaseFullModel model) {
223  f = fopen(fullfile(this.TargetFolder," model.xml ")," w+ ");
224  fprintf(f," <?xml version='1.0' encoding='utf-8'?>\n ");
225  fprintf(f," <!-- Generated by rbmatlab on %s -->\n ",date);
226  /* Always use big endian format as it's java's native byte order */
227  version = " JRB ";
228  if this.Version == 1
229  version = " rbappmit ";
230  end
231  fprintf(f," <model type='%s' machformat='be'>\n ",version);
232  fprintf(f," <description>\n ");
233  if isfield(this.Params," title ")
234  t = this.Params.title;
235  else
236  t = [" rbmatlab: " func2str(model.gen_model_data)];
237  end
238  fprintf(f," \t<name>%s</name>\n ",t);
239  fprintf(f," \t<created>%s</created>\n ",datestr(now));
240  if isfield(this.Params," short ")
241  t = this.Params.short;
242  else
243  t = [" rbmatlab: " func2str(model.gen_model_data)];
244  end
245  fprintf(f," \t<short>%s</short>\n ",t);
246  if exist(" figure.png "," file ") == 2
247  copyfile(" figure.png ",fullfile(this.TargetFolder," figure.png "))
248  fprintf(f," \t<image>figure.png</image>\n ");
249  end
250 /* fprintf(f,'\t<infohtml>site_info.html</infohtml>\n'); */
251  fprintf(f," </description>\n ");
252  }
267  function endExportXML(f) {
268  fprintf(f," </model>\n ");
269  fclose(f);
270  }
271 
272 
273  function exportAffineFunctions(f) {
274  jfile = this.AffFcnsJava;
275  package = ;
276  if this.Version == 0
277  if isempty(this.JRBSource)
278  error(" For JRB model export version a the JRBSource property must not be empty. ");
279  end
280  if isempty(jfile)
281  [par, fname] = fileparts(this.TargetFolder);
282  package = fullfile(" models ",fname);
283  jfile = fullfile(fullfile(this.JRBSource,package)," AffineFunctions.java ");
284  end
285  cmd = sprintf(" javac -classpath %s -d %s %s ",this.JRBSource, this.TargetFolder, jfile);
286  elseif this.Version == 1
287  if isempty(this.AffFcnsJava)
288  error(" Error exporting affine functions: AffFcnsJava field must be set for rbappmit model export. ");
289  end
290  cmd = sprintf(" javac -d %s %s ",this.TargetFolder, jfile);
291  end
292  if exist(jfile," file ") ~= 2
293  error(" Affine functions file '%s' does not exist. ",jfile);
294  end
295 
296  fprintf(" Compiling and exporting AffineFunctions in '%s'...\n ",jfile);
297  system(cmd);
298 
299  outcl = fullfile(fullfile(this.TargetFolder,package)," AffineFunctions.class ");
300  javajar = fullfile(this.TargetFolder," classes.jar ");
301  dexjar = fullfile(this.TargetFolder," dexclasses.jar ");
302 
303  /* Create dex files for Android DalvikVM
304  *system(sprintf('dx --dex --output="dexclasses.jar" %s',outcl)); */
305  system(sprintf(" dx --dex --no-strict --output='%s' %s ",dexjar,outcl));
306 
307  /* Create normal jar file for Java VMs */
308  system(sprintf(" jar -cf %s -C %s %s ",javajar,this.TargetFolder,fullfile(package," AffineFunctions.class ")));
309  /* Remove .class file - we're tidy :-) */
310  if ~isempty(package)
311  rmdir(fullfile(this.TargetFolder," models ")," s ");
312  package = [" models. " fname];
313  else
314  delete(outcl);
315  end
316 
317  if ~isempty(package)
318  fprintf(f," <package>%s</package>\n ",package);
319  end
320  }
328  function exportGeometry(g,f) {
329  if ~isa(g," triagrid ")
330  error(" Cannot export an object of class %s as geometry. Instance of triagrid is required. ",class(g));
331  end
332 
333  fprintf(" Exporting model grid (%s) to geometry files...\n ",class(g));
334 
335  /* Write XML entries */
336  fprintf(f," <geometry>\n ");
337  fprintf(f," \t<dimension>2</dimension>\n ");
338  fprintf(f," \t<nodes>%d</nodes>\n ",length(g.X));
339  fprintf(f," \t<fieldmapping>ELEMENT</fieldmapping>\n ");
340  fprintf(f," </geometry>\n ");
341 
342  /* COMMENTED - dont write useless zeros to files, is big enough already.
343  * Rather read the model XML and fill up zeros inside the program, if need be.
344  * Insert zero z coords (JRB has only 3D vertices)
345  *z = single(zeros(size(g.X))); */
346 
347  /* Make big column vector */
348  nodes = single(reshape([g.X g.Y]^t,[],1));
349 
350  m = max(g.VI(:));
351  if m > intmax(" int16 ")
352  error(" Too many faces for app: %d. Max allowed is intmax(int16) = %d ",m,intmax(" int16 "));
353  end
354  faces = int16(reshape(g.VI^t,[],1));
355 
356  export.AppExport.saveRealVector(nodes," vertices.bin ",this.TargetFolder);
357  export.AppExport.saveRealVector(faces," faces.bin ",this.TargetFolder);
358 /* save geo nodes faces; */
359  }
360 
361 
362  function export_rbappmit(models.BaseFullModel model,model_data,det,red) {
363  fid = fopen(fullfile(this.TargetFolder," input.in ")," w ");
364 
365  /* check if system type is predefined. If not... make a guess
366  *---------------------------------------------------- */
367  if (isfield(this.Params," model_type "))
368  system_type = this.Params.model_type;
369  else
370  if isfield(model," nt ")
371  /* unsteady... */
372  if isfield(model," affinely_decomposed ")&&model.affinely_decomposed
373  system_type = " LINEAR_UNSTEADY ";
374  else
375  system_type = " NONLINEAR_UNSTEADY ";
376  end
377  else
378  /* steady */
379  if isfield(model," affinely_decomposed ")&&model.affinely_decomposed
380  system_type = " LINEAR_STEADY ";
381  else
382  system_type = " NONLINEAR_STEADY ";
383  end
384  end
385  end
386 
387  fprintf(fid," system_type = %s\n ",system_type);
388 
389  /* scm type (successive constraint method)
390  *--------------------------------------- */
391  if isfield(this.Params," scm_type ")
392  scm_type = this.Params.scm_type;
393  else
394  scm_type = " NONE ";
395  end
396  fprintf(fid," scm_type = %s\n ",scm_type);
397 
398  /* n_field (number of field variables... bei uns bisher immer nur eine)
399  *---------------------------------------------------------------------- */
400  if isfield(this.Params," n_field ")
401  n_field = this.Params.n_field;
402  else
403  n_field = 1; /* standard: nur eine Feldvariable */
404 
405  end
406  fprintf(fid," n_field = %d\n\n ",n_field);
407 
408  /* number of components Q
409  *---------------------- */
410  fprintf(fid," Q_a = %d\n ",Qa);
411  fprintf(fid," Q_f = %d\n\n ",Qf);
412  /* Kommentar: eigentlich fehlen hier noch Komponenten LL_I des
413  *impliziten Operators und die Komponenten der parameter separierten
414  *Anfangsbedingungen */
415 
416  /* Nmax: maximum number of basis vectors
417  *-------------------------------------- */
418  fprintf(fid," Nmax = %d\n\n ",size(det.RB,2));
419 
420  /* Information about parameterization
421  *-------------------------------------- */
422  n_parameters = length(model.mu_names);
423  fprintf(fid," n_parameters = %d\n ",n_parameters);
424  for i=1:n_parameters
425  fprintf(fid,[" mu ",num2str(i-1)," _min = %d\n "],model.mu_ranges[i](1));
426  fprintf(fid,[" mu ",num2str(i-1)," _max = %d\n "],model.mu_ranges[i](2));
427  end
428 
429  /* Information about outputs
430  *------------------------- */
431  if isfield(this.Params," n_outputs ")
432  n_outputs = this.Params.n_outputs;
433  else
434  n_outputs = 1;
435  end
436  fprintf(fid," n_outputs = %d\n ",n_outputs);
437 
438  /* Information about time discretization
439  *------------------------------------- */
440  if strcmp(system_type," LINEAR_UNSTEADY ")||strcmp(system_type," NONLINEAR_UNSTEADY ")
441  fprintf(fid," dt = %f\n ",(model.T/model.nt)); /* Zeitschrittweite */
442 
443  fprintf(fid," K = %d\n ",model.nt); /* number of time steps */
444 
445  if isfield(model," theta ")
446  fprintf(fid," euler_theta = %d\n ",model.theta);
447  else
448  fprintf(fid," euler_theta = %f\n ",0);
449  end
450  end
451 
452  /* Labels
453  *------------------------------------ */
454  if isfield(this.Params," title ")
455  fprintf(fid," title = %s\n ",this.Params.title);
456  end
457  for i=1:n_parameters
458  fprintf(fid,[" param ",num2str(i-1)," _label = %s\n "],model.mu_names[i]);
459  end
460 
461  fclose(fid);
462  /* keyboard
463  *----------------------------------------------------------- */
464 
465  /* number of basisvectors in RB */
466  fid = fopen(fullfile(this.TargetFolder," n_bfs.dat ")," w ");
467  fprintf(fid," %d ",size(det.RB,2));
468  fclose(fid);
469 
470  /* number of nodes in geometry */
471  fid = fopen(fullfile(this.TargetFolder," calN.dat ")," w ");
472  fprintf(fid," %d ",size(model_data.grid.VI,1));
473  fclose(fid);
474 
475  /* write output */
476  disp(" Writing output ")
477  fid=fopen(fullfile(this.TargetFolder," output_000_000.dat ")," w ");
478  for i=1:(length(red.s_RB))
479  fprintf(fid," %17.17e ",(red.s_RB(i)));
480  end
481  fclose(fid);
482 
483  /* write L_E operator components */
484  disp(" Writing LL_E ")
485  for q=1:Qa
486  fid= fopen(fullfile(this.TargetFolder,[" RB_A_00 ",num2str(q-1)," .dat "])," w ");
487  for i=1:(size(red.LL_E[q],1)^2)
488  fprintf(fid," %17.17e ",red.LL_E[q](i));
489  end
490  fclose(fid);
491  end
492 
493  /* write rhs b components */
494  disp(" Writing bb ")
495  for q=1:Qf
496  fid = fopen(fullfile(this.TargetFolder,[" RB_F_00 ",num2str(q-1)," .dat "])," w ");
497  for i=1:size(red.bb[q],1)
498  fprintf(fid," %17.17e ", red.bb[q](i));
499  end
500  fclose(fid);
501  end
502 
503  /* write M matrix (identity matrix) */
504  disp(" Writing M ")
505  M=eye(size(red.LL_E[1],1), size(red.LL_E[1],2));
506  fid = fopen(fullfile(this.TargetFolder," RB_M_000.dat ")," w ");
507  for i=1:size(M,1)^2
508  fprintf(fid," %17.17e ",M(i));
509  end
510  fclose(fid);
511 
512  /* write mass matrices (try=also idendity matrices) */
513  disp(" Writing mass matrices ")
514  fid = fopen(fullfile(this.TargetFolder," RB_mass_matrix.dat ")," w ");
515  for i=1:size(M,1)^2
516  fprintf(fid," %17.17e ",M(i));
517  end
518  fclose(fid);
519 
520  fid = fopen(fullfile(this.TargetFolder," RB_inner_product_matrix.dat ")," w ");
521  for i=1:size(M,1)^2
522  fprintf(fid," %17.17e ",M(i));
523  end
524  fclose(fid);
525 
526  fid = fopen(fullfile(this.TargetFolder," RB_L2_matrix.dat ")," w ");
527  for i=1:size(M,1)^2
528  fprintf(fid," %17.17e ",M(i));
529  end
530  fclose(fid);
531 
532  /* write RB-vectors */
533  disp(" Writing RB-vectors ");
534  for n=1:size(det.RB,2)
535  if n-1<10
536  ns = [" 0 ",num2str(n-1)];
537  else
538  ns=num2str(n-1);
539  end
540  fid = fopen(fullfile(this.TargetFolder,[" Z_000_0 ",ns," .bin "])," w ");
541  /* for i=1:size(det.RB,1) */
542  fwrite(fid,det.RB(:,n)," double ");
543  /* end */
544  fclose(fid);
545  end
546 
547  /* write error matrices AqAq */
548  disp(" Writing AqAq ")
549  Q=length(red.M_EE);
550  for q=1:length(red.M_EE)
551  fid = fopen(fullfile(this.TargetFolder,[" Aq_Aq_00 ",num2str(floor((q-1)/sqrt(Q)))," _00 ",num2str(q-floor((q-1)/sqrt(Q))*sqrt(Q)-1)," _norms.bin "])," w ");
552  fwrite(fid,red.M_EE[q]," double ");
553  fclose(fid);
554  end
555 
556  /* write error matrices FqAq */
557  disp(" Writing FqAq ")
558  Qb=Qf;
559  QL=Qa;
560  Fq_Aq=cell(1,QL*Qb);
561  for q1=1:Qb
562  for q2=1:QL
563  Fq_Aq[q2+(q1-1)*QL] = red.M_Eb[q1+(q2-1)*Qb];
564  end
565  end
566  fid=fopen(fullfile(this.TargetFolder," Fq_Aq_norms.dat ")," w ");
567  for i=1:QL*Qb
568  for j=1:size(Fq_Aq[i],1)
569  fprintf(fid," %17.17e ",Fq_Aq[i](j));
570  end
571  end
572  fclose(fid);
573 
574 
575  /* write Aq_Mq norms and Aq_M */
576  disp(" Writing Aq_Mq and Aq_M ")
577  fid=fopen(fullfile(this.TargetFolder," Aq_M_norms.dat ")," w ");
578  for q=1:length(red.M_E)
579  for i=1:size(red.M_E[q],1)^2
580  fprintf(fid," %17.17e ",red.M_E[q](i));
581  end
582  end
583  fclose(fid);
584  fid=fopen(fullfile(this.TargetFolder," Aq_Mq_norms.dat ")," w ");
585  for q=1:length(red.M_E)
586  for i=1:size(red.M_E[q],1)^2
587  fprintf(fid," %17.17e ",red.M_E[q](i));
588  end
589  end
590  fclose(fid);
591 
592  /* write Fq_M and Fq_Mq */
593  disp(" Writing Fq_Mq and Fq_M ")
594  fid=fopen(fullfile(this.TargetFolder," Fq_Mq_norms.dat ")," w ");
595  for q=1:length(red.M_b)
596  for i=1:size(red.M_b[q],1)*size(red.M_b[q],2)
597  fprintf(fid," %17.17e ",red.M_b[q](i));
598  end
599  end
600  fclose(fid);
601 
602  fid=fopen(fullfile(this.TargetFolder," Fq_M_norms.dat ")," w ");
603  for q=1:length(red.M_b)
604  for i=1:size(red.M_b[q],1)*size(red.M_b[q],2)
605  fprintf(fid," %17.17e ",red.M_b[q](i));
606  end
607  end
608  fclose(fid);
609 
610  /* write Fq_Fq */
611  disp(" Writing Fq norms ");
612  fid = fopen(fullfile(this.TargetFolder," Fq_norms.dat ")," w ");
613  for q=1:length(red.M_bb)
614  fprintf(fid," %17.17e ",red.M_bb[q]);
615  end
616  fclose(fid);
617 
618  /* write idendity matrices for M_M_norms */
619  disp(" Writing M_M_norms and Mq_Mq_norms ");
620  fid=fopen(fullfile(this.TargetFolder," M_M_norms.dat ")," w ");
621  for i=1:size(M,1)^2
622  fprintf(fid," %17.17e ",M(i));
623  end
624  fclose(fid);
625 
626  fid=fopen(fullfile(this.TargetFolder," Mq_Mq_norms.dat ")," w ");
627  for i=1:size(M,1)^2
628  fprintf(fid," %17.17e ",M(i));
629  end
630  fclose(fid);
631 
632  /* output_dual_norm */
633  disp(" Writing dual norm of output ")
634  fid = fopen(fullfile(this.TargetFolder," output_000_dual_norms.dat ")," w ");
635  model.decomp_mode= 0;
636  v=model.operators_output(model,model_data);
637  fprintf(fid," %17.17e ",norm(v));
638  fclose(fid);
639 
640  /* %write LL_E operator
641  * for i=1:Qa
642  * fid = fopen(fullfile(this.TargetFolder,['Aq_Aq_000_00',num2str(i-1),'_norms.bin')],'w');
643  * fwrite(fid,red.LL_E{i},'double');
644  * fclose(fid);
645  * end
646  *
647  *
648  * %write mass matrix WRONG!!
649  * fid=fopen(fullfile(this.TargetFolder,'RB_inner_product_matrix.dat'),'w');
650  * for i=1:(size(model_data.W,1)^2)
651  * fwrite(fid,model_data.W(i),'double');
652  * fwrite(fid,' ');
653  * end
654  * fclose(fid); */
655  }
673  function export_JRB(models.BaseFullModel model,model_data,det,red,fxml) {
674 
675  /* % Static settings, that might change for different models */
676  Qm = 1; /* number of mass matrices for UNSTEADY-type systems? */
677 
678 
679  /* % Determine system type */
680  if (isfield(this.Params," model_type "))
681  system_type = this.Params.model_type;
682  else
683  if isfield(model," nt ")
684  /* unsteady... */
685  if isfield(model," affinely_decomposed ") && model.affinely_decomposed
686  system_type = " LINEAR_UNSTEADY ";
687  else
688  system_type = " NONLINEAR_UNSTEADY ";
689  end
690  else
691  /* steady */
692  if isfield(model," affinely_decomposed ") && model.affinely_decomposed
693  system_type = " LINEAR_STEADY ";
694  else
695  system_type = " NONLINEAR_STEADY ";
696  end
697  end
698  end
699 
700  /* % Write rb_model attributes
701  * n_field (number of field variables... bei uns bisher immer nur eine)
702  *---------------------------------------------------------------------- */
703  if isfield(this.Params," n_field ")
704  n_field = this.Params.n_field;
705  else
706  n_field = 1; /* standard: nur eine Feldvariable */
707 
708  end
709  /* Number of components Q */
710  Qa = length(red.LL_E);
711  Qf = length(red.bb);
712  /* Kommentar: eigentlich fehlen hier noch Komponenten LL_I des
713  *impliziten Operators und die Komponenten der parameter separierten
714  *Anfangsbedingungen */
715 
716  /* Nmax: maximum number of basis vectors
717  * same as n_bfs, why artificially reduce? */
718  nmax = size(det.RB,2);
719  n_bfs = nmax;
720 
721  fprintf(fxml," <rb_model num_basisfcn='%d' fields='%d' Qa='%d' Qf='%d' Nmax='%d'>\n ",...
722  n_bfs,n_field,Qa,Qf,nmax);
723 
724  /* % System type */
725  fprintf(fxml," \t<systype>%s</systype>\n ",system_type);
726 
727  /* % Scm type (successive constraint method) -------------------- */
728  if isfield(this.Params," scm_type ")
729  scm_type = this.Params.scm_type;
730  else
731  scm_type = " NONE ";
732  end
733  fprintf(fxml," \t<scmtype>%s</scmtype>\n ",scm_type);
734 
735  /* % Time discretization ---------------------------------------- */
736  if strcmp(system_type," LINEAR_UNSTEADY ") || strcmp(system_type," NONLINEAR_UNSTEADY ")
737  fprintf(fxml," \t<timeinfo>\n ");
738  fprintf(fxml," \t\t<dt>%17.17f</dt>\n ",model.T/model.nt);
739  fprintf(fxml," \t\t<K>%d</K>\n ",model.nt);
740  if isfield(model," theta ")
741  et = model.theta;
742  else
743  et = 0;
744  end
745  fprintf(fxml," \t\t<euler_theta>%17.17f</euler_theta>\n ",et);
746  fprintf(fxml," \t</timeinfo>\n ");
747  end
748 
749  /* % Information about parameterization ------------------------- */
750  if isfield(model," mu_names ") && ~isempty(model.mu_names)
751  pvals = model.get_mu(model);
752  n_parameters = length(model.mu_names);
753  fprintf(fxml," \t<parameters number='%d'>\n ",n_parameters);
754  for i=1:n_parameters
755  fprintf(fxml," \t\t<param name='%s' min='%17.17f' max='%17.17f' label='%s' default='%17.17f'/>\n ",...
756  model.mu_names[i],model.mu_ranges[i](1),model.mu_ranges[i](2),model.mu_names[i],pvals(i));
757  end
758  fprintf(fxml," \t</parameters>\n ");
759  end
760 
761  /* % Model output */
762  disp(" Writing output ");
763  export.AppExport.saveRealVector(double(red.s_RB)," output_000_000.bin ",this.TargetFolder);
764  /* Dual norms */
765  model.decomp_mode= 0;
766  v=norm(model.operators_output(model,model_data));
767  /* The dual norms must equal an Ql*(Ql+1)/2 vector
768  * (symmetric information) */
769  v = this.uppertria(v);
770  if numel(v) > 1
771  warning(" Model:Export "," Export of dual norms for more than one output not yet checked. ");
772  end
773  export.AppExport.saveRealVector(double(v)," output_000_dual_norms.bin ",this.TargetFolder);
774 
775  /* % Model initial value data */
776  disp(" Writing initial data ");
777  for q=1:length(red.a0)
778  export.AppExport.saveRealVector(double(red.a0[q]),...
779  sprintf(" RB_initial_%.3d.bin ",q-1),this.TargetFolder);
780  end
781 
782 
783  /* % Write reduced basis data
784  * L_E operator components (JRB: A_q matrices) */
785  disp(" Writing LL_E ");
786  for q=1:Qa
787  export.AppExport.saveRealMatrix(double(red.LL_E[q]),...
788  sprintf(" RB_A_%.3d.bin ",q-1),this.TargetFolder);
789  end
790 
791  /* Write rhs b components (JRB: F_q vectors) */
792  disp(" Writing bb ")
793  for q=1:Qf
794  export.AppExport.saveRealVector(double(red.bb[q]),...
795  sprintf(" RB_F_%.3d.bin ",q-1),this.TargetFolder);
796  end
797 
798  /* Write M matrix (identity matrix, JRB: M_q matrices) */
799  disp(" Writing M ")
800  M = double(eye(size(red.LL_E[1],1), size(red.LL_E[1],2)));
801  export.AppExport.saveRealMatrix(M, " RB_M_000.bin ",this.TargetFolder);
802 
803  /* JRB: read in TransientRBSystem
804  * Here: identity matrix */
805  export.AppExport.saveRealMatrix(M, " RB_L2_matrix.bin ",this.TargetFolder);
806 
807  /* write RB-vectors */
808  disp(" Writing RB-vectors ");
809  for n=1:size(det.RB,2)
810  export.AppExport.saveRealVector(single(det.RB(:,n)),...
811  sprintf(" Z_000_%.3d.bin ",n-1),...
812  this.TargetFolder);
813  end
814 
815  /* % Error matrices
816  * Write error matrices AqAq */
817  disp(" Writing Aq Aq matrices ")
818  hlp = this.uppertria(red.M_EE);
819  for i=1:Qa
820  for j=1:Qa-i+1
821  export.AppExport.saveRealMatrix(double(hlp[(i-1)*Qa + j]),...
822  sprintf(" Aq_Aq_%.3d_%.3d_norms.bin ",i-1,j-1),...
823  this.TargetFolder);
824  end
825  end
826 
827  /* Write error matrices Fq Aq (JRB: Fq_Aq representor data in RBSystem)
828  * Order looked up in lin_evol_opt_rb_operators */
829  disp(" Writing Fq Aq norms. ")
830  for i=1:Qa
831  for j=1:Qf
832  export.AppExport.saveRealVector(double(red.M_Eb[j+(i-1)*Qf]),...
833  sprintf(" Fq_Aq_%.3d_%.3d.bin ",j-1,i-1),this.TargetFolder);
834  end
835  end
836 
837  /* write Fq_Fq */
838  disp(" Writing Fq norms ");
839  norms = this.uppertria([red.M_bb[:]]);
840  export.AppExport.saveRealVector(double(norms),...
841  " Fq_norms.bin ",this.TargetFolder);
842 
843  /* Write Aq_Mq norms */
844  disp(" Writing Aq_Mq ")
845  for i=1:Qa
846  for j=1:Qm
847  export.AppExport.saveRealMatrix(double(red.M_E[(i-1)*Qm+j]),...
848  sprintf(" Aq_Mq_%.3d_%.3d_norms.bin ",i-1,j-1),this.TargetFolder);
849  end
850  end
851 
852  /* Write and Fq_Mq */
853  disp(" Writing Fq_Mq ")
854  for i=1:Qf
855  for j=1:Qm
856  export.AppExport.saveRealVector(double(red.M_b[(i-1)*Qm+j]),...
857  sprintf(" Fq_Mq_%.3d_%.3d.bin ",i-1,j-1),this.TargetFolder);
858  end
859  end
860 
861  /* write idendity matrices for M_M_norms */
862  disp(" Writing M_M_norms and Mq_Mq_norms ");
863  for i=1:Qm
864  for j=1:Qm-i+1
865  export.AppExport.saveRealMatrix(M,...
866  sprintf(" Mq_Mq_%.3d_%.3d.bin ",i-1,j-1),this.TargetFolder);
867  end
868  end
869 
870  fprintf(fxml," </rb_model>\n ");
871  }
872 
873 
874  function res = uppertria(vec) {
875  n = sqrt(numel(vec));
876  if n*n ~= numel(vec)
877  error(" vec has not a square number of elements. ");
878  end
879  res = reshape(vec,n,n);
880  res = res(triu(true(n,n)));
881  }
901 };
902 
fields
Returns a cell array of string containing the names of public properties.
Params
Some additional export parameters.
Definition: JRBExport.m:66
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
A MatLab cell array or matrix.
AffFcnsJava
Path to the AffineFunctions file giving the coefficient functions.
Definition: JRBExport.m:78
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
function export(model, det)
Exports the given model using the detailed data.
Definition: JRBExport.m:157
ForWebFolder
Flag that indicates if the export is for a web folder.
Definition: JRBExport.m:93
Version
The model export version to use. Can be either 0 for for JRB models or 1 for rbappmit-models.
Definition: JRBExport.m:37
JRBExport: Exporting rbmatlab models for the JRB project.
Definition: JRBExport.m:17
JaRMoSExport: Export base class for JaRMoS Models.
Definition: JaRMoSExport.m:17
delete
Handle object destructor method that is called when the object's lifecycle ends.
disp
Handle object disp method which is called by the display method. See the MATLAB disp function...
#define X(i, j)
TargetFolder
The folder to write the model data to.
Definition: JRBExport.m:48
#define Y(i, j)
JRBSource
The source of the JRB software.
Definition: JRBExport.m:57
function export_file(matfile)
Exports an m-file containing rb data to a model.
Definition: JRBExport.m:144