void MultiGridSubsetHandler::assign_grid(MultiGrid& mg) { if(m_pMG == &mg) return; if(m_pMG) cleanup(); m_pMG = &mg; ISubsetHandler::set_grid(&mg); // attach shared entries if(elements_are_supported(SHE_VERTEX)) m_pGrid->attach_to_vertices(m_aSharedEntryVRT); if(elements_are_supported(SHE_EDGE)) m_pGrid->attach_to_edges(m_aSharedEntryEDGE); if(elements_are_supported(SHE_FACE)) m_pGrid->attach_to_faces(m_aSharedEntryFACE); if(elements_are_supported(SHE_VOLUME)) m_pGrid->attach_to_volumes(m_aSharedEntryVOL); // register the callback m_callbackId = m_pMG->message_hub()->register_class_callback( this, &ug::MultiGridSubsetHandler::multigrid_changed); level_required(m_pMG->num_levels()); }
void MultiGridSubsetHandler:: assign_subset_impl(TElem* elem, int subsetIndex) { assert((m_pGrid != NULL) && "ERROR in SubsetHandler::assign_subset(): No grid assigned to SubsetHandler."); int level = m_pMG->get_level(elem); // check if we have to remove elem from a subset. int oldIndex = get_subset_index(elem); if(oldIndex != -1) section_container<TElem>(oldIndex, level).erase(get_list_iterator(elem), elem->container_section()); // add the element to the subset. if(subsetIndex != -1) { subset_required(subsetIndex); level_required(level); section_container<TElem>(subsetIndex, level).insert(elem, elem->container_section()); subset_assigned(elem, subsetIndex); } else { //TODO: iterator is useless! subset_assigned(elem, -1); } }
void MultiGrid::element_created(TElem* elem, TParent* pParent, TElem* pReplaceMe) { UG_ASSERT(pReplaceMe, "Only call this method with a valid element which shall be replaced."); int level = get_level(pReplaceMe); // register parent and child set_parent(elem, pParent); if(pParent) { // add the element to the parents children list // pParent should have an info object at this time! typename mginfo_traits<TParent>::info_type& parentInfo = get_info(pParent); parentInfo.replace_child(elem, pReplaceMe); } // put the element into the hierarchy level_required(level); m_hierarchy.assign_subset(elem, level); // explicitly copy the parent-type from pReplaceMe to the new vrt. // This has to be done explicitly since a parent may not exist locally in // a parallel environment. set_parent_type(elem, parent_type(pReplaceMe)); }
void MultiGrid::element_created(TElem* elem, TParent* pParent) { // if hierarchical_insertion is enabled, the element will be put // into the next higher level of pParents level. int level = 0; if(pParent) { // the element is inserted into a new layer. level = get_level(pParent) + 1; set_parent_type(elem, pParent->base_object_id()); } else set_parent_type(elem, -1); // register parent and child //typename mginfo_traits<TElem>::info_type& info = get_info(elem); //info.m_pParent = pParent; set_parent(elem, pParent); if(pParent) { // make sure that the parent has an info object create_child_info(pParent); // add the element to the parents children list typename mginfo_traits<TParent>::info_type& parentInfo = get_info(pParent); parentInfo.add_child(elem); } // put the element into the hierarchy level_required(level); m_hierarchy.assign_subset(elem, level); }
typename Grid::traits<TElem>::SectionContainer& MGSelector:: section_container(int level) { assert(level >= 0 && "bad level index."); level_required(level); Level* lev = m_levels[level]; return SectionContainerSelector<typename geometry_traits<TElem>::grid_base_object>:: section_container(lev->m_vertices, lev->m_edges, lev->m_faces, lev->m_volumes); }
GridObjectCollection MultiGridSubsetHandler:: get_grid_objects(int subsetIndex, int level) const { subset_required(subsetIndex); level_required(level); return GridObjectCollection(&m_levels[level][subsetIndex]->m_vertices, &m_levels[level][subsetIndex]->m_edges, &m_levels[level][subsetIndex]->m_faces, &m_levels[level][subsetIndex]->m_volumes); }
typename geometry_traits<TGeomObj>::iterator MultiGrid::create(size_t level) { typename geometry_traits<TGeomObj>::iterator iter = Grid::create<TGeomObj>(); // put the element into the hierarchy // (by default it already was assigned to level 0) if(level > 0){ level_required(level); m_hierarchy.assign_subset(*iter, level); } return iter; }
GridObjectCollection MultiGridSubsetHandler:: get_grid_objects_in_level(int level) const { level_required(level); uint numSubsets = num_subsets_in_list(); GridObjectCollection goc(numSubsets); for(uint i = 0; i < numSubsets; ++i) { goc.add_level( &m_levels[level][i]->m_vertices, &m_levels[level][i]->m_edges, &m_levels[level][i]->m_faces, &m_levels[level][i]->m_volumes); } return goc; }
void MGSelector::assign_grid(MultiGrid* grid) { if(grid != m_pMultiGrid){ uint elementSupport = m_supportedElements; // if a grid already exists, we'll perform cleanup if(m_pMultiGrid) cleanup(); m_supportedElements = SE_NONE; m_pMultiGrid = grid; BaseClass::set_grid(grid); // attach shared entry-attachments to section containers if(m_pMultiGrid){ enable_element_support(elementSupport); // register the callback m_callbackId = m_pMultiGrid->message_hub()->register_class_callback( this, &ug::MGSelector::multigrid_changed); level_required(m_pMultiGrid->num_levels()); } m_supportedElements = elementSupport; } }
void MultiGridSubsetHandler:: multigrid_changed(const GridMessage_MultiGridChanged& gm) { if(gm.message_type() == GMMGCT_LEVEL_ADDED) level_required(gm.num_levels_in_grid() - 1); }