00001 #include "vecdoubleghost.h" 00002 00003 00004 00005 00006 void GhostBC::setGhostCellAsMirror(unsigned ghostIndex,unsigned cellIndex) 00007 { 00008 assert(ghostIndex >= m_mesh.numCells()); 00009 assert(cellIndex < m_mesh.numCells()); 00010 unsigned index = ghostIndex-m_mesh.numCells(); 00011 assert(index < m_vIndices.size()); 00012 m_vIndices[index]=cellIndex; 00013 } 00014 00015 00016 00017 void GhostBC::setGhostBC(Function3D &f) 00018 { 00019 unsigned _numBC=0; 00020 OrthoMesh::Face_It face = mesh.begin(); 00021 OrthoMesh::Face_It endf = mesh.end(); 00022 00023 for(;face!=endf;face++) 00024 { 00025 if (face->at_boundary()) 00026 { 00027 Point3D p; 00028 face->barycenter(p); 00029 face->ghostAdjCellIndices(cell1,cell2); 00030 if (isGhostIndex(cell1)) 00031 { 00032 ghostIndex=cell1; 00033 cellIndex=cell2; 00034 } 00035 else 00036 { 00037 assert(isGhostIndex(cell2)); 00038 ghostIndex=cell2; 00039 cellIndex=cell1; 00040 } 00041 if (f.isInDomain(p)) 00042 m_vIndices[ghostIndex-off]=_off+_numBC++; 00043 else 00044 setGhostCellAsMirror(ghostIndex,cellIndex); 00045 } 00046 } 00047 00048 } 00049 00050 void GhostBC::setGhostBCVector(Function3D &f,VecDouble &v) 00051 { 00052 v.reinit(_numBC); 00053 OrthoMesh::Face_It face = mesh.begin(); 00054 OrthoMesh::Face_It endf = mesh.end(); 00055 00056 for(;face!=endf;face++) 00057 { 00058 if (face->at_boundary()) 00059 { 00060 Point3D p; 00061 face->barycenter(p); 00062 face->ghostAdjCellIndices(cell1,cell2); 00063 ghostIndex=isGhostIndex(cell1) ? cell1 : cell2; 00064 if (f.isInDomain(p)) 00065 { 00066 assert(!isMirrorBC(ghostIndex)); 00067 v(getPrescribedBCIndex(ghostIndex))=f.value(p); 00068 } 00069 else 00070 { 00071 assert(isMirrorBC(ghostIndex)); 00072 } 00073 } 00074 } 00075 } 00076 00077 00078 bool GhostBC::isMirrorBC(Index ghostIndex) 00079 { 00080 assert(ghostIndex >= _off); 00081 return m_vIndices[ghostIndex-_off] < _off; 00082 } 00083 00084 Index GhostBC::getPrescribedBCIndex(Index ghostIndex) 00085 { 00086 assert(!isMirrorBC(ghostIndex)); 00087 return m_vIndices[ghostIndex-_off]-_off; 00088 } 00089 00090 00091 bool GhostBC::isGhostIndex(Index ghostIndex) 00092 { 00093 return ghostIndex >= _off; 00094 }