Changeset 22086
- Timestamp:
- 09/15/17 18:50:36 (8 years ago)
- Location:
- issm/branches/trunk-larour-NatGeoScience2016/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/c/modules/Bamgx/Bamgx.cpp
r21759 r22086 149 149 } 150 150 151 //Add geometry metric if provided152 if(bamgopts->geometricalmetric) BTh.AddGeometryMetric(bamgopts);153 154 151 //Smoothe metric 155 152 BTh.SmoothMetric(bamgopts->gradation); -
issm/branches/trunk-larour-NatGeoScience2016/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r21759 r22086 24 24 R2 r; 25 25 I2 I; 26 int i,j ;26 int i,j,k; 27 27 int it; 28 28 int i0,i1,i2; 29 29 double areacoord[3]; 30 30 double aa,bb; 31 Icoor2dete[3];31 long long dete[3]; 32 32 33 33 /*Checks*/ … … 66 66 } 67 67 68 /*Create Single vertex to element connectivity*/ 69 int* connectivity = xNew<int>(nods_data); 70 for(i=0;i<nels_data;i++){ 71 for(j=0;j<3;j++){ 72 k = index_data[i*3+j]-1; 73 _assert_(k>=0 & k<nods_data); 74 connectivity[k]=i; 75 } 76 } 77 68 78 /*Loop over output nodes*/ 69 79 for(i=0;i<N_interp;i++){ … … 88 98 89 99 /*Area coordinates*/ 90 areacoord[0]= (double) dete[0]/tb.det;91 areacoord[1]= (double) dete[1]/tb.det;92 areacoord[2]= (double) dete[2]/tb.det;100 areacoord[0]= reCast<double>(dete[0])/reCast<double>(tb.det); 101 areacoord[1]= reCast<double>(dete[1])/reCast<double>(tb.det); 102 areacoord[2]= reCast<double>(dete[2])/reCast<double>(tb.det); 93 103 /*3 vertices of the triangle*/ 94 104 i0=Th->GetId(tb[0]); … … 137 147 /*If we fall outside of the convex or outside of the mesh, return NaN*/ 138 148 if(tb.det<0 || reft[it]<0){ 139 for (j=0;j<N_data;j++){ 140 data_interp[i*N_data+j]=NAN; 141 } 149 _assert_(i0>=0 & i0<nods_data); 150 it=connectivity[i0]; //or i1 or i2 151 _assert_(it>=0 && it<nels_data); 152 for(j=0;j<N_data;j++) data_interp[i*N_data+j]=data[N_data*it+j]; 142 153 } 143 154 else{ 155 /*Inside the mesh!*/ 144 156 if(it<0 || it>=nels_data){ 145 157 _error_("Triangle number " << it << " not in [0 " << nels_data 146 158 << "], report bug to developers (interpolation point: " <<x_interp[i]<<" "<<y_interp[i]<<")"); 147 159 } 148 for (j=0;j<N_data;j++){ 149 150 data_interp[i*N_data+j]=data[N_data*it+j]; 151 } 160 for (j=0;j<N_data;j++) data_interp[i*N_data+j]=data[N_data*it+j]; 152 161 } 153 162 } … … 158 167 delete Th; 159 168 xDelete<long>(reft); 169 xDelete<int>(connectivity); 160 170 *pdata_interp=data_interp; 161 171 return 1; -
issm/branches/trunk-larour-NatGeoScience2016/src/m/modules/ContourToMesh.m
r20875 r22086 6 6 % 7 7 % index,x,y: mesh triangulation 8 % contourname: name of .exp file containing the contours.8 % contourname: name of .exp or .shp file containing the contours. 9 9 % interptype: string defining type of interpolation ('element', or 'node'). 10 10 % edgevalue: integer (0, 1, or 2) defining the value associated to the nodes on the edges of the polygons. … … 25 25 end 26 26 27 %Some conversion of files: 28 [path,name,ext]=fileparts(contourname); 29 if strcmpi(ext,'.shp'), 30 %read contour from shapefile: 31 contour=shpread(contourname); 32 33 %write it to a temporary filename: 34 contourname=tempname; 35 expwrite(contour,contourname); 36 end 37 27 38 %Call mex module 28 39 [in_nod,in_elem] = ContourToMesh_matlab(index,x,y,contourname,interptype,edgevalue); -
issm/branches/trunk-larour-NatGeoScience2016/src/m/modules/ContourToNodes.m
r22038 r22086 6 6 % 7 7 % x,y: list of nodes 8 % contourname: name of .expfile containing the contours, or resulting structure from call to expread8 % contourname: name of Argus or Shape file containing the contours, or resulting structure from call to expread 9 9 % edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons 10 10 % flags: vector of flags (0 or 1), of size nodes … … 16 16 end 17 17 18 %Some conversion of files: 19 [path,name,ext]=fileparts(contourname); 20 if strcmpi(ext,'.shp'), 21 %read contour from shapefile: 22 contour=shpread(contourname); 18 %Some conversion of files: 19 if ischar(contourname), 20 [path,name,ext]=fileparts(contourname); 21 if strcmpi(ext,'.shp'), 22 %read contour from shapefile: 23 contour=shpread(contourname); 23 24 24 %write it to a temporary filename: 25 contourname=tempname; 26 expwrite(contour,contourname); 25 %write it to a temporary filename: 26 contourname=tempname; 27 expwrite(contour,contourname); 28 end 27 29 end 28 30 -
issm/branches/trunk-larour-NatGeoScience2016/src/m/modules/MeshProfileIntersection.m
r20875 r22086 7 7 % input: 8 8 % index,x,y is a triangulation 9 % filename: name of Argus style .expfile containing the segments (can be groups of disconnected segments)9 % filename: name of Argus or Shape file containing the segments (can be groups of disconnected segments) 10 10 % output: 11 11 % segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremities for a segment … … 19 19 end 20 20 21 [path,name,ext]=fileparts(filename); 22 if strcmpi(ext,'.shp'), 23 24 %convert to expfile and store in a temporary directory: 25 oldfilename=filename; 26 filename=[tempname '.exp']; 27 shp2exp(oldfilename,filename); 28 end 29 21 30 % Call mex module 22 31 [segments] = MeshProfileIntersection_matlab(index,x,y,filename); -
issm/branches/trunk-larour-NatGeoScience2016/src/wrappers/matlab/io/FetchMatlabData.cpp
r16968 r22086 537 537 FetchData(&bamgopts->gradation,mxGetField(dataref,0,"gradation")); 538 538 FetchData(&bamgopts->Hessiantype,mxGetField(dataref,0,"Hessiantype")); 539 FetchData(&bamgopts->MaxCornerAngle,mxGetField(dataref,0,"MaxCornerAngle"));540 539 FetchData(&bamgopts->maxnbv,mxGetField(dataref,0,"maxnbv")); 541 540 FetchData(&bamgopts->maxsubdiv,mxGetField(dataref,0,"maxsubdiv")); … … 545 544 FetchData(&bamgopts->omega,mxGetField(dataref,0,"omega")); 546 545 FetchData(&bamgopts->power,mxGetField(dataref,0,"power")); 547 FetchData(&bamgopts->random,mxGetField(dataref,0,"random"));548 546 FetchData(&bamgopts->verbose,mxGetField(dataref,0,"verbose")); 549 547 550 548 FetchData(&bamgopts->Crack,mxGetField(dataref,0,"Crack")); 551 FetchData(&bamgopts->geometricalmetric,mxGetField(dataref,0,"geometricalmetric"));552 549 FetchData(&bamgopts->KeepVertices,mxGetField(dataref,0,"KeepVertices")); 553 550 FetchData(&bamgopts->splitcorners,mxGetField(dataref,0,"splitcorners")); … … 999 996 mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){ 1000 997 1001 //output 1002 mxArray* mxfield=NULL; 1003 1004 //input 1005 mxArray *inputs[2]; 1006 mxArray *pindex = NULL; 1007 const char *fnames[2]; 1008 mwSize ndim = 2; 1009 mwSize onebyone[2] = {1,1}; 1010 1011 //We want to call the subsasgn method, and get the returned array.This ensures that if we are running 1012 //large sized problems, the data is truly loaded from disk by the model subsasgn class method. 1013 inputs[0]=(mxArray*)pmxa_array; //this is the model 1014 1015 //create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex) 1016 fnames[0] = "type"; 1017 fnames[1] = "subs"; 1018 pindex=mxCreateStructArray( ndim,onebyone,2,fnames); 1019 mxSetField( pindex, 0, "type",mxCreateString(".")); 1020 mxSetField( pindex, 0, "subs",mxCreateString(field)); 1021 inputs[1]=pindex; 1022 1023 mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref"); 998 /*Output*/ 999 mxArray *mxfield = NULL; 1000 1001 if(mxIsStruct(pmxa_array)){ 1002 mxfield = mxGetField(pmxa_array,number,field); 1003 } 1004 else{ 1005 /*This is an object, mxGetField returns NULL in old version of matlab (we do not have access to them)*/ 1006 1007 /*Intermediaries*/ 1008 mxArray *inputs[2]; 1009 mwSize ndim = 2; 1010 mwSize onebyone[2] = {1,1}; 1011 1012 /*create index structure used in the assignment (index.type='.' and index.subs='x' for field x*/ 1013 const char *fnames[2]; 1014 fnames[0] = "type"; fnames[1] = "subs"; 1015 mxArray* pindex=mxCreateStructArray( ndim,onebyone,2,fnames); 1016 mxSetField( pindex, 0, "type",mxCreateString(".")); 1017 mxSetField( pindex, 0, "subs",mxCreateString(field)); 1018 inputs[0]=(mxArray*)pmxa_array; //this is the model 1019 inputs[1]=pindex; 1020 1021 mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref"); 1022 } 1023 1024 if(mxfield == NULL) _error_("Could not find field "<< field <<" in structure"); 1024 1025 1025 1026 return mxfield; … … 1091 1092 1092 1093 return(ochar); 1093 }/*}}}*/1094 GenericOption<Options**>* OptionStructParse( char* name, const mxArray* prhs[]){ /*{{{*/1095 1096 int i;1097 char namei[161];1098 Option* option = NULL;1099 GenericOption<Options**> *ostruct = NULL;1100 const mwSize *ipt = NULL;1101 const mxArray *structi;1102 mwIndex sindex;1103 1104 /*check and parse the name */1105 ostruct=new GenericOption<Options**>();1106 ostruct->name =xNew<char>(strlen(name)+1);1107 memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));1108 1109 /*check and parse the value */1110 if (!mxIsClass(prhs[0],"struct")){1111 _error_("Value of option \"" << ostruct->name << "\" must be class \"struct\", not class \"" << mxGetClassName(prhs[0]) <<"\".");1112 }1113 ostruct->numel=mxGetNumberOfElements(prhs[0]);1114 ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);1115 ipt =mxGetDimensions(prhs[0]);1116 ostruct->size =xNew<int>(ostruct->ndims);1117 for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];1118 if (ostruct->numel) ostruct->value=xNew<Options*>(ostruct->numel);1119 1120 /*loop through and process each element of the struct array */1121 for (sindex=0; sindex<ostruct->numel; sindex++) {1122 ostruct->value[sindex]=new Options;1123 1124 /*loop through and process each field for the element */1125 for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {1126 sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));1127 structi=mxGetFieldByNumber(prhs[0],sindex,i);1128 1129 option=(Option*)OptionParse(namei,&structi);1130 ostruct->value[sindex]->AddObject((Object*)option);1131 option=NULL;1132 }1133 }1134 1135 return(ostruct);1136 }/*}}}*/1137 GenericOption<Options*>* OptionCellParse( char* name, const mxArray* prhs[]){ /*{{{*/1138 1139 int i;1140 int *dims;1141 char namei[161];1142 char cstr[81];1143 GenericOption<Options*> *ocell = NULL;1144 Option *option = NULL;1145 const mwSize *ipt = NULL;1146 const mxArray *celli;1147 mwIndex cindex;1148 1149 /*check and parse the name */1150 ocell=new GenericOption<Options*>();1151 ocell->name =xNew<char>(strlen(name)+1);1152 memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));1153 1154 /*check and parse the value */1155 if (!mxIsClass(prhs[0],"cell")){1156 _error_("Value of option \"" << ocell->name << "\" must be class \"cell\", not class \"" << mxGetClassName(prhs[0]) <<"\".");1157 }1158 1159 ocell->numel=mxGetNumberOfElements(prhs[0]);1160 ocell->ndims=mxGetNumberOfDimensions(prhs[0]);1161 ipt =mxGetDimensions(prhs[0]);1162 ocell->size =xNew<int>(ocell->ndims);1163 for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];1164 ocell->value=new Options;1165 1166 /*loop through and process each element of the cell array */1167 dims=xNew<int>(ocell->ndims);1168 for (cindex=0; cindex<ocell->numel; cindex++) {1169 ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);1170 StringFromDims(cstr,dims,ocell->ndims);1171 #ifdef _INTEL_WIN_1172 _snprintf(namei,161,"%s%s",name,cstr);1173 #else1174 snprintf(namei,161,"%s%s",name,cstr);1175 #endif1176 celli=mxGetCell(prhs[0],cindex);1177 1178 option=(Option*)OptionParse(namei,&celli);1179 ocell->value->AddObject((Object*)option);1180 option=NULL;1181 }1182 xDelete<int>(dims);1183 1184 return(ocell);1185 1094 }/*}}}*/ 1186 1095 Option* OptionParse(char* name, const mxArray* prhs[]){ /*{{{*/ … … 1198 1107 else if(mxIsClass(prhs[0],"char")) 1199 1108 option=(Option*)OptionCharParse(name,prhs); 1200 else if(mxIsClass(prhs[0],"struct"))1201 option=(Option*)OptionStructParse(name,prhs);1202 else if(mxIsClass(prhs[0],"cell"))1203 option=(Option*)OptionCellParse(name,prhs);1204 1109 else { 1205 _printf0_(" Converting value of option \"" << name << "\" from unrecognized class \"" << mxGetClassName(prhs[0]) << "\" to class \"" << "struct" << "\".\n"); 1206 if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) { 1207 option=(Option*)OptionStructParse(name,(const mxArray**)lhs); 1208 mxDestroyArray(lhs[0]); 1209 } 1210 else _error_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\"."); 1110 _error_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\"."); 1211 1111 } 1212 1112
Note:
See TracChangeset
for help on using the changeset viewer.