SimpleMesh.cpp

Go to the documentation of this file.
00001 #include <SimpleMesh.h>
00002 
00003 Square:: Square(GiNaC::ex x0_, GiNaC::ex xn_, int nx_, int ny_) {
00004   x0 = x0_; 
00005   xn = xn_; 
00006   nx = nx_; 
00007   ny = ny_;
00008 }
00009 
00010 int Square::no_of_triangles() {
00011   return 2*(nx-1)*(ny-1);  
00012 }
00013 
00014 int Square:: no_of_boundary_nodes() {
00015   return 2*nx + 2*(ny-2);  
00016 }
00017 
00018 GiNaC::ex Square:: boundary_node( int i) {
00019   if (i>= 0 && i <= nx-1 ) {  
00020     GiNaC::ex dx = (xn.op(0) - x0.op(0))/(nx-1); 
00021     return GiNaC::lst(x0.op(0) + (i-1)*dx, x0.op(1));  
00022   } else if (i >= nx && i <= nx+ny-2) { 
00023     GiNaC::ex dy = (xn.op(1) - x0.op(1))/(ny-1); 
00024     return GiNaC::lst(xn.op(0), x0.op(1) + (i-nx)*dy);  
00025   } else if (i >= nx+ny-1 && i <= 2*nx+ny-3) { 
00026     GiNaC::ex dx = (xn.op(0) - x0.op(0))/(nx-1); 
00027     return GiNaC::lst(xn.op(0) - dx*(i-nx-ny+1) , xn.op(1));    
00028   } else if (i >= 2*nx+ny-2&& i <= no_of_boundary_nodes() ) {
00029     GiNaC::ex dy = (xn.op(1) - x0.op(1))/(ny-1); 
00030     return GiNaC::lst(x0.op(0), xn.op(1) - (i-2*nx-ny+2)*dy);  
00031   }
00032   return DUMMY; 
00033 }
00034 
00035 Triangle Square::triangle(int i) {
00036   GiNaC::ex dx = (xn.op(0) - x0.op(0))/(nx-1); 
00037   GiNaC::ex dy = (xn.op(1) - x0.op(1))/(ny-1); 
00038 
00039   int box = (i-1)/2+1; 
00040 
00041   GiNaC::ex p0,p1,p2,p3; 
00042   p0 = GiNaC::lst(0,0,0); 
00043   p0 = GiNaC::lst(x0.op(0) + ((box-1)%(nx-1))*dx, x0.op(1)     + ((box-1)/(ny-1))*dy);     
00044   p1 = GiNaC::lst(x0.op(0) + (((box-1)%(nx-1))+1)*dx, x0.op(1) + ((box-1)/(ny-1))*dy);     
00045   p2 = GiNaC::lst(x0.op(0) + ((box-1)%(nx-1))*dx, x0.op(1)     + (((box-1)/(ny-1))+1)*dy);     
00046   p3 = GiNaC::lst(x0.op(0) + (((box-1)%(nx-1))+1)*dx, x0.op(1) + (((box-1)/(ny-1))+1)*dy);     
00047 
00048   if (i%2 == 1) {
00049     return Triangle(p0,p1,p2); 
00050   } else if ( i%2 == 0) {
00051     return Triangle(p3,p1,p2); 
00052   }
00053   return Triangle(DUMMY,DUMMY,DUMMY); 
00054 }
00055 
00056 

Generated on Tue Mar 21 13:16:30 2006 for SyFi by  doxygen 1.4.4