00001 #include "orthomesh.h"
00002
00003
00004 OrthoFaceAccessorWithHoles::OrthoFaceAccessorWithHoles(const OrthoMesh &mesh,unsigned rawIndex)
00005 :OrthoFaceAccessor(mesh,rawIndex)
00006 {
00007 m_delFace = mesh._delFaceLst.begin();
00008 m_newIndex = mesh._delFaceLst.adjust(rawIndex,m_delFace);
00009 m_delFace= mesh._delFaceLst.findLUEntry(rawIndex);
00010
00011 m_delCell=mesh._delCellLst.begin();
00012 m_delVert=mesh._delVertLst.begin();
00013 m_bComputedAdjCells=false;
00014 }
00015
00016 OrthoFaceAccessorWithHoles::OrthoFaceAccessorWithHoles(const OrthoCellAccessorWithHoles &cell,FaceDirection3D dir)
00017 :OrthoFaceAccessor(cell,dir)
00018 {
00019 const OrthoMesh &mesh = cell.getMesh();
00020 m_delFace = mesh._delFaceLst.begin();
00021 m_newIndex = mesh._delFaceLst.adjust(m_index,m_delFace);
00022 m_delFace= mesh._delFaceLst.findLUEntry(m_index);
00023
00024 m_delCell=mesh._delCellLst.begin();
00025 m_delVert=mesh._delVertLst.begin();
00026 m_bComputedAdjCells=false;
00027 }
00028
00029
00030
00031 OrthoFaceAccessorWithHoles::OrthoFaceAccessorWithHoles(const OrthoFaceAccessor &face)
00032 {
00033 *this=face;
00034 const OrthoMesh &mesh=face.getMesh();
00035 m_delFace = mesh._delFaceLst.begin();
00036 m_newIndex = mesh._delFaceLst.adjust(m_index,m_delFace);
00037 m_delFace= mesh._delFaceLst.findLUEntry(m_index);
00038
00039 m_delCell=mesh._delCellLst.begin();
00040 m_delVert=mesh._delVertLst.begin();
00041 m_bComputedAdjCells=false;
00042
00043 }
00044
00045 OrthoFaceAccessorWithHoles::OrthoFaceAccessorWithHoles()
00046 {
00047 m_bComputedAdjCells=false;
00048
00049
00050 }
00056 void OrthoFaceAccessorWithHoles::updateAdjCells() const
00057 {
00058 if (m_bComputedAdjCells)
00059 {
00060 return;
00061 }
00062 else
00063 {
00064 OrthoFaceAccessor::getAdjCellIndices(m_cell1,m_cell2);
00065 if (m_cell1 != OrthoMesh::INVALID_INDEX)
00066 {
00067 m_cell1 = m_mesh->_delCellLst.convert(m_cell1,m_delCell);
00068 }
00069 if (m_cell2 != OrthoMesh::INVALID_INDEX)
00070 {
00071 m_cell2 = m_mesh->_delCellLst.convert(m_cell2,m_delCell);
00072 }
00073 m_bComputedAdjCells=true;
00074 }
00075 }
00076
00077
00078 void OrthoFaceAccessorWithHoles::getAdjCellIndices(unsigned &index1,unsigned &index2) const
00079 {
00080 assert(isValid());
00081 updateAdjCells();
00082 index1=m_cell1;
00083 index2=m_cell2;
00084 }
00085
00086 void OrthoFaceAccessorWithHoles::getValidCellIndices(unsigned &index1,unsigned &index2)
00087 {
00088 assert(isValid());
00089 updateAdjCells();
00090 index1=m_cell1;
00091 index2=m_cell2;
00092 if (index1 == OrthoMesh::INVALID_INDEX)
00093 index1=index2;
00094 if (index2 == OrthoMesh::INVALID_INDEX)
00095 index2=index1;
00096 }
00097
00098 bool OrthoFaceAccessorWithHoles::at_boundary()
00099 {
00100 assert(isValid());
00101 updateAdjCells();
00102 return (m_cell1 == OrthoMesh::INVALID_INDEX ||
00103 m_cell2 == OrthoMesh::INVALID_INDEX);
00104 }
00105
00106
00107 void OrthoFaceAccessorWithHoles::operator++(int)
00108 {
00109 assert(isValid());
00110 m_bComputedAdjCells=false;
00111 OrthoFaceAccessor &rawFace = *this;
00112 assert(rawFace.index() < m_delFace->index());
00113 rawFace++;
00114 if (rawFace.index() < m_delFace->index())
00115 {
00116 m_newIndex = m_delFace->adjust(rawFace.index());
00117 return;
00118 }
00119 else
00120 {
00121 do {
00122 rawFace++;
00123 m_delFace++;
00124 } while(rawFace.index() == m_delFace->index());
00125 m_newIndex = m_delFace->adjust(rawFace.index());
00126 }
00127 }
00128
00129
00130 bool OrthoFaceAccessorWithHoles::hasPosCell()
00131 {
00132 updateAdjCells();
00133 return m_cell2 != OrthoMesh::INVALID_INDEX;
00134 }
00135
00136
00137 bool OrthoFaceAccessorWithHoles::hasNegCell()
00138 {
00139 updateAdjCells();
00140 return m_cell1 != OrthoMesh::INVALID_INDEX;
00141 }
00142
00143 unsigned OrthoFaceAccessorWithHoles::getNegCell()
00144 {
00145 updateAdjCells();
00146 return m_cell2;
00147 }
00148
00149 unsigned OrthoFaceAccessorWithHoles::getPosCell()
00150 {
00151 updateAdjCells();
00152 return m_cell1;
00153 }
00154
00155
00156 void OrthoFaceAccessorWithHoles::ghostAdjCellIndices(unsigned &index1,unsigned &index2)
00157 {
00158 assert(this->isValid());
00159
00160 if (m_normal == OrthoMesh::NORMAL_X)
00161 {
00162 if (m_i == m_mesh->_nElemX)
00163 {
00164 index2 = m_mesh->_HGhostRightOff + m_j + m_k*m_mesh->_nElemY;
00165 index1 = m_index - m_j - m_k*m_mesh->_nElemY -1;
00166 }
00167 else if (m_i == 0)
00168 {
00169 index1 = m_mesh->_HGhostLeftOff + m_j + m_k*m_mesh->_nElemY;
00170 index2 = m_index - m_j - m_k*m_mesh->_nElemY;
00171 }
00172 else
00173 {
00174 index2 = m_index - m_j - m_k*m_mesh->_nElemY;
00175 index1 = index2 -1;
00176
00177
00178
00179 index1=m_mesh->_delCellLst.convertGhost(index1,m_delCell,m_mesh->_HGhostWellOff);
00180 index2=m_mesh->_delCellLst.convertGhost(index2,m_delCell,m_mesh->_HGhostWellOff);
00181
00182 }
00183 }
00184 if (m_normal == OrthoMesh::NORMAL_Y)
00185 {
00186 unsigned setIndex = m_index - m_mesh->_fyOff;
00187
00188 if (m_j == 0)
00189 {
00190 index2 = setIndex - m_k*m_mesh->_nElemX;
00191 index1 = m_mesh->_HGhostFrontOff + m_i + m_k*m_mesh->_nElemX;
00192 }
00193 else if (m_j == m_mesh->_nElemY)
00194 {
00195 index1 = setIndex - (m_k+1)*m_mesh->_nElemX;
00196 index2 = m_mesh->_HGhostBackOff + m_i + m_k*m_mesh->_nElemX;
00197 }
00198 else
00199 {
00200 index2 = setIndex - m_k*m_mesh->_nElemX;
00201 index1 = index2 - m_mesh->_nElemX;
00202
00203 index1=m_mesh->_delCellLst.convertGhost(index1,m_delCell,m_mesh->_HGhostWellOff);
00204 index2=m_mesh->_delCellLst.convertGhost(index2,m_delCell,m_mesh->_HGhostWellOff);
00205
00206 }
00207 }
00208 if (m_normal == OrthoMesh::NORMAL_Z)
00209 {
00210 unsigned setIndex = m_index - m_mesh->_fzOff;
00211
00212 if (m_k == 0)
00213 {
00214 index2 = setIndex;
00215 index1 = m_mesh->_HGhostBottomOff + m_i + m_j*m_mesh->_nElemX;
00216 }
00217 else if (m_k == m_mesh->_nElemZ)
00218 {
00219 index2 = m_mesh->_HGhostUpOff + m_i + m_j*m_mesh->_nElemX;
00220 index1 = setIndex - m_mesh->_ZStride;
00221 }
00222 else
00223 {
00224 index2 = setIndex;
00225 index1 = index2 - m_mesh->_ZStride;
00226
00227 index1=m_mesh->_delCellLst.convertGhost(index1,m_delCell,m_mesh->_HGhostWellOff);
00228 index2=m_mesh->_delCellLst.convertGhost(index2,m_delCell,m_mesh->_HGhostWellOff);
00229
00230 }
00231 }
00232
00233 }
00234
00235
00236