Changeset 3022
- Timestamp:
- 02/11/10 15:28:10 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r2981 r3022 92 92 //generate mesh 93 93 if (verbosity>1) printf(" Generating Mesh...\n"); 94 Triangles Th(maxnbv,Gh );94 Triangles Th(maxnbv,Gh,bamgopts); 95 95 if(bamgopts->splitcorners) Th.SplitInternalEdgeWithBorderVertices(); 96 96 Th.ReNumberingTheTriangleBySubDomain(); … … 103 103 if (verbosity>1) printf(" Write Geometry...\n"); 104 104 Gh.WriteGeometry(bamggeom,bamgopts); 105 106 //clean up 107 // delete &Th; 108 // delete &Gh; 105 109 /*}}}*/ 106 110 } … … 183 187 184 188 /*clean up*/ 185 delete &Th; //TEST crash 189 delete &Th; 190 //delete &BTh; 186 191 /*}}}*/ 187 192 } -
issm/trunk/src/c/Bamgx/Mesh2.h
r2992 r3022 655 655 656 656 //Genetare mesh from geometry 657 Triangles(Int4 nbvx,Geometry & G ) :Gh(G),BTh(*this){658 try { GeomToTriangles0(nbvx );}657 Triangles(Int4 nbvx,Geometry & G,BamgOpts* bamgopts) :Gh(G),BTh(*this){ 658 try { GeomToTriangles0(nbvx,bamgopts);} 659 659 catch(...) { this->~Triangles(); throw; } 660 660 } … … 680 680 void Insert(); 681 681 void ForceBoundary(); 682 void Heap(); 682 //void Heap(); 683 void Renumber(BamgOpts* bamgopts); 683 684 void FindSubDomain(int OutSide=0); 684 685 Int4 ConsRefTriangle(Int4 *) const; … … 742 743 private: 743 744 void GeomToTriangles1(Int4 nbvx,int KeepVertices=1);// the real constructor mesh adaption 744 void GeomToTriangles0(Int4 nbvx );// the real constructor mesh generator745 void GeomToTriangles0(Int4 nbvx,BamgOpts* bamgopts);// the real constructor mesh generator 745 746 void PreInit(Int4); 746 747 … … 755 756 Int4 nbv,nbt,nbiv,nbe; // nombre de sommets, de Geometry, de sommets initiaux, 756 757 Int4 NbSubDomains; // 757 Int4 NbEquiEdges;758 Int4 NbCrackedEdges;759 758 // Int4 nbtf;// de triangle frontiere 760 759 Int4 NbOfCurves; … … 810 809 // to sort in descending order 811 810 template<class T> inline void HeapSort(T *c,long n){ 812 long l,j,r,i; 813 T crit; 814 c--; // on decale de 1 pour que le tableau commence a 1 815 if( n <= 1) return; 816 l = n/2 + 1; 817 r = n; 818 while (1) { // label 2 819 if(l <= 1 ) { // label 20 820 crit = c[r]; 821 c[r--] = c[1]; 822 if ( r == 1 ) { c[1]=crit; return;} 823 } else crit = c[--l]; 811 /*Intermediary*/ 812 int l,j,r,i; 813 T crit; 814 c--; //the array must starts at 1 and not 0 815 if(n<=1) return; //return if size <=1 816 l=n/2+1; //initialize l and r 817 r=n; 818 for(;;){ 819 if(l<=1){ 820 crit =c[r]; 821 c[r--]=c[1]; 822 if (r==1){c[1]=crit; return;} 823 } 824 else crit = c[--l]; 824 825 j=l; 825 while (1) {// label 4826 for(;;){ 826 827 i=j; 827 828 j=2*j; 828 if (j>r) {c[i]=crit;break;} // L8 -> G2 829 if ((j<r) && (c[j] < c[j+1])) j++; // L5 830 if (crit < c[j]) c[i]=c[j]; // L6+1 G4 831 else {c[i]=crit;break;} //L8 -> G2 829 if (j>r) {c[i]=crit;break;} 830 if ((j<r) && (c[j] < c[j+1])) j++;//c[j+1]> c[j] -> take j+1 instead of j (larger value) 831 if (crit < c[j]) c[i]=c[j]; //c[j] > crit -> stock this large value in i(<j) 832 else{c[i]=crit;break;} //c[j] < crit -> stock crit in i (<j) 833 } 834 } 835 } 836 // to sort in descending order and return ordering 837 template<class T> inline void HeapSort(int** porder,T* c,int n){ 838 /*Intermediary*/ 839 int l,j,r,i; 840 T crit; 841 int pos; 842 int* order=NULL; 843 order=(int*)xmalloc(n*sizeof(int)); 844 for(i=0;i<n;i++) order[i]=i+1; 845 c--; //the array must starts at 1 and not 0 846 order--; 847 if(n<=1) return; //return if size <=1 848 l=n/2+1; //initialize l and r 849 r=n; 850 for(;;){ 851 if(l<=1){ 852 crit =c[r]; pos=order[r]; 853 c[r--]=c[1]; order[r+1]=order[1]; 854 if (r==1){ 855 c[1]=crit; order[1]=pos; 856 order++; 857 *porder=order; 858 return; 859 } 860 } 861 else {crit=c[--l]; pos=order[l];} 862 j=l; 863 for(;;){ 864 i=j; 865 j=2*j; 866 if (j>r) {c[i]=crit;order[i]=pos;break;} 867 if ((j<r) && (c[j] < c[j+1]))j++; 868 if (crit < c[j]) {c[i]=c[j];order[i]=order[j];} 869 else{c[i]=crit;order[i]=pos;break;} 832 870 } 833 871 } … … 958 996 /*INLINE functions of CLASS Triangles{{{1*/ 959 997 inline Triangles::Triangles(Int4 i) :Gh(*new Geometry()),BTh(*this){PreInit(i);} 960 inline void Triangles::ReMakeTriangleContainingTheVertex() 961 { 998 inline void Triangles::ReMakeTriangleContainingTheVertex(){ 962 999 register Int4 i; 963 for ( i=0;i<nbv;i++) 964 { 965 vertices[i].vint = 0; 1000 for ( i=0;i<nbv;i++){ 1001 vertices[i].vint=0; 966 1002 vertices[i].t=0; 967 1003 } 968 for ( i=0;i<nbt;i++) 969 triangles[i].SetTriangleContainingTheVertex(); 1004 for ( i=0;i<nbt;i++) triangles[i].SetTriangleContainingTheVertex(); 970 1005 } 971 1006 -
issm/trunk/src/c/Bamgx/objects/Geometry.cpp
r2966 r3022 893 893 printf(" nbv (number of initial vertices) : %i\n",nbiv); 894 894 printf(" NbSubDomains: %i\n",NbSubDomains); 895 printf(" NbEquiEdges: %i\n",NbEquiEdges);896 printf(" NbCrackedEdges: %i\n",NbCrackedEdges);897 895 printf(" NbOfCurves: %i\n",NbOfCurves); 898 896 printf(" vertices: %p\n",vertices); -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r2981 r3022 479 479 480 480 int i,j,k,num; 481 int verbose; 482 483 verbose=bamgopts->verbose; 481 int verbose=bamgopts->verbose; 482 483 //renumber 484 if (bamgopts->renumber){ 485 if(verbose>3) printf(" Renumbering..."); 486 Renumber(bamgopts); 487 if(verbose>3) printf(" done\n"); 488 } 484 489 485 490 //Build reft that holds the number the subdomain number of each triangle 486 Int4 *reft = new Int4[nbt];491 Int4* reft = new Int4[nbt]; 487 492 Int4 nbInT = ConsRefTriangle(reft); 488 493 … … 524 529 525 530 //Segments 531 bamgmesh->NumSegments=0; 526 532 if(verbose>3) printf(" writing Segments\n"); 533 527 534 //chaining algorithm 528 int head_v[nbv]; 529 int next_p[3*nbt]; 535 int* head_v=NULL; 536 head_v=(int*)xmalloc(nbv*sizeof(int)); 537 int* next_p=NULL; 538 next_p=(int*)xmalloc(3*nbt*sizeof(int)); 539 530 540 for (i=0;i<nbv;i++) head_v[i]=-1; 531 541 k=0; … … 535 545 for (j=0;j<3;j++){ 536 546 int v=Number(triangles[i][j]); //jth vertex of the ith triangle 547 if (k>3*nbt-1 || k<0) throw ErrorException(__FUNCT__,exprintf("k = %i, nbt = %i",k,nbt)); 537 548 next_p[k]=head_v[v]; 549 if (v>nbv-1 || v<0) throw ErrorException(__FUNCT__,exprintf("v = %i, nbv = %i",v,nbv)); 538 550 head_v[v]=k++; 539 551 } … … 582 594 } 583 595 } 596 //clean up 597 xfree((void**)&head_v); 598 xfree((void**)&next_p); 584 599 585 600 //CrackedEdges … … 615 630 bamgmesh->Triangles[num*4+3]=subdomains[reft[i]].ref; 616 631 num=num+1; 617 /*if (reft[i]==-1){618 if (!t(0)) printf("%i %i %i\n",Number(t[1])+1,Number(t[2]),i);619 if (!t(1)) printf("%i %i %i\n",Number(t[2])+1,Number(t[0]),i);620 if (!t(2)) printf("%i %i %i\n",Number(t[0])+1,Number(t[1]),i);621 }*/622 632 } 623 633 } … … 746 756 bamgmesh->EdgesOnGeometricEdge=NULL; 747 757 } 758 759 760 //clean up 761 delete [] reft; 748 762 } 749 763 /*}}}1*/ … … 1462 1476 1463 1477 //first, build the chains that will be used for the Hessian computation, as weel as the area of each element 1464 int head_s[nbv]; 1465 int next_p[3*nbt]; 1478 int* head_s=NULL; 1479 head_s=(int*)xmalloc(nbv*sizeof(int)); 1480 int* next_p=NULL; 1481 next_p=(int*)xmalloc(3*nbt*sizeof(int)); 1466 1482 int p=0; 1467 1483 //initialization … … 1602 1618 1603 1619 //clean up 1620 xfree((void**)&head_s); 1621 xfree((void**)&next_p); 1604 1622 delete [] detT; 1605 1623 delete [] alpha; … … 2769 2787 /*}}}1*/ 2770 2788 /*FUNCTION Triangles::GeomToTriangles0{{{1*/ 2771 void Triangles::GeomToTriangles0(Int4 inbvx ) {2789 void Triangles::GeomToTriangles0(Int4 inbvx,BamgOpts* bamgopts) { 2772 2790 /*Generate mesh from geometry*/ 2773 2791 … … 2784 2802 GeometricalEdge * e; 2785 2803 2804 /*Get options*/ 2805 int verbose=bamgopts->verbose; 2806 2786 2807 //initialize this 2808 if (verbose>3) printf(" Generating vertices\n"); 2787 2809 PreInit(inbvx); 2788 2810 nbv=0; … … 3064 3086 3065 3087 //Insert points inside existing triangles 3088 if (verbose>3) printf(" Inserting vertices in mesh\n"); 3066 3089 Insert(); 3067 3090 3068 3091 //Force the boundary 3092 if (verbose>3) printf(" Forcing boundaries\n"); 3069 3093 ForceBoundary(); 3070 3094 3071 3095 //Extract SubDomains 3096 if (verbose>3) printf(" Extracting subdomains\n"); 3072 3097 FindSubDomain(); 3073 3098 3074 3099 // NewPointsOld(*this) ; 3100 if (verbose>3) printf(" Generating mesh properties\n"); 3075 3101 NewPoints(*this,0) ; 3076 3102 } … … 3381 3407 } 3382 3408 }//for(phase;;) 3383 /* modif FH add Curve class3384 }}//for (iedge=0;iedge<BTh.nbe;iedge++)3385 */3386 // new code Curve class3387 3409 } // end of curve loop 3388 3410 // end new code … … 3886 3908 /*FUNCTION Triangles::NewPoints{{{1*/ 3887 3909 void Triangles::NewPoints(Triangles & Bh,int KeepVertices) { 3910 3888 3911 long int verbosity=2; 3889 3912 Int4 nbtold(nbt),nbvold(nbv); 3890 if (verbosity>2) printf(" Triangles::NewPoints\n");3891 3913 Int4 i,k; 3892 3914 int j; 3893 3915 Int4 *first_np_or_next_t = new Int4[nbtx]; 3894 3916 Int4 NbTSwap =0; 3895 // insert old point 3917 3918 //display info 3919 if (verbosity>2) printf(" Triangles::NewPoints\n"); 3920 3921 /*First, insert old points*/ 3922 3896 3923 nbtold = nbt; 3897 3924 3898 3925 if (KeepVertices && (&Bh != this) && (nbv+Bh.nbv< nbvx)){ 3899 3926 // Bh.SetVertexFieldOn(); 3900 for (i=0;i<Bh.nbv;i++) 3901 { 3902 Vertex & bv = Bh[i]; 3903 if (!bv.onGeometry) { 3927 for (i=0;i<Bh.nbv;i++){ 3928 Vertex &bv=Bh[i]; 3929 if (!bv.onGeometry){ 3904 3930 vertices[nbv].r = bv.r; 3905 vertices[nbv++].m = bv.m;} 3906 } 3931 vertices[nbv++].m = bv.m; 3932 } 3933 } 3907 3934 int nbv1=nbv; 3908 3935 Bh.ReMakeTriangleContainingTheVertex(); 3909 3936 InsertNewPoints(nbvold,NbTSwap) ; 3910 3937 } 3911 else 3912 Bh.ReMakeTriangleContainingTheVertex(); 3938 else Bh.ReMakeTriangleContainingTheVertex(); 3913 3939 3914 3940 Triangle *t; … … 3922 3948 // the next traingle on i is -first_np_or_next_t[i] 3923 3949 int iter=0; 3924 // Big loop 3950 3951 // Big loop (most time consuming) 3925 3952 do { 3926 3953 iter++; … … 3929 3956 3930 3957 // default size of IntersectionTriangle 3931 3932 3958 i=Headt; 3933 3959 next_t=-first_np_or_next_t[i]; … … 3999 4025 Int4 NbSwapf =0,NbSwp; 4000 4026 4001 // bofbof4002 4003 4004 4027 NbSwp = NbSwapf; 4005 4028 for (i=0;i<nbv;i++) 4006 4029 NbSwapf += vertices[i].Optim(0); 4007 /*4008 for (i=0;i<nbv;i++)4009 NbSwapf += vertices[i].Optim(0);4010 for (i=0;i<nbv;i++)4011 NbSwapf += vertices[i].Optim(0);4012 for (i=0;i<nbv;i++)4013 NbSwapf += vertices[i].Optim(0);4014 for (i=0;i<nbv;i++)4015 NbSwapf += vertices[i].Optim(0);4016 */4017 4030 NbTSwap += NbSwapf ; 4018 4031 } … … 4212 4225 } 4213 4226 /*}}}1*/ 4227 /*FUNCTION Triangles::Renumber {{{1*/ 4228 void Triangles::Renumber(BamgOpts* bamgopts){ 4229 4230 /*Intermediary*/ 4231 int i,j,k; 4232 int* r=NULL; 4233 int* rprime=NULL; 4234 rprime =(int*) xmalloc(nbv*sizeof(int)); 4235 4236 //renumbering with respect to lower left corner 4237 if (bamgopts->renumber==1){ 4238 4239 //compute distance to pmin 4240 double* distance; 4241 distance=(double*)xmalloc(nbv*sizeof(double)); 4242 for (i=0;i<nbv;i++) distance[i]=pow(vertices[i].r.x - pmin.x,2)+pow(vertices[i].r.y - pmin.y,2); 4243 4244 //get ordering 4245 HeapSort(&r,distance,nbv); 4246 xfree((void**)&distance); 4247 } 4248 //renumbering randomly 4249 else if (bamgopts->renumber==2){ 4250 4251 //allocate memory to r 4252 r=(int*)xmalloc(nbv*sizeof(int)); 4253 int PrimeNumber= AGoodNumberPrimeWith(nbv) ; 4254 int k0=rand()%nbv; 4255 for (int i=0; i<nbv; i++){ 4256 r[i]=(k0=(k0+PrimeNumber)%nbv)+1; 4257 } 4258 } 4259 //else: error 4260 else{ 4261 throw ErrorException(__FUNCT__,exprintf("renumbering option %i not supported yet",bamgopts->renumber)); 4262 } 4263 4264 //Keep copy of old vertices 4265 Vertex* oldvertices=NULL; 4266 oldvertices=(Vertex*)xmalloc(nbv*sizeof(Vertex)); 4267 for (i=0;i<nbv;i++){ 4268 oldvertices[i]=vertices[i]; 4269 } 4270 4271 //renumber vertices 4272 for (i=0;i<nbv;i++){ 4273 //check r[i] 4274 if (r[i]>nbv){ 4275 throw ErrorException(__FUNCT__,exprintf("r[i]>nbv (r[i]=%i and nbv=%i)",r[i],nbv)); 4276 } 4277 if (r[i]<=0){ 4278 throw ErrorException(__FUNCT__,exprintf("r[i]<=0 (r[i]=%i)",r[i])); 4279 } 4280 vertices[i]=oldvertices[r[i]-1]; 4281 rprime[r[i]-1]=i+1; 4282 } 4283 //clean up 4284 xfree((void**)&oldvertices); 4285 4286 //renumber triangles 4287 for (i=0; i<nt;i++){ 4288 for (j=0;j<3;j++){ 4289 if (triangles[i](j)){ 4290 triangles[i](j)=&vertices[rprime[Number(triangles[i](j))] -1 ]; 4291 } 4292 } 4293 } 4294 4295 //renumber edges 4296 for (i=0; i<nbe;i++){ 4297 for (j=0;j<2;j++){ 4298 edges[i].v[j]=&vertices[rprime[Number(edges[i].v[j])] -1 ]; 4299 } 4300 } 4301 4302 //clean up 4303 xfree((void**)&r); 4304 xfree((void**)&rprime); 4305 } 4306 /*}}}1*/ 4214 4307 /*FUNCTION Triangles::ReNumberingTheTriangleBySubDomain{{{1*/ 4215 4308 void Triangles::ReNumberingTheTriangleBySubDomain(bool justcompress) { -
issm/trunk/src/c/objects/BamgOpts.h
r2942 r3022 14 14 int Metrictype; 15 15 int KeepVertices; 16 int renumber; 16 17 double maxsubdiv; 17 18 double power; -
issm/trunk/src/m/classes/public/bamg.m
r2977 r3022 2 2 %BAMG - mesh generation 3 3 % 4 % Usage: 5 % md=bamg(md,varargin); 4 % Available options (for more details see ISSM website http://issm.jpl.nasa.gov/): 5 % 6 % - domain : followed by an ARGUS file that prescribes the domain outline (rifts and holes) 7 % - hmin : minimum edge length (default is 10^-100) 8 % - hmax : maximum esge length (default is 10^100) 9 % - hVertices : imposed edge length for each vertex (geometry or mesh) 10 % 11 % - anisomax : maximum ration between the smallest and largest edges (default is 10^30) 12 % - coef : coefficient applied to the metric (2-> twice as many elements, default is 1) 13 % - cutoff : scalar used to compute the metric when metric type 2 or 3 are applied 14 % - err : error used to generate the metric from a field 15 % - errg : geometrical error (default is 0.1) 16 % - field : field of the model that will be used to compute the metric 17 % to apply several fields, use one column per field 18 % - gradation : maximum ration between two adjacent edges 19 % - Hessiantype : 0 -> use double P2 projection (default) 20 % 1 -> use Green formula 21 % - KeepVertices: try to keep initial vertices when adaptation is done on an existing mesh (default 1) 22 % - MaximalAngleOfCorner: maximal angle of corners in degree (default is 10) 23 % - maxnbv : maximum number of vertices used to allocate memory (default is 10^6) 24 % - maxsubdiv : maximum subdivision of exisiting elements (default is 10) 25 % - metric : matrix (numberofgrids x 3) used as a metric 26 % - Metrictype : 1 -> absolute error c/(err coeff^2) * Abs(H) (default) 27 % 2 -> relative error c/(err coeff^2) * Abs(H)/max(s,cutoff*max(s)) 28 % 3 -> rescaled absolute error c/(err coeff^2) * Abs(H)/(smax-smin) 29 % - nbjacoby : correction used by Hessiantype=1 (default is 1) 30 % - NbSmooth : number of metric smoothing procedure (default is 3) 31 % - omega : relaxation parameter of the smoothing procedure (default is 1.8) 32 % - power : power applied to the metric (default is 1) 33 % - renumber : 0 -> no renumbering 34 % 1 -> renumber by distance to lower left corner (default) 35 % 2 -> random renumbering 36 % - splitcorner : split triangles whuch have 3 vertices on the outline (default is 1) 37 % - verbose : level of verbosity (default is 1) 38 % 39 % Examples: 40 % md=bamg(md,'domain','DomainOutline.exp','hmax',3000); 41 % md=bamg(md,'field',[md.vel_obs md.thickness],'hmax',20000,'hmin',1000); 42 % md=bamg(md,'metric',A,'hmin',1000,'hmax',20000,'gradation',3,'anisomax',1); 6 43 7 44 %process options … … 104 141 105 142 % Bamg Options {{{1 143 bamg_options.anisomax=getfieldvalue(options,'anisomax',10^30); 144 bamg_options.coef=getfieldvalue(options,'coef',1); 145 bamg_options.cutoff=getfieldvalue(options,'cutoff',10^-5); 106 146 bamg_options.err=getfieldvalue(options,'err',0.01); 107 147 bamg_options.errg=getfieldvalue(options,'errg',0.1); 108 bamg_options.coef=getfieldvalue(options,'coef',1); 148 bamg_options.field=getfieldvalue(options,'field',[]); 149 bamg_options.gradation=getfieldvalue(options,'gradation',1.5); 150 bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0); 151 bamg_options.hmin=getfieldvalue(options,'hmin',10^-100); 152 bamg_options.hmax=getfieldvalue(options,'hmax',10^100); 153 bamg_options.KeepVertices=getfieldvalue(options,'KeepVertices',1); 154 bamg_options.MaximalAngleOfCorner=getfieldvalue(options,'MaximalAngleOfCorner',10); 155 bamg_options.maxnbv=getfieldvalue(options,'maxnbv',10^6); 109 156 bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10); 110 bamg_options.power=getfieldvalue(options,'power',1); 157 bamg_options.metric=getfieldvalue(options,'metric',[]); 158 bamg_options.Metrictype=getfieldvalue(options,'Metrictype',0); 111 159 bamg_options.nbjacobi=getfieldvalue(options,'nbjacobi',1); 112 bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0);113 bamg_options.Metrictype=getfieldvalue(options,'Metrictype',0);114 bamg_options.KeepVertices=getfieldvalue(options,'KeepVertices',1);115 160 bamg_options.NbSmooth=getfieldvalue(options,'NbSmooth',3); 116 161 bamg_options.omega=getfieldvalue(options,'omega',1.8); 117 bamg_options.maxnbv=getfieldvalue(options,'maxnbv',10^6); 118 bamg_options.MaximalAngleOfCorner=getfieldvalue(options,'MaximalAngleOfCorner',10); 119 bamg_options.hmin=getfieldvalue(options,'hmin',10^-100); 120 bamg_options.hmax=getfieldvalue(options,'hmax',10^100); 121 bamg_options.anisomax=getfieldvalue(options,'anisomax',10^30); 122 bamg_options.gradation=getfieldvalue(options,'gradation',1.5); 123 bamg_options.cutoff=getfieldvalue(options,'cutoff',10^-5); 162 bamg_options.power=getfieldvalue(options,'power',1); 163 bamg_options.renumber=getfieldvalue(options,'renumber',1); 164 bamg_options.splitcorners=getfieldvalue(options,'splitcorners',1); 124 165 bamg_options.verbose=getfieldvalue(options,'verbose',1); 125 bamg_options.splitcorners=getfieldvalue(options,'splitcorners',1);126 bamg_options.metric=getfieldvalue(options,'metric',[]);127 bamg_options.field=getfieldvalue(options,'field',[]);128 166 %}}} 129 167 -
issm/trunk/src/mex/Bamg/Bamg.cpp
r2977 r3022 10 10 int i; 11 11 int nods=0; //to be removed 12 int lines,cols; 12 13 BamgOpts bamgopts; 13 14 BamgMesh bamgmesh; … … 41 42 double power; 42 43 int Hessiantype,Metrictype,NbSmooth; 43 int nbjacobi,KeepVertices ;44 int nbjacobi,KeepVertices,renumber; 44 45 double omega; 45 46 double gradation,errg; … … 65 66 FetchData(&EdgesGeom,NULL,NULL,mxGetField(BAMGGEOMETRY,0,"Edges")); 66 67 bamggeom.Edges=EdgesGeom; 67 FetchData(&hVerticesGeom,NULL,NULL,mxGetField(BAMGGEOMETRY,0,"hVertices")); 68 FetchData(&hVerticesGeom,&lines,&cols,mxGetField(BAMGGEOMETRY,0,"hVertices")); 69 if (hVerticesGeom && (cols!=1 || lines!=NumVerticesGeom)){throw ErrorException(__FUNCT__,exprintf("the size of 'hVertices' should be [%i %i]",NumVerticesGeom,1));} 68 70 bamggeom.hVertices=hVerticesGeom; 69 71 bamggeom.MetricVertices=NULL; … … 95 97 FetchData(&TrianglesMesh,NULL,NULL,mxGetField(BAMGMESH,0,"Triangles")); 96 98 bamgmesh.Triangles=TrianglesMesh; 97 FetchData(&hVerticesMesh,NULL,NULL,mxGetField(BAMGMESH,0,"hVertices")); 99 FetchData(&hVerticesMesh,&lines,&cols,mxGetField(BAMGMESH,0,"hVertices")); 100 if (hVerticesMesh && (cols!=1 || lines!=NumVerticesMesh)){throw ErrorException(__FUNCT__,exprintf("the size of 'hVertices' should be [%i %i]",NumVerticesMesh,1));} 98 101 bamgmesh.hVertices=hVerticesMesh; 99 102 bamgmesh.NumQuadrilaterals=0; … … 121 124 /*create bamg options input*/ 122 125 FetchData(&coef,mxGetField(BAMGOPTIONS,0,"coef")); 126 if (coef==0) throw ErrorException(__FUNCT__,exprintf("'coef' should be positive")); 123 127 bamgopts.coef=coef; 124 128 FetchData(&maxsubdiv,mxGetField(BAMGOPTIONS,0,"maxsubdiv")); 129 if (maxsubdiv<1) throw ErrorException(__FUNCT__,exprintf("'maxsubdiv' should be >=1")); 125 130 bamgopts.maxsubdiv=maxsubdiv; 126 131 FetchData(&Hessiantype,mxGetField(BAMGOPTIONS,0,"Hessiantype")); 132 if (Hessiantype!=0 && Hessiantype!=1) throw ErrorException(__FUNCT__,exprintf("'Hessiantype' supported options are 0 and 1")); 127 133 bamgopts.Hessiantype=Hessiantype; 128 134 FetchData(&Metrictype,mxGetField(BAMGOPTIONS,0,"Metrictype")); 135 if (Metrictype!=0 && Metrictype!=1 && Metrictype!=2) throw ErrorException(__FUNCT__,exprintf("'Metrictype' supported options are 0, 1 and 2")); 129 136 bamgopts.Metrictype=Metrictype; 130 137 FetchData(&KeepVertices,mxGetField(BAMGOPTIONS,0,"KeepVertices")); 138 if (KeepVertices!=0 && KeepVertices!=1) throw ErrorException(__FUNCT__,exprintf("'KeepVertices' supported options are 0 and 1")); 131 139 bamgopts.KeepVertices=KeepVertices; 140 FetchData(&renumber,mxGetField(BAMGOPTIONS,0,"renumber")); 141 if (renumber!=0 && renumber!=1 && renumber!=2) throw ErrorException(__FUNCT__,exprintf("'renumber' supported options are 0, 1 and 2")); 142 bamgopts.renumber=renumber; 132 143 FetchData(&power,mxGetField(BAMGOPTIONS,0,"power")); 133 144 bamgopts.power=power; 134 145 FetchData(&errg,mxGetField(BAMGOPTIONS,0,"errg")); 146 if (errg<0) throw ErrorException(__FUNCT__,exprintf("'errg' option should be >0")); 135 147 bamgopts.errg=errg; 136 148 FetchData(&nbjacobi,mxGetField(BAMGOPTIONS,0,"nbjacobi")); 149 if (nbjacobi<=0) throw ErrorException(__FUNCT__,exprintf("'nbjacobi' option should be >0")); 137 150 bamgopts.nbjacobi=nbjacobi; 138 151 FetchData(&NbSmooth,mxGetField(BAMGOPTIONS,0,"NbSmooth")); 152 if (NbSmooth<=0) throw ErrorException(__FUNCT__,exprintf("'NbSmooth' option should be >0")); 139 153 bamgopts.NbSmooth=NbSmooth; 140 154 FetchData(&omega,mxGetField(BAMGOPTIONS,0,"omega")); 141 155 bamgopts.omega=omega; 142 156 FetchData(&maxnbv,mxGetField(BAMGOPTIONS,0,"maxnbv")); 157 if (maxnbv<3) throw ErrorException(__FUNCT__,exprintf("'maxnbv' option should be >3")); 143 158 bamgopts.maxnbv=maxnbv; 144 159 FetchData(&hmin,mxGetField(BAMGOPTIONS,0,"hmin")); 160 if (hmin<=0) throw ErrorException(__FUNCT__,exprintf("'hmin' option should be >0")); 145 161 bamgopts.hmin=hmin; 146 162 FetchData(&hmax,mxGetField(BAMGOPTIONS,0,"hmax")); 163 if (hmax<=0 || hmax<hmin) throw ErrorException(__FUNCT__,exprintf("'hmax' option should be between 0 and hmin=%g",hmin)); 147 164 bamgopts.hmax=hmax; 148 165 FetchData(&anisomax,mxGetField(BAMGOPTIONS,0,"anisomax")); 166 if (anisomax<1) throw ErrorException(__FUNCT__,exprintf("'anisomax' option should be >=1")); 149 167 bamgopts.anisomax=anisomax; 150 168 FetchData(&gradation,mxGetField(BAMGOPTIONS,0,"gradation")); 169 if (anisomax<1) throw ErrorException(__FUNCT__,exprintf("'anisomax' option should be >=1")); 151 170 bamgopts.gradation=gradation; 152 171 FetchData(&cutoff,mxGetField(BAMGOPTIONS,0,"cutoff")); … … 158 177 FetchData(&MaximalAngleOfCorner,mxGetField(BAMGOPTIONS,0,"MaximalAngleOfCorner")); 159 178 bamgopts.MaximalAngleOfCorner=MaximalAngleOfCorner; 160 FetchData(&metric,NULL,NULL,mxGetField(BAMGOPTIONS,0,"metric")); 179 FetchData(&metric,&lines,&cols,mxGetField(BAMGOPTIONS,0,"metric")); 180 if (metric && (cols!=3 || lines!=NumVerticesMesh)){throw ErrorException(__FUNCT__,exprintf("the size of 'metric' should be [%i %i]",NumVerticesMesh,3));} 161 181 bamgopts.metric=metric; 162 FetchData(&field,NULL,&numfields,mxGetField(BAMGOPTIONS,0,"field")); 182 FetchData(&field,&lines,&numfields,mxGetField(BAMGOPTIONS,0,"field")); 183 if (field && lines!=NumVerticesMesh){throw ErrorException(__FUNCT__,exprintf("the size of 'field' should be [%i %i]",NumVerticesMesh,numfields));} 163 184 bamgopts.numfields=numfields; 164 185 bamgopts.field=field; 165 FetchData(&err,NULL,&numerr,mxGetField(BAMGOPTIONS,0,"err")); 186 FetchData(&err,NULL,&cols,mxGetField(BAMGOPTIONS,0,"err")); 187 if (numfields!=0 && cols!=numfields){throw ErrorException(__FUNCT__,exprintf("the size of 'err' should be the same as 'field'"));} 188 for (i=0;i<numfields;i++) {if (err[i]<=0) throw ErrorException(__FUNCT__,exprintf("'err' option should be >0"));}; 166 189 bamgopts.err=err; 167 168 /*Some checks*/169 if (numfields!=0 && numerr!=numfields){170 throw ErrorException(__FUNCT__,exprintf("the size of 'err' should be the same as 'field'"));171 }172 190 173 191 /*!Generate internal degree of freedom numbers: */ … … 192 210 { 193 211 _printf_("\n"); 194 _printf_(" usage: [elements, x,y]=%s(bamgmesh,bamggeom,bamgoptions,nbv);\n",__FUNCT__);212 _printf_(" usage: [elements,vertices,segments,segmentmarkers,metric]=%s(bamgmesh,bamggeom,bamgoptions);\n",__FUNCT__); 195 213 _printf_("\n"); 196 214 }
Note:
See TracChangeset
for help on using the changeset viewer.