DealBaseDoFs Class Reference

#include <dealbasedofs.h>

List of all members.

Public Member Functions

 DealBaseDoFs ()
 ~DealBaseDoFs ()
void projectDofSolutionAtVertice (const DoFHandler< 3 > &dofs, int deg, const VecDouble &vDofSol, VecDouble &vSol)
void printCellDofsInformation (const DoFHandler< 2 > &dofs, std::ostream &out)
void printCellDofsInformation (const DoFHandler< 3 > &dofs)
void getCentralValuesFromDofs (DoFHandler< 3 > &dof, const VecDouble &sol, VecDouble &cValues, unsigned component)
void printFE (FiniteElement< 3 > &fe)
void getValuesAtCells (DoFHandler< 3 > &dofs, const VecDouble &sol, VecDouble cValues)
template<class Vetor >
void getValuesAtFaces (DoFHandler< 3 > &dof, const Vetor &sol, Matrix &Mvalues, const std::vector< unsigned > &components, const bool homMesh)

Static Public Member Functions

static DoFCell getDoFCellAtPoint (const DoFHandler< 3 > &dof, const Point< 3 > &p)
static DoFCell getAdjDoFCell (DoFCell cell, CellDirection3D dir)
static double getDoFVerticeValue (DoFCell cell, VertexDirection3D dir, unsigned deg, const VecDouble &vSol)
static void getVerticeValuesFromDofs (DoFHandler< 3 > &dofs, const VecDouble &vSol, VecDouble &vVerticesValues, unsigned deg)

Detailed Description

Definition at line 9 of file dealbasedofs.h.


Constructor & Destructor Documentation

DealBaseDoFs::DealBaseDoFs (  )  [inline]

Definition at line 16 of file dealbasedofs.h.

00016 {}

DealBaseDoFs::~DealBaseDoFs (  )  [inline]

Definition at line 17 of file dealbasedofs.h.

00017 {}


Member Function Documentation

DoFCell DealBaseDoFs::getAdjDoFCell ( DoFCell  cell,
CellDirection3D  dir 
) [static]

Objetivo: Get the DoFCell adjacent to the current cell.

Parametros: dir = Direction of the cell adjacent in relation of the current cell cell = Cell in the neighbour. Retorno:

Definition at line 30 of file dealbasedofs.cpp.

00031 {
00032   if (cell->face(dir)->at_boundary())
00033     return DoFCell();
00034   else
00035     return cell->neighbor(dir);
00036 }

void DealBaseDoFs::getCentralValuesFromDofs ( DoFHandler< 3 > &  dof,
const VecDouble sol,
VecDouble cValues,
unsigned  component 
)

This function retrives the value of a component solution of a finite element problem for each center point of the mesh cells putting the values in the vector cValues.

Parameters:
dofs The DOF Handler used in the problem.
sol Vector containing the values of degree of freedom.
cValues (Output) Vector indexed by the cells numbers to contain the Central values of the finite element solution

Definition at line 227 of file dealbasedofs.cpp.

00228 {
00229   assert(sol.size() == dof.n_dofs());
00230   assert(cValues.size() == dof.get_tria().n_active_cells());
00231   assert(component < dof.get_fe().n_components());
00232 
00233   QMidpoint<DIM> qMidPoint;
00234   FEValues<DIM> fe_values(dof.get_fe(),qMidPoint,update_values);
00235 
00236   const unsigned int   dofs_per_cell = dof.get_fe().dofs_per_cell;
00237  
00238  std::vector<unsigned int> local_dof_indices (dofs_per_cell);
00239  
00240  DoFHandler<3>::active_cell_iterator cell = dof.begin_active(),
00241    endc = dof.end();
00242 
00243  double acum;
00244  for (; cell!=endc; ++cell)
00245  {
00246    fe_values.reinit (cell);
00247    acum =0.0;
00248    cell->get_dof_indices(local_dof_indices);
00249    for (unsigned int i=0; i<dofs_per_cell; ++i)
00250    {
00251      acum+= sol(local_dof_indices[i])*fe_values.shape_value_component(i,0,component);
00252    }
00253    cValues(cell->index())=acum;
00254  }
00255   
00256 }

static DoFCell DealBaseDoFs::getDoFCellAtPoint ( const DoFHandler< 3 > &  dof,
const Point< 3 > &  p 
) [static]
double DealBaseDoFs::getDoFVerticeValue ( DoFCell  cell,
VertexDirection3D  dir,
unsigned  deg,
const VecDouble vSol 
) [static]

Objetivo: Obter o valor do grau de liberdade (deg), no vertice (dir) da celula (cell) da solucao (vSol).

Definition at line 43 of file dealbasedofs.cpp.

00044 {
00045   assert(cell->vertex_dof_index(dir,deg) < vSol.size());
00046   return vSol(cell->vertex_dof_index(dir,deg));
00047 }

void DealBaseDoFs::getValuesAtCells ( DoFHandler< 3 > &  dofs,
const VecDouble sol,
VecDouble  cValues 
)
template<class Vetor >
void DealBaseDoFs::getValuesAtFaces ( DoFHandler< 3 > &  dof,
const Vetor &  sol,
Matrix Mvalues,
const std::vector< unsigned > &  components,
const bool  homMesh 
) [inline]

Get the values of the solution given in the vector sol in each face midpoint. The values are returned in the Matrix Mvalues that has dimensions of ( number of faces x number of components). The components of the solution we want to be copied to the Mvalues is set by the parameter vector "components". In the the position (i,j) in the matrix Mvalues is the value of the component with number (components[j]) belonging to the face [i]

Parameters:
dofs 
sol Solution of the problem
Mvalues Matrix to contain the components values of the faces
components The components we want from the solution. Remeber that each component is a primary variable in the finite element system. Boolean indicating if the mesh is homogeneous (i.e all elements has the same shape and dimensions). This boolean exists for optimization purposes. If the mesh is homogeneous we dont need to always use the function fe_values.reinit(cell) to update fe_values with the values of the cells since all cells have the same geometry and identical shape functions. If the user set homMesh, and the mesh is not homogeneous THE METHOD RETURNS WRONG RESULTS.
Returns:

Definition at line 65 of file dealbasedofs.h.

00066 {
00067   assert(Mvalues.n() == components.size());
00068   assert(Mvalues.m() == dof.get_tria().n_active_faces());
00069   std::vector<Point<3> > points;
00070   points.push_back(Point<3>(0,0.5,0.5)); // MidPoint of the left face
00071   points.push_back(Point<3>(1,0.5,0.5)); // MidPoint of the right face
00072   points.push_back(Point<3>(0.5,0,0.5)); // MidPoint of the front face
00073   points.push_back(Point<3>(0.5,1,0.5)); // MidPoint of the back face
00074   points.push_back(Point<3>(0.5,0.5,0)); // MidPoint of the bottom face
00075   points.push_back(Point<3>(0.5,0.5,1)); // MidPoint of the up face
00076   std::vector<double> weights(6,1);
00077   unsigned n_quadrature_points = points.size();
00078   
00079   Quadrature<3> quad(points,weights);
00080 
00081   FEValues<DIM> fe_values(dof.get_fe(),quad,update_values);
00082 
00083   const unsigned int   dofs_per_cell = dof.get_fe().dofs_per_cell;
00084   const unsigned int n_components = components.size();
00085   std::vector<unsigned int> local_dof_indices (dofs_per_cell);
00086 
00087   
00088  DoFHandler<3>::active_cell_iterator cell = dof.begin_active(),
00089    endc = dof.end();
00090 
00091 
00092  if (homMesh)
00093    fe_values.reinit (cell);
00094  for (; cell!=endc; ++cell)
00095  {
00096    if (!homMesh)
00097      fe_values.reinit (cell);
00098 
00099    cell->get_dof_indices(local_dof_indices);
00100 
00101    //For each quadratue point
00102    for (unsigned q_point=0;q_point < n_quadrature_points;q_point++)
00103    {
00104      //The quadrature points are organized such that each qpoint
00105      //indice correspond to the indice of its face.
00106      //values points to the beginning of the line belonging to the current face 
00107      double *values = &(Mvalues(cell->face_index(q_point),0));
00108 
00109      //Now for each component
00110      for (unsigned j=0;j < n_components;j++)
00111      {
00112        double acum = 0.0;
00113        //For each shape function
00114        for (unsigned int i=0; i<dofs_per_cell; ++i)
00115        {
00116          acum += sol(local_dof_indices[i])*fe_values.shape_value_component(i,q_point,components[j]);
00117        }
00118        values[j]=acum;
00119 
00120      }
00121    }
00122  }
00123 }

static void DealBaseDoFs::getVerticeValuesFromDofs ( DoFHandler< 3 > &  dofs,
const VecDouble vSol,
VecDouble vVerticesValues,
unsigned  deg 
) [static]
void DealBaseDoFs::printCellDofsInformation ( const DoFHandler< 3 > &  dofs  ) 

Definition at line 73 of file dealbasedofs.cpp.

00074  {
00075   const  DoFHandler<DIM> &dof = dofs;
00076   DoFHandler<DIM>::active_cell_iterator cell = dof.begin_active(),
00077                                       endc = dof.end();
00078   int dofs_per_face = dof.get_fe().n_dofs_per_face();
00079   vector<unsigned> dofs_face(dofs_per_face);
00080   
00081   for (;cell!=endc; ++cell)
00082     {
00083       printf("\n==================\nCell %d at <%3g,%3g,%3g>\n",cell->index(),
00084              cell->barycenter()[0],
00085              cell->barycenter()[1],
00086              cell->barycenter()[2]);
00087       if (dofs_per_face > 0)
00088       {
00089         printf("Dof at Faces:\n");
00090         
00091         for (unsigned i=0;i<GeometryInfo<DIM>::faces_per_cell;i++)
00092         {
00093           
00094           printf("%d)  Index: %d Dofs:",i,cell->face(i)->index());
00095           cell->face(i)->get_dof_indices(dofs_face);
00096           for (int j=0;j<dofs_per_face;j++)
00097           {
00098             printf("%d ",dofs_face[j]);
00099           }
00100           printf("\n");
00101         }
00102       }
00103     }
00104 }

void DealBaseDoFs::printCellDofsInformation ( const DoFHandler< 2 > &  dofs,
std::ostream &  out 
)

Definition at line 51 of file dealbasedofs.cpp.

00052  {
00053   const  DoFHandler<2> &dof = dofs;
00054   DoFHandler<2>::active_cell_iterator cell = dof.begin_active(),
00055                                       endc = dof.end();
00056   char strOut[500];
00057   
00058   for (;cell!=endc; ++cell)
00059     {
00060       sprintf(strOut,"\n==================\nCell %d:\nDoFs: %d\n\nVertices:\n",cell->index(),dof.get_fe().dofs_per_cell);
00061       out << strOut;
00062       for (unsigned i=0;i<GeometryInfo<DIM>::vertices_per_cell;i++)
00063       {
00064         sprintf(strOut,"\n%d) Pt: <%6g,%6g>, Index: %d, Dofs Index:",i,cell->vertex(i)(0),cell->vertex(i)(1),cell->vertex_index(i));
00065         out << strOut;
00066         for (unsigned j=0;j<dof.get_fe().dofs_per_vertex;j++)
00067         {
00068           out << cell->vertex_dof_index(i,j) << " ";
00069         }  
00070       }
00071     }
00072 }

void DealBaseDoFs::printFE ( FiniteElement< 3 > &  fe  ) 

This is just a debug function for printing information about a finite element

Parameters:
fe The finite element whose data is to be printed.
Returns:

Definition at line 136 of file dealbasedofs.cpp.

00137 {
00138   cout << "Finite Element Name: " << fe.get_name() << std::endl;
00139   cout << "Is primitive: " << fe.is_primitive() << std::endl;
00140   cout << "Num Base Elements: " << fe.n_base_elements() << std::endl;
00141   cout << "Num components: " << fe.n_components() << std::endl;
00142   //  cout << "Num DOFS per object: " << fe.n_dofs_per_object() << std::endl;
00143   cout << "DOFS per vertex: " << fe.n_dofs_per_vertex() << std::endl;
00144   cout << "DOFS per line: " << fe.n_dofs_per_line() << std::endl;
00145   cout << "DOFS per quad: " << fe.n_dofs_per_quad() << std::endl;
00146   cout << "DOFS per hex: " << fe.n_dofs_per_hex() << std::endl;
00147   cout << "DOFS per face: " << fe.n_dofs_per_face() << std::endl;
00148   cout << "DOFS per cell: " << fe.n_dofs_per_cell() << std::endl;
00149   
00150   cout << "Unit Support Points: " <<  std::endl;
00151 
00152   const std::vector<Point<3> > &vPts = fe.get_unit_support_points();
00153   for (unsigned i =0; i < vPts.size(); i++)
00154     printf("%d) %g, %g, %g\n", i, vPts[i](0), vPts[i](1) , vPts[i](2));
00155   if (vPts.size() == 0)
00156     printf("None\n");
00157 
00158 
00159 
00160 
00161   //Now to see the values of the shape functions we need a triangulation
00162   //with one element in it.
00163   Triangulation<3> tria;
00164   Point<3> P1(0,0,0);
00165   Point<3> P2(1,1,1);
00166   std::vector<unsigned> v(3);
00167   v[0]=2;
00168   v[1]=2;
00169   v[2]=2;
00170   GridGenerator::subdivided_hyper_rectangle(tria,v,P1,P2);
00171 
00172 
00173   //We need a dofHandler too
00174   DoFHandler<3> dof(tria);
00175   dof.distribute_dofs(fe);
00176   DoFHandler<3>::active_cell_iterator cell = dof.begin_active();
00177 
00178   //Define the points where we will extract the values of the shape function.
00179   //These points are stored in the vector v and passed as argumento to the Quadrature class
00180   //who is responsible for the gaussian integration.
00181   std::vector<Point<3> > vQuad;
00182   vQuad.push_back(Point<3>(0,0,0));
00183   vQuad.push_back(Point<3>(1,0,0));
00184   vQuad.push_back(Point<3>(0,1,0));
00185   vQuad.push_back(Point<3>(1,1,0));
00186   vQuad.push_back(Point<3>(0,0,1));
00187   vQuad.push_back(Point<3>(1,0,1));
00188   vQuad.push_back(Point<3>(0,1,1));
00189   vQuad.push_back(Point<3>(1,1,1));
00190 
00191   std::vector<double> vWeights(8,1);
00192   Quadrature<3> quad(vQuad,vWeights);
00193   FEValues<3> feValues(fe,quad,UpdateFlags(update_values | update_JxW_values));
00194   feValues.reinit(cell);
00195 
00196 
00197   cout << "Shape Values At Vertex: " <<std::endl;
00198   for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
00199   {
00200     cout << "Shape Value: " << i <<"\n";
00201     for (unsigned int q_point=0; q_point < quad.size(); ++q_point)
00202     {
00203       cout << vQuad[q_point] << ":\t";
00204       for (unsigned int component=0; component < fe.n_components(); component++)
00205       {
00206         //cout << fe.shape_value_component(i, quad.point(q_point), component) << "\t";
00207         cout << feValues.shape_value_component(i,q_point,component);
00208         //cout << feValues.shape_value(i,q_point);
00209 
00210       }
00211       cout << std::endl;
00212     }
00213   }
00214   
00215   //  for (unsigned i=0;i<
00216 
00217 
00218 }

void DealBaseDoFs::projectDofSolutionAtVertice ( const DoFHandler< 3 > &  dofs,
int  deg,
const VecDouble vDofSol,
VecDouble vSol 
)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:00 2012 for CO2INJECTION by  doxygen 1.6.3