source: issm/trunk-jpl/src/m/classes/autodiff.js@ 19787

Last change on this file since 19787 was 19787, checked in by Eric.Larour, 9 years ago

CHG: implemented ismodelselfconsistent routine and all corresponding checkconsistency
routines in the main model classes. Implemented embryo of i/o routines to start marshalling
model. Implemented issm.js and compilation of main issm module to run ISSM in javascript.

File size: 2.8 KB
RevLine 
[19759]1//AUTODIFF class definition
2//
3// Usage:
4// autodiff=new autodiff();
5
6function autodiff (){
7 //methods
8 this.setdefaultparameters = function(){// {{{
9
10 this.obufsize = 524288;
11 this.lbufsize = 524288;
12 this.cbufsize = 524288;
13 this.tbufsize = 524288;
14 this.gcTriggerRatio=2.0;
15 this.gcTriggerMaxSize=65536;
16
17 }// }}}
18 this.disp= function(){// {{{
19
20 console.log(sprintf(' automatic differentiation parameters:'));
21 fielddisplay(this,'isautodiff','indicates if the automatic differentiation is activated');
22 fielddisplay(this,'dependents','list of dependent variables');
23 fielddisplay(this,'independents','list of independent variables');
24 fielddisplay(this,'driver',"ADOLC driver ('fos_forward' or 'fov_forward')");
25 fielddisplay(this,'obufsize','Number of operations per buffer (==OBUFSIZE in usrparms.h)');
26 fielddisplay(this,'lbufsize','Number of locations per buffer (==LBUFSIZE in usrparms.h)');
27 fielddisplay(this,'cbufsize','Number of values per buffer (==CBUFSIZE in usrparms.h)');
28 fielddisplay(this,'tbufsize','Number of taylors per buffer (<=TBUFSIZE in usrparms.h)');
29 fielddisplay(this,'gcTriggerRatio','free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio');
30 fielddisplay(this,'gcTriggerMaxSize','free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize');
31
32 }// }}}
[19787]33 this.checkconsistency = function(md,solution,analyses){ //{{{
34
35 //Early return
36 if (!this.isautodiff) return;
37
38 //Driver value:
39 checkfield(md,'fieldname','autodiff.driver','values',['fos_forward','fov_forward','fov_forward_all','fos_reverse','fov_reverse','fov_reverse_all']);
40
41 //buffer values:
42 checkfield(md,'fieldname','autodiff.obufsize','>=',16);
43 checkfield(md,'fieldname','autodiff.lbufsize','>=',16);
44 checkfield(md,'fieldname','autodiff.cbufsize','>=',16);
45 checkfield(md,'fieldname','autodiff.tbufsize','>=',16);
46 checkfield(md,'fieldname','autodiff.gcTriggerRatio','>=',0);
47 checkfield(md,'fieldname','autodiff.gcTriggerMaxSize','>=',65536);
48
49 //go through our dependents and independents and check consistency:
50 for (var i=0;i<this.dependents.length;i++){
51 dep=this.dependents[i];
52 dep.checkconsistency(md,solution,analyses);
53 }
54 for (var i=0;i<this.independents.length;i++){
55 indep=this.independents[i];
56 indep.checkconsistency(md,i,solution,analyses,this.driver);
57 }
58 } // }}}
[19759]59 //properties
60 // {{{
61 this.isautodiff = false;
62 this.dependents = {};
63 this.independents = {};
64 this.driver = 'fos_forward';
65 this.obufsize = NaN;
66 this.lbufsize = NaN;
67 this.cbufsize = NaN;
68 this.tbufsize = NaN;
69 this.gcTriggerRatio = NaN;
70 this.gcTriggerMaxSize = NaN;
71
72 this.setdefaultparameters();
73 //}}}
74}
Note: See TracBrowser for help on using the repository browser.