41 std::vector<CellPtr>& rCells,
42 const std::vector<unsigned> locationIndices,
47 if (!locationIndices.empty())
50 std::set<unsigned> node_indices;
51 std::set<unsigned> location_indices;
52 std::set<unsigned> particle_indices;
58 node_indices.insert(node_iter->GetIndex());
60 for (
unsigned i=0; i<locationIndices.size(); i++)
62 location_indices.insert(locationIndices[i]);
65 std::set_difference(node_indices.begin(), node_indices.end(),
66 location_indices.begin(), location_indices.end(),
67 std::inserter(particle_indices, particle_indices.begin()));
78 (*node_iter).SetIsParticle(
false);
155 std::map<unsigned, bool> validated_nodes;
157 node_iter != this->mrMesh.GetNodeIteratorEnd();
160 validated_nodes[node_iter->GetIndex()] = node_iter->IsParticle();
166 unsigned node_index = this->GetLocationIndexUsingCell((*cell_iter));
169 if (this->GetNode(node_index)->IsParticle())
171 EXCEPTION(
"Node " << node_index <<
" is labelled as a particle and has a cell attached");
173 validated_nodes[node_index] =
true;
176 for (std::map<unsigned, bool>::iterator map_iter = validated_nodes.begin();
177 map_iter != validated_nodes.end();
180 if (!map_iter->second)
182 EXCEPTION(
"Node " << map_iter->first <<
" does not appear to be a particle or has a cell associated with it");
191 node_iter != this->rGetMesh().GetNodeIteratorEnd();
195 if (! this->IsParticle(node_iter->GetIndex()))
198 cell_writer_iter != this->mCellWriters.end();
201 CellPtr cell_from_node = this->GetCellUsingLocationIndex(node_iter->GetIndex());
202 this->AcceptCellWriter(*cell_writer_iter, cell_from_node);
213 std::stringstream time;
217 NodeMap map(1 + this->mpNodesOnlyMesh->GetMaximumNodeIndex());
218 this->mpNodesOnlyMesh->ReMesh(map);
221 unsigned num_nodes = this->GetNumNodes();
222 std::vector<double> rank(num_nodes);
223 std::vector<double> particles(num_nodes);
225 unsigned num_cell_data_items = 0;
226 std::vector<std::string> cell_data_names;
231 num_cell_data_items = this->Begin()->GetCellData()->GetNumItems();
232 cell_data_names = this->Begin()->GetCellData()->GetKeys();
235 std::vector<std::vector<double> > cell_data;
236 for (
unsigned var=0; var<num_cell_data_items; var++)
238 std::vector<double> cell_data_var(num_nodes);
239 cell_data.push_back(cell_data_var);
248 cell_writer_iter != this->mCellWriters.end();
252 std::vector<double> vtk_cell_data(num_nodes);
256 node_iter != this->mrMesh.GetNodeIteratorEnd();
259 unsigned node_index = node_iter->GetIndex();
262 if (this->IsParticle(node_index))
264 vtk_cell_data[node_index] = -2.0;
269 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
270 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
274 mesh_writer.
AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
279 cell_iter != this->End();
283 unsigned global_index = this->GetLocationIndexUsingCell(*cell_iter);
284 unsigned node_index = this->rGetMesh().SolveNodeMapping(global_index);
286 for (
unsigned var=0; var<num_cell_data_items; var++)
288 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
298 node_iter != this->mrMesh.GetNodeIteratorEnd();
301 unsigned node_index = node_iter->GetIndex();
302 particles[node_index] = (
double) (this->IsParticle(node_index));
307 if (num_cell_data_items > 0)
309 for (
unsigned var=0; var<cell_data.size(); var++)
311 mesh_writer.
AddPointData(cell_data_names[var], cell_data[var]);
317 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
319 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
323 *(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)