| [19793] | 1 | function issm(fid,toolkitstring,solutionstring,modelname){ | 
|---|
|  | 2 | /*issm | 
|---|
|  | 3 | usage: var output = issm(fid,toolkitstring); | 
|---|
|  | 4 | where: fid is a pointer to a memory buffer created by marshall, toolkitstring is a toolkits | 
|---|
|  | 5 | string created by ToolkitsToFile and | 
|---|
|  | 6 | output is a binary buffer to be read by loadresultsfromcluster. | 
|---|
|  | 7 | */ | 
|---|
| [19806] | 8 |  | 
|---|
|  | 9 | /*variables: */ | 
|---|
|  | 10 | var poutput,output,poutputsize,outputsize; | 
|---|
|  | 11 | var dbinaryPtr,binHeap,binary,binarybuffer,nb | 
|---|
| [19793] | 12 |  | 
|---|
| [19806] | 13 | /*recover input buffer: */ | 
|---|
|  | 14 | binarybuffer=fid.rawbuffer(); //binarybuffer is now an arraybuffer | 
|---|
|  | 15 | nb = fid.ptr; //size of array buffer in bytes. | 
|---|
| [19793] | 16 |  | 
|---|
| [19806] | 17 | /*dyanmically allocate the raw buffer onto the Module heap: */ | 
|---|
|  | 18 | dbinaryPtr= Module._malloc(nb); binHeap = new Uint8Array(Module.HEAPU8.buffer,dbinaryPtr,nb); | 
|---|
|  | 19 | binHeap.set(new Uint8Array(binarybuffer)); binary=binHeap.byteOffset; | 
|---|
| [19793] | 20 |  | 
|---|
| [19806] | 21 | /*allocate output pointers: */ | 
|---|
|  | 22 | poutputsize = Module._malloc(4); | 
|---|
|  | 23 | poutput = Module._malloc(4); | 
|---|
| [19793] | 24 |  | 
|---|
|  | 25 | //Declare TriMesh module: | 
|---|
| [19806] | 26 | issmmodule= Module.cwrap('IssmModule','number',['number','number','number','number','string','string','string']); | 
|---|
| [19793] | 27 |  | 
|---|
|  | 28 | //Call issm: | 
|---|
| [19806] | 29 | issmmodule(poutput, poutputsize,binary, nb, toolkitstring,solutionstring,modelname); | 
|---|
|  | 30 |  | 
|---|
|  | 31 | //recover outputs from pointers: | 
|---|
|  | 32 | var outputsize = Module.getValue(poutputsize,'i32'); | 
|---|
| [19793] | 33 |  | 
|---|
| [19806] | 34 | var outputptr = Module.getValue(poutput,'i32'); | 
|---|
|  | 35 | output = Module.HEAP8.slice(outputptr, outputptr + outputsize); | 
|---|
|  | 36 |  | 
|---|
|  | 37 | return [output,outputsize]; | 
|---|
| [19793] | 38 | } | 
|---|