Changeset 3329
- Timestamp:
- 03/24/10 15:20:31 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r3312 r3329 74 74 //Renumbering 75 75 Th.ReNumberingTheTriangleBySubDomain(); 76 77 //Crack mesh if requested 78 if(bamgopts->Crack) Th.CrackMesh(bamgopts); 76 79 77 80 //Build output -
issm/trunk/src/c/Bamgx/objects/CrackedEdge.cpp
r3325 r3329 12 12 13 13 /*Constructors/Destructors*/ 14 /*FUNCTION CrackedEdge() {{{1*/ 15 CrackedEdge::CrackedEdge() { 16 a=NULL; 17 b=NULL; 18 E=NULL; 19 e1=NULL; 20 e2=NULL; 21 indexa[0]=-1; 22 indexa[1]=-1; 23 indexa[2]=-1; 24 indexb[0]=-1; 25 indexb[1]=-1; 26 indexb[2]=-1; 27 length=0; 28 normal.x=0; 29 normal.y=0; 30 31 } 32 /*}}}*/ 14 33 15 34 /*Methods*/ -
issm/trunk/src/c/Bamgx/objects/CrackedEdge.h
r3325 r3329 21 21 class CrackedEdge { 22 22 23 Triangle a,b; 23 public: 24 Triangle* a; 25 Triangle* b; 26 GeometricalEdge* E; 27 Edge* e1; 28 Edge* e2; 29 double length; 30 R2 normal; 31 long indexa[3]; 32 long indexb[3]; 24 33 25 34 //Constructors 26 CrackedEdge() :a(),b() {} 27 28 //Methods 35 CrackedEdge(); 29 36 }; 30 37 -
issm/trunk/src/c/Bamgx/objects/Geometry.cpp
r3326 r3329 6 6 7 7 #include "BamgObjects.h" 8 9 #undef __FUNCT__10 #define __FUNCT__ "Geometry"11 8 12 9 namespace bamg { … … 84 81 //some checks 85 82 if (bamggeom->Vertices==NULL){ 86 throw ErrorException(__FUNCT__,exprintf("the domain provided does not contain any vertex"));83 ISSMERROR("the domain provided does not contain any vertex"); 87 84 } 88 85 if (bamggeom->Edges==NULL){ … … 161 158 edges[i].Adj[0] = edges[i].Adj[1] = 0; 162 159 edges[i].flag = 0; 160 161 //Cracked? 162 if (edges[i].ref!=1){ 163 edges[i].SetCracked(); 164 } 163 165 164 166 //prepare metric -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3326 r3329 234 234 if(edges) delete [] edges; 235 235 if(triangles) delete [] triangles; 236 if(quadtree) delete 236 if(quadtree) delete quadtree; 237 237 //if(ordre) delete [] ordre; //TEST crash if not commented 238 238 if( subdomains) delete [] subdomains; … … 532 532 BamgMeshInit(bamgmesh); 533 533 534 /*Build reft that holds the number the subdomain number of each triangle */534 /*Build reft that holds the number the subdomain number of each triangle, and the real numbering of the elements*/ 535 535 long* reft = new long[nbt]; 536 long* numt = new long[nbt]; 536 537 long nbInT = TriangleReferenceList(reft); 538 TriangleIntNumbering(numt); 537 539 538 540 /*Chaining algorithm used to generate connectivity tables and other outputs*/ … … 890 892 } 891 893 894 /*Cracked vertices*/ 895 if(verbose>5) printf(" writing Cracked vertices\n"); 896 bamgmesh->CrackedVerticesSize[0]=NbCrackedVertices; 897 bamgmesh->CrackedVerticesSize[1]=2; 898 if (NbCrackedVertices){ 899 bamgmesh->CrackedVertices=(double*)xmalloc(2*NbCrackedVertices*sizeof(double)); 900 for (i=0;i<NbCrackedVertices;i++){ 901 bamgmesh->CrackedVertices[i*2+0]=CrackedVertices[i*2+0]+1; //M indexing 902 bamgmesh->CrackedVertices[i*2+1]=CrackedVertices[i*2+1]+1; //M indexing 903 } 904 } 905 906 /*Cracked vertices*/ 907 if(verbose>5) printf(" writing Cracked vertices\n"); 908 bamgmesh->CrackedEdgesSize[0]=NbCrackedEdges; 909 bamgmesh->CrackedEdgesSize[1]=4; 910 if (NbCrackedEdges){ 911 bamgmesh->CrackedEdges=(double*)xmalloc(2*NbCrackedEdges*sizeof(double)); 912 for (i=0;i<NbCrackedEdges;i++){ 913 bamgmesh->CrackedEdges[i*2+0]=0;//CrackedEdges[i]->+1; //M indexing 914 bamgmesh->CrackedEdges[i*2+1]=0;//CrackedEdges[i]-]->+1; //M indexing 915 } 916 } 917 892 918 //clean up 893 919 xfree((void**)&connectivitysize_1); … … 898 924 xfree((void**)&next_2); 899 925 delete [] reft; 926 delete [] numt; 900 927 } 901 928 /*}}}1*/ … … 2142 2169 delete [] Mmassxx; 2143 2170 delete [] OnBoundary; 2171 2172 } 2173 /*}}}1*/ 2174 /*FUNCTION Triangles::CrackMesh{{{1*/ 2175 void Triangles::CrackMesh(BamgOpts* bamgopts) { 2176 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CrackMesh)*/ 2177 2178 /*Intermediary*/ 2179 int i,j,k,num,count; 2180 int i1,i2; 2181 int j1,j2; 2182 2183 /*Options*/ 2184 int verbose=bamgopts->verbose; 2185 2186 // computed the number of cracked edge 2187 for (k=i=0;i<nbe;i++){ 2188 if(edges[i].onGeometry->Cracked()) k++; 2189 } 2190 2191 //Return if no edge is cracked 2192 if(k==0) return; 2193 if (verbose>4) printf(" number of Cracked Edges = %i\n",k); 2194 2195 //Initialize Cracked edge 2196 NbCrackedEdges=k; 2197 CrackedEdges=new CrackedEdge[k]; 2198 2199 //Compute number of Cracked Vertices 2200 k=0; 2201 NbCrackedVertices=0; 2202 2203 int* splitvertex=new int[nbv]; 2204 for (i=0;i<nbv;i++) splitvertex[i]=0; 2205 2206 for (i=0;i<nbe;i++){ 2207 if(edges[i].onGeometry->Cracked()){ 2208 2209 //Fill edges fields of CrackedEdges 2210 CrackedEdges[k ].E =edges[i].onGeometry; 2211 CrackedEdges[k++].e1=&edges[i]; 2212 2213 //Get number of the two vertices on the edge 2214 i1=Number(edges[i][0]); 2215 i2=Number(edges[i][1]); 2216 assert(i1>=0 && i1<nbv && i2>=0 && i2<nbv); 2217 splitvertex[i1]++; 2218 splitvertex[i2]++; 2219 2220 //If the vertex has already been flagged once, it is a cracked vertex (tip otherwise) 2221 if (splitvertex[i1]==2) NbCrackedVertices++; 2222 if (splitvertex[i2]==2) NbCrackedVertices++; 2223 2224 //The vertex cannot be marked more than twice 2225 if (splitvertex[i1]==3 || splitvertex[i2]==3){ 2226 throw ErrorException(__FUNCT__,exprintf("Crossing rifts not supported yet")); 2227 } 2228 } 2229 } 2230 assert(k==NbCrackedEdges); 2231 2232 //Add new vertices 2233 if (verbose>4) printf(" number of Cracked Vertices = %i\n",NbCrackedVertices); 2234 if (NbCrackedVertices){ 2235 CrackedVertices=(long*)xmalloc(2*NbCrackedVertices*sizeof(double)); 2236 num=0; 2237 for (i=0;i<nbv;i++){ 2238 if (splitvertex[i]==2){ 2239 CrackedVertices[num*2+0]=i; //index of first vertex 2240 CrackedVertices[num*2+1]=nbv+num;//index of new vertex 2241 num++; 2242 } 2243 } 2244 assert(num==NbCrackedVertices); 2245 } 2246 delete [] splitvertex; 2247 2248 //Now, find the triangles that hold a cracked edge 2249 ReMakeTriangleContainingTheVertex(); 2250 2251 long* Edgeflags=new long[NbCrackedEdges]; 2252 for(i=0;i<NbCrackedEdges;i++) Edgeflags[i]=0; 2253 2254 for(i=0;i<NbCrackedEdges;i++){ 2255 //Get the numbers of the 2 vertices of the crren cracked edge 2256 i1=Number((*CrackedEdges[i].e1)[0]); 2257 i2=Number((*CrackedEdges[i].e1)[1]); 2258 2259 //find a triangle holding the vertex i1 (first vertex of the ith cracked edge) 2260 Triangle* tbegin=vertices[i1].t; 2261 k=vertices[i1].vint;//local number of i in triangle tbegin 2262 assert(Number((*tbegin)[k])==Number(vertices[i1])); 2263 2264 //Now, we are going to go through the adjacent triangle that hold i1 till 2265 //we find one that has the cracked edge 2266 TriangleAdjacent ta(tbegin,EdgesVertexTriangle[k][0]); 2267 count=0; 2268 do { 2269 for(j=0;j<3;j++){ 2270 //Find the position of i1 in the triangle index 2271 if (Number((*ta.t)[j])==i1){ 2272 j1=j; 2273 break; 2274 } 2275 } 2276 for(j=0;j<3;j++){ 2277 //Check wether i2 is also in the triangle index 2278 if (Number((*ta.t)[j])==i2){ 2279 j2=j; 2280 //Invert j1 and j2 if necessary 2281 if ((j1+1)%3==j2){ 2282 int j3=j1; 2283 j1=j2; 2284 j2=j3; 2285 } 2286 if (Edgeflags[i]==0){ 2287 //first element 2288 CrackedEdges[k].a=ta.t; 2289 CrackedEdges[k].length=Norme2((*ta.t)[j1].r-(*ta.t)[j2].r); 2290 CrackedEdges[k].normal=Orthogonal((*ta.t)[j1].r-(*ta.t)[j2].r); 2291 } 2292 else{ 2293 //Second element -> to renumber 2294 CrackedEdges[k].b=ta.t; 2295 CrackedEdges[k].length=Norme2((*ta.t)[j1].r-(*ta.t)[j2].r); 2296 CrackedEdges[k].normal=Orthogonal((*ta.t)[j1].r-(*ta.t)[j2].r); 2297 } 2298 Edgeflags[i]++; 2299 break; 2300 } 2301 } 2302 //printf("%i -> %i %i %i, edge [%i->%i %i->%i]\n",element_renu[Number(ta.t)],Number((*ta.t)[0])+1,Number((*ta.t)[1])+1,Number((*ta.t)[2])+1,i1,j1,i2,j2); 2303 ta = Next(ta).Adj(); 2304 if (count++>50) throw ErrorException(__FUNCT__,exprintf("Maximum number of iteration exceeded")); 2305 }while ((tbegin != ta)); 2306 } 2307 2308 //Check EdgeFlag 2309 for(i=0;i<NbCrackedEdges;i++){ 2310 if (Edgeflags[i]!=2){ 2311 throw ErrorException(__FUNCT__,exprintf("A problem occured: at least one crack edge (number %i) does not belong to 2 elements",i+1)); 2312 } 2313 } 2314 delete [] Edgeflags; 2315 2316 //Reset Vertex to On 2317 SetVertexFieldOn(); 2144 2318 2145 2319 } … … 3725 3899 3726 3900 NbCrackedVertices=0; 3901 CrackedVertices =NULL; 3727 3902 NbCrackedEdges =0; 3728 3903 CrackedEdges =NULL; … … 5260 5435 } 5261 5436 /*}}}1*/ 5437 /*FUNCTION Triangles::TriangleIntNumbering{{{1*/ 5438 void Triangles::TriangleIntNumbering(long* renumbering){ 5439 5440 long num=0; 5441 for (int i=0;i<nbt;i++){ 5442 if (triangles[i].det>0) renumbering[i]=num++; 5443 else renumbering[i]=-1; 5444 } 5445 return; 5446 } 5447 /*}}}1*/ 5262 5448 5263 5449 /*Intermediary*/ -
issm/trunk/src/c/Bamgx/objects/Triangles.h
r3326 r3329 58 58 VertexOnEdge *VertexOnBThEdge; 59 59 long NbCrackedVertices; 60 long* CrackedVertices; 60 61 long NbCrackedEdges; 61 62 CrackedEdge* CrackedEdges; … … 104 105 void ForceBoundary(); 105 106 void FindSubDomain(int OutSide=0); 106 long TriangleReferenceList(long *) const; 107 long TriangleReferenceList(long*) const; 108 void TriangleIntNumbering(long* renumbering); 107 109 void ShowHistogram() const; 110 void CrackMesh(BamgOpts* bamgopts); 108 111 void ShowRegulaty() const; 109 112 void SmoothMetric(double raisonmax) ; … … 128 131 long Number(const Edge & t) const { return &t - edges;} 129 132 long Number(const Edge * t) const { return t - edges;} 130 long Number2(const Triangle * t) const { 131 return t - triangles; 132 } 133 long Number2(const Triangle * t) const { return t - triangles; } 133 134 Vertex* NearestVertex(Icoor1 i,Icoor1 j) ; 134 135 Triangle* FindTriangleContaining(const I2 & ,Icoor2 [3],Triangle *tstart=0) const; -
issm/trunk/src/c/include/macros.h
r3263 r3329 8 8 /*Printing macro: */ 9 9 #define _printf_(...) PrintfFunction(__VA_ARGS__) 10 11 /*Error exception macro*/ 12 #ifdef _INTEL_WIN_ 13 #define ISSMERROR(error_string)\ 14 throw ErrorException(error_string) 15 #else 16 #define ISSMERROR(error_string)\ 17 throw ErrorException(__FILE__,__func__,__LINE__,error_string) 18 #endif 10 19 11 20 /*The following macros hide the error exception handling in a matlab module. Just put … … 21 30 catch(ErrorException &exception){\ 22 31 exception.Report(); \ 23 mexErrMsgTxt(" 32 mexErrMsgTxt(""); \ 24 33 }\ 25 34 catch (exception& e) {\ -
issm/trunk/src/c/objects/BamgOpts.cpp
r3301 r3329 11 11 bamgopts->Metrictype=0; 12 12 bamgopts->KeepVertices=0; 13 bamgopts->Crack=0; 13 14 bamgopts->maxsubdiv=0; 14 15 bamgopts->power=0; … … 41 42 if (bamgopts->coef==0) throw ErrorException(__FUNCT__,exprintf("'coef' should be positive")); 42 43 if (bamgopts->maxsubdiv<=1) throw ErrorException(__FUNCT__,exprintf("'maxsubdiv' should be >1")); 44 if (bamgopts->Crack!=0 && bamgopts->Crack!=1) throw ErrorException(__FUNCT__,exprintf("'Crack' supported options are 0 and 1")); 43 45 if (bamgopts->Hessiantype!=0 && bamgopts->Hessiantype!=1) throw ErrorException(__FUNCT__,exprintf("'Hessiantype' supported options are 0 and 1")); 44 46 if (bamgopts->Metrictype!=0 && bamgopts->Metrictype!=1 && bamgopts->Metrictype!=2) throw ErrorException(__FUNCT__,exprintf("'Metrictype' supported options are 0, 1 and 2")); -
issm/trunk/src/c/objects/BamgOpts.h
r3301 r3329 11 11 int maxnbv; 12 12 double MaximalAngleOfCorner; 13 int Crack; 13 14 int Hessiantype; 14 15 int Metrictype; -
issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
r1 r3329 2 2 * \brief: implementation of the exceptions. 3 3 */ 4 5 4 6 5 #include "../shared.h" … … 10 9 11 10 what_str=what_arg; 11 file_name=""; 12 12 function_name=what_function; 13 file_line=0; 14 } 15 16 ErrorException::ErrorException(string what_arg){ 17 18 what_str=what_arg; 19 file_name=""; 20 function_name=""; 21 file_line=0; 22 } 23 24 ErrorException::ErrorException(string what_file,string what_function,int what_line,string what_arg){ 25 26 what_str=what_arg; 27 file_name=what_file; 28 function_name=what_function; 29 file_line=what_line; 13 30 } 14 31 … … 22 39 void ErrorException::Report(){ 23 40 24 _printf_("%s%s%s",function_name.c_str()," error message: ",what()); 41 if (function_name==""){ 42 _printf_("%s%s"," error message: ",what()); 43 } 44 else if (file_line==0){ 45 _printf_("%s%s%s",function_name.c_str()," error message: ",what()); 46 } 47 else{ 48 _printf_("\n%s%s%s%i\n","??? Error using ==> ",file_name.c_str()," at ",file_line); 49 _printf_("%s%s%s\n\n",function_name.c_str()," error message: ",what()); 50 } 25 51 return; 26 52 } 27 28 -
issm/trunk/src/c/shared/Exceptions/exceptions.h
r1 r3329 17 17 class ErrorException: public exception { 18 18 19 string what_str; 20 string function_name; 19 string what_str; 20 string function_name; 21 string file_name; 22 int file_line; 21 23 22 24 public: 23 25 24 ErrorException(const string &what_function,const string &what_arg); 26 ErrorException(const string &what_function,const string &what_arg);//default 27 ErrorException(const string &what_arg); //for windows 28 ErrorException(string what_file,string what_function,int what_line,string what_arg);//UNIX 25 29 ~ErrorException() throw(); 26 30 … … 29 33 void Report(); 30 34 31 32 35 }; 33 34 36 35 37 char* exprintf(char* format,...);
Note:
See TracChangeset
for help on using the changeset viewer.