int IRefiner:: get_local_edge_mark(Face* f, Edge* e) const { const int edgeInd = GetEdgeIndex(f, e); UG_COND_THROW(edgeInd == -1, "Given edge is not an edge of the given face."); if(marked_local(f)){ const int faceLocalMark = get_local_mark(f); return (faceLocalMark >> edgeInd) & 1; } else if(marked_full(f)){
void ReadCombinedParallelFile(ug::BinaryBuffer &buffer, std::string strFilename, pcl::ProcessCommunicator pc) { MPI_Status status; MPI_Comm m_mpiComm = pc.get_mpi_communicator(); MPI_File fh; char filename[1024]; strcpy(filename, strFilename.c_str()); if(MPI_File_open(m_mpiComm, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh)) UG_THROW("could not open "<<filename); std::vector<int> allNextOffsets; allNextOffsets.resize(pc.size()+1); allNextOffsets[0] = (pc.size()+1)*sizeof(int); bool bFirst = pc.get_proc_id(0) == pcl::ProcRank(); if(bFirst) { int numProcs; MPI_File_read(fh, &numProcs, sizeof(numProcs), MPI_BYTE, &status); UG_COND_THROW(numProcs != pcl::NumProcs(), "checkPoint numProcs = " << numProcs << ", but running on " << pcl::NumProcs()); for(size_t i=1; i<allNextOffsets.size(); i++) { MPI_File_read(fh, &allNextOffsets[i], sizeof(allNextOffsets[i]), MPI_BYTE, &status); // UG_LOG("allNextOffsets[" << i << "] = " << allNextOffsets[i] << "\n"); } } int myNextOffset, myNextOffset2; MPI_Scatter(&allNextOffsets[0], 1, MPI_INT, &myNextOffset, 1, MPI_INT, pc.get_proc_id(0), m_mpiComm); MPI_Scatter(&allNextOffsets[1], 1, MPI_INT, &myNextOffset2, 1, MPI_INT, pc.get_proc_id(0), m_mpiComm); int mySize = myNextOffset2-myNextOffset; // UG_LOG_ALL_PROCS("MySize = " << mySize << "\n" << "myNextOffset = " << myNextOffset << " - " << myNextOffset2 << "\n"); MPI_File_seek(fh, myNextOffset, MPI_SEEK_SET); char *p = new char[mySize]; MPI_File_read(fh, p, mySize, MPI_BYTE, &status); buffer.clear(); buffer.reserve(mySize); buffer.write(p, mySize); delete[] p; MPI_File_close(&fh); // UG_LOG("File read.\n"); }
void ntree<tree_dim, world_dim, elem_t, common_data_t>:: split_leaf_node(size_t nodeIndex) { if(m_nodes[nodeIndex].numEntries <= 1) return; if(m_nodes[nodeIndex].level >= m_desc.maxDepth){ if(m_warningsEnabled){ UG_LOG("WARNING in ntree::split_leaf_node(): maximum tree depth " << m_desc.maxDepth << " reached. No further splits are performed for " " this node. Note that too many elements per node may lead to performance issues.\n" << " Number of elements in this node: " << m_nodes[nodeIndex].numEntries << std::endl << " Corner coordinates of this node: " << m_nodes[nodeIndex].tightBox << std::endl); } return; } if(m_nodes[nodeIndex].childNodeInd[0] != s_invalidIndex) return; const size_t firstChild = m_nodes.size(); m_nodes.resize(firstChild + s_numChildren); // ATTENTION: Be careful not to resize m_nodes while using node, since this would invalidate the reference! Node& node = m_nodes[nodeIndex]; // calculate center of mass and use the traits class to split the box of // the current node into 's_numChildren' child boxes. Each child box thereby // spanned by one of the corners of the original box and 'centerOfMass'. vector_t centerOfMass = calculate_center_of_mass(node); box_t childBoxes[s_numChildren]; traits::split_box(childBoxes, node.tightBox, centerOfMass); // iterate over all entries in the current node and assign them to child nodes. size_t numEntriesAssigned = 0; for(size_t entryInd = node.firstEntryInd; entryInd != s_invalidIndex;){ Entry& entry = m_entries[entryInd]; size_t nextEntryInd = entry.nextEntryInd; size_t i_child; vector_t center; traits::calculate_center(center, entry.elem, m_commonData); for(i_child = 0; i_child < s_numChildren; ++i_child){ if(traits::box_contains_point(childBoxes[i_child], center)){ add_entry_to_node(m_nodes[firstChild + i_child], entryInd); ++numEntriesAssigned; break; } } /*-- For debugging only: --* if(i_child == s_numChildren){ UG_LOG ("ERROR in ntree::split_leaf_node(): Element with center @ " << center << " does not belong to any child of the box " << node.tightBox << std::endl); } *--*/ entryInd = nextEntryInd; } // all elements of the current box now should be assigned to child boxes. // we thus clear element lists and entry-count from the current node. UG_COND_THROW(numEntriesAssigned != node.numEntries, "Couldn't find a matching " "child node for some elements during split_leaf_node in " "ntree::split_leaf_node"); node.firstEntryInd = node.lastEntryInd = s_invalidIndex; node.numEntries = 0; for(size_t i_child = 0; i_child < s_numChildren; ++i_child){ node.childNodeInd[i_child] = firstChild + i_child; Node& childNode = m_nodes[firstChild + i_child]; childNode.level = node.level + 1; childNode.tightBox = childBoxes[i_child]; update_loose_bounding_box(childNode); } // since split_leaf_node resizes m_nodes and since this invalidates any references // to m_nodes, we perform the recursion in a last step for(size_t i_child = 0; i_child < s_numChildren; ++i_child){ size_t childNodeInd = firstChild + i_child; if(m_nodes[childNodeInd].numEntries >= m_desc.splitThreshold) split_leaf_node(childNodeInd); } }
const T& Table<T>::operator() (size_t rowInd, size_t colInd) const { UG_COND_THROW(rowInd >= num_rows(), "Bad row index: " << rowInd << "! Only " << num_rows() << " rows exist."); UG_COND_THROW(colInd >= num_cols(), "Bad col index: " << colInd << "! Only " << num_cols() << " cols exist."); return *m_data[rowInd][colInd]; }