Changeset 19753 for issm/trunk-jpl/src


Ignore:
Timestamp:
11/18/15 14:53:42 (9 years ago)
Author:
Eric.Larour
Message:

CHG: new modules in javascript, IssmConfig and InterpFromMeshToMesh2d, which uses the
bamg objects.
New classes to be able to finish off the model.js implementation. New paterson, solvers for javacsript.

Location:
issm/trunk-jpl/src
Files:
21 added
11 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/array/arrayoperations.js

    r19736 r19753  
    7474        return notarray;
    7575} //}}}
     76function ArrayPow(array,coefficient) { //{{{
     77
     78        var powarray=array;
     79        for (i=0;i<array.length;i++)powarray[i]=Math.pow(array[i],coefficient);
     80        return powarray;
     81} //}}}
     82function ArraySqrt(array) { //{{{
     83
     84        var sqrtarray=array;
     85        for (i=0;i<array.length;i++)sqrtarray[i]=Math.sqrt(array[i]);
     86        return sqrtarray;
     87} //}}}
     88function ArrayMag(array1,array2) { //{{{
     89
     90        var arraymag=NewArrayFill(array1.length,0);
     91        for (var i=0;i<array1.length;i++)arraymag[i]=Math.sqrt(Math.pow(array1[i],2)+Math.pow(array2[i],2));
     92        return arraymag;
     93} //}}}
    7694function ArrayAnyNaN(array) { //{{{
    7795
    7896        for(var i=0;i<array.length;i++){
    7997                if (isNaN(array[i])) return 1;
     98        }
     99        return 0;
     100} //}}}
     101function ArrayAnyBelowOrEqual(array,value) { //{{{
     102
     103        for(var i=0;i<array.length;i++){
     104                if (array[i]<=value)return 1;
     105        }
     106        return 0;
     107} //}}}
     108function ArrayAnyBelowStrict(array,value) { //{{{
     109
     110        for(var i=0;i<array.length;i++){
     111                if (array[i]<value)return 1;
    80112        }
    81113        return 0;
  • issm/trunk-jpl/src/m/classes/model.js

    r19719 r19753  
    5252                        this.constants        = new constants();
    5353                        this.geometry         = new geometry();
    54 //                      this.initialization   = initialization();
    55 //                      this.smb              = SMBforcing();
    56 //                      this.basalforcings    = basalforcings();
    57 //                      this.friction         = friction();
    58 //                      this.rifts            = rifts();
    59 //                      this.timestepping     = timestepping();
    60 //                      this.groundingline    = groundingline();
    61 //                      this.materials        = matice();
    62 //                      this.damage           = damage();
    63 //                      this.flowequation     = flowequation();
    64 //                      this.debug            = debug();
    65 //                      this.verbose          = verbose();
    66 //                      this.settings         = settings();
    67 //                      this.toolkits         = toolkits();
    68 //                      this.cluster          = generic();
    69 //                      this.balancethickness = balancethickness();
    70 //                      this.stressbalance    = stressbalance();
    71 //                      this.hydrology        = hydrologyshreve();
    72 //                      this.masstransport    = masstransport();
    73 //                      this.thermal          = thermal();
    74 //                      this.steadystate      = steadystate();
    75 //                      this.transient        = transient();
    76 //                      this.calving          = calving();
    77 //                      this.gia              = gia();
    78 //                      this.autodiff         = autodiff();
    79 //                      this.flaim            = flaim();
    80 //                      this.inversion        = inversion();
    81 //                      this.qmu              = qmu();
    82 //                      this.radaroverlay     = radaroverlay();
    83 //                      this.results          = struct();
    84 //                      this.outputdefinition = outputdefinition();
    85 //                      this.miscellaneous    = miscellaneous();
    86 //                      this.private          = private();
     54                        this.initialization   = new initialization();
     55                        this.smb              = new SMBforcing();
     56                        this.basalforcings    = new basalforcings();
     57                        this.friction         = new friction();
     58                        this.rifts            = new rifts();
     59                        this.timestepping     = new timestepping();
     60                        this.groundingline    = new groundingline();
     61                        this.materials        = new matice();
     62                        this.damage           = new damage();
     63                        this.flowequation     = new flowequation();
     64                        this.debug            = new debug();
     65                        this.verbose          = new verbose();
     66                        this.settings         = new settings();
     67                        this.toolkits         = new toolkits();
     68                        this.toolkits.disp();
     69                        this.cluster          = new generic();
     70                        this.balancethickness = new balancethickness();
     71                        this.stressbalance    = new stressbalance();
     72                        this.hydrology        = new hydrologyshreve();
     73                        this.masstransport    = new masstransport();
     74                        this.thermal          = new thermal();
     75                        this.steadystate      = new steadystate();
     76                        this.transient        = new transient();
     77                        this.calving          = new calving();
     78                        this.gia              = new gia();
     79                        this.autodiff         = new autodiff();
     80                        this.flaim            = new flaim();
     81                        this.inversion        = new inversion();
     82                        this.qmu              = new qmu();
     83                        this.radaroverlay     = new radaroverlay();
     84                        this.results          = [];
     85                        this.outputdefinition = new outputdefinition();
     86                        this.miscellaneous    = new miscellaneous();
     87                        this.private          = new private();
    8788                } //}}}
    8889        //properties
  • issm/trunk-jpl/src/m/classes/pairoptions.js

    r19721 r19753  
    265265
    266266        //properties
    267         list         = [];
     267        this.list         = [];
    268268        this.constructor(args);
    269269}
  • issm/trunk-jpl/src/m/classes/plotoptions.js

    r19721 r19753  
    159159    //properties
    160160         // {{{
    161          numberofplots = 0;
    162          figurenumber  = 1;
    163          list          = [];
     161         this.numberofplots = 0;
     162         this.figurenumber  = 1;
     163         this.list          = [];
    164164         this.constructor(args);
    165165         //}}}
  • issm/trunk-jpl/src/m/miscellaneous/fielddisplay.js

    r19721 r19753  
    2121                }
    2222                else{
    23                         console.log(offset)
    24                         console.log(name)
    25                         console.log(field)
    26                         //displayunit(offset,name,"""" + field """",comment),
     23                        displayunit(offset,name,"'"+field+"'",comment);
    2724                }
    2825        }
     
    8279        else{
    8380                if (typeof(comment) == "string"){
    84                         console.log(sprintf("%s%-23s: %-15s -- %s",offset,name,characterization,comment));
     81                        //console.log(sprintf("%s%-23s: %-15s -- %s",offset,name,characterization,comment));
     82                        console.log(sprintf("%s%s: %-15s -- %s",offset,name,characterization,comment));
    8583                }
    8684                else{
  • issm/trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h

    r14996 r19753  
    5555#endif
    5656
     57#ifdef _HAVE_JAVASCRIPT_MODULES_
     58/* serial input macros: */
     59#define INDEX          indexin,nelin,3
     60#define X              xin,nodsin
     61#define Y              yin,nodsin
     62#define DATA           datain,nodsin,1
     63#define XINTERP        x_interpin, nods_interpin
     64#define YINTERP        y_interpin, nods_interpin
     65#define ARGUMENTS "default_value",default_value
     66/* serial output macros: */
     67#define DATAINTERP pdata_interp,NULL,NULL
     68#define WRAPPER(modulename) extern "C" { int  InterpFromMeshToMesh2dModule(double** pdata_interp,int* indexin,double* xin,double* yin,double* datain,double* x_interpin,double* y_interpin,int nelin,int nodsin,int nods_interpin,double default_value)
     69#define nrhs  6
     70#endif
     71
    5772/* serial arg counts: */
    5873#undef NLHS
  • issm/trunk-jpl/src/wrappers/IssmConfig/IssmConfig.h

    r15905 r19753  
    3131/* serial output macros: */
    3232#define VALUE (mxArray**)&plhs[0]
     33#define SVALUE (mxArray**)&plhs[0]
    3334#endif
    3435
     
    3839/* serial output macros: */
    3940#define VALUE output,0
     41#define SVALUE output,0
     42#endif
     43
     44
     45#ifdef _HAVE_JAVASCRIPT_MODULES_
     46/* serial input macros: */
     47#define NAME string
     48/* serial output macros: */
     49#define VALUE pvalue
     50#define SVALUE psvalue
     51#define WRAPPER(modulename) extern "C" { int  IssmConfigModule(double* pvalue, char** psvalue, char* string)
    4052#endif
    4153
  • issm/trunk-jpl/src/wrappers/javascript/Makefile.am

    r19739 r19753  
    1010bin_SCRIPTS += ../TriMesh/TriMesh.js  \
    1111                           ../NodeConnectivity/NodeConnectivity.js\
    12                            ../ElementConnectivity/ElementConnectivity.js
     12                           ../ElementConnectivity/ElementConnectivity.js\
     13                           ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.js\
     14                           ../IssmConfig/IssmConfig.js
    1315       
    1416#javascript io{{{
     
    7577IssmModule_SOURCES = ../TriMesh/TriMesh.cpp \
    7678                                         ../NodeConnectivity/NodeConnectivity.cpp\
    77                                          ../ElementConnectivity/ElementConnectivity.cpp
     79                                         ../ElementConnectivity/ElementConnectivity.cpp\
     80                                         ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
     81                                         ../IssmConfig/IssmConfig.cpp
    7882
    79 IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_ --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule','_ElementConnectivityModule']"  -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1
     83IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_ --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule','_ElementConnectivityModule','_InterpFromMeshToMesh2dModule','_IssmConfigModule']"  -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1
    8084IssmModule_LDADD = ${deps} $(TRIANGLELIB)
    8185#}}}
  • issm/trunk-jpl/src/wrappers/javascript/io/FetchJavascriptData.cpp

    r19711 r19753  
    1313
    1414/*Primitive data types*/
     15/*FUNCTION FetchData(char** pstring, char* string){{{*/
     16void FetchData(char** pstring, char* stringin){
     17
     18        char* string=xNew<char>(strlen(stringin)+1);
     19        xMemCpy<char>(string,stringin,strlen(stringin)+1);
     20
     21        *pstring=string;
     22}
     23/*}}}*/
    1524/*FUNCTION FetchData(double* pscalar,double scalar){{{*/
    1625void FetchData(double* pscalar,double scalar){
     
    3544}
    3645/*}}}*/
     46/*FUNCTION FetchData(double **pvector, int* pnods, double* vectorin, int nods){{{*/
     47void FetchData(double** pvector, int* pnods, double* vectorin, int nods){
     48
     49        double* vector=NULL;
     50       
     51        vector=xNew<IssmPDouble>(nods); xMemCpy<IssmPDouble>(vector,vectorin,nods);
     52       
     53        *pvector=vector;
     54        *pnods=nods;
     55}
     56/*}}}*/
    3757/*FUNCTION FetchData(double **pmatrix, int* pM, int* pN, int* matrix, int M, int N){{{*/
    3858void FetchData(double **pmatrix, int* pM, int* pN, int* matrixin, int M, int N){
     
    4464                matrix=xNew<IssmPDouble>(M*N);
    4565                for(int i=0;i<M*N;i++)matrix[i]=(IssmPDouble)matrixin[i];
     66                if (pM)*pM=M;
     67                if (pN)*pN=N;
     68                *pmatrix=matrix;
     69        }
     70}
     71/*}}}*/
     72/*FUNCTION FetchData(double **pmatrix, int* pM, int* pN, double* matrix, int M, int N){{{*/
     73void FetchData(double **pmatrix, int* pM, int* pN, double* matrixin, int M, int N){
     74
     75        double* matrix=NULL;
     76       
     77        if(pmatrix && matrixin){
     78
     79                matrix=xNew<IssmPDouble>(M*N);
     80                for(int i=0;i<M*N;i++)matrix[i]=matrixin[i];
    4681                if (pM)*pM=M;
    4782                if (pN)*pN=N;
     
    89124}
    90125/*}}}*/
     126/*FUNCTION FetchData(Options** poptions,int NRHS, int nrhs, const char* optionname, double optionvalue){{{*/
     127void FetchData(Options** poptions,int NRHS, int nrhs, const char* optionname, double optionvalue){
     128
     129        /*Initialize output*/
     130        Options* options=new Options();
     131       
     132        GenericOption<double> *odouble = NULL;
     133
     134        /*check and parse the name  */
     135        odouble=new GenericOption<double>();
     136        odouble->name =xNew<char>(strlen(optionname)+1);
     137        memcpy(odouble->name,optionname,(strlen(optionname)+1)*sizeof(char));
     138        odouble->value=optionvalue;
     139        odouble->numel=1;
     140        odouble->ndims=1;
     141        odouble->size=NULL;
     142         
     143        options->AddOption((Option*)odouble);
     144
     145        /*Assign output pointers:*/
     146        *poptions=options;
     147}
     148/*}}}*/
  • issm/trunk-jpl/src/wrappers/javascript/io/WriteJavascriptData.cpp

    r19711 r19753  
    4040}
    4141/*}}}*/
     42/*FUNCTION WriteData(IssmPDouble** pmatrix, int* pM, IssmPDouble* pN, , int* matrix, int M,int N){{{*/
     43void WriteData(IssmPDouble** pmatrix,int* pM, int* pN, IssmPDouble* matrix, int M, int N){
     44
     45        if(pmatrix && matrix){
     46
     47                /*Copy matrix: */
     48                IssmPDouble* dmatrix = xNew<IssmPDouble>(M*N);
     49                for (int i=0;i<M*N;i++)dmatrix[i]=matrix[i];
     50                *pmatrix=dmatrix;
     51                if(pM)*pM=M;
     52                if(pN)*pN=N;
     53        }
     54}
     55/*}}}*/
    4256/*FUNCTION WriteData(IssmPDouble** px, int* pnods, double* vector, int M){{{*/
    4357void WriteData(IssmPDouble** px, int* pnods, double* vector, int M){
     
    6478}
    6579/*}}}*/
     80/*FUNCTION WriteData(IssmPDouble* pdouble, IssmPDouble double){{{*/
     81void WriteData(IssmPDouble* pdouble, IssmPDouble doublein){
    6682
    67 /*ISSM objects*/
     83        *pdouble=doublein;
     84}
     85/*}}}*/
     86/*FUNCTION WriteData(char** pstring, char* string){{{*/
     87void WriteData(char** pstring, char* stringin){
    6888
    69 /*Toolkit*/
     89        char* string=xNew<char>(strlen(stringin)+1);
     90        xMemCpy<char>(string,stringin,strlen(stringin)+1);
     91
     92        *pstring=string;
     93}
     94/*}}}*/
  • issm/trunk-jpl/src/wrappers/javascript/io/javascriptio.h

    r19711 r19753  
    2020void WriteData(IssmPDouble** pmatrix,int* pnel, int* matrix, int M,int N);
    2121void WriteData(IssmPDouble** pmatrix,int* pM, int* pN, int* matrix, int M, int N);
     22void WriteData(IssmPDouble** pmatrix,int* pM, int* pN, IssmPDouble* matrix, int M, int N);
    2223void WriteData(IssmPDouble** px, int* pnods, int* vector, int M);
    2324void WriteData(IssmPDouble** px, int* pnods, double* vector, int M);
     25void WriteData(char** pstring, char* stringin);
     26void WriteData(IssmPDouble* pdouble, IssmPDouble doublein);
    2427
     28void FetchData(char** pstring, char* stringin);
    2529void FetchData(double* pscalar,double scalar);
    2630void FetchData(int* pinteger,int integer);
    2731void FetchData(double** pvector, double* vectorin, int nods);
     32void FetchData(double** pvector, int* pnods, double* vectorin, int nods);
    2833void FetchData(double **pmatrix, int* pM, int* pN, int* matrixin, int M, int N);
     34void FetchData(double **pmatrix, int* pM, int* pN, double* matrixin, int M, int N);
    2935void FetchData(int **pmatrix, int* pM, int* pN, int* matrixin, int M, int N);
    3036void FetchData(Contours** pcontours,double* x, double* y, int nods);
     37void FetchData(Options** poptions,int NRHS, int nrhs, const char* optionname, double optionvalue);
    3138
    3239/*Print*/
Note: See TracChangeset for help on using the changeset viewer.