source: issm/oecreview/Archive/14312-15392/ISSM-14406-14407.diff

Last change on this file was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 7.4 KB
  • ../trunk-jpl/test/NightlyRun/android.m

     
    1 md=triangle(model(),'../Exp/Square.exp',100000.);
     1md=triangle(model(),'../Exp/Square.exp',40000.);
    22md=setmask(md,'all','');
    33md=parameterize(md,'../Par/SquareShelfConstrained.par');
    44md=setflowequation(md,'macayeal','all');
  • ../trunk-jpl/src/mobile/android/ISSM/jni/Main.cpp

     
    1 #include "../../../c/issm.h"
    2 #include <cstddef>
    3 #include <stdio.h>
    4 
    5 //Android specific header includes:
    6 #include <jni.h>
    7 #include <android/log.h>
    8 #include <android/log.h>
    9 
    10 //iOS specific header includes:
    11 
    12 namespace gov_nasa_jpl_issm
    13 {
    14         /*Global variables{{{*/
    15         FemModel *fm;
    16         double* xyz; /*keep vertices information here*/
    17         /*}}}*/
    18         jint Initialize(JNIEnv *env, jclass clazz, jstring jsolution_type, jstring jabsfile, jstring jrelfile) /*{{{*/
    19         {
    20                
    21                 /*arguments to constructor: */
    22                 int argc; //arguments to constructor.
    23                 char** argv = NULL;
    24                 COMM    communicator = 1; //fake communicator for constructor
    25                 const char* issmname = "issm.exe";
    26                 char *solution_type = NULL;
    27                 char *absfile = NULL;
    28                 char *relfile = NULL;
    29 
    30                 /*log:*/
    31                 __android_log_print(ANDROID_LOG_INFO, "Native","Initializing FemModel");
    32 
    33                 /*retrieve from java machine: */
    34                 solution_type = (char*)env->GetStringUTFChars(jsolution_type,0);
    35                 absfile = (char*)env->GetStringUTFChars(jabsfile,0);
    36                 relfile = (char*)env->GetStringUTFChars(jrelfile,0);
    37 
    38                 /*creat arguments to call constructor for FemModel: */
    39                 argc=4;
    40                 argv=(char**)malloc(argc*sizeof(char*));
    41                 argv[0]=(char*)issmname;
    42                 argv[1]=solution_type;
    43                 argv[2]=absfile;
    44                 argv[3]=relfile;
    45                
    46                 /*call Model constructor passing in infile as File Descriptor parameter.*/
    47                 fm  = new FemModel(argc,argv,communicator);
    48 
    49                 /*release strings: */
    50                 env->ReleaseStringUTFChars(jsolution_type, solution_type); //must realease the char*
    51                 env->ReleaseStringUTFChars(jabsfile, absfile); //must realease the char*
    52                 env->ReleaseStringUTFChars(jrelfile, relfile); //must realease the char*
    53 
    54                 /*figure out size of solution: */
    55                 __android_log_print(ANDROID_LOG_INFO, "Native","Number of elements");
    56                 jint size = (jint) fm->elements->NumberOfElements();
    57 
    58                 /*retrieve vertices x,y and z coordinates: */
    59                 __android_log_print(ANDROID_LOG_INFO, "Native","Retrieving vertices");
    60                 xyz=fm->vertices->ToXYZ();
    61                
    62                 /*log: */
    63                 __android_log_print(ANDROID_LOG_INFO, "Native","Done Initializing FemModel");
    64 
    65                 return size;
    66 
    67         }
    68         /*}}}*/
    69         void Solve(JNIEnv *env, jclass clazz , jdouble alpha, jobject buf){ /*{{{*/
    70 
    71                 int i,count;
    72                 double x1,y1,z1,vel1;
    73                 double x2,y2,z2,vel2;
    74                 double x3,y3,z3,vel3;
    75                 int    v1,v2,v3,eid;
    76                 Patch* patch=NULL;
    77                
    78                 /*log:*/
    79                 __android_log_print(ANDROID_LOG_INFO, "Native","Solving ");
    80 
    81                 /*retrieve buffer: */
    82                 jdouble *dBuf = (jdouble *)env->GetDirectBufferAddress(buf);
    83 
    84                 /*reset basal friction to what it was before: */
    85                 __android_log_print(ANDROID_LOG_INFO, "Native","alpha %g ",alpha);
    86                 InputDuplicatex(fm->elements,fm->nodes,fm->vertices,fm->loads,fm->materials,fm->parameters,AndroidFrictionCoefficientEnum,FrictionCoefficientEnum);
    87 
    88                 /*now scale friction by alpha: */
    89                 InputScalex(fm->elements,fm->nodes,fm->vertices,fm->loads,fm->materials,fm->parameters,FrictionCoefficientEnum,alpha/100);
    90 
    91                 /*solve: */
    92                 fm -> Solve();
    93 
    94                 /*retrieve results: */
    95                 __android_log_print(ANDROID_LOG_INFO, "Native","Retrieving results ");
    96                 patch=fm->elements->ResultsToPatch();
    97 
    98                 /*sort out the velocities: */
    99                 for(i=0;i<patch->numrows;i++){
    100                         if ((patch->values[i*patch->numcols+0])==VelEnum){
    101 
    102                                 /*Each row of the Patch object is made of the following information:
    103                                   - the result enum_type,
    104                                   - the step and time,
    105                                   - the id of the element,
    106                                   - the interpolation type,
    107                                   - the vertices ids,
    108                                   - and the values at the nodes (could be different from the vertices)
    109                                 */
    110                                 eid=(int)patch->values[i*patch->numcols+3]-1;
    111                                 v1=(int)patch->values[i*patch->numcols+5];
    112                                 x1=xyz[3*(v1-1)+0]; y1=xyz[3*(v1-1)+1]; z1=xyz[3*(v1-1)+2];
    113                                
    114                                 v2=(int)patch->values[i*patch->numcols+6];
    115                                 x2=xyz[3*(v2-1)+0]; y2=xyz[3*(v2-1)+1]; z2=xyz[3*(v2-1)+2];
    116                                
    117                                 v3=(int)patch->values[i*patch->numcols+7];
    118                                 x3=xyz[3*(v3-1)+0]; y3=xyz[3*(v3-1)+1]; z3=xyz[3*(v3-1)+2];
    119 
    120                                 vel1=patch->values[i*patch->numcols+8];
    121                                 vel2=patch->values[i*patch->numcols+9];
    122                                 vel3=patch->values[i*patch->numcols+10];
    123 
    124                                 /*plug into dBuf: */
    125                                 /*vertex 1: */
    126                                 dBuf[12*eid+0]=x1;
    127                                 dBuf[12*eid+1]=y1;
    128                                 dBuf[12*eid+2]=z1;
    129 
    130                                 /*vertex 2: */
    131                                 dBuf[12*eid+3]=x2;
    132                                 dBuf[12*eid+4]=y2;
    133                                 dBuf[12*eid+5]=z2;
    134                        
    135                                 /*vertex 3: */
    136                                 dBuf[12*eid+6]=x3;
    137                                 dBuf[12*eid+7]=y3;
    138                                 dBuf[12*eid+8]=z3;
    139                                
    140                                 /*values at 3 vertices: */
    141                                 dBuf[12*eid+9]=vel1;
    142                                 dBuf[12*eid+10]=vel2;
    143                                 dBuf[12*eid+11]=vel3;
    144 
    145                         }
    146                 }
    147 
    148                 /*for(i=0;i<148;i++){
    149                 __android_log_print(ANDROID_LOG_INFO, "Native","%g %g %g | %g %g %g | %g %g %g | %g %g %g\n",
    150                                 dBuf[12*i+0],dBuf[12*i+1],dBuf[12*i+2],
    151                                 dBuf[12*i+3],dBuf[12*i+4],dBuf[12*i+5],
    152                                 dBuf[12*i+6],dBuf[12*i+7],dBuf[12*i+8],
    153                                 dBuf[12*i+9],dBuf[12*i+10],dBuf[12*i+11]);
    154                 }*/
    155 
    156                 /*delete temporary data:*/
    157                 delete patch;
    158 
    159         }/*}}}*/
    160         static JNINativeMethod method_table[] = /*{{{*/
    161         {
    162                         {"createISSMModel"   ,"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I"  , (void *) Initialize},
    163                         {"solveISSMModel", "(DLjava/nio/DoubleBuffer;)V", (void *) Solve}
    164         };
    165         /*}}}*/
    166 }
    167 
    168 using namespace gov_nasa_jpl_issm;
    169 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) /*{{{*/
    170 {
    171     JNIEnv* env;
    172     if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
    173         return -1;
    174     }
    175     else
    176     {
    177         jclass clazz = env->FindClass("gov/nasa/jpl/issm/IssmJni");
    178         if(clazz)
    179         {
    180                 env->RegisterNatives(clazz, method_table, 3);
    181                 env->DeleteLocalRef(clazz);
    182                 return JNI_VERSION_1_6;
    183         }
    184         else return -1;
    185     }
    186 }
    187 /*}}}*/
  • ../trunk-jpl/src/mobile/android/ISSM/Makefile.am

     
    11EXTRA_DIST =  AndroidManifest.xml  assets gen jni obj project.properties src Makefile.am bin ic_launcher-web.png libs proguard-project.txt res
    2 
    3 #Generate JNI library
    4 lib_LTLIBRARIES = libISSMJNI.la
    5 
    6 libISSMJNI_la_SOURCES = ./jni/Main.cpp
    7 libISSMJNI_la_LIBADD = $(ISSM_DIR)/src/c/libISSMCore.a $(ISSM_DIR)/externalpackages/gsl/install/lib/libgsl.a
  • ../trunk-jpl

Note: See TracBrowser for help on using the repository browser.