46 std::vector<CellPtr>& rCells,
47 const std::vector<unsigned> locationIndices,
52 if (!locationIndices.empty())
55 std::set<unsigned> node_indices;
56 std::set<unsigned> location_indices;
57 std::set<unsigned> particle_indices;
63 node_indices.insert(node_iter->GetIndex());
65 for (
unsigned i=0; i<locationIndices.size(); i++)
67 location_indices.insert(locationIndices[i]);
70 std::set_difference(node_indices.begin(), node_indices.end(),
71 location_indices.begin(), location_indices.end(),
72 std::inserter(particle_indices, particle_indices.begin()));
83 (*node_iter).SetIsParticle(
false);
160 std::map<unsigned, bool> validated_nodes;
162 node_iter != this->mrMesh.GetNodeIteratorEnd();
165 validated_nodes[node_iter->GetIndex()] = node_iter->IsParticle();
171 unsigned node_index = this->GetLocationIndexUsingCell((*cell_iter));
174 if (this->GetNode(node_index)->IsParticle())
176 EXCEPTION(
"Node " << node_index <<
" is labelled as a particle and has a cell attached");
178 validated_nodes[node_index] =
true;
181 for (std::map<unsigned, bool>::iterator map_iter = validated_nodes.begin();
182 map_iter != validated_nodes.end();
185 if (!map_iter->second)
187 EXCEPTION(
"Node " << map_iter->first <<
" does not appear to be a particle or has a cell associated with it");
196 node_iter != this->rGetMesh().GetNodeIteratorEnd();
200 if (! this->IsParticle(node_iter->GetIndex()))
203 cell_writer_iter != this->mCellWriters.end();
206 CellPtr cell_from_node = this->GetCellUsingLocationIndex(node_iter->GetIndex());
207 this->AcceptCellWriter(*cell_writer_iter, cell_from_node);
218 std::stringstream time;
222 NodeMap map(1 + this->mpNodesOnlyMesh->GetMaximumNodeIndex());
223 this->mpNodesOnlyMesh->ReMesh(map);
226 unsigned num_nodes = this->GetNumNodes();
227 std::vector<double> rank(num_nodes);
228 std::vector<double> particles(num_nodes);
230 unsigned num_cell_data_items = 0;
231 std::vector<std::string> cell_data_names;
236 num_cell_data_items = this->Begin()->GetCellData()->GetNumItems();
237 cell_data_names = this->Begin()->GetCellData()->GetKeys();
240 std::vector<std::vector<double> > cell_data;
241 for (
unsigned var=0; var<num_cell_data_items; var++)
243 std::vector<double> cell_data_var(num_nodes);
244 cell_data.push_back(cell_data_var);
253 cell_writer_iter != this->mCellWriters.end();
257 std::vector<double> vtk_cell_data(num_nodes);
261 node_iter != this->mrMesh.GetNodeIteratorEnd();
264 unsigned node_index = node_iter->GetIndex();
267 if (this->IsParticle(node_index))
269 vtk_cell_data[node_index] = -2.0;
274 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
275 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
279 mesh_writer.
AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
284 cell_iter != this->End();
288 unsigned global_index = this->GetLocationIndexUsingCell(*cell_iter);
289 unsigned node_index = this->rGetMesh().SolveNodeMapping(global_index);
291 for (
unsigned var=0; var<num_cell_data_items; var++)
293 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
303 node_iter != this->mrMesh.GetNodeIteratorEnd();
306 unsigned node_index = node_iter->GetIndex();
307 particles[node_index] = (
double) (this->IsParticle(node_index));
312 if (num_cell_data_items > 0)
314 for (
unsigned var=0; var<cell_data.size(); var++)
316 mesh_writer.
AddPointData(cell_data_names[var], cell_data[var]);
322 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
324 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
328 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
void OutputCellPopulationParameters(out_stream &rParamsFile)
std::set< unsigned > GetParticleIndices()
virtual void AcceptCellWritersAcrossPopulation()
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
void UpdateParticlesAfterReMesh(NodeMap &rMap)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
void SetParticles(const std::set< unsigned > &rParticleIndices)
NodeBasedCellPopulationWithParticles(NodesOnlyMesh< DIM > &rMesh, std::vector< CellPtr > &rCells, const std::vector< unsigned > locationIndices=std::vector< unsigned >(), bool deleteMesh=false)