ElementComputations.h File Reference

#include <FE.h>
#include <Dof.h>

Go to the source code of this file.

Functions

void usage (FE &fe)
void usage (FE &v_fe, FE &p_fe)
void compute_Poisson_element_matrix (FE &fe, Dof &dof, std::map< std::pair< int, int >, GiNaC::ex > &A)
void compute_Stokes_element_matrix (FE &v_fe, FE &p_fe, Dof &dof, std::map< std::pair< int, int >, GiNaC::ex > &A)
void compute_mixed_Poisson_element_matrix (FE &v_fe, FE &p_fe, Dof &dof, std::map< std::pair< int, int >, GiNaC::ex > &A)


Function Documentation

void compute_mixed_Poisson_element_matrix FE v_fe,
FE p_fe,
Dof dof,
std::map< std::pair< int, int >, GiNaC::ex > &  A
 

Definition at line 112 of file ElementComputations.cpp.

References div(), FE::dof(), FE::getPolygon(), Dof::glob_dof(), inner(), Dof::insert_dof(), Polygon::integrate(), FE::N(), and FE::nbf().

Referenced by main().

00117 {
00118   std::pair<int,int> index; 
00119   std::pair<int,int> index2; 
00120 
00121   // FIXME: need to check that p_fe 
00122   // contains the same domain
00123   Polygon& domain = v_fe.getPolygon(); 
00124 
00125    // Insert the local degrees of freedom into the global Dof
00126   for (int i=0; i< v_fe.nbf(); i++) {
00127     dof.insert_dof(1,i,v_fe.dof(i)); 
00128   }
00129   for (int i=0; i< p_fe.nbf(); i++) {
00130     dof.insert_dof(1,v_fe.nbf()+i+1,p_fe.dof(i)); 
00131   }
00132 
00133 
00134 
00135   // The term (u,v)  
00136   for (int i=0; i< v_fe.nbf(); i++) {
00137     index.first = dof.glob_dof(v_fe.dof(i));     // fetch the global dof related to i and v   
00138     for (int j=0; j< v_fe.nbf(); j++) {
00139       index.second = dof.glob_dof(v_fe.dof(j));  // fetch the global dof related to j and p 
00140       GiNaC::ex mass = inner(v_fe.N(i),v_fe.N(j));            // compute the integrand
00141       GiNaC::ex Aij = domain.integrate(mass);          // compute the integral  
00142       A[index] += Aij;                           // add to global matrix 
00143     }
00144   }
00145 
00146   // The term -(div u, q)  
00147   for (int i=0; i< p_fe.nbf(); i++) {
00148     index.first = dof.glob_dof(p_fe.dof(i));     // fetch the global dof for p_i  
00149     for (int j=0; j< v_fe.nbf(); j++) {
00150       index.second=dof.glob_dof(v_fe.dof(j));    // fetch the global dof for v_j  
00151       GiNaC::ex divV= -p_fe.N(i)*div(v_fe.N(j));  // compute the integrand 
00152       GiNaC::ex Aij = domain.integrate(divV);    // compute the integral  
00153       A[index] += Aij;                           // add to global matrix  
00154 
00155       // Do not need to compute the term (grad(p),v), since the system is 
00156       // symmetric we simply set Aji = Aij 
00157       index2.first = index.second; 
00158       index2.second = index.first; 
00159       A[index2] += Aij; 
00160     }
00161   }
00162 }

void compute_Poisson_element_matrix FE fe,
Dof dof,
std::map< std::pair< int, int >, GiNaC::ex > &  A
 

Definition at line 25 of file ElementComputations.cpp.

References FE::dof(), FE::getPolygon(), Dof::glob_dof(), grad(), inner(), Dof::insert_dof(), Polygon::integrate(), FE::N(), and FE::nbf().

00029 {
00030   std::pair<int,int> index; 
00031 
00032    // Insert the local degrees of freedom into the global Dof
00033   for (int i=0; i< fe.nbf(); i++) {
00034     dof.insert_dof(1,i,fe.dof(i)); 
00035   }
00036 
00037   Polygon& domain = fe.getPolygon(); 
00038 
00039   // The term (grad u, grad v)  
00040   for (int i=0; i< fe.nbf(); i++) {
00041     index.first = dof.glob_dof(fe.dof(i));       // fetch the global dof for Ni 
00042     for (int j=0; j< fe.nbf(); j++) {
00043       index.second = dof.glob_dof(fe.dof(j));    // fetch the global dof for Nj 
00044       GiNaC::ex nabla = inner(grad(fe.N(i)),     // compute the integrand
00045                               grad(fe.N(j))); 
00046       GiNaC::ex Aij = domain.integrate(nabla);   // compute the integral  
00047       A[index] += Aij;                           // add to global matrix 
00048     }
00049   }
00050 }

void compute_Stokes_element_matrix FE v_fe,
FE p_fe,
Dof dof,
std::map< std::pair< int, int >, GiNaC::ex > &  A
 

Definition at line 54 of file ElementComputations.cpp.

References div(), FE::dof(), FE::getPolygon(), Dof::glob_dof(), grad(), inner(), Dof::insert_dof(), Polygon::integrate(), FE::N(), and FE::nbf().

Referenced by main().

00059 {
00060   std::pair<int,int> index; 
00061   std::pair<int,int> index2; 
00062 
00063   // FIXME: need to check that p_fe 
00064   // contains the same domain
00065   Polygon& domain = v_fe.getPolygon(); 
00066 
00067    // Insert the local degrees of freedom into the global Dof
00068   for (int i=0; i< v_fe.nbf(); i++) {
00069     dof.insert_dof(1,i,v_fe.dof(i)); 
00070   }
00071   for (int i=0; i< p_fe.nbf(); i++) {
00072     dof.insert_dof(1,v_fe.nbf()+i,p_fe.dof(i)); 
00073   }
00074 
00075 
00076 
00077 
00078   // The term (grad u, grad v)  
00079   for (int i=0; i< v_fe.nbf(); i++) {
00080     index.first = dof.glob_dof(v_fe.dof(i));     // fetch the global dof for v_i 
00081     for (int j=0; j< v_fe.nbf(); j++) {
00082       index.second = dof.glob_dof(v_fe.dof(j));  // fetch the global dof for v_j 
00083       GiNaC::ex nabla = inner(grad(v_fe.N(i)),
00084                               grad(v_fe.N(j)));  // compute the integrand  
00085       GiNaC::ex Aij = domain.integrate(nabla);   // compute the integral  
00086       A[index] += Aij;                           // add to global matrix 
00087     }
00088   }
00089 
00090 
00091 
00092   // The term -(div u, q)  
00093   for (int i=0; i< p_fe.nbf(); i++) {
00094     index.first = dof.glob_dof(p_fe.dof(i));     // fetch the global dof for p_i  
00095     for (int j=0; j< v_fe.nbf(); j++) {
00096       index.second=dof.glob_dof(v_fe.dof(j));    // fetch the global dof for v_j  
00097       GiNaC::ex divV= -p_fe.N(i)*div(v_fe.N(j));  // compute the integrand 
00098       GiNaC::ex Aij = domain.integrate(divV);    // compute the integral  
00099       A[index] += Aij;                           // add to global matrix  
00100 
00101       // Do not need to compute the term (grad(p),v), since the system is 
00102       // symmetric. We simply set Aji = Aij 
00103       index2.first = index.second; 
00104       index2.second = index.first; 
00105       A[index2] += Aij; 
00106     }
00107   }
00108 }

void usage FE v_fe,
FE p_fe
 

Definition at line 11 of file ElementComputations.cpp.

References FE::dof(), grad(), FE::N(), and FE::nbf().

00011                                {
00012   for (int i=0; i< v_fe.nbf(); i++) {
00013     cout <<"v_fe.N("<<i<<")         =   "<<v_fe.N(i)<<endl;
00014     cout <<"grad(v_fe.N("<<i<<"))   =   "<<grad(v_fe.N(i))<<endl;
00015     cout <<"v_fe.dof("<<i<<")       =   "<<v_fe.dof(i)<<endl;
00016   }
00017   for (int i=0; i< p_fe.nbf(); i++) {
00018     cout <<"p_fe.N("<<i<<")=   "<<p_fe.N(i)<<endl;
00019     cout <<"p_fe.dof("<<i<<")= "<<p_fe.dof(i)<<endl;
00020   }
00021 }

void usage FE fe  ) 
 

Definition at line 3 of file ElementComputations.cpp.

References FE::dof(), grad(), FE::N(), and FE::nbf().

00003                    {
00004   for (int i=0; i< fe.nbf(); i++) {
00005     cout <<"fe.N("<<i<<")         =   "<<fe.N(i)<<endl;
00006     cout <<"grad(fe.N("<<i<<"))   =   "<<grad(fe.N(i))<<endl;
00007     cout <<"fe.dof("<<i<<")       =   "<<fe.dof(i)<<endl;
00008   }
00009 }


Generated on Wed Apr 19 12:38:14 2006 for SyFi by  doxygen 1.4.4