void VertexBasedCellPopulation<DIM>::Update(bool hasHadBirthsOrDeaths) { VertexElementMap element_map(mpMutableVertexMesh->GetNumAllElements()); mpMutableVertexMesh->ReMesh(element_map); if (!element_map.IsIdentityMap()) { // Fix up the mappings between CellPtrs and VertexElements ///\todo We want to make these maps private, so we need a better way of doing the code below. std::map<Cell*, unsigned> old_map = this->mCellLocationMap; this->mCellLocationMap.clear(); this->mLocationCellMap.clear(); for (std::list<CellPtr>::iterator cell_iter = this->mCells.begin(); cell_iter != this->mCells.end(); ++cell_iter) { // The cell vector should only ever contain living cells unsigned old_elem_index = old_map[(*cell_iter).get()]; assert(!element_map.IsDeleted(old_elem_index)); unsigned new_elem_index = element_map.GetNewIndex(old_elem_index); this->SetCellUsingLocationIndex(new_elem_index, *cell_iter); } // Check that each VertexElement has only one CellPtr associated with it in the updated cell population Validate(); } element_map.ResetToIdentity(); }
void T2SwapCellKiller<DIM>::CheckAndLabelCellsForApoptosisOrDeath() { /* * This killer is different to other killers: it does not only check and label * cells for apoptosis or death, it actually carries out vertex rearrangements * and removes elements from the vertex mesh. * * We start with carrying out T2 swaps. Get the mesh and an element map. * The static_cast will work since we already know it's a VertexBasedCellPopulation. */ MutableVertexMesh<DIM,DIM>& mesh = static_cast<MutableVertexMesh<DIM,DIM>&>(this->mpCellPopulation->rGetMesh()); VertexBasedCellPopulation<DIM>* p_vertex_population = static_cast<VertexBasedCellPopulation<DIM>*>(this->mpCellPopulation); VertexElementMap element_map(mesh.GetNumAllElements()); bool recheck_mesh = true; while (recheck_mesh == true) { // Note that whenever we call CheckForT2Swaps(), the element indices must run from zero up to mElements.size()-1 recheck_mesh = mesh.CheckForT2Swaps(element_map); /* * There might have maximally one T2 swap happened above, where a vertex element was removed from the * mesh but the associated cell is still there. Here we check whether a new cell * underwent a T2 swap and label it as dead as well as record its location and ID. */ for (unsigned elem_index = 0; elem_index < element_map.Size(); elem_index++) { CellPtr p_cell = this->mpCellPopulation->GetCellUsingLocationIndex(elem_index); if (element_map.IsDeleted(elem_index) && !(p_cell->IsDead())) { p_vertex_population->AddLocationOfT2Swap(mesh.GetLastT2SwapLocation()); p_vertex_population->AddCellIdOfT2Swap(p_cell->GetCellId()); p_cell->Kill(); // There can't have been more than one new cell death, so leave the for loop here. break; } } } }
CRCFile::element_map* CRCFile::GetElementMap(UINT uiGroup) { // insert menu if does not exist element_map* pElementMap = NULL; group_map::iterator itGroup = m_mapOutputLanguage.find(uiGroup); if(itGroup == m_mapOutputLanguage.end()) { std::pair<group_map::iterator, bool> pairGroup = m_mapOutputLanguage.insert(std::make_pair(uiGroup, element_map())); if(!pairGroup.second) { _ASSERTE(false); return NULL; } pElementMap = &(*(pairGroup.first)).second; } else pElementMap = &((*itGroup).second); if(!pElementMap) { _ASSERTE(false); return NULL; } return pElementMap; }