void SpaceHelper<BasisFunctionType>::getGlobalDofBoundingBoxes_defaultImplementation( const GridView &view, const std::vector<std::vector<LocalDof>> &global2localDofs, std::vector<BoundingBox<CoordinateType>> &bboxes) { const IndexSet &indexSet = view.indexSet(); const int elementCount = view.entityCount(0); std::vector<arma::Mat<CoordinateType>> elementCorners(elementCount); std::unique_ptr<EntityIterator<0>> it = view.entityIterator<0>(); while (!it->finished()) { const Entity<0> &e = it->entity(); int index = indexSet.entityIndex(e); const Geometry &geo = e.geometry(); geo.getCorners(acc(elementCorners, index)); it->next(); } BoundingBox<CoordinateType> model; const CoordinateType maxCoord = std::numeric_limits<CoordinateType>::max(); model.lbound.x = model.lbound.y = model.lbound.z = maxCoord; model.ubound.x = model.ubound.y = model.ubound.z = -maxCoord; const int globalDofCount_ = global2localDofs.size(); bboxes.resize(globalDofCount_, model); for (int i = 0; i < globalDofCount_; ++i) { const std::vector<LocalDof> &localDofs = acc(global2localDofs, i); BoundingBox<CoordinateType> &bbox = acc(bboxes, i); for (int j = 0; j < localDofs.size(); ++j) extendBoundingBox(bbox, acc(elementCorners, acc(localDofs, j).entityIndex)); assert(!localDofs.empty()); setBoundingBoxReference<CoordinateType>( bbox, acc(elementCorners, localDofs[0].entityIndex) .col(localDofs[0].dofIndex)); } #ifndef NDEBUG for (size_t i = 0; i < globalDofCount_; ++i) { assert(bboxes[i].reference.x >= bboxes[i].lbound.x); assert(bboxes[i].reference.y >= bboxes[i].lbound.y); assert(bboxes[i].reference.z >= bboxes[i].lbound.z); assert(bboxes[i].reference.x <= bboxes[i].ubound.x); assert(bboxes[i].reference.y <= bboxes[i].ubound.y); assert(bboxes[i].reference.z <= bboxes[i].ubound.z); } #endif // NDEBUG }
void PiecewiseLinearDiscontinuousScalarSpaceBarycentric<BasisFunctionType>:: getFlatLocalDofBoundingBoxes( std::vector<BoundingBox<CoordinateType> >& bboxes) const { // TODO: extract this loop into a private function const IndexSet& indexSet = this->gridView().indexSet(); const int elementCount = this->gridView().entityCount(0); std::vector<arma::Mat<CoordinateType> > elementCorners(elementCount); std::auto_ptr<EntityIterator<0> > it = this->gridView().template entityIterator<0>(); while (!it->finished()) { const Entity<0>& e = it->entity(); int index = indexSet.entityIndex(e); const Geometry& geo = e.geometry(); geo.getCorners(acc(elementCorners, index)); it->next(); } BoundingBox<CoordinateType> model; const CoordinateType maxCoord = std::numeric_limits<CoordinateType>::max(); model.lbound.x = model.lbound.y = model.lbound.z = maxCoord; model.ubound.x = model.ubound.y = model.ubound.z = -maxCoord; const int flatLocalDofCount_ = m_flatLocal2localDofs.size(); bboxes.resize(flatLocalDofCount_, model); for (int i = 0; i < flatLocalDofCount_; ++i) { const LocalDof& localDof = acc(m_flatLocal2localDofs, i); BoundingBox<CoordinateType>& bbox = acc(bboxes, i); extendBoundingBox(bbox, acc(elementCorners, localDof.entityIndex)); setBoundingBoxReference<CoordinateType>( bbox, acc(elementCorners, localDof.entityIndex).col( localDof.dofIndex)); } #ifndef NDEBUG const int globalDofCount_ = globalDofCount(); for (size_t i = 0; i < globalDofCount_; ++i) { assert(bboxes[i].reference.x >= bboxes[i].lbound.x); assert(bboxes[i].reference.y >= bboxes[i].lbound.y); assert(bboxes[i].reference.z >= bboxes[i].lbound.z); assert(bboxes[i].reference.x <= bboxes[i].ubound.x); assert(bboxes[i].reference.y <= bboxes[i].ubound.y); assert(bboxes[i].reference.z <= bboxes[i].ubound.z); } #endif // NDEBUG }