00001 #include "dealfewrapper.h"
00002 #include <grid/grid_generator.h>
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 DealFEWrapper::DealFEWrapper()
00041 {
00042 m_fev=NULL;
00043 m_pTria=NULL;
00044 m_pDof=NULL;
00045 m_fe=NULL;
00046 m_pMesh=NULL;
00047 }
00048
00049
00050 void DealFEWrapper::initFEValues(OrthoMesh &mesh,const FiniteElement<3> &fe, const Quadrature<3> &quadrature, const Quadrature<2> &face_quadrature,const UpdateFlags update_flags,const UpdateFlags face_update_flags)
00051 {
00052 m_pMesh=&mesh;
00053 m_fe=&fe;
00054 m_pTria= new Triangulation<3>();
00055 Point3D P1(0,0,0);
00056 GridGenerator::hyper_rectangle(*m_pTria,P1,mesh.getDX());
00057 m_pDof = new DoFHandler<3>(*m_pTria);
00058 m_pDof->distribute_dofs(fe);
00059 m_pDoFCell = new DoFHandler<DIM>::active_cell_iterator(m_pDof->begin_active());
00060 m_fev = new FEValues<3>(fe,quadrature,update_flags);
00061 m_fev->reinit(*m_pDoFCell);
00062
00063
00064
00065 m_facesValues.resize(6,NULL);
00066 m_facesValues[UP_FACE] =new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00067 m_facesValues[BOTTOM_FACE]=new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00068 m_facesValues[LEFT_FACE] =new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00069 m_facesValues[RIGHT_FACE] =new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00070 m_facesValues[BACK_FACE] =new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00071 m_facesValues[FRONT_FACE] =new FEFaceValues<3>(fe,face_quadrature,face_update_flags);
00072
00073
00074 m_facesValues[LEFT_FACE ]->reinit(*m_pDoFCell,LEFT_FACE );
00075 m_facesValues[RIGHT_FACE ]->reinit(*m_pDoFCell,RIGHT_FACE );
00076 m_facesValues[BOTTOM_FACE]->reinit(*m_pDoFCell,BOTTOM_FACE);
00077 m_facesValues[UP_FACE ]->reinit(*m_pDoFCell,UP_FACE );
00078 m_facesValues[FRONT_FACE ]->reinit(*m_pDoFCell,FRONT_FACE );
00079 m_facesValues[BACK_FACE ]->reinit(*m_pDoFCell,BACK_FACE) ;
00080 }
00081
00082
00083 void DealFEWrapper::clear()
00084 {
00085 assert(m_pDof);
00086 m_pDof->clear();
00087 delete m_pDoFCell;
00088 delete m_pDof;
00089 delete m_pTria;
00090 delete m_fev;
00091 for (unsigned i=0;i<6;i++)
00092 delete m_facesValues[i];
00093
00094 m_pDoFCell=NULL;
00095 m_pDof=NULL;
00096 m_pTria=NULL;
00097 m_fev=NULL;
00098 }
00099
00100 DealFEWrapper::~DealFEWrapper()
00101 {
00102 if (m_pDof)
00103 {
00104 this->clear();
00105 }
00106 }
00107 void DealFEWrapper::setCell(OrthoMesh::Cell_It &cell)
00108 {
00109 m_pCell=&cell;
00110 }
00111
00112
00113
00114
00115 Point3D DealFEWrapper::get_qpoint(unsigned qPoint)
00116 {
00117 assert(m_fev);
00118 Point3D pt = m_fev->get_quadrature_points()[qPoint];
00119 pt+=getCell()->vertex(VERTEX_000);
00120 return pt;
00121 }
00122
00123 Point3D DealFEWrapper::get_face_qpoint(unsigned qPoint)
00124 {
00125 assert(m_facesValues[m_faceDir]);
00126 Point3D pt = m_facesValues[m_faceDir]->get_quadrature_points()[qPoint];
00127 pt+=(*m_pCell)->vertex(VERTEX_000);
00128 return pt;
00129 }
00130
00131
00132
00133 void DealFEWrapper::setFace(OrthoMesh::Face_It &face)
00134 {
00135 m_faceDir = face->getFaceDir();
00136
00137 }
00138
00139
00140
00141
00142 void DealFEWrapper::printDealFEInfo()
00143 {
00144 assert(m_fe);
00145 printf("====Printing Finete Element====\n");
00146 printf("DOFS PER CELL %d\n",m_fe->n_dofs_per_cell());
00147 printf("DOFS PER FACE %d\n",m_fe->n_dofs_per_face());
00148 printf("DOFS PER HEX %d\n",m_fe->n_dofs_per_hex());
00149 printf("COMPONENTS %d\n",m_fe->n_components());
00150
00151 printf("LOCAL FACE LOCAL CELL MAPPING\n\n");
00152 for (unsigned face=0;face < GeometryInfo<3>::faces_per_cell;face++)
00153 {
00154 printf("FACE %d\n",face);
00155 for (unsigned i=0;i<m_fe->n_dofs_per_face();i++)
00156 {
00157 printf("\tDOF %d = %d\n",i,local_face_to_local_cell_map(face,i));
00158 }
00159 }
00160 printf("DOF TO COMPONENT MAPPING\n\n");
00161 for (unsigned dof=0;dof<n_dofs_per_cell();dof++)
00162 {
00163 printf("\tDof %d is Component %d\n",dof,local_dof_component(dof));
00164 }
00165
00166 }
00167
00168