Changeset 3309
- Timestamp:
- 03/19/10 15:13:26 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/SetOfE4.cpp
r3272 r3309 1 2 1 #include <assert.h> 3 2 #include "BamgObjects.h" … … 39 38 40 39 //check that head is not empty 41 if (head==NULL) { 42 throw ErrorException(__FUNCT__,exprintf("SetOfEdges4::add no head is NULL (How come?)")); 43 } 40 assert(head); 44 41 45 42 //get n from h (usually h=ii) -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3301 r3309 482 482 if(verbose>5) printf(" no Edges found\n"); 483 483 } 484 484 485 //CrackedEdges 485 486 if(bamgmesh->CrackedEdges){ … … 554 555 void Triangles::WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts){ 555 556 556 int i,j,k,num; 557 int i,j,k,num,i1,i2; 558 long n; 557 559 /*Get options*/ 558 560 int verbose=bamgopts->verbose; … … 599 601 } 600 602 601 //Segments 602 bamgmesh->NumSegments=0; 603 if(verbose>5) printf(" writing Segments\n"); 604 605 //chaining algorithm 603 //Element Connectivity 604 if(verbose>5) printf(" writing Element connectivity\n"); 605 bamgmesh->NumElementConnectivity=nbt-NbOutT; 606 bamgmesh->ElementConnectivity=(double*)xmalloc(3*(nbt-NbOutT)*sizeof(double)); 607 for (i=0;i<3*(nbt-NbOutT);i++) bamgmesh->ElementConnectivity[i]=NAN; 608 num=0; 609 for (i=0;i<nbt;i++){ 610 if (reft[i]>=0){ 611 for (j=0;j<3;j++){ 612 k=Number(triangles[i].TriangleAdj(j)); 613 if (reft[k]>=0){ 614 assert(3*num+j<3*(nbt-NbOutT)); 615 bamgmesh->ElementConnectivity[3*num+j]=k+1; // back to Matlab indexing 616 } 617 } 618 num+=1; 619 } 620 } 621 622 //ElementNodal Connectivity 623 if(verbose>5) printf(" writing Nodal element connectivity\n"); 624 //chaining algorithm to get nodal connectivity 606 625 int* head_v=NULL; 607 626 head_v=(int*)xmalloc(nbv*sizeof(int)); 608 627 int* next_p=NULL; 609 628 next_p=(int*)xmalloc(3*nbt*sizeof(int)); 610 629 int* connectivitysize=NULL; 630 connectivitysize=(int*)xmalloc(nbv*sizeof(int)); 611 631 for (i=0;i<nbv;i++) head_v[i]=-1; 632 for (i=0;i<nbv;i++) connectivitysize[i]=0; 612 633 k=0; 613 634 for (i=0;i<nbt;i++) { … … 618 639 if (k>3*nbt-1 || k<0) throw ErrorException(__FUNCT__,exprintf("k = %i, nbt = %i",k,nbt)); 619 640 next_p[k]=head_v[v]; 620 if (v>nbv-1 || v<0) throw ErrorException(__FUNCT__,exprintf("v = %i, nbv = %i",v,nbv));641 if (v>nbv-1 || v<0) throw ErrorException(__FUNCT__,exprintf("v = %i, nbv = %i",v,nbv)); 621 642 head_v[v]=k++; 622 } 623 } 624 } 643 connectivitysize[v]+=1; 644 } 645 } 646 } 647 int max=0; 648 for (i=0;i<nbv;i++){ 649 if (connectivitysize[i]>max) max=connectivitysize[i]; 650 } 651 //Build output 652 bamgmesh->NumNodalElementConnectivity=max; 653 bamgmesh->NodalElementConnectivity=(double*)xmalloc(max*nbv*sizeof(double)); 654 for (i=0;i<max*nbv;i++) bamgmesh->NodalElementConnectivity[i]=NAN; 655 for (i=0;i<nbv;i++){ 656 k=0; 657 for(j=head_v[i];j!=-1;j=next_p[j]){ 658 assert(max*i+k < max*nbv); 659 bamgmesh->NodalElementConnectivity[max*i+k]=floor(j/3)+1; 660 k++; 661 } 662 } 663 //clean up (do not erase head_v and next_p-> used and destroyed by segments) 664 xfree((void**)&connectivitysize); 665 666 //Build Unique edges 667 if(verbose>5) printf(" writing all edges\n"); 668 SetOfEdges4* edge4=new SetOfEdges4(nbt*3,nbv); 669 double* elemedge=new double[3*nbt]; 670 for (i=0;i<3*nbt;i++) elemedge[i]=NAN; 671 k=0; 672 for (i=0;i<nbt;i++){ 673 //Do not take into account outside triangles (reft<0) 674 if (reft[i]>=0){ 675 for (j=0;j<3;j++) { 676 i1=Number(triangles[i][VerticesOfTriangularEdge[j][0]]); 677 i2=Number(triangles[i][VerticesOfTriangularEdge[j][1]]); 678 n =edge4->SortAndFind(i1,i2); 679 if (n==-1){ 680 //first time 681 n=edge4->SortAndAdd(i1,i2); 682 elemedge[n*2+0]=double(k); 683 } 684 else{ 685 //second time 686 elemedge[n*2+1]=double(k); 687 } 688 } 689 k++; 690 } 691 } 692 bamgmesh->NumAllEdges=edge4->nb(); 693 bamgmesh->AllEdges=(double*)xmalloc(4*edge4->nb()*sizeof(double)); 694 for (i=0;i<edge4->nb();i++){ 695 bamgmesh->AllEdges[i*4+0]=edge4->i(i)+1;// back to M indexing 696 bamgmesh->AllEdges[i*4+1]=edge4->j(i)+1;// back to M indexing 697 bamgmesh->AllEdges[i*4+2]=elemedge[2*i+0]+1; // back to M indexing 698 bamgmesh->AllEdges[i*4+3]=elemedge[2*i+1]+1; // back to M indexing 699 } 700 //clean up 701 delete edge4; 702 delete elemedge; 703 704 //Segments 705 bamgmesh->NumSegments=0; 706 if(verbose>5) printf(" writing Segments\n"); 625 707 bamgmesh->NumSegments=NumSegments; 626 708 bamgmesh->Segments=(double*)xmalloc(3*NumSegments*sizeof(double)); -
issm/trunk/src/c/objects/BamgGeom.cpp
r3284 r3309 1 #ifdef _SERIAL_2 #include "mex.h"3 1 #include "stdio.h" 4 2 #include "./BamgGeom.h" … … 28 26 } 29 27 28 #ifdef _SERIAL_ 30 29 void BamgGeomWrite(mxArray** pbamggeom_mat, BamgGeom* bamggeom){ 31 30 -
issm/trunk/src/c/objects/BamgGeom.h
r3274 r3309 39 39 40 40 #ifdef _SERIAL_ 41 #include "mex.h" 41 42 void BamgGeomWrite(mxArray** bamggeom_mat,BamgGeom* bamggeom); 42 43 #endif -
issm/trunk/src/c/objects/BamgMesh.cpp
r3284 r3309 1 #ifdef _SERIAL_2 1 #include "stdio.h" 3 #include "mex.h"4 2 #include "./BamgMesh.h" 5 3 … … 12 10 bamgmesh->NumEdges=0; 13 11 bamgmesh->Edges=NULL; 12 bamgmesh->NumAllEdges=0; 13 bamgmesh->AllEdges=NULL; 14 14 bamgmesh->NumSegments=0; 15 15 bamgmesh->Segments=NULL; … … 30 30 bamgmesh->SubDomainsFromGeom=NULL; 31 31 bamgmesh->hVertices=NULL; 32 bamgmesh->NumElementConnectivity=0; 33 bamgmesh->ElementConnectivity=NULL; 34 bamgmesh->NumNodalConnectivity=0; 35 bamgmesh->NodalConnectivity=NULL; 36 bamgmesh->NumNodalElementConnectivity=0; 37 bamgmesh->NodalElementConnectivity=NULL; 32 38 33 39 } 34 40 41 #ifdef _SERIAL_ 35 42 void BamgMeshWrite(mxArray** pbamgmesh_mat, BamgMesh* bamgmesh){ 36 43 … … 42 49 mxArray* pfield=NULL; 43 50 mxArray* pfield2=NULL; 44 int numfields= 23;51 int numfields=31; 45 52 const char* fnames[numfields]; 46 53 mwSize ndim=2; 47 54 mwSize dimensions[2]={1,1}; 48 55 49 fnames[0] = "NumTriangles"; 50 fnames[1] = "Triangles"; 51 fnames[2] = "NumVertices"; 52 fnames[3] = "Vertices"; 53 fnames[4] = "NumEdges"; 54 fnames[5] = "Edges"; 55 fnames[6] = "NumSegments"; 56 fnames[7] = "Segments"; 57 fnames[8] = "SegmentsMarkers"; 58 fnames[9] = "NumCrackedEdges"; 59 fnames[10] = "CrackedEdges"; 60 fnames[11] = "NumQuadrilaterals"; 61 fnames[12] = "Quadrilaterals"; 62 fnames[13] = "NumVerticesOnGeometricVertex"; 63 fnames[14] = "VerticesOnGeometricVertex"; 64 fnames[15] = "NumVerticesOnGeometricEdge"; 65 fnames[16] = "VerticesOnGeometricEdge"; 66 fnames[17] = "NumEdgesOnGeometricEdge"; 67 fnames[18] = "EdgesOnGeometricEdge"; 68 fnames[19] = "NumSubDomains"; 69 fnames[20] = "SubDomains"; 70 fnames[21] = "NumSubDomainsFromGeom"; 71 fnames[22] = "SubDomainsFromGeom"; 56 fnames[0] = "NumTriangles"; 57 fnames[1] = "Triangles"; 58 fnames[2] = "NumVertices"; 59 fnames[3] = "Vertices"; 60 fnames[4] = "NumEdges"; 61 fnames[5] = "Edges"; 62 fnames[6] = "NumSegments"; 63 fnames[7] = "Segments"; 64 fnames[8] = "NumAllEdges"; 65 fnames[9] = "AllEdges"; 66 fnames[10] = "SegmentsMarkers"; 67 fnames[11] = "NumCrackedEdges"; 68 fnames[12] = "CrackedEdges"; 69 fnames[13] = "NumQuadrilaterals"; 70 fnames[14] = "Quadrilaterals"; 71 fnames[15] = "NumVerticesOnGeometricVertex"; 72 fnames[16] = "VerticesOnGeometricVertex"; 73 fnames[17] = "NumVerticesOnGeometricEdge"; 74 fnames[18] = "VerticesOnGeometricEdge"; 75 fnames[19] = "NumEdgesOnGeometricEdge"; 76 fnames[20] = "EdgesOnGeometricEdge"; 77 fnames[21] = "NumSubDomains"; 78 fnames[22] = "SubDomains"; 79 fnames[23] = "NumSubDomainsFromGeom"; 80 fnames[24] = "SubDomainsFromGeom"; 81 fnames[25] = "NumElementConnectivity"; 82 fnames[26] = "ElementConnectivity"; 83 fnames[27] = "NumNodalConnectivity"; 84 fnames[28] = "NodalConnectivity"; 85 fnames[29] = "NumNodalElementConnectivity"; 86 fnames[30] = "NodalElementConnectivity"; 72 87 73 88 bamgmesh_mat=mxCreateStructArray(ndim,dimensions,numfields,fnames); … … 108 123 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 109 124 mxSetField(bamgmesh_mat,0,"Segments",pfield2); 125 126 mxSetField(bamgmesh_mat,0,"NumAllEdges",mxCreateDoubleScalar(bamgmesh->NumAllEdges)); 127 128 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 129 mxSetM(pfield,4); 130 mxSetN(pfield,bamgmesh->NumAllEdges); 131 mxSetPr(pfield,bamgmesh->AllEdges); 132 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 133 mxSetField(bamgmesh_mat,0,"AllEdges",pfield2); 110 134 111 135 pfield=mxCreateDoubleMatrix(0,0,mxREAL); … … 178 202 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 179 203 mxSetField(bamgmesh_mat,0,"SubDomainsFromGeom",pfield2); 204 205 mxSetField(bamgmesh_mat,0,"NumElementConnectivity",mxCreateDoubleScalar(bamgmesh->NumElementConnectivity)); 206 207 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 208 mxSetM(pfield,3); 209 mxSetN(pfield,bamgmesh->NumElementConnectivity); 210 mxSetPr(pfield,bamgmesh->ElementConnectivity); 211 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 212 mxSetField(bamgmesh_mat,0,"ElementConnectivity",pfield2); 213 214 mxSetField(bamgmesh_mat,0,"NumNodalConnectivity",mxCreateDoubleScalar(bamgmesh->NumNodalConnectivity)); 215 216 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 217 mxSetM(pfield,2); 218 mxSetN(pfield,bamgmesh->NumNodalConnectivity); 219 mxSetPr(pfield,bamgmesh->NodalConnectivity); 220 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 221 mxSetField(bamgmesh_mat,0,"NodalConnectivity",pfield2); 222 223 mxSetField(bamgmesh_mat,0,"NumNodalElementConnectivity",mxCreateDoubleScalar(bamgmesh->NumNodalElementConnectivity)); 224 225 pfield=mxCreateDoubleMatrix(0,0,mxREAL); 226 mxSetM(pfield,bamgmesh->NumNodalElementConnectivity); 227 mxSetN(pfield,bamgmesh->NumVertices); 228 mxSetPr(pfield,bamgmesh->NodalElementConnectivity); 229 mexCallMATLAB(1,&pfield2,1,&pfield,"transpose");//transpose 230 mxSetField(bamgmesh_mat,0,"NodalElementConnectivity",pfield2); 180 231 181 232 /*Assign output pointer*/ -
issm/trunk/src/c/objects/BamgMesh.h
r3274 r3309 15 15 int NumEdges; 16 16 double* Edges; 17 18 int NumAllEdges; 19 double* AllEdges; 17 20 18 21 int NumSegments; … … 42 45 43 46 double* hVertices; 47 48 int NumElementConnectivity; 49 double* ElementConnectivity; 50 51 int NumNodalConnectivity; 52 double* NodalConnectivity; 53 54 int NumNodalElementConnectivity; 55 double* NodalElementConnectivity; 44 56 }; 45 57 … … 47 59 48 60 #ifdef _SERIAL_ 61 #include "mex.h" 49 62 void BamgMeshWrite(mxArray** bamgmesh_mat,BamgMesh* bamgmesh); 50 63 #endif -
issm/trunk/src/m/classes/@bamgmesh/bamgmesh.m
r3277 r3309 19 19 bm.NumQuadrilaterals=0; 20 20 bm.Quadrilaterals=[]; 21 22 bm.NumAllEdges=0; 23 bm.AllEdges=zeros(0,2); 21 24 22 25 bm.NumSegments=0; … … 42 45 bm.SubDomainsFromGeom=zeros(0,4); 43 46 47 bm.NumElementConnectivity=0; 48 bm.ElementConnectivity=zeros(0,3); 49 50 bm.NumNodalConnectivity=0; 51 bm.NodalConnectivity=zeros(0,2); 52 53 bm.NumNodalElementConnectivity=0; 54 bm.NodalElementConnectivity=[]; 55 44 56 bm.hVertices=[]; 45 57 -
issm/trunk/src/mex/Bamg/Bamg.cpp
r3301 r3309 50 50 FetchData(&bamgmesh_in.Triangles,NULL,NULL,mxGetField(BAMGMESH,0,"Triangles")); 51 51 FetchData(&bamgmesh_in.hVertices,&lines,&cols,mxGetField(BAMGMESH,0,"hVertices")); 52 FetchData(&bamgmesh_in.NumSegments,mxGetField(BAMGMESH,0,"NumSegments")); 53 FetchData(&bamgmesh_in.Segments,NULL,NULL,mxGetField(BAMGMESH,0,"Segments")); 54 FetchData(&bamgmesh_in.SegmentsMarkers,NULL,NULL,mxGetField(BAMGMESH,0,"SegmentsMarkers")); 52 55 FetchData(&bamgmesh_in.NumCrackedEdges,mxGetField(BAMGMESH,0,"NumCrackedEdges")); 53 56 FetchData(&bamgmesh_in.CrackedEdges,NULL,NULL,mxGetField(BAMGMESH,0,"CrackedEdges"));
Note:
See TracChangeset
for help on using the changeset viewer.