57 JRBSource =
"/home/dwirtz/aghhome/Software/Eclipse/JRB/src";
112 #if 0 //mtoc++: 'set.TargetFolder'
115 error(
" Target folder value must not be empty. ");
118 if value(end) ==
" / " || value(end) ==
" \ "
119 value = value(1:end-1);
121 if exist(value,
" dir ") ~= 7
123 error(
" Could not create directory '%s' ", value);
133 #if 0 //mtoc++: 'set.Version'
135 if ~any(value == [0 1])
136 error(" Only 0 for 'jrb' and 1 for 'rbappmit' versions allowed. ");
146 this.
export(S.model, S.detailed_data);
160 fprintf(
" Starting model export to %s ...\n ",this.
TargetFolder);
163 model_data = gen_model_data(model);
164 red = gen_reduced_data(model, det);
167 f = this.startExportXML(model);
171 this.export_JRB(model, model_data, det, red, f);
173 fprintf(f,
" <rbappmit_model />\n ");
174 this.export_rbappmit(model, model_data, det, red);
178 this.exportAffineFunctions(f);
181 this.exportGeometry(model_data.grid, f);
183 fprintf(f,
" \t<visual>\n ");
184 fprintf(f,
" \t\t<plotSteps>%d</plotSteps>\n ",model.nt+1);
185 fprintf(f,
" \t</visual>\n ");
187 this.endExportXML(f);
192 mtxt = fullfile(parent,
" models.txt ");
193 fid = fopen(mtxt,
" a+ ");
197 if strcmp(ln,foldername)
203 fprintf(fid,
" %s\n ",foldername);
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);
229 version =
" rbappmit ";
231 fprintf(f,
" <model type='%s' machformat='be'>\n ",version);
232 fprintf(f,
" <description>\n ");
233 if isfield(this.
Params,
" title ")
236 t = [" rbmatlab: " func2str(model.gen_model_data)];
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;
243 t = [" rbmatlab: " func2str(model.gen_model_data)];
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 ");
251 fprintf(f," </description>\n ");
267 function endExportXML(f) {
268 fprintf(f,
" </model>\n ");
273 function exportAffineFunctions(f) {
278 error(" For JRB model
export version a the
JRBSource property must not be empty. ");
282 package = fullfile(" models ",fname);
283 jfile = fullfile(fullfile(this.
JRBSource,package)," AffineFunctions.java ");
285 cmd = sprintf(" javac -classpath %s -d %s %s ",this.JRBSource, this.TargetFolder, jfile);
288 error(" Error exporting affine functions:
AffFcnsJava field must be set for rbappmit model
export. ");
290 cmd = sprintf(" javac -d %s %s ",this.TargetFolder, jfile);
292 if exist(jfile," file ") ~= 2
293 error(" Affine functions file '%s' does not exist. ",jfile);
296 fprintf(" Compiling and exporting AffineFunctions in '%s'...\n ",jfile);
299 outcl = fullfile(fullfile(this.TargetFolder,package)," AffineFunctions.class ");
300 javajar = fullfile(this.TargetFolder," classes.jar ");
301 dexjar = fullfile(this.TargetFolder," dexclasses.jar ");
305 system(sprintf(" dx --dex --no-strict --output='%s' %s ",dexjar,outcl));
308 system(sprintf(" jar -cf %s -C %s %s ",javajar,this.TargetFolder,fullfile(package," AffineFunctions.class ")));
311 rmdir(fullfile(this.TargetFolder," models ")," s ");
312 package = [" models. " fname];
318 fprintf(f," <package>%s</package>\n ",package);
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));
333 fprintf(" Exporting model grid (%s) to geometry files...\n ",class(g));
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 ");
348 nodes = single(
reshape([g.X g.
Y]^
t,[],1));
351 if m > intmax(" int16 ")
352 error(" Too many faces for app: %d. Max allowed is intmax(int16) = %d ",m,intmax(" int16 "));
354 faces = int16(
reshape(g.VI^t,[],1));
356 export.AppExport.saveRealVector(nodes," vertices.bin ",this.TargetFolder);
357 export.AppExport.saveRealVector(faces," faces.bin ",this.TargetFolder);
362 function export_rbappmit(models.BaseFullModel model,model_data,det,red) {
363 fid = fopen(fullfile(this.TargetFolder,
" input.in "),
" w ");
367 if (isfield(this.
Params,
" model_type "))
368 system_type = this.
Params.model_type;
370 if isfield(model,
" nt ")
372 if isfield(model," affinely_decomposed ")&&model.affinely_decomposed
373 system_type = " LINEAR_UNSTEADY ";
375 system_type = " NONLINEAR_UNSTEADY ";
379 if isfield(model," affinely_decomposed ")&&model.affinely_decomposed
380 system_type = " LINEAR_STEADY ";
382 system_type = " NONLINEAR_STEADY ";
387 fprintf(fid," system_type = %s\n ",system_type);
391 if isfield(this.
Params," scm_type ")
392 scm_type = this.Params.scm_type;
396 fprintf(fid," scm_type = %s\n ",scm_type);
400 if isfield(this.Params," n_field ")
401 n_field = this.Params.n_field;
406 fprintf(fid," n_field = %d\n\n ",n_field);
410 fprintf(fid," Q_a = %d\n ",Qa);
411 fprintf(fid," Q_f = %d\n\n ",Qf);
418 fprintf(fid," Nmax = %d\n\n ",size(det.RB,2));
422 n_parameters = length(model.mu_names);
423 fprintf(fid," n_parameters = %d\n ",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));
431 if isfield(this.Params," n_outputs ")
432 n_outputs = this.Params.n_outputs;
436 fprintf(fid," n_outputs = %d\n ",n_outputs);
440 if strcmp(system_type," LINEAR_UNSTEADY ")||strcmp(system_type," NONLINEAR_UNSTEADY ")
441 fprintf(fid," dt = %f\n ",(model.T/model.nt));
443 fprintf(fid," K = %d\n ",model.nt);
445 if isfield(model," theta ")
446 fprintf(fid," euler_theta = %d\n ",model.theta);
448 fprintf(fid," euler_theta = %f\n ",0);
454 if isfield(this.Params," title ")
455 fprintf(fid," title = %s\n ",this.Params.title);
458 fprintf(fid,[" param ",num2str(i-1)," _label = %s\n "],model.mu_names[i]);
466 fid = fopen(fullfile(this.TargetFolder," n_bfs.dat ")," w ");
467 fprintf(fid," %d ",size(det.RB,2));
471 fid = fopen(fullfile(this.TargetFolder," calN.dat ")," w ");
472 fprintf(fid," %d ",size(model_data.grid.VI,1));
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)));
484 disp(" Writing LL_E ")
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));
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));
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 ");
508 fprintf(fid," %17.17e ",M(i));
513 disp(" Writing mass matrices ")
514 fid = fopen(fullfile(this.TargetFolder," RB_mass_matrix.dat ")," w ");
516 fprintf(fid," %17.17e ",M(i));
520 fid = fopen(fullfile(this.TargetFolder," RB_inner_product_matrix.dat ")," w ");
522 fprintf(fid," %17.17e ",M(i));
526 fid = fopen(fullfile(this.TargetFolder," RB_L2_matrix.dat ")," w ");
528 fprintf(fid," %17.17e ",M(i));
533 disp(" Writing RB-vectors ");
534 for n=1:size(det.RB,2)
536 ns = [" 0 ",num2str(n-1)];
540 fid = fopen(fullfile(this.TargetFolder,[" Z_000_0 ",ns," .bin "])," w ");
542 fwrite(fid,det.RB(:,n),"
double ");
548 disp(" Writing AqAq ")
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 ");
557 disp(" Writing FqAq ")
563 Fq_Aq[q2+(q1-1)*QL] = red.M_Eb[q1+(q2-1)*Qb];
566 fid=fopen(fullfile(this.TargetFolder," Fq_Aq_norms.dat ")," w ");
568 for j=1:size(Fq_Aq[i],1)
569 fprintf(fid," %17.17e ",Fq_Aq[i](j));
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));
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));
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));
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));
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]);
619 disp(" Writing M_M_norms and Mq_Mq_norms ");
620 fid=fopen(fullfile(this.TargetFolder," M_M_norms.dat ")," w ");
622 fprintf(fid," %17.17e ",M(i));
626 fid=fopen(fullfile(this.TargetFolder," Mq_Mq_norms.dat ")," w ");
628 fprintf(fid," %17.17e ",M(i));
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));
673 function export_JRB(models.BaseFullModel model,model_data,det,red,fxml) {
680 if (isfield(this.Params,
" model_type "))
681 system_type = this.Params.model_type;
683 if isfield(model,
" nt ")
685 if isfield(model," affinely_decomposed ") && model.affinely_decomposed
686 system_type = " LINEAR_UNSTEADY ";
688 system_type = " NONLINEAR_UNSTEADY ";
692 if isfield(model," affinely_decomposed ") && model.affinely_decomposed
693 system_type = " LINEAR_STEADY ";
695 system_type = " NONLINEAR_STEADY ";
703 if isfield(this.Params," n_field ")
704 n_field = this.Params.n_field;
710 Qa = length(red.LL_E);
718 nmax = size(det.RB,2);
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);
725 fprintf(fxml," \t<systype>%s</systype>\n ",system_type);
728 if isfield(this.Params," scm_type ")
729 scm_type = this.Params.scm_type;
733 fprintf(fxml," \t<scmtype>%s</scmtype>\n ",scm_type);
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 ")
745 fprintf(fxml," \t\t<euler_theta>%17.17f</euler_theta>\n ",et);
746 fprintf(fxml," \t</timeinfo>\n ");
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);
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));
758 fprintf(fxml," \t</parameters>\n ");
762 disp(" Writing output ");
763 export.AppExport.saveRealVector(
double(red.s_RB)," output_000_000.bin ",this.TargetFolder);
765 model.decomp_mode= 0;
766 v=norm(model.operators_output(model,model_data));
769 v = this.uppertria(v);
771 warning(" Model:Export "," Export of dual norms for more than one output not yet checked. ");
773 export.AppExport.saveRealVector(
double(v)," output_000_dual_norms.bin ",this.TargetFolder);
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);
785 disp(" Writing LL_E ");
787 export.AppExport.saveRealMatrix(
double(red.LL_E[q]),...
788 sprintf(" RB_A_%.3d.bin ",q-1),this.TargetFolder);
794 export.AppExport.saveRealVector(
double(red.bb[q]),...
795 sprintf(" RB_F_%.3d.bin ",q-1),this.TargetFolder);
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);
805 export.AppExport.saveRealMatrix(M, " RB_L2_matrix.bin ",this.TargetFolder);
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),...
817 disp(" Writing Aq Aq matrices ")
818 hlp = this.uppertria(red.M_EE);
821 export.AppExport.saveRealMatrix(
double(hlp[(i-1)*Qa + j]),...
822 sprintf(" Aq_Aq_%.3d_%.3d_norms.bin ",i-1,j-1),...
829 disp(" Writing Fq Aq norms. ")
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);
838 disp(" Writing Fq norms ");
839 norms = this.uppertria([red.M_bb[:]]);
840 export.AppExport.saveRealVector(
double(norms),...
841 " Fq_norms.bin ",this.TargetFolder);
844 disp(" Writing Aq_Mq ")
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);
853 disp(" Writing Fq_Mq ")
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);
862 disp(" Writing M_M_norms and Mq_Mq_norms ");
865 export.AppExport.saveRealMatrix(M,...
866 sprintf(" Mq_Mq_%.3d_%.3d.bin ",i-1,j-1),this.TargetFolder);
870 fprintf(fxml," </rb_model>\n ");
874 function res = uppertria(vec) {
875 n = sqrt(numel(vec));
877 error(" vec has not a square number of elements. ");
880 res = res(triu(true(n,n)));
fields
Returns a cell array of string containing the names of public properties.
Params
Some additional export parameters.
The base class for any KerMor detailed model.
A MatLab cell array or matrix.
AffFcnsJava
Path to the AffineFunctions file giving the coefficient functions.
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.
ForWebFolder
Flag that indicates if the export is for a web folder.
Version
The model export version to use. Can be either 0 for for JRB models or 1 for rbappmit-models.
JRBExport: Exporting rbmatlab models for the JRB project.
JaRMoSExport: Export base class for JaRMoS Models.
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...
TargetFolder
The folder to write the model data to.
JRBSource
The source of the JRB software.
function export_file(matfile)
Exports an m-file containing rb data to a model.