00001 #include "feorthosystem.h" 00002 00003 00004 FEOrthoSystem::FEOrthoSystem(FEOrthoMesh &fe,unsigned multiplicity) 00005 :_fes(multiplicity,&fe) 00006 { 00007 assert(multiplicity > 0); 00008 this->_fe_dof_offsets.resize(_fes.size()); 00009 00010 00011 //_local_dof_offset[i] means the offset where the dofs 00012 //of the element i in the 00013 //vector of finite element _fes begin to be counted. 00014 //If _local_dof_offset[2]=7 means that the 3 element in _fes 00015 //has its first dof counted starting from 7 00016 _fe_dof_offsets[0]=0; 00017 for (unsigned i=1;i<_fes.size();i++) 00018 { 00019 _fe_dof_offsets[i]=_fe_dof_offsets[i-1]+_fes[i-1]->n_local_dofs(); 00020 } 00021 00022 //Now get the number of local dofs in the FE System 00023 //and the number of fields 00024 unsigned total_dofs=0; 00025 _n_fields=0; 00026 for (unsigned i=0;i<_fes.size();i++) 00027 { 00028 _n_fields+=_fes[i]->n_fields(); 00029 total_dofs+=_fes[i]->n_local_dofs(); 00030 } 00031 //Reset the global_map vector with the total dofs in 00032 //the system 00033 _global_map.resize(total_dofs); 00034 00035 //Create the dof to field number map 00036 _dof_field_map.resize(total_dofs); 00037 unsigned field_off=0; 00038 for (unsigned i=0;i<_fes.size();i++) 00039 { 00040 unsigned n_local_dofs = _fes[i]->n_local_dofs(); 00041 for (unsigned dofs=0;dofs<n_local_dofs;dofs++) 00042 { 00043 _dof_field_map[field_off+dofs]=_fes[i]->local_dof_field(dofs); 00044 } 00045 field_off+=_fes[i]->n_fields(); 00046 } 00047 } 00048 00049 00050 00051 00052 00053 00058 void FEOrthoSystem::reinit(OrthoMesh &mesh) 00059 { 00060 //Do reinit for all its finite elements 00061 std::vector<FEOrthoMesh*>::iterator it; 00062 for ( it= _fes.begin();it!=_fes.end();it++) 00063 { 00064 (*it)->reinit(mesh); 00065 } 00066 } 00067 00068 00069 00070 const VecIndex& FEOrthoSystem::get_global_map(OrthoMesh::Cell_It &cell) 00071 { 00072 VecIndex::iterator it = _global_map.begin(); 00073 for (unsigned feI=0;feI<_fes.size();feI++) 00074 { 00075 const VecIndex &fe_global_map=_fes[feI]->get_global_map(cell); 00076 unsigned offset = _fe_dof_offsets[feI]; 00077 for (unsigned i=0;i<fe_global_map.size();i++) 00078 { 00079 *it++=offset+fe_global_map[i]; 00080 } 00081 } 00082 assert(it==_global_map.end()); 00083 return _global_map; 00084 00085 } 00086 00087 00088 00089 00090 Index FEOrthoSystem::local_dof_field(Index dof) 00091 { 00092 assert(dof < _dof_field_map.size()); 00093 return _dof_field_map[dof]; 00094 00095 }