Changeset 19719
- Timestamp:
- 11/13/15 15:18:03 (9 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/array/ArrayOperations.js
r19711 r19719 55 55 return list; 56 56 } //}}} 57 function IsArray(object) { //{{{ 58 59 if( Object.prototype.toString.call( object ) === '[object Array]' ) { 60 return 1; 61 } 62 else return 0; 63 64 } //}}} 65 function ArrayNot(array) { //{{{ 66 67 var notarray=array; 68 for (i=0;i<array.length;i++)notarray[i]=-array[i]; 69 return notarray; 70 } //}}} 71 function ArrayAnd(array1,array2) { //{{{ 72 73 var array=array1; 74 for (i=0;i<array1.length;i++)array[i]=array1[i] & array2[i]; 75 return array; 76 } //}}} 77 function NewArrayFill(size,value) { //{{{ 78 79 return new Array(size).fill(value); 80 } //}}} 81 function ArrayFind(array,value) { //{{{ 82 83 //find number of indices 84 var count=0; 85 for (i=0;i<array.length;i++)if(array[i]==value)count++; 86 87 //allocate: 88 var indices= NewArrayFill(count,0); 89 90 //fill in: 91 count=0; 92 for (i=0;i<array.length;i++){ 93 if(array[i]==value){ 94 indices[count]=i; 95 count++; 96 } 97 } 98 return indices; 99 } //}}} -
issm/trunk-jpl/src/m/classes/mesh2d.js
r19702 r19719 5 5 6 6 function mesh2d () { 7 //properties8 // {{{9 this.x = NaN;10 this.y = NaN;11 this.elements = NaN;12 this.numberofelements = 0;13 this.numberofvertices = 0;14 this.numberofedges = 0;15 16 this.lat = NaN;17 this.long = NaN;18 this.epsg = 0;19 20 this.vertexonboundary = NaN;21 22 this.edges = NaN;23 this.segments = NaN;24 this.segmentmarkers = NaN;25 this.vertexconnectivity = NaN;26 this.elementconnectivity = NaN;27 this.average_vertex_connectivity = 0;28 29 this.extractedvertices = NaN;30 this.extractedelements = NaN;31 //}}}32 7 //methods 33 8 this.setdefaultparameters = function () //{{{ … … 69 44 fielddisplay(this,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)"); 70 45 } //}}} 46 //properties 47 // {{{ 48 this.x = NaN; 49 this.y = NaN; 50 this.elements = NaN; 51 this.numberofelements = 0; 52 this.numberofvertices = 0; 53 this.numberofedges = 0; 54 55 this.lat = NaN; 56 this.long = NaN; 57 this.epsg = 0; 58 59 this.vertexonboundary = NaN; 60 61 this.edges = NaN; 62 this.segments = NaN; 63 this.segmentmarkers = NaN; 64 this.vertexconnectivity = NaN; 65 this.elementconnectivity = NaN; 66 this.average_vertex_connectivity = 0; 67 68 this.extractedvertices = NaN; 69 this.extractedelements = NaN; 70 71 this.setdefaultparameters(); 72 //}}} 71 73 72 74 } -
issm/trunk-jpl/src/m/classes/model.js
r19702 r19719 49 49 //initialize subclasses 50 50 this.mesh = new mesh2d(); 51 // this.mask =mask();52 // this.constants =constants();53 // this.geometry =geometry();51 this.mask = new mask(); 52 this.constants = new constants(); 53 this.geometry = new geometry(); 54 54 // this.initialization = initialization(); 55 55 // this.smb = SMBforcing(); -
issm/trunk-jpl/src/m/parameterization/setmask.js
r19711 r19719 1 function md=setmask(md,floatingicename,groundedicename,varargin) 2 %SETMASK - establish boundaries between grounded and floating ice. 3 % 4 % By default, ice is considered grounded. The contour floatingicename defines nodes 5 % for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 6 % that are grounded (ie: ice rises, islands, etc ...) 7 % All input files are in the Argus format (extension .exp). 8 % 9 % Usage: 10 % md=setmask(md,floatingicename,groundedicename) 11 % 12 % Examples: 13 % md=setmask(md,'all',''); 14 % md=setmask(md,'Iceshelves.exp','Islands.exp'); 1 function setmask(md,floatingice,groundedice){ 2 //SETMASK - establish boundaries between grounded and floating ice. 3 // 4 // By default, ice is considered grounded. The contour floatingice defines nodes 5 // for which ice is floating. The contour groundedice defines nodes inside a floatingice, 6 // that are grounded (ie: ice rises, islands, etc ...) 7 // All inputs are either strings or actually javascript arrays (included in the html file) 8 // For example: 9 // 10 // floatingice[0]['x']=[0,0,0,1]; 11 // floatingice[0]['y']=[0,1,1,1]; 12 // floatingice[1]['x']=[0,0.5,0.5,.5]; 13 // floatingice[1]['y']=[0,.5,.5,.5]; 14 // 15 // 16 // Usage: 17 // md=setmask(md,floatingice,groundedice) 18 // 19 // Examples: 20 // md=setmask(md,'all',''); 21 // md=setmask(md,iceshelves,islands); 15 22 16 %some checks on list of arguments 17 if ((mod(nargin,2)==0) | (nargout~=1)), 18 help mask 19 error('mask error message'); 20 end 23 //variables: 24 var icedomain=[]; 25 26 //some checks on list of arguments 27 if (!((arguments.length==3) | (arguments.length==5))){ 28 console.error('mask error message: wrong usage.'); 29 } 21 30 22 if(nargin>3) 23 if(varargin(1)=='icedomain'), 24 icedomainname=varargin(2); 25 else 26 error('mask error message: wrong field specified. Only icedomain allowed for now.'); 27 end 28 if ~exist(icedomainname), 29 error(['setmask error message: file ' icedomainname ' not found!']); 30 end 31 end 31 if(arguments.length>3){ 32 if (arguments[3]=='icedomain'){ 33 icedomain=arguments[4]; 34 } 35 else{ 36 console.error('mask error message: wrong field specified. Only icedomain allowed for now.'); 37 } 38 if (IsArray(icedomain)){ 39 console.error('setmask error message: icedomain should be an array!'); 40 } 41 } 42 43 //Get assigned fields 44 x=md.mesh.x; 45 y=md.mesh.y; 46 elements=md.mesh.elements; 32 47 33 %Get assigned fields 34 x=md.mesh.x; 35 y=md.mesh.y;36 elements=md.mesh.elements;48 //Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. 49 //Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. 50 elementonfloatingice=FlagElements(md,floatingice); 51 elementongroundedice=FlagElements(md,groundedice); 37 52 38 %Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{ 39 elementonfloatingice=FlagElements(md,floatingicename); 40 elementongroundedice=FlagElements(md,groundedicename); 53 //Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 54 //arrays come from domain outlines that can intersect one another: 55 elementonfloatingice=ArrayAnd(elementonfloatingice,ArrayNot(elementongroundedice)); 56 elementongroundedice=ArrayNot(elementonfloatingice); 41 57 42 %Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 43 %arrays come from domain outlines that can intersect one another: 44 elementonfloatingice=double((elementonfloatingice & ~elementongroundedice)); 45 elementongroundedice=double(~elementonfloatingice); 58 //the order here is important. we choose vertexongroundedice as default on the grounding line. 59 vertexonfloatingice=NewArrayFill(md.mesh.numberofvertices,0); 60 vertexongroundedice=NewArrayFill(md.mesh.numberofvertices,0); 61 pos=ArrayFind(elementongroundedice,1); for (i=0;i<pos.length;i++)for(j=0;j<3;j++) vertexongroundedice[md.mesh.elements[i,j]-1]=1; 62 pos=ArrayFind(vertexongroundedice,0); for (i=0;i<pos.length;i++)vertexonfloatingice[i]=1; 46 63 47 %the order here is important. we choose vertexongroundedice as default on the grounding line. 48 vertexonfloatingice=zeros(md.mesh.numberofvertices,1); 49 vertexongroundedice=zeros(md.mesh.numberofvertices,1); 50 vertexongroundedice(md.mesh.elements(find(elementongroundedice),:))=1; 51 vertexonfloatingice(find(~vertexongroundedice))=1; 52 %}}} 64 //level sets 65 groundedice_levelset=vertexongroundedice; 66 pos=ArrayFind(vertexongroundedice,0);for(i=0;i<pos.length;i++) groundedice_levelset[i]=-1; 67 md.mask.groundedice_levelset=groundedice_levelset; 53 68 54 %level sets 55 md.mask.groundedice_levelset=vertexongroundedice; 56 md.mask.groundedice_levelset(find(vertexongroundedice==0.))=-1.; 57 58 if(nargin>3) 59 if(varargin(1)=='icedomain') 60 md.mask.ice_levelset = 1.*ones(md.mesh.numberofvertices,1); 61 %use contourtomesh to set ice values inside ice domain 62 [vertexinsideicedomain,elementinsideicedomain]=ContourToMesh(elements,x,y,icedomainname,'node',1); 63 pos=find(vertexinsideicedomain==1.); 64 md.mask.ice_levelset(pos) = -1.; 65 end 66 else 67 md.mask.ice_levelset = -1.*ones(md.mesh.numberofvertices,1); 68 end 69 70 69 if(arguments.length>3){ 70 md.mask.ice_levelset = NewArrayFill(md.mesh.numberofvertices,1.0); 71 //use contourtomesh to set ice values inside ice domain 72 [vertexinsideicedomain,elementinsideicedomain]=ContourToMesh(elements,x,y,icedomain,'node',1); 73 pos=ArrayFind(vertexinsideicedomain,1.0);for(i=0;i<pos.length;i++) md.mask.ice_levelset[pos]=-1; 74 } 75 else{ 76 md.mask.ice_levelset = NewArrayFill(md.mesh.numberofvertices,-1); 77 } 78 }
Note:
See TracChangeset
for help on using the changeset viewer.