Changeset 20815


Ignore:
Timestamp:
06/27/16 11:36:15 (9 years ago)
Author:
ayfeng
Message:

CHG: Update model in src/m/classes
CHG: Implement extrude for hydrologyshreve

Location:
issm/trunk-jpl
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/jenkins/javascript/karma/lib/bin/model.js

    r20814 r20815  
    340340                md.levelset=md.levelset.extrude(md);
    341341                md.calving=md.calving.extrude(md);
    342                 md.hydrology = extrude(md.hydrology,md);
     342                md.hydrology = md.hydrology.extrude(md);
    343343
    344344                //connectivity
  • issm/trunk-jpl/src/m/classes/hydrologyshreve.js

    r20777 r20815  
    1919
    2020        }// }}}
     21    this.extrude = function(md) {//{{{
     22        return this;
     23    };//}}}
    2124                this.classname= function(){// {{{
    2225                        return "hydrologyshreve";
  • issm/trunk-jpl/src/m/classes/model.js

    r20486 r20815  
    88                this.disp = function() { //{{{
    99                        console.log(sprintf("class model echo: "));
    10                         console.log(sprintf("%19s: %-22s -- %s","mesh"            ,"[1x1 " + typeof(this.mesh) + "]","mesh properties"));
    11                         console.log(sprintf("%19s: %-22s -- %s","mask"            ,"[1x1 " + typeof(this.mask) + "]","defines grounded and floating elements"));
    12                         console.log(sprintf("%19s: %-22s -- %s","geometry"        ,"[1x1 " + typeof(this.geometry) + "]","surface elevation, bedrock topography, ice thickness,..."));
    13                         console.log(sprintf("%19s: %-22s -- %s","constants"       ,"[1x1 " + typeof(this.constants) + "]","physical constants"));
    14                         console.log(sprintf("%19s: %-22s -- %s","smb"             ,"[1x1 " + typeof(this.smb) + "]","surface mass balance"));
    15                         console.log(sprintf("%19s: %-22s -- %s","basalforcings"   ,"[1x1 " + typeof(this.basalforcings) + "]","bed forcings"));
    16                         console.log(sprintf("%19s: %-22s -- %s","materials"       ,"[1x1 " + typeof(this.materials) + "]","material properties"));
    17                         console.log(sprintf("%19s: %-22s -- %s","damage"          ,"[1x1 " + typeof(this.damage) + "]","parameters for damage evolution solution"));
    18                         console.log(sprintf("%19s: %-22s -- %s","friction"        ,"[1x1 " + typeof(this.friction) + "]","basal friction/drag properties"));
    19                         console.log(sprintf("%19s: %-22s -- %s","flowequation"    ,"[1x1 " + typeof(this.flowequation) + "]","flow equations"));
    20                         console.log(sprintf("%19s: %-22s -- %s","timestepping"    ,"[1x1 " + typeof(this.timestepping) + "]","time stepping for trans models"));
    21                         console.log(sprintf("%19s: %-22s -- %s","initialization"  ,"[1x1 " + typeof(this.initialization) + "]","initial guess/state"));
    22                         console.log(sprintf("%19s: %-22s -- %s","rifts"           ,"[1x1 " + typeof(this.rifts) + "]","rifts properties"));
    23                         console.log(sprintf("%19s: %-22s -- %s","slr"             ,"[1x1 " + typeof(this.slr) + "]","slr forcings"));
    24                         console.log(sprintf("%19s: %-22s -- %s","debug"           ,"[1x1 " + typeof(this.debug) + "]","debugging tools (valgrind, gprof)"));
    25                         console.log(sprintf("%19s: %-22s -- %s","verbose"         ,"[1x1 " + typeof(this.verbose) + "]","verbosity level in solve"));
    26                         console.log(sprintf("%19s: %-22s -- %s","settings"        ,"[1x1 " + typeof(this.settings) + "]","settings properties"));
    27                         console.log(sprintf("%19s: %-22s -- %s","toolkits"        ,"[1x1 " + typeof(this.toolkits) + "]","PETSc options for each solution"));
    28                         console.log(sprintf("%19s: %-22s -- %s","cluster"         ,"[1x1 " + typeof(this.cluster) + "]","cluster parameters (number of cpus...)"));
    29                         console.log(sprintf("%19s: %-22s -- %s","balancethickness","[1x1 " + typeof(this.balancethickness) + "]","parameters for balancethickness solution"));
    30                         console.log(sprintf("%19s: %-22s -- %s","stressbalance"   ,"[1x1 " + typeof(this.stressbalance) + "]","parameters for stressbalance solution"));
    31                         console.log(sprintf("%19s: %-22s -- %s","groundingline"   ,"[1x1 " + typeof(this.groundingline) + "]","parameters for groundingline solution"));
    32                         console.log(sprintf("%19s: %-22s -- %s","hydrology"       ,"[1x1 " + typeof(this.hydrology) + "]","parameters for hydrology solution"));
    33                         console.log(sprintf("%19s: %-22s -- %s","masstransport"   ,"[1x1 " + typeof(this.masstransport) + "]","parameters for masstransport solution"));
    34                         console.log(sprintf("%19s: %-22s -- %s","thermal"         ,"[1x1 " + typeof(this.thermal) + "]","parameters for thermal solution"));
    35                         console.log(sprintf("%19s: %-22s -- %s","steadystate"     ,"[1x1 " + typeof(this.steadystate) + "]","parameters for steadystate solution"));
    36                         console.log(sprintf("%19s: %-22s -- %s","trans"       ,"[1x1 " + typeof(this.trans) + "]","parameters for trans solution"));
    37                         console.log(sprintf("%19s: %-22s -- %s","levelset"        ,"[1x1 " + typeof(this.levelset) + "]","parameters for moving boundaries (level-set method)"));
    38                         console.log(sprintf("%19s: %-22s -- %s","calving"         ,"[1x1 " + typeof(this.calving) + "]","parameters for calving"));
    39                         console.log(sprintf("%19s: %-22s -- %s","gia"             ,"[1x1 " + typeof(this.gia) + "]","parameters for gia solution"));
    40                         console.log(sprintf("%19s: %-22s -- %s","autodiff"        ,"[1x1 " + typeof(this.autodiff) + "]","automatic differentiation parameters"));
    41                         console.log(sprintf("%19s: %-22s -- %s","flaim"           ,"[1x1 " + typeof(this.flaim) + "]","flaim parameters"));
    42                         console.log(sprintf("%19s: %-22s -- %s","inversion"       ,"[1x1 " + typeof(this.inversion) + "]","parameters for inverse methods"));
    43                         console.log(sprintf("%19s: %-22s -- %s","qmu"             ,"[1x1 " + typeof(this.qmu) + "]","dakota properties"));
    44                         console.log(sprintf("%19s: %-22s -- %s","outputdefinition","[1x1 " + typeof(this.outputdefinition) + "]","output definition"));
    45                         console.log(sprintf("%19s: %-22s -- %s","results"         ,"[1x1 " + typeof(this.results) + "]","model results"));
    46                         console.log(sprintf("%19s: %-22s -- %s","radaroverlay"    ,"[1x1 " + typeof(this.radaroverlay) + "]","radar image for plot overlay"));
    47                         console.log(sprintf("%19s: %-22s -- %s","miscellaneous"   ,"[1x1 " + typeof(this.miscellaneous) + "]","miscellaneous fields"));
     10                        console.log(sprintf("//19s: //-22s -- //s","mesh"            ,"[1x1 " + typeof(this.mesh) + "]","mesh properties"));
     11                        console.log(sprintf("//19s: //-22s -- //s","mask"            ,"[1x1 " + typeof(this.mask) + "]","defines grounded and floating elements"));
     12                        console.log(sprintf("//19s: //-22s -- //s","geometry"        ,"[1x1 " + typeof(this.geometry) + "]","surface elevation, bedrock topography, ice thickness,..."));
     13                        console.log(sprintf("//19s: //-22s -- //s","constants"       ,"[1x1 " + typeof(this.constants) + "]","physical constants"));
     14                        console.log(sprintf("//19s: //-22s -- //s","smb"             ,"[1x1 " + typeof(this.smb) + "]","surface mass balance"));
     15                        console.log(sprintf("//19s: //-22s -- //s","basalforcings"   ,"[1x1 " + typeof(this.basalforcings) + "]","bed forcings"));
     16                        console.log(sprintf("//19s: //-22s -- //s","materials"       ,"[1x1 " + typeof(this.materials) + "]","material properties"));
     17                        console.log(sprintf("//19s: //-22s -- //s","damage"          ,"[1x1 " + typeof(this.damage) + "]","parameters for damage evolution solution"));
     18                        console.log(sprintf("//19s: //-22s -- //s","friction"        ,"[1x1 " + typeof(this.friction) + "]","basal friction/drag properties"));
     19                        console.log(sprintf("//19s: //-22s -- //s","flowequation"    ,"[1x1 " + typeof(this.flowequation) + "]","flow equations"));
     20                        console.log(sprintf("//19s: //-22s -- //s","timestepping"    ,"[1x1 " + typeof(this.timestepping) + "]","time stepping for trans models"));
     21                        console.log(sprintf("//19s: //-22s -- //s","initialization"  ,"[1x1 " + typeof(this.initialization) + "]","initial guess/state"));
     22                        console.log(sprintf("//19s: //-22s -- //s","rifts"           ,"[1x1 " + typeof(this.rifts) + "]","rifts properties"));
     23                        console.log(sprintf("//19s: //-22s -- //s","slr"             ,"[1x1 " + typeof(this.slr) + "]","slr forcings"));
     24                        console.log(sprintf("//19s: //-22s -- //s","debug"           ,"[1x1 " + typeof(this.debug) + "]","debugging tools (valgrind, gprof)"));
     25                        console.log(sprintf("//19s: //-22s -- //s","verbose"         ,"[1x1 " + typeof(this.verbose) + "]","verbosity level in solve"));
     26                        console.log(sprintf("//19s: //-22s -- //s","settings"        ,"[1x1 " + typeof(this.settings) + "]","settings properties"));
     27                        console.log(sprintf("//19s: //-22s -- //s","toolkits"        ,"[1x1 " + typeof(this.toolkits) + "]","PETSc options for each solution"));
     28                        console.log(sprintf("//19s: //-22s -- //s","cluster"         ,"[1x1 " + typeof(this.cluster) + "]","cluster parameters (number of cpus...)"));
     29                        console.log(sprintf("//19s: //-22s -- //s","balancethickness","[1x1 " + typeof(this.balancethickness) + "]","parameters for balancethickness solution"));
     30                        console.log(sprintf("//19s: //-22s -- //s","stressbalance"   ,"[1x1 " + typeof(this.stressbalance) + "]","parameters for stressbalance solution"));
     31                        console.log(sprintf("//19s: //-22s -- //s","groundingline"   ,"[1x1 " + typeof(this.groundingline) + "]","parameters for groundingline solution"));
     32                        console.log(sprintf("//19s: //-22s -- //s","hydrology"       ,"[1x1 " + typeof(this.hydrology) + "]","parameters for hydrology solution"));
     33                        console.log(sprintf("//19s: //-22s -- //s","masstransport"   ,"[1x1 " + typeof(this.masstransport) + "]","parameters for masstransport solution"));
     34                        console.log(sprintf("//19s: //-22s -- //s","thermal"         ,"[1x1 " + typeof(this.thermal) + "]","parameters for thermal solution"));
     35                        console.log(sprintf("//19s: //-22s -- //s","steadystate"     ,"[1x1 " + typeof(this.steadystate) + "]","parameters for steadystate solution"));
     36                        console.log(sprintf("//19s: //-22s -- //s","trans"       ,"[1x1 " + typeof(this.trans) + "]","parameters for trans solution"));
     37                        console.log(sprintf("//19s: //-22s -- //s","levelset"        ,"[1x1 " + typeof(this.levelset) + "]","parameters for moving boundaries (level-set method)"));
     38                        console.log(sprintf("//19s: //-22s -- //s","calving"         ,"[1x1 " + typeof(this.calving) + "]","parameters for calving"));
     39                        console.log(sprintf("//19s: //-22s -- //s","gia"             ,"[1x1 " + typeof(this.gia) + "]","parameters for gia solution"));
     40                        console.log(sprintf("//19s: //-22s -- //s","autodiff"        ,"[1x1 " + typeof(this.autodiff) + "]","automatic differentiation parameters"));
     41                        console.log(sprintf("//19s: //-22s -- //s","flaim"           ,"[1x1 " + typeof(this.flaim) + "]","flaim parameters"));
     42                        console.log(sprintf("//19s: //-22s -- //s","inversion"       ,"[1x1 " + typeof(this.inversion) + "]","parameters for inverse methods"));
     43                        console.log(sprintf("//19s: //-22s -- //s","qmu"             ,"[1x1 " + typeof(this.qmu) + "]","dakota properties"));
     44                        console.log(sprintf("//19s: //-22s -- //s","outputdefinition","[1x1 " + typeof(this.outputdefinition) + "]","output definition"));
     45                        console.log(sprintf("//19s: //-22s -- //s","results"         ,"[1x1 " + typeof(this.results) + "]","model results"));
     46                        console.log(sprintf("//19s: //-22s -- //s","radaroverlay"    ,"[1x1 " + typeof(this.radaroverlay) + "]","radar image for plot overlay"));
     47                        console.log(sprintf("//19s: //-22s -- //s","miscellaneous"   ,"[1x1 " + typeof(this.miscellaneous) + "]","miscellaneous fields"));
    4848                } //}}}
    4949                this.setdefaultparameters = function () { // {{{
     
    111111
    112112                } //}}}
     113        this.extrude = function(md) { //{{{
     114        //EXTRUDE - vertically extrude a 2d mesh
     115        //
     116        //   vertically extrude a 2d mesh and create corresponding 3d mesh.
     117        //   The vertical distribution can:
     118        //    - follow a polynomial law
     119        //    - follow two polynomial laws, one for the lower part and one for the upper part of the mesh
     120        //    - be discribed by a list of coefficients (between 0 and 1)
     121        //   
     122        //
     123        //   Usage:
     124        //      md=extrude(md,numlayers,extrusionexponent);
     125        //      md=extrude(md,numlayers,lowerexponent,upperexponent);
     126        //      md=extrude(md,listofcoefficients);
     127        //
     128        //   Example:
     129        //      md=extrude(md,15,1.3);
     130        //      md=extrude(md,15,1.3,1.2);
     131        //      md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]);
     132        //
     133        //   See also: MODELEXTRACT, COLLAPSE
     134
     135        //some checks on list of arguments
     136            var argc = arguments.length;
     137
     138            if ((argc > 4) | (argc < 2)) {
     139                throw "extrude error message";
     140            }
     141
     142            //Extrude the mesh
     143            if (argc==2) { //list of coefficients
     144                clist=arguments[0];
     145
     146                if (clist.some(function(x) { return x < 0; }) | clist.some(function(x) { return x > 1; }))
     147                    throw 'extrusioncoefficients must be between 0 and 1';
     148                clistcopy.push.apply(clistcopy, [0, 1]);
     149
     150                extrusionlist=clistcopy.reverse().filter(function(e, i, arr) { //only keep unique elements
     151                    return arr.indexOf(e, i+1) === -1;
     152                }).sort();
     153
     154                console.log("extrusionlist is " + extrusionlist) //@REMOVE
     155
     156                numlayers=extrusionlist.length;
     157            } else if (argc==3) { //one polynomial law
     158                if (arguments[2]<=0) {
     159                    //help extrude;
     160                    throw 'extrusionexponent must be >=0';
     161                }
     162                numlayers=arguments[0];
     163
     164                extrusionlist = [];
     165
     166                for (var i = 0; i < numlayers; i++) {
     167                    extrusionlist.push(Math.pow(i/(numlayers-1), arguments[2]));
     168                };
     169
     170            } else if (argc==4) { //two polynomial laws
     171                numlayers=arguments[0];
     172                lowerexp=arguments[1];
     173                upperexp=arguments[2];
     174
     175                if (arguments[1]<=0 | args[2]<=0) {
     176                    throw 'lower and upper extrusionexponents must be >=0';
     177                }
     178
     179                lowerextrusionlist = [];
     180                for (var i = 0; i <= 1; i += (2/(numlayers-1))) {
     181                    lowerextrusionlist.push(Math.pow(i, lowerexp)/2)
     182                };
     183
     184                upperextrusionlist = [];
     185                for (var i = 0; i <= 1; i += (2/(numlayers-1))) {
     186                    upperextrusionlist.push(Math.pow(i, upperexp)/2)
     187                };
     188
     189                //lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2;
     190                //upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2;
     191
     192                var temp = lowerextrusionlist;
     193                temp.push.apply(temp, [1]);
     194
     195                var temp2 = upperextrusionlist.map(function(x) { return -x; });
     196                temp.push.apply(temp, temp2);
     197
     198                clistcopy.push.apply(clistcopy, [0, 1]);
     199                //extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist]));
     200                extrusionlist=temp.sort();
     201            }
     202
     203            if (numlayers<2) {
     204                console.error('number of layers should be at least 2');
     205            }
     206
     207            if (md.mesh.domaintype() !== '3D') {
     208                console.error('Cannot extrude a 3d mesh (extrude cannot be called more than once)');
     209            }
     210
     211            //Initialize with the 2d mesh
     212            mesh2d = md.mesh;
     213            md.mesh=new mesh3dprisms();
     214
     215            md.mesh.x                           = mesh2d.x;
     216            md.mesh.y                           = mesh2d.y;
     217            md.mesh.elements                    = mesh2d.elements;
     218            md.mesh.numberofelements            = mesh2d.numberofelements;
     219            md.mesh.numberofvertices            = mesh2d.numberofvertices;
     220
     221            md.mesh.lat                         = mesh2d.lat;
     222            md.mesh.long                        = mesh2d.long;
     223            md.mesh.epsg                        = mesh2d.epsg;
     224
     225            md.mesh.vertexonboundary            = mesh2d.vertexonboundary;
     226            md.mesh.vertexconnectivity          = mesh2d.vertexconnectivity;
     227            md.mesh.elementconnectivity         = mesh2d.elementconnectivity;
     228            md.mesh.average_vertex_connectivity = mesh2d.average_vertex_connectivity;
     229
     230            md.mesh.extractedvertices           = mesh2d.extractedvertices;
     231            md.mesh.extractedelements           = mesh2d.extractedelements;
     232
     233            x3d=[];
     234            y3d=[];
     235            z3d=[];  //the lower node is on the bed
     236            thickness3d=md.geometry.thickness; //thickness and bed for these nodes
     237                bed3d=md.geometry.base;
     238
     239            //Create the new layers
     240            for (var i = 1; i <= numlayers; i++) {
     241                x3d=[x3d, md.mesh.x];
     242                y3d=[y3d, md.mesh.y];
     243                //nodes are distributed between bed and surface accordingly to the given exponent
     244                z3d=[z3d, bed3d+thickness3d*extrusionlist(i)];
     245            };
     246
     247            number_nodes3d=x3d.length; //number of 3d nodes for the non extruded part of the mesh
     248
     249            //Extrude elements
     250            elements3d=[];
     251            for (var i = 0; i < numlayers; i++) {
     252                elements3d.push(md.mesh.elements+(i-1)*md.mesh.numberofvertices, md.mesh.elements+i*md.mesh.numberofvertices); //Create the elements of the 3d mesh for the non extruded part
     253            };
     254
     255            number_el3d=elements3d.length; //number of 3d nodes for the non extruded part of the mesh
     256
     257            function fillArray(value, len) {
     258                if (len == 0) return [];
     259                var a = [value];
     260                while (a.length * 2 <= len) a = a.concat(a);
     261                if (a.length < len) a = a.concat(a.slice(0, len - a.length));
     262                return a;
     263            }
     264
     265            //Keep a trace of lower and upper nodes
     266            //lowervertex=NaN*ones(number_nodes3d,1);
     267            //uppervertex=NaN*ones(number_nodes3d,1);
     268
     269            lowervertex = fillArray(null, number_nodes3d);
     270            uppervertex = fillArray(null, number_nodes3d);
     271
     272            //lowervertex(md.mesh.numberofvertices+1:end)=1:(numlayers-1)*md.mesh.numberofvertices;
     273            //uppervertex(1:(numlayers-1)*md.mesh.numberofvertices)=md.mesh.numberofvertices+1:number_nodes3d;
     274
     275            for (var i = md.mesh.numberofvertices+1, k = 1; i < lowervertex.length && k <= (numlayers-1)*md.mesh.numberofvertices; i++, k++) {
     276                lowervertex[i] = k;
     277            };
     278
     279            for (var i = 1, k = md.mesh.numberofvertices+1; i <= (numlayers-1)*md.mesh.numberofvertices && k <= number_nodes3d; i++, k++) {
     280                uppervertex[i] = k;
     281            };
     282
     283            md.mesh.lowervertex=lowervertex;
     284            md.mesh.uppervertex=uppervertex;
     285
     286            //same for lower and upper elements
     287            lowerelements = fillArray(null, number_el3d);
     288            upperelements = fillArray(null, number_el3d);
     289            //lowerelements(md.mesh.numberofelements+1:end)=1:(numlayers-2)*md.mesh.numberofelements;
     290            //upperelements(1:(numlayers-2)*md.mesh.numberofelements)=md.mesh.numberofelements+1:(numlayers-1)*md.mesh.numberofelements;
     291
     292            for (var i = md.mesh.numberofvertices+1, k = 1; i < lowerelements.length && k <= (numlayers-2)*md.mesh.numberofelements; i++, k++) {
     293                lowerelements[i] = k;
     294            };
     295
     296            for (var i = 1, k = md.mesh.numberofelements + 1; i <= (numlayers-2)*md.mesh.numberofelements && k <= (numlayers-1)*md.mesh.numberofelements; i++, k++) {
     297                upperelements[i] = k;
     298            };
     299
     300            md.mesh.lowerelements=lowerelements;
     301            md.mesh.upperelements=upperelements;
     302
     303            //Save old mesh
     304            md.mesh.x2d=md.mesh.x;
     305            md.mesh.y2d=md.mesh.y;
     306            md.mesh.elements2d=md.mesh.elements;
     307            md.mesh.numberofelements2d=md.mesh.numberofelements;
     308            md.mesh.numberofvertices2d=md.mesh.numberofvertices;
     309
     310            //Build global 3d mesh
     311            md.mesh.elements=elements3d;
     312            md.mesh.x=x3d;
     313            md.mesh.y=y3d;
     314            md.mesh.z=z3d;
     315            md.mesh.numberofelements=number_el3d;
     316            md.mesh.numberofvertices=number_nodes3d;
     317            md.mesh.numberoflayers=numlayers;
     318
     319            //Ok, now deal with the other fields from the 2d mesh:
     320
     321            //bedinfo and surface info
     322            md.mesh.vertexonbase=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1);
     323            md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers);
     324            md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node');
     325
     326            //lat long
     327            md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node');
     328            md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node');
     329
     330                md.geometry=md.geometry.extrude(md);
     331                md.friction=md.friction.extrude(md);
     332                md.inversion=md.inversion.extrude(md);
     333                md.smb=md.smb.extrude(md);
     334                md.initialization=md.initialization.extrude(md);
     335
     336                md.flowequation=md.flowequation.extrude(md);
     337                md.stressbalance=md.stressbalance.extrude(md);
     338                md.thermal=md.thermal.extrude(md);
     339                md.masstransport=md.masstransport.extrude(md);
     340                md.levelset=md.levelset.extrude(md);
     341                md.calving=md.calving.extrude(md);
     342                md.hydrology = md.hydrology.extrude(md);
     343
     344                //connectivity
     345                //if ~isnan(md.mesh.elementconnectivity)
     346
     347                if (md.mesh.elementconnectivity.every(function(e, i, arr) { return e !== null && typeof e !== 'undefined'; })) {
     348                    var temparr = [];
     349                    for (var i = 0; i < numlayers; i++) {
     350                        temparr.push(md.mesh.elementconnectivity);
     351                    };
     352
     353                    //md.mesh.elementconnectivity=repmat(md.mesh.elementconnectivity,numlayers-1,1);
     354
     355                    md.mesh.elementconnectivity = temparr;
     356
     357                    //md.mesh.elementconnectivity(find(md.mesh.elementconnectivity==0))=NaN;
     358
     359                    for (var i = 0; i < md.mesh.elementconnectivity.length; i++) {
     360                        if (md.mesh.elementconnectivity[i] == 0) {
     361                            md.mesh.elementconnectivity[i] = null;
     362                        }
     363                    };
     364
     365                    for (var i = 2; i < numlayers; i++) {
     366                        for (var j = (i-1)*md.mesh.nuberofelements2d+1; i <= (i)*md.mesh.numberofelements2d; i++) {
     367                            md.mesh.elementconnectivity[i] += md.mesh.numberofelements2d;
     368                        };
     369                        //md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)...
     370                            //=md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d;
     371                    };
     372
     373                    md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0;
     374
     375                    for (var i = 0; i < md.mesh.elementconnectivity.length; ++i) {
     376                        if (md.mesh.elementconnectivity[i] === null || typeof md.mesh.elementconnectivity[i] === 'undefined') {
     377                            md.mesh.elementconnectivity[i] = 0;
     378                        }
     379                    }
     380                }
     381
     382                md.materials=extrude(md.materials,md);
     383                md.damage=extrude(md.damage,md);
     384                md.mask=extrude(md.mask,md);
     385                md.qmu=extrude(md.qmu,md);
     386                md.basalforcings=extrude(md.basalforcings,md);
     387
     388                //increase connectivity if less than 25:
     389                if (md.mesh.average_vertex_connectivity<=25)
     390                    md.mesh.average_vertex_connectivity=100;
     391                // }}}
     392
     393        } //}}}
    113394        //properties
    114395        // {{{
Note: See TracChangeset for help on using the changeset viewer.