Changeset 5177
- Timestamp:
- 08/12/10 09:43:45 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp
r5154 r5177 20 20 21 21 /*Options*/ 22 BamgOpts bamgopts;22 BamgOpts* bamgopts=NULL; 23 23 24 24 // read mesh … … 28 28 //write mesh and geometry 29 29 if (verbose) printf("Write Geometry\n"); 30 Th.Gh.WriteGeometry(bamggeom, &bamgopts);30 Th.Gh.WriteGeometry(bamggeom,bamgopts); 31 31 if (verbose) printf("Write Mesh\n"); 32 Th.WriteMesh(bamgmesh,&bamgopts); 32 Th.WriteMesh(bamgmesh,bamgopts); 33 34 //clean up 35 delete bamgopts; 33 36 34 37 /*No error return*/ -
issm/trunk/src/c/objects/Bamg/BamgGeom.cpp
r5172 r5177 20 20 } 21 21 /*}}}*/ 22 /*FUNCTION BamgGeom::BamgGeom(mxArray* matlab_struct){{{1*/ 23 #ifdef _SERIAL_ 24 BamgGeom::BamgGeom(mxArray* matlab_struct){ 25 26 int lines,cols; 27 28 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetField(matlab_struct,0,"Vertices")); 29 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetField(matlab_struct,0,"Edges")); 30 FetchData(&this->hVertices,&lines,&cols,mxGetField(matlab_struct,0,"hVertices")); 31 this->MetricVertices=NULL; 32 this->TangentAtEdgesSize[0]=0, this->TangentAtEdgesSize[1]=0; this->TangentAtEdges=NULL; 33 FetchData(&this->Corners, &this->CornersSize[0], &this->CornersSize[1], mxGetField(matlab_struct,0,"Corners")); 34 FetchData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetField(matlab_struct,0,"RequiredVertices")); 35 FetchData(&this->RequiredEdges, &this->RequiredEdgesSize[0], &this->RequiredEdgesSize[1], mxGetField(matlab_struct,0,"RequiredEdges")); 36 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetField(matlab_struct,0,"CrackedEdges")); 37 FetchData(&this->SubDomains, &this->SubDomainsSize[0], &this->SubDomainsSize[1], mxGetField(matlab_struct,0,"SubDomains")); 38 39 /*Some checks*/ 40 if (this->hVertices && (cols!=1 || lines!=this->VerticesSize[0])){ISSMERROR("the size of 'hVertices' should be [%i %i]",this->VerticesSize[0],1);} 41 42 } 43 #endif 44 /*}}}*/ 22 45 /*FUNCTION BamgGeom::~BamgGeom(){{{1*/ 23 46 BamgGeom::~BamgGeom(){ … … 38 61 39 62 /*Methods*/ 40 /*FUNCTION BamgGeom::GetMatlabStructureFields{{{1*/41 #ifdef _SERIAL_42 void BamgGeom::GetMatlabStructureFields(mxArray* matlab_struct){43 44 int lines,cols;45 46 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetField(matlab_struct,0,"Vertices"));47 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetField(matlab_struct,0,"Edges"));48 FetchData(&this->Corners, &this->CornersSize[0], &this->CornersSize[1], mxGetField(matlab_struct,0,"Corners"));49 FetchData(&this->RequiredVertices,&this->RequiredVerticesSize[0],&this->RequiredVerticesSize[1],mxGetField(matlab_struct,0,"RequiredVertices"));50 FetchData(&this->RequiredEdges, &this->RequiredEdgesSize[0], &this->RequiredEdgesSize[1], mxGetField(matlab_struct,0,"RequiredEdges"));51 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetField(matlab_struct,0,"CrackedEdges"));52 FetchData(&this->SubDomains, &this->SubDomainsSize[0], &this->SubDomainsSize[1], mxGetField(matlab_struct,0,"SubDomains"));53 FetchData(&this->hVertices,&lines,&cols,mxGetField(matlab_struct,0,"hVertices"));54 if (this->hVertices && (cols!=1 || lines!=this->VerticesSize[0])){ISSMERROR("the size of 'hVertices' should be [%i %i]",this->VerticesSize[0],1);}55 56 }57 #endif58 /*}}}*/59 63 /*FUNCTION BamgGeom::SetMatlabStructureFields{{{1*/ 60 64 #ifdef _SERIAL_ … … 62 66 63 67 /*Intermediary*/ 64 int i,i1,i2; 65 mxArray* pfield=NULL; 66 mxArray* pfield2=NULL; 68 int i; 67 69 mxArray* output=NULL; 68 70 int numfields=7; 69 71 const char* fnames[numfields]; 70 int fsize[numfields][2];71 double** fpointer[numfields];72 72 mwSize ndim=2; 73 73 mwSize dimensions[2]={1,1}; 74 74 75 /* Build fnames and fsize names and sizes of each field*/76 i= -1;77 fnames[ ++i] = "Vertices"; fsize[i][0]=this->VerticesSize[0]; fsize[i][1]=this->VerticesSize[1]; fpointer[i]=&this->Vertices;78 fnames[ ++i] = "Edges"; fsize[i][0]=this->EdgesSize[0]; fsize[i][1]=this->EdgesSize[1]; fpointer[i]=&this->Edges;79 fnames[ ++i] = "TangentAtEdges"; fsize[i][0]=this->TangentAtEdgesSize[0]; fsize[i][1]=this->TangentAtEdgesSize[1]; fpointer[i]=&this->TangentAtEdges;80 fnames[ ++i] = "RequiredVertices";fsize[i][0]=this->RequiredVerticesSize[0];fsize[i][1]=this->RequiredVerticesSize[1];fpointer[i]=&this->RequiredVertices;81 fnames[ ++i] = "RequiredEdges"; fsize[i][0]=this->RequiredEdgesSize[0]; fsize[i][1]=this->RequiredEdgesSize[1]; fpointer[i]=&this->RequiredEdges;82 fnames[ ++i] = "CrackedEdges"; fsize[i][0]=this->CrackedEdgesSize[0]; fsize[i][1]=this->CrackedEdgesSize[1]; fpointer[i]=&this->CrackedEdges;83 fnames[ ++i] = "SubDomains"; fsize[i][0]=this->SubDomainsSize[0]; fsize[i][1]=this->SubDomainsSize[1]; fpointer[i]=&this->SubDomains;84 ISSMASSERT(i==numfields -1);75 /*Initialize field names*/ 76 i=0; 77 fnames[i++] = "Vertices"; 78 fnames[i++] = "Edges"; 79 fnames[i++] = "TangentAtEdges"; 80 fnames[i++] = "RequiredVertices"; 81 fnames[i++] = "RequiredEdges"; 82 fnames[i++] = "CrackedEdges"; 83 fnames[i++] = "SubDomains"; 84 ISSMASSERT(i==numfields); 85 85 86 86 /*Initialize Matlab structure*/ 87 87 output=mxCreateStructArray(ndim,dimensions,numfields,fnames); 88 88 89 /*Add every field tu structure*/ 90 for(i=0;i<numfields;i++){ 91 92 /*Copy field*/ 93 double* fieldcopy=NULL; 94 if (fsize[i][0]*fsize[i][1]){ 95 fieldcopy=(double*)xmalloc(fsize[i][0]*fsize[i][1]*sizeof(double)); 96 for(i1=0;i1<fsize[i][0];i1++){ 97 for(i2=0;i2<fsize[i][1];i2++){ 98 fieldcopy[fsize[i][1]*i1+i2]=*(*fpointer[i] + fsize[i][1]*i1+i2); 99 } 100 } 101 } 102 103 /*Set matlab field*/ 104 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 105 mxSetM(pfield,fsize[i][1]); 106 mxSetN(pfield,fsize[i][0]); 107 mxSetPr(pfield,fieldcopy); 108 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 109 mxSetField(output,0,fnames[i],pfield2); 110 } 89 /*set each matlab each field*/ 90 i=0; 91 i++; SetMatlabStructureField(output,"Vertices", this->VerticesSize[0], this->VerticesSize[1], this->Vertices); 92 i++; SetMatlabStructureField(output,"Edges", this->EdgesSize[0], this->EdgesSize[1], this->Edges); 93 i++; SetMatlabStructureField(output,"TangentAtEdges", this->TangentAtEdgesSize[0], this->TangentAtEdgesSize[1], this->TangentAtEdges); 94 i++; SetMatlabStructureField(output,"RequiredVertices",this->RequiredVerticesSize[0],this->RequiredVerticesSize[1],this->RequiredVertices); 95 i++; SetMatlabStructureField(output,"RequiredEdges", this->RequiredEdgesSize[0], this->RequiredEdgesSize[1], this->RequiredEdges); 96 i++; SetMatlabStructureField(output,"CrackedEdges", this->CrackedEdgesSize[0], this->CrackedEdgesSize[1], this->CrackedEdges); 97 i++; SetMatlabStructureField(output,"SubDomains", this->SubDomainsSize[0], this->SubDomainsSize[1], this->SubDomains); 98 ISSMASSERT(i==numfields); 111 99 112 100 /*Assign output*/ … … 116 104 #endif 117 105 /*}}}*/ 106 /*FUNCTION BamgGeom::SetMatlabStructureField{{{1*/ 107 #ifdef _SERIAL_ 108 void BamgGeom::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){ 109 110 /*Intermediary*/ 111 int i1,i2; 112 mxArray* pfield=NULL; 113 mxArray* pfield2=NULL; 114 115 /*Copy field*/ 116 double* fieldcopy=NULL; 117 if (fieldrows*fieldcols){ 118 fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double)); 119 for(i1=0;i1<fieldrows;i1++){ 120 for(i2=0;i2<fieldcols;i2++){ 121 fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2]; 122 } 123 } 124 } 125 126 /*Set matlab field*/ 127 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 128 mxSetM(pfield,fieldcols); 129 mxSetN(pfield,fieldrows); 130 mxSetPr(pfield,fieldcopy); 131 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 132 mxSetField(matlab_struct,0,fieldname,pfield2); 133 } 134 #endif 135 /*}}}*/ -
issm/trunk/src/c/objects/Bamg/BamgGeom.h
r5172 r5177 32 32 33 33 BamgGeom(); 34 #ifdef _SERIAL_ 35 BamgGeom(mxArray* matlab_struct); 36 #endif 34 37 ~BamgGeom(); 35 38 36 39 #ifdef _SERIAL_ 37 void GetMatlabStructureFields(mxArray* matlab_struct);38 40 void SetMatlabStructureFields(mxArray** matlab_struct); 41 void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer); 39 42 #endif 40 43 }; -
issm/trunk/src/c/objects/Bamg/BamgMesh.cpp
r5172 r5177 11 11 this->TrianglesSize[0]=0, this->TrianglesSize[1]=0; this->Triangles=NULL; 12 12 this->QuadrilateralsSize[0]=0, this->QuadrilateralsSize[1]=0; this->Quadrilaterals=NULL; 13 14 this->SubDomainsSize[0]=0, this->SubDomainsSize[1]=0; this->SubDomains=NULL; 15 this->SubDomainsFromGeomSize[0]=0, this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL; 16 this->CrackedVerticesSize[0]=0, this->CrackedVerticesSize[1]=0; this->CrackedVertices=NULL; 17 this->CrackedEdgesSize[0]=0, this->CrackedEdgesSize[1]=0; this->CrackedEdges=NULL; 18 13 19 this->VerticesOnGeometricVertexSize[0]=0, this->VerticesOnGeometricVertexSize[1]=0;this->VerticesOnGeometricVertex=NULL; 14 20 this->VerticesOnGeometricEdgeSize[0]=0, this->VerticesOnGeometricEdgeSize[1]=0; this->VerticesOnGeometricEdge=NULL; 15 21 this->EdgesOnGeometricEdgeSize[0]=0, this->EdgesOnGeometricEdgeSize[1]=0; this->EdgesOnGeometricEdge=NULL; 16 this->SubDomainsSize[0]=0, this->SubDomainsSize[1]=0; this->SubDomains=NULL; 17 this->SubDomainsFromGeomSize[0]=0, this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL; 22 18 23 this->hVertices=NULL; 24 19 25 this->IssmEdgesSize[0]=0, this->IssmEdgesSize[1]=0; this->IssmEdges=NULL; 20 26 this->IssmSegmentsSize[0]=0, this->IssmSegmentsSize[1]=0; this->IssmSegments=NULL; 27 21 28 this->ElementConnectivitySize[0]=0, this->ElementConnectivitySize[1]=0; this->ElementConnectivity=NULL; 22 29 this->NodalConnectivitySize[0]=0, this->NodalConnectivitySize[1]=0; this->NodalConnectivity=NULL; 23 30 this->NodalElementConnectivitySize[0]=0, this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL; 24 this->CrackedVerticesSize[0]=0, this->CrackedVerticesSize[1]=0; this->CrackedVertices=NULL; 25 this->CrackedEdgesSize[0]=0, this->CrackedEdgesSize[1]=0; this->CrackedEdges=NULL; 31 26 32 27 33 } 34 /*}}}*/ 35 /*FUNCTION BamgMesh::BamgMesh(mxArray* matlab_struct){{{1*/ 36 #ifdef _SERIAL_ 37 BamgMesh::BamgMesh(mxArray* matlab_struct){ 38 39 int lines,cols; 40 41 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetField(matlab_struct,0,"Vertices")); 42 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetField(matlab_struct,0,"Edges")); 43 FetchData(&this->Triangles, &this->TrianglesSize[0], &this->TrianglesSize[1], mxGetField(matlab_struct,0,"Triangles")); 44 this->QuadrilateralsSize[0]=0, this->QuadrilateralsSize[1]=0; this->Quadrilaterals=NULL; 45 46 this->SubDomainsSize[0]=0, this->SubDomainsSize[1]=0; this->SubDomains=NULL; 47 this->SubDomainsFromGeomSize[0]=0, this->SubDomainsFromGeomSize[1]=0; this->SubDomainsFromGeom=NULL; 48 this->CrackedVerticesSize[0]=0, this->CrackedVerticesSize[1]=0; this->CrackedVertices=NULL; 49 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetField(matlab_struct,0,"CrackedEdges")); 50 51 FetchData(&this->VerticesOnGeometricEdge, &this->VerticesOnGeometricEdgeSize[0], &this->VerticesOnGeometricEdgeSize[1], mxGetField(matlab_struct,0,"VerticesOnGeometricEdge")); 52 FetchData(&this->VerticesOnGeometricVertex,&this->VerticesOnGeometricVertexSize[0],&this->VerticesOnGeometricVertexSize[1],mxGetField(matlab_struct,0,"VerticesOnGeometricVertex")); 53 FetchData(&this->EdgesOnGeometricEdge, &this->EdgesOnGeometricEdgeSize[0], &this->EdgesOnGeometricEdgeSize[1], mxGetField(matlab_struct,0,"EdgesOnGeometricEdge")); 54 55 FetchData(&this->hVertices, &lines, &cols, mxGetField(matlab_struct,0,"hVertices")); 56 57 this->IssmEdgesSize[0]=0, this->IssmEdgesSize[1]=0; this->IssmEdges=NULL; 58 FetchData(&this->IssmSegments, &this->IssmSegmentsSize[0], &this->IssmSegmentsSize[1], mxGetField(matlab_struct,0,"IssmSegments")); 59 60 this->ElementConnectivitySize[0]=0, this->ElementConnectivitySize[1]=0; this->ElementConnectivity=NULL; 61 this->NodalConnectivitySize[0]=0, this->NodalConnectivitySize[1]=0; this->NodalConnectivity=NULL; 62 this->NodalElementConnectivitySize[0]=0, this->NodalElementConnectivitySize[1]=0; this->NodalElementConnectivity=NULL; 63 64 /*Checks*/ 65 if (this->hVertices && (cols!=1 || lines!=this->VerticesSize[0])){ISSMERROR("the size of 'hVertices' should be [%i %i]",this->VerticesSize[0],1);} 66 67 } 68 #endif 28 69 /*}}}*/ 29 70 /*FUNCTION BamgMesh::~BamgMesh(){{{1*/ … … 34 75 xfree((void**)&this->Triangles); 35 76 xfree((void**)&this->Quadrilaterals); 77 78 xfree((void**)&this->SubDomains); 79 xfree((void**)&this->SubDomainsFromGeom); 80 xfree((void**)&this->CrackedVertices); 81 xfree((void**)&this->CrackedEdges); 82 36 83 xfree((void**)&this->VerticesOnGeometricVertex); 37 84 xfree((void**)&this->VerticesOnGeometricEdge); 38 85 xfree((void**)&this->EdgesOnGeometricEdge); 39 xfree((void**)&this->SubDomains); 40 xfree((void**)&this->SubDomainsFromGeom); 86 41 87 xfree((void**)&this->hVertices); 88 42 89 xfree((void**)&this->IssmEdges); 43 90 xfree((void**)&this->IssmSegments); 91 44 92 xfree((void**)&this->ElementConnectivity); 45 93 xfree((void**)&this->NodalConnectivity); 46 94 xfree((void**)&this->NodalElementConnectivity); 47 xfree((void**)&this->CrackedVertices); 48 xfree((void**)&this->CrackedEdges); 95 49 96 50 97 } … … 52 99 53 100 /*Methods*/ 54 /*FUNCTION BamgMesh::GetMatlabStructureFields{{{1*/55 #ifdef _SERIAL_56 void BamgMesh::GetMatlabStructureFields(mxArray* matlab_struct){57 58 int lines,cols;59 60 FetchData(&this->Triangles, &this->TrianglesSize[0], &this->TrianglesSize[1], mxGetField(matlab_struct,0,"Triangles"));61 FetchData(&this->Vertices, &this->VerticesSize[0], &this->VerticesSize[1], mxGetField(matlab_struct,0,"Vertices"));62 FetchData(&this->Edges, &this->EdgesSize[0], &this->EdgesSize[1], mxGetField(matlab_struct,0,"Edges"));63 FetchData(&this->IssmSegments, &this->IssmSegmentsSize[0], &this->IssmSegmentsSize[1], mxGetField(matlab_struct,0,"IssmSegments"));64 FetchData(&this->CrackedEdges, &this->CrackedEdgesSize[0], &this->CrackedEdgesSize[1], mxGetField(matlab_struct,0,"CrackedEdges"));65 FetchData(&this->EdgesOnGeometricEdge, &this->EdgesOnGeometricEdgeSize[0], &this->EdgesOnGeometricEdgeSize[1], mxGetField(matlab_struct,0,"EdgesOnGeometricEdge"));66 FetchData(&this->VerticesOnGeometricEdge, &this->VerticesOnGeometricEdgeSize[0], &this->VerticesOnGeometricEdgeSize[1], mxGetField(matlab_struct,0,"VerticesOnGeometricEdge"));67 FetchData(&this->VerticesOnGeometricVertex,&this->VerticesOnGeometricVertexSize[0],&this->VerticesOnGeometricVertexSize[1],mxGetField(matlab_struct,0,"VerticesOnGeometricVertex"));68 FetchData(&this->hVertices, &lines, &cols, mxGetField(matlab_struct,0,"hVertices"));69 if (this->hVertices && (cols!=1 || lines!=this->VerticesSize[0])){ISSMERROR("the size of 'hVertices' should be [%i %i]",this->VerticesSize[0],1);}70 71 }72 #endif73 /*}}}*/74 101 /*FUNCTION BamgMesh::SetMatlabStructureFields{{{1*/ 75 102 #ifdef _SERIAL_ … … 77 104 78 105 /*Intermediary*/ 79 int i,i1,i2; 80 mxArray* pfield=NULL; 81 mxArray* pfield2=NULL; 106 int i; 82 107 mxArray* output=NULL; 83 108 int numfields=16; 84 109 const char* fnames[numfields]; 85 int fsize[numfields][2];86 double** fpointer[numfields];87 110 mwSize ndim=2; 88 111 mwSize dimensions[2]={1,1}; 89 112 90 /* Build fnames and fsize names and sizes of each field*/91 i= -1;92 fnames[ ++i] = "Triangles"; fsize[i][0]=this->TrianglesSize[0]; fsize[i][1]=this->TrianglesSize[1]; fpointer[i]=&this->Triangles;93 fnames[ ++i] = "Vertices"; fsize[i][0]=this->VerticesSize[0]; fsize[i][1]=this->VerticesSize[1]; fpointer[i]=&this->Vertices;94 fnames[ ++i] = "Edges"; fsize[i][0]=this->EdgesSize[0]; fsize[i][1]=this->EdgesSize[1]; fpointer[i]=&this->Edges;95 fnames[ ++i] = "IssmSegments"; fsize[i][0]=this->IssmSegmentsSize[0]; fsize[i][1]=this->IssmSegmentsSize[1]; fpointer[i]=&this->IssmSegments;96 fnames[ ++i] = "IssmEdges"; fsize[i][0]=this->IssmEdgesSize[0]; fsize[i][1]=this->IssmEdgesSize[1]; fpointer[i]=&this->IssmEdges;97 fnames[ ++i] = "Quadrilaterals"; fsize[i][0]=this->QuadrilateralsSize[0]; fsize[i][1]=this->QuadrilateralsSize[1]; fpointer[i]=&this->Quadrilaterals;98 fnames[ ++i] = "VerticesOnGeometricVertex";fsize[i][0]=this->VerticesOnGeometricVertexSize[0]; fsize[i][1]=this->VerticesOnGeometricVertexSize[1];fpointer[i]=&this->VerticesOnGeometricVertex;99 fnames[ ++i] = "VerticesOnGeometricEdge"; fsize[i][0]=this->VerticesOnGeometricEdgeSize[0]; fsize[i][1]=this->VerticesOnGeometricEdgeSize[1]; fpointer[i]=&this->VerticesOnGeometricEdge;100 fnames[ ++i] = "EdgesOnGeometricEdge"; fsize[i][0]=this->EdgesOnGeometricEdgeSize[0]; fsize[i][1]=this->EdgesOnGeometricEdgeSize[1]; fpointer[i]=&this->EdgesOnGeometricEdge;101 fnames[ ++i] = "SubDomains"; fsize[i][0]=this->SubDomainsSize[0]; fsize[i][1]=this->SubDomainsSize[1]; fpointer[i]=&this->SubDomains;102 fnames[ ++i] = "SubDomainsFromGeom"; fsize[i][0]=this->SubDomainsFromGeomSize[0]; fsize[i][1]=this->SubDomainsFromGeomSize[1]; fpointer[i]=&this->SubDomainsFromGeom;103 fnames[ ++i] = "ElementConnectivity"; fsize[i][0]=this->ElementConnectivitySize[0]; fsize[i][1]=this->ElementConnectivitySize[1]; fpointer[i]=&this->ElementConnectivity;104 fnames[ ++i] = "NodalConnectivity"; fsize[i][0]=this->NodalConnectivitySize[0]; fsize[i][1]=this->NodalConnectivitySize[1]; fpointer[i]=&this->NodalConnectivity;105 fnames[ ++i] = "NodalElementConnectivity"; fsize[i][0]=this->NodalElementConnectivitySize[0]; fsize[i][1]=this->NodalElementConnectivitySize[1]; fpointer[i]=&this->NodalElementConnectivity;106 fnames[ ++i] = "CrackedVertices"; fsize[i][0]=this->CrackedVerticesSize[0]; fsize[i][1]=this->CrackedVerticesSize[1]; fpointer[i]=&this->CrackedVertices;107 fnames[ ++i] = "CrackedEdges"; fsize[i][0]=this->CrackedEdgesSize[0]; fsize[i][1]=this->CrackedEdgesSize[1]; fpointer[i]=&this->CrackedEdges;108 ISSMASSERT(i==numfields -1);113 /*Initialize field names*/ 114 i=0; 115 fnames[i++] = "Triangles"; 116 fnames[i++] = "Vertices"; 117 fnames[i++] = "Edges"; 118 fnames[i++] = "IssmSegments"; 119 fnames[i++] = "IssmEdges"; 120 fnames[i++] = "Quadrilaterals"; 121 fnames[i++] = "VerticesOnGeometricVertex"; 122 fnames[i++] = "VerticesOnGeometricEdge"; 123 fnames[i++] = "EdgesOnGeometricEdge"; 124 fnames[i++] = "SubDomains"; 125 fnames[i++] = "SubDomainsFromGeom"; 126 fnames[i++] = "ElementConnectivity"; 127 fnames[i++] = "NodalConnectivity"; 128 fnames[i++] = "NodalElementConnectivity"; 129 fnames[i++] = "CrackedVertices"; 130 fnames[i++] = "CrackedEdges"; 131 ISSMASSERT(i==numfields); 109 132 110 133 /*Initialize Matlab structure*/ 111 134 output=mxCreateStructArray(ndim,dimensions,numfields,fnames); 112 135 113 /*Add every field tu structure*/ 114 for(i=0;i<numfields;i++){ 115 116 /*Copy field*/ 117 double* fieldcopy=NULL; 118 if (fsize[i][0]*fsize[i][1]){ 119 fieldcopy=(double*)xmalloc(fsize[i][0]*fsize[i][1]*sizeof(double)); 120 for(i1=0;i1<fsize[i][0];i1++){ 121 for(i2=0;i2<fsize[i][1];i2++){ 122 fieldcopy[fsize[i][1]*i1+i2]=*(*fpointer[i] + fsize[i][1]*i1+i2); 123 } 124 } 125 } 126 127 /*Set matlab field*/ 128 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 129 mxSetM(pfield,fsize[i][1]); 130 mxSetN(pfield,fsize[i][0]); 131 mxSetPr(pfield,fieldcopy); 132 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 133 mxSetField(output,0,fnames[i],pfield2); 134 } 136 /*set each matlab each field*/ 137 i=0; 138 i++; SetMatlabStructureField(output,"Triangles", this->TrianglesSize[0], this->TrianglesSize[1], this->Triangles); 139 i++; SetMatlabStructureField(output,"Vertices", this->VerticesSize[0], this->VerticesSize[1], this->Vertices); 140 i++; SetMatlabStructureField(output,"Edges", this->EdgesSize[0], this->EdgesSize[1], this->Edges); 141 i++; SetMatlabStructureField(output,"IssmSegments", this->IssmSegmentsSize[0], this->IssmSegmentsSize[1], this->IssmSegments); 142 i++; SetMatlabStructureField(output,"IssmEdges", this->IssmEdgesSize[0], this->IssmEdgesSize[1], this->IssmEdges); 143 i++; SetMatlabStructureField(output,"Quadrilaterals", this->QuadrilateralsSize[0], this->QuadrilateralsSize[1], this->Quadrilaterals); 144 i++; SetMatlabStructureField(output,"VerticesOnGeometricVertex",this->VerticesOnGeometricVertexSize[0],this->VerticesOnGeometricVertexSize[1], this->VerticesOnGeometricVertex); 145 i++; SetMatlabStructureField(output,"VerticesOnGeometricEdge", this->VerticesOnGeometricEdgeSize[0], this->VerticesOnGeometricEdgeSize[1], this->VerticesOnGeometricEdge); 146 i++; SetMatlabStructureField(output,"EdgesOnGeometricEdge", this->EdgesOnGeometricEdgeSize[0], this->EdgesOnGeometricEdgeSize[1], this->EdgesOnGeometricEdge); 147 i++; SetMatlabStructureField(output,"SubDomains", this->SubDomainsSize[0], this->SubDomainsSize[1], this->SubDomains); 148 i++; SetMatlabStructureField(output,"SubDomainsFromGeom", this->SubDomainsFromGeomSize[0], this->SubDomainsFromGeomSize[1], this->SubDomainsFromGeom); 149 i++; SetMatlabStructureField(output,"ElementConnectivity", this->ElementConnectivitySize[0], this->ElementConnectivitySize[1], this->ElementConnectivity); 150 i++; SetMatlabStructureField(output,"NodalConnectivity", this->NodalConnectivitySize[0], this->NodalConnectivitySize[1], this->NodalConnectivity); 151 i++; SetMatlabStructureField(output,"NodalElementConnectivity", this->NodalElementConnectivitySize[0], this->NodalElementConnectivitySize[1], this->NodalElementConnectivity); 152 i++; SetMatlabStructureField(output,"CrackedVertices", this->CrackedVerticesSize[0], this->CrackedVerticesSize[1], this->CrackedVertices); 153 i++; SetMatlabStructureField(output,"CrackedEdges", this->CrackedEdgesSize[0], this->CrackedEdgesSize[1], this->CrackedEdges); 154 ISSMASSERT(i==numfields); 135 155 136 156 /*Assign output*/ … … 140 160 #endif 141 161 /*}}}*/ 162 /*FUNCTION BamgMesh::SetMatlabStructureField{{{1*/ 163 #ifdef _SERIAL_ 164 void BamgMesh::SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer){ 165 166 /*Intermediary*/ 167 int i1,i2; 168 mxArray* pfield=NULL; 169 mxArray* pfield2=NULL; 170 171 /*Copy field*/ 172 double* fieldcopy=NULL; 173 if (fieldrows*fieldcols){ 174 fieldcopy=(double*)xmalloc(fieldrows*fieldcols*sizeof(double)); 175 for(i1=0;i1<fieldrows;i1++){ 176 for(i2=0;i2<fieldcols;i2++){ 177 fieldcopy[fieldcols*i1+i2]=fieldpointer[fieldcols*i1+i2]; 178 } 179 } 180 } 181 182 /*Set matlab field*/ 183 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 184 mxSetM(pfield,fieldcols); 185 mxSetN(pfield,fieldrows); 186 mxSetPr(pfield,fieldcopy); 187 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 188 mxSetField(matlab_struct,0,fieldname,pfield2); 189 } 190 #endif 191 /*}}}*/ -
issm/trunk/src/c/objects/Bamg/BamgMesh.h
r5172 r5177 21 21 int QuadrilateralsSize[2]; 22 22 double* Quadrilaterals; 23 23 24 int VerticesOnGeometricVertexSize[2]; 24 25 double* VerticesOnGeometricVertex; … … 27 28 int EdgesOnGeometricEdgeSize[2]; 28 29 double* EdgesOnGeometricEdge; 30 29 31 int SubDomainsSize[2]; 30 32 double* SubDomains; … … 35 37 int CrackedEdgesSize[2]; 36 38 double* CrackedEdges; 39 37 40 double* hVertices; 38 41 … … 50 53 51 54 BamgMesh(); 55 #ifdef _SERIAL_ 56 BamgMesh(mxArray* matlab_struct); 57 #endif 52 58 ~BamgMesh(); 53 59 54 60 #ifdef _SERIAL_ 55 void GetMatlabStructureFields(mxArray* matlab_struct);56 61 void SetMatlabStructureFields(mxArray** matlab_struct); 62 void SetMatlabStructureField(mxArray* matlab_struct,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer); 57 63 #endif 58 64 -
issm/trunk/src/c/objects/Bamg/BamgOpts.cpp
r5154 r5177 3 3 #include "../../include/include.h" 4 4 #include "../objects.h" 5 #include "../../io/io.h" 5 6 6 7 /*Constructors/Destructors*/ … … 8 9 BamgOpts::BamgOpts(){ 9 10 10 this->iso=0;11 11 this->maxnbv=0; 12 12 this->MaxCornerAngle=0; 13 this->Crack=0; 13 14 this->Hessiantype=0; 14 15 this->Metrictype=0; 15 16 this->KeepVertices=0; 16 this->Crack=0;17 17 this->maxsubdiv=0; 18 18 this->power=0; … … 38 38 39 39 } 40 /*}}}*/ 41 /*FUNCTION BamgOpts::BamgOpts(mxArray* matlab_struct){{{1*/ 42 #ifdef _SERIAL_ 43 BamgOpts::BamgOpts(mxArray* matlab_struct){ 44 45 int lines,cols; 46 47 FetchData(&this->maxnbv,mxGetField(matlab_struct,0,"maxnbv")); 48 FetchData(&this->MaxCornerAngle,mxGetField(matlab_struct,0,"MaxCornerAngle")); 49 FetchData(&this->Crack,mxGetField(matlab_struct,0,"Crack")); 50 FetchData(&this->Hessiantype,mxGetField(matlab_struct,0,"Hessiantype")); 51 FetchData(&this->Metrictype,mxGetField(matlab_struct,0,"Metrictype")); 52 FetchData(&this->KeepVertices,mxGetField(matlab_struct,0,"KeepVertices")); 53 FetchData(&this->maxsubdiv,mxGetField(matlab_struct,0,"maxsubdiv")); 54 FetchData(&this->power,mxGetField(matlab_struct,0,"power")); 55 FetchData(&this->anisomax,mxGetField(matlab_struct,0,"anisomax")); 56 FetchData(&this->nbsmooth,mxGetField(matlab_struct,0,"nbsmooth")); 57 FetchData(&this->nbjacobi,mxGetField(matlab_struct,0,"nbjacobi")); 58 FetchData(&this->omega,mxGetField(matlab_struct,0,"omega")); 59 FetchData(&this->hmin,mxGetField(matlab_struct,0,"hmin")); 60 FetchData(&this->hmax,mxGetField(matlab_struct,0,"hmax")); 61 FetchData(&this->hminVertices,&lines,&cols,mxGetField(matlab_struct,0,"hminVertices")); 62 FetchData(&this->hmaxVertices,&lines,&cols,mxGetField(matlab_struct,0,"hmaxVertices")); 63 FetchData(&this->gradation,mxGetField(matlab_struct,0,"gradation")); 64 FetchData(&this->cutoff,mxGetField(matlab_struct,0,"cutoff")); 65 FetchData(&this->splitcorners,mxGetField(matlab_struct,0,"splitcorners")); 66 FetchData(&this->geometricalmetric,mxGetField(matlab_struct,0,"geometricalmetric")); 67 FetchData(&this->verbose,mxGetField(matlab_struct,0,"verbose")); 68 FetchData(&this->field,&lines,&this->numfields,mxGetField(matlab_struct,0,"field")); 69 FetchData(&this->err,NULL,&cols,mxGetField(matlab_struct,0,"err")); 70 if (this->numfields!=0 && cols!=this->numfields){ISSMERROR("the size of 'err' should be the same as 'field'");} 71 FetchData(&this->errg,mxGetField(matlab_struct,0,"errg")); 72 FetchData(&this->coeff,mxGetField(matlab_struct,0,"coeff")); 73 FetchData(&this->metric,&lines,&cols,mxGetField(matlab_struct,0,"metric")); 74 75 /*Additional checks*/ 76 this->Check(); 77 78 } 79 #endif 40 80 /*}}}*/ 41 81 /*FUNCTION BamgOpts::~BamgOpts() {{{1*/ -
issm/trunk/src/c/objects/Bamg/BamgOpts.h
r5154 r5177 6 6 #define _BAMGOPTS_H_ 7 7 8 #ifdef _SERIAL_ 9 #include <mex.h> 10 #endif 11 8 12 class BamgOpts{ 9 13 10 14 public: 11 15 12 int iso;13 16 int maxnbv; 14 17 double MaxCornerAngle; … … 40 43 41 44 BamgOpts(); 45 #ifdef _SERIAL_ 46 BamgOpts(mxArray* matlab_struct); 47 #endif 42 48 ~BamgOpts(); 43 49 -
issm/trunk/src/c/objects/Bamg/Geometry.cpp
r5154 r5177 111 111 * where D is the longest side of the domain (direction x or y) 112 112 * so that (x-pmin.x)/D is in ]0 1[ 113 * 114 * coefIcoor = (2^30 -1)/D 113 115 */ 114 116 coefIcoor=(MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y)); … … 398 400 399 401 /*Methods*/ 400 /*FUNCTION Geometry::AfterRead (){{{1*/402 /*FUNCTION Geometry::AfterRead{{{1*/ 401 403 void Geometry::AfterRead(){ 402 404 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/ 403 405 404 long int verbose=0; 405 406 long i,j,k; 407 int jj; 408 long* head_v=new long[nbv]; 409 long* next_p=new long[2*nbe]; 410 float* eangle=new float[nbe]; 411 double eps=1e-20; 412 QuadTree quadtree; // build quadtree to find duplicates 413 BamgVertex* v0=vertices; 414 GeometricalVertex* v0g=(GeometricalVertex*) (void*)v0; 406 long i,j,k; 407 int jj; 408 long *head_v = new long[nbv]; 409 long *next_p = new long[2*nbe]; 410 float *eangle = new float[nbe]; 411 double eps = 1e-20; 412 QuadTree quadtree; // build quadtree to find duplicates 413 BamgVertex *v0 = vertices; 414 GeometricalVertex *v0g = (GeometricalVertex*) (void*)v0; 415 415 416 416 k=0; … … 424 424 All the coordinates are transformed to ]0,1[^2 425 425 then, the integer coordinates are computed using 426 the transformation ]0,1[^2 -> [0 2^ (30-1)[^2 for a quadtree of depth 30*/426 the transformation ]0,1[^2 -> [0 2^30-1[^2 for a quadtree of depth 30*/ 427 427 vertices[i].i=toI2(vertices[i].r); 428 428 429 / /find nearest vertex already present in the quadtree (NULL if empty)429 /*find nearest vertex already present in the quadtree (NULL if empty)*/ 430 430 BamgVertex* v=quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); 431 431 432 / /if there is a vertex found that is to close to vertices[i] -> error433 if( v && Norme1(v->r - vertices[i] ) < eps ){434 printf("WARNING: two points of the geometry are very closed to each other\n");435 } 436 437 / /Add vertices[i] to the quadtree432 /*if there is a vertex found that is to close to vertices[i] -> error*/ 433 if( v && Norme1(v->r - vertices[i].r) < eps ){ 434 ISSMERROR("two points of the geometry are very closed to each other"); 435 } 436 437 /*Add vertices[i] to the quadtree*/ 438 438 quadtree.Add(vertices[i]); 439 }440 441 //if k>0, there are some duplicate vertices -> error442 if (k) {443 printf("number of distinct vertices= %i, over %i\n",nbv - k,nbv);444 printf("List of duplicate vertices:\n");445 ISSMERROR("See above");446 439 } 447 440 … … 767 760 nbv=0; 768 761 nbe=0; 769 quadtree= 0;770 curves= 0;771 edges= 0;772 vertices= 0;762 quadtree=NULL; 763 curves=NULL; 764 edges=NULL; 765 vertices=NULL; 773 766 nbsubdomains=0; 774 767 nbcurves=0; 775 subdomains= 0;768 subdomains=NULL; 776 769 MaxCornerAngle = 10*Pi/180; //default is 10 degres 777 770 } … … 941 934 /*FUNCTION Geometry::toI2{{{1*/ 942 935 I2 Geometry::toI2(const R2 & P) const { 943 return I2( (Icoor1) (coefIcoor*(P.x-pmin.x)) 944 ,(Icoor1) (coefIcoor*(P.y-pmin.y)) ); 936 /*coefIcoor is the coefficient used for integer coordinates: 937 * (x-pmin.x) 938 * Icoor x = (2^30 -1) ------------ 939 * D 940 * where D is the longest side of the domain (direction x or y) 941 * so that (x-pmin.x)/D is in ]0 1[ 942 * 943 * coefIcoor = (2^30 -1)/D 944 */ 945 return I2( (Icoor1) (coefIcoor*(P.x-pmin.x)) ,(Icoor1) (coefIcoor*(P.y-pmin.y)) ); 945 946 }/*}}}*/ 946 947 /*FUNCTION Geometry::UnMarkEdges{{{1*/ -
issm/trunk/src/c/objects/Bamg/QuadTree.cpp
r5150 r5177 72 72 73 73 /*Constructors/Destructors*/ 74 /*FUNCTION QuadTree::QuadTree(){{{1*/ 75 QuadTree::QuadTree() : 76 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/QuadTree)*/ 77 78 lenStorageQuadTreeBox(100), // by default 100 vertices by box 79 th(NULL), // initial mesh = NULL 80 NbQuadTreeBox(0), // initial number of quadtree boxes = 0 81 NbVertices(0), // initial number of vertices = 0 82 NbQuadTreeBoxSearch(0), // initial ?? = 0 83 NbVerticesSearch(0){ // initial ?? = 0 84 85 //create lenStorageQuadTreeBox (100) StorageQuadTreeBox elements 86 sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); 87 88 //root=QuadTreeBox* pointer toward next quadtree box 89 root=NewQuadTreeBox(); 90 91 } 92 /*}}}1*/ 74 93 /*FUNCTION QuadTree::QuadTree(Mesh * t,long nbv){{{1*/ 75 94 QuadTree::QuadTree(Mesh * t,long nbv) : … … 84 103 { 85 104 if (nbv == -1) nbv = t->nbv; 86 sb =new StorageQuadTreeBox(lenStorageQuadTreeBox);105 sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); 87 106 root=NewQuadTreeBox(); 88 107 if ( MaxISize <= MaxICoor){ … … 93 112 } 94 113 /*}}}1*/ 95 /*FUNCTION QuadTree::QuadTree(){{{1*/96 QuadTree::QuadTree() :97 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/QuadTree)*/98 99 lenStorageQuadTreeBox(100), // by default 100 vertices by box100 th(0), // initial mesh = NULL101 NbQuadTreeBox(0), // initial number of quadtree boxes = 0102 NbVertices(0), // initial number of vertices = 0103 NbQuadTreeBoxSearch(0), // initial ?? = 0104 NbVerticesSearch(0){ // initial ?? = 0105 //create lenStorageQuadTreeBox (100) StorageQuadTreeBox elements106 sb =new StorageQuadTreeBox(lenStorageQuadTreeBox);107 //root=QuadTreeBox* pointer roward ??108 root=NewQuadTreeBox();109 }110 /*}}}1*/111 114 /*FUNCTION QuadTree::~QuadTree(){{{1*/ 112 115 QuadTree::~QuadTree() { … … 115 118 delete sb; 116 119 root=0; 120 } 121 /*}}}1*/ 122 /*FUNCTION QuadTree::StorageQuadTreeBox::StorageQuadTreeBox{{{1*/ 123 QuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll,StorageQuadTreeBox *nn) { 124 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/StorageQuadTreeBox)*/ 125 126 /*Initilalize variables*/ 127 len = ll; // number of quadtree boxes 128 n = nn; // next StorageQuadTreeBox pointer 129 b = new QuadTreeBox[ll]; // quadtree boxes 130 ISSMASSERT(b); // check allocation 131 132 /*Initialize all quadtree boxes (empty)*/ 133 for (int i = 0; i <ll;i++){ 134 b[i].n=0; 135 b[i].b[0]=b[i].b[1]=b[i].b[2]=b[i].b[3]=NULL; 136 } 137 138 bc = b; //first quadtree box 139 be = b + ll; //last quadtree box 140 117 141 } 118 142 /*}}}1*/ … … 123 147 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/Add)*/ 124 148 125 QuadTreeBox** pb; 126 QuadTreeBox* b; 149 QuadTreeBox** pb=NULL; 150 QuadTreeBox* b=NULL; 151 152 /*Get integer coodinate of current point w*/ 127 153 register long i=w.i.x, j=w.i.y; 154 155 /*Initialize level*/ 128 156 register long level=MaxISize; 129 157 130 / /Get inital box (the largest)158 /*Get inital box (the largest)*/ 131 159 pb = &root; 132 160 … … 460 488 } 461 489 /*}}}1*/ 462 /*FUNCTION QuadTree::StorageQuadTreeBox::StorageQuadTreeBox{{{1*/463 QuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll,StorageQuadTreeBox *nn) {464 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, QuadTree.cpp/StorageQuadTreeBox)*/465 466 len = ll;467 n = nn;468 b = new QuadTreeBox[ll];469 for (int i = 0; i <ll;i++)470 b[i].n =0,b[i].b[0]=b[i].b[1]=b[i].b[2]=b[i].b[3]=0;471 bc =b;472 be = b +ll;473 if (!b){474 ISSMERROR("!b");475 }476 }477 /*}}}1*/478 490 /*FUNCTION QuadTree::ToClose {{{1*/ 479 491 BamgVertex* QuadTree::ToClose(BamgVertex & v,double seuil,Icoor1 hx,Icoor1 hy){ -
issm/trunk/src/c/objects/Bamg/QuadTree.h
r5150 r5177 7 7 namespace bamg { 8 8 9 const int MaxDeep = 30;10 const long MaxISize = ( 1L << MaxDeep); 9 const int MaxDeep = 30; 10 const long MaxISize = ( 1L << MaxDeep); // = 2^30 : 010000000000..000 (bitwise operation) 11 11 12 12 class Mesh; … … 18 18 19 19 class QuadTreeBox{ 20 /*A quadtree box contains a maximum of 4 vertices. 4 other quadtree boxes are 21 * created if a fifth vertex is added to the same box. A Quadtree box is therefore 22 * composed of EITHER: 23 * - up to 4 vertices 24 * - 4 "sub" quadtree boxes*/ 25 20 26 public: 21 long n; 22 //contains only one object form the list (either BamgVertex or QuadTreeBox)23 // if n < 4 => BamgVertex else => QuadTreeBox; 27 28 int n; // number of current vertices in the box 29 24 30 union{ 25 31 QuadTreeBox* b[4]; 26 BamgVertex* v[4];32 BamgVertex* v[4]; 27 33 }; 28 34 }; 35 29 36 class StorageQuadTreeBox{ 37 30 38 public: 39 40 /*Fields*/ 31 41 QuadTreeBox *b,*bc,*be; 32 42 long len; 33 43 StorageQuadTreeBox* n; // next StorageQuadTreeBox 44 45 /*Methods*/ 34 46 StorageQuadTreeBox(long ,StorageQuadTreeBox* =NULL); 35 47 ~StorageQuadTreeBox() { … … 39 51 long SizeOf() const {return len*sizeof(QuadTreeBox)+sizeof(StorageQuadTreeBox)+ (n?n->SizeOf():0);} 40 52 }; 53 54 /*QuadTree private Fields*/ 41 55 StorageQuadTreeBox* sb; 42 56 long lenStorageQuadTreeBox; … … 44 58 public: 45 59 46 / /fields60 /*QuadTree public Fields*/ 47 61 QuadTreeBox* root; 48 Mesh* th; 62 Mesh* th; 63 long NbQuadTreeBox,NbVertices; 64 long NbQuadTreeBoxSearch,NbVerticesSearch; 49 65 50 //functions51 ~QuadTree();52 66 QuadTree(Mesh *t,long nbv=-1); 53 67 QuadTree(); 54 long NbQuadTreeBox,NbVertices; 55 long NbQuadTreeBoxSearch,NbVerticesSearch; 68 ~QuadTree(); 56 69 BamgVertex* NearestVertex(Icoor1 i,Icoor1 j); 57 70 BamgVertex* NearestVertexWithNormal(Icoor1 i,Icoor1 j); … … 63 76 * a private class and is declared before QuadTree::*/ 64 77 QuadTreeBox* NewQuadTreeBox(void){ 65 if(! (sb->bc<sb->be)) sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb); 66 if (!sb || (sb->bc->n != 0)){ISSMERROR("!sb || (sb->bc->n != 0)");} 78 79 /*if bc==be or bc>be (we have reach the end of the StorageQuadTreeBox) 80 * create a new StorageQuadTreeBox)*/ 81 if(!(sb->bc<sb->be)){ 82 sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb); 83 } 84 ISSMASSERT(sb && sb->bc->n==0); 85 86 /*Increase counter*/ 67 87 NbQuadTreeBox++; 88 89 /*bc now points toward next quadtree box*/ 68 90 return sb->bc++; 91 69 92 } 70 93 }; -
issm/trunk/src/mex/Bamg/Bamg.cpp
r5172 r5177 11 11 12 12 /*diverse: */ 13 int i;14 int lines,cols;15 13 BamgOpts *bamgopts=NULL; 16 14 BamgMesh *bamgmesh_in=NULL; … … 26 24 27 25 /*Initialize variables*/ 28 bamgopts=new BamgOpts; 29 bamggeom_in=new BamgGeom; 30 bamgmesh_in=new BamgMesh; 31 bamggeom_out=new BamgGeom; 32 bamgmesh_out=new BamgMesh; 26 bamgopts = new BamgOpts(BAMGOPTIONS); 27 bamggeom_in= new BamgGeom(BAMGGEOMETRY); 28 bamgmesh_in= new BamgMesh(BAMGMESH); 33 29 34 /*Build objects from matlab structures*/ 35 bamggeom_in->GetMatlabStructureFields(BAMGGEOMETRY); 36 bamgmesh_in->GetMatlabStructureFields(BAMGMESH); 37 38 /*create bamg options input*/ 39 FetchData(&bamgopts->coeff,mxGetField(BAMGOPTIONS,0,"coeff")); 40 FetchData(&bamgopts->maxsubdiv,mxGetField(BAMGOPTIONS,0,"maxsubdiv")); 41 FetchData(&bamgopts->Crack,mxGetField(BAMGOPTIONS,0,"Crack")); 42 FetchData(&bamgopts->Hessiantype,mxGetField(BAMGOPTIONS,0,"Hessiantype")); 43 FetchData(&bamgopts->Metrictype,mxGetField(BAMGOPTIONS,0,"Metrictype")); 44 FetchData(&bamgopts->KeepVertices,mxGetField(BAMGOPTIONS,0,"KeepVertices")); 45 FetchData(&bamgopts->power,mxGetField(BAMGOPTIONS,0,"power")); 46 FetchData(&bamgopts->errg,mxGetField(BAMGOPTIONS,0,"errg")); 47 FetchData(&bamgopts->nbjacobi,mxGetField(BAMGOPTIONS,0,"nbjacobi")); 48 FetchData(&bamgopts->nbsmooth,mxGetField(BAMGOPTIONS,0,"nbsmooth")); 49 FetchData(&bamgopts->omega,mxGetField(BAMGOPTIONS,0,"omega")); 50 FetchData(&bamgopts->maxnbv,mxGetField(BAMGOPTIONS,0,"maxnbv")); 51 FetchData(&bamgopts->hmin,mxGetField(BAMGOPTIONS,0,"hmin")); 52 FetchData(&bamgopts->hmax,mxGetField(BAMGOPTIONS,0,"hmax")); 53 FetchData(&bamgopts->anisomax,mxGetField(BAMGOPTIONS,0,"anisomax")); 54 FetchData(&bamgopts->gradation,mxGetField(BAMGOPTIONS,0,"gradation")); 55 FetchData(&bamgopts->cutoff,mxGetField(BAMGOPTIONS,0,"cutoff")); 56 FetchData(&bamgopts->verbose,mxGetField(BAMGOPTIONS,0,"verbose")); 57 FetchData(&bamgopts->splitcorners,mxGetField(BAMGOPTIONS,0,"splitcorners")); 58 FetchData(&bamgopts->geometricalmetric,mxGetField(BAMGOPTIONS,0,"geometricalmetric")); 59 FetchData(&bamgopts->MaxCornerAngle,mxGetField(BAMGOPTIONS,0,"MaxCornerAngle")); 60 FetchData(&bamgopts->hminVertices,&lines,&cols,mxGetField(BAMGOPTIONS,0,"hminVertices")); 61 if (bamgopts->hminVertices && (cols!=1 || lines!=bamgmesh_in->VerticesSize[0])){ISSMERROR("the size of 'hminVertices' should be [%i %i]",bamgmesh_in->VerticesSize[0],1);} 62 FetchData(&bamgopts->hmaxVertices,&lines,&cols,mxGetField(BAMGOPTIONS,0,"hmaxVertices")); 63 if (bamgopts->hmaxVertices && (cols!=1 || lines!=bamgmesh_in->VerticesSize[0])){ISSMERROR("the size of 'hmaxVertices' should be [%i %i]",bamgmesh_in->VerticesSize[0],1);} 64 FetchData(&bamgopts->metric,&lines,&cols,mxGetField(BAMGOPTIONS,0,"metric")); 65 if (bamgopts->metric && (cols!=3 || lines!=bamgmesh_in->VerticesSize[0])){ISSMERROR("the size of 'metric' should be [%i %i]",bamgmesh_in->VerticesSize[0],3);} 66 FetchData(&bamgopts->field,&lines,&bamgopts->numfields,mxGetField(BAMGOPTIONS,0,"field")); 67 if (bamgopts->field && lines!=bamgmesh_in->VerticesSize[0]){ISSMERROR("the size of 'field' should be [%i %i]",bamgmesh_in->VerticesSize[0],bamgopts->numfields);} 68 FetchData(&bamgopts->err,NULL,&cols,mxGetField(BAMGOPTIONS,0,"err")); 69 if (bamgopts->numfields!=0 && cols!=bamgopts->numfields){ISSMERROR("the size of 'err' should be the same as 'field'");} 70 bamgopts->Check(); 30 /*Initialize outputs*/ 31 bamggeom_out=new BamgGeom(); 32 bamgmesh_out=new BamgMesh(); 71 33 72 34 /*!Generate internal degree of freedom numbers: */ -
issm/trunk/src/mex/BamgConvertMesh/BamgConvertMesh.cpp
r5172 r5177 67 67 bamgmesh->SetMatlabStructureFields(BAMGMESHOUT); 68 68 69 /*Clean up*/ 70 delete bamggeom; 71 delete bamgmesh; 72 69 73 /*end module: */ 70 74 MODULEEND();
Note:
See TracChangeset
for help on using the changeset viewer.