36 #include "NodeBasedCellPopulationWithParticles.hpp" 37 #include "VtkMeshWriter.hpp" 38 #include "CellAgesWriter.hpp" 39 #include "CellAncestorWriter.hpp" 40 #include "CellProliferativePhasesWriter.hpp" 41 #include "CellVolumesWriter.hpp" 42 #include "CellMutationStatesCountWriter.hpp" 44 template<
unsigned DIM>
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);
89 template<
unsigned DIM>
95 template<
unsigned DIM>
98 return this->
GetNode(index)->IsParticle();
101 template<
unsigned DIM>
104 std::set<unsigned> particle_indices;
107 node_iter != this->
mrMesh.GetNodeIteratorEnd();
110 if (node_iter->IsParticle())
112 particle_indices.insert(node_iter->GetIndex());
116 return particle_indices;
119 template<
unsigned DIM>
123 node_iter != this->
mrMesh.GetNodeIteratorEnd();
126 if (rParticleIndices.find(node_iter->GetIndex()) != rParticleIndices.end())
128 node_iter->SetIsParticle(
true);
134 template<
unsigned DIM>
139 template<
unsigned DIM>
146 assert(p_created_cell == pNewCell);
150 this->
GetNode(node_index)->SetRadius(0.5);
151 this->
GetNode(node_index)->SetIsParticle(
false);
154 return p_created_cell;
157 template<
unsigned DIM>
160 std::map<unsigned, bool> validated_nodes;
162 node_iter != this->
mrMesh.GetNodeIteratorEnd();
165 validated_nodes[node_iter->GetIndex()] = node_iter->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");
192 template<
unsigned DIM>
200 if (! this->
IsParticle(node_iter->GetIndex()))
213 template<
unsigned DIM>
218 std::stringstream time;
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);
257 std::vector<double> vtk_cell_data(num_nodes);
261 node_iter != this->
mrMesh.GetNodeIteratorEnd();
264 unsigned node_index = node_iter->GetIndex();
269 vtk_cell_data[node_index] = -2.0;
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();
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]);
299 mesh_writer.AddPointData(
"Process rank", rank);
303 node_iter != this->
mrMesh.GetNodeIteratorEnd();
306 unsigned node_index = node_iter->GetIndex();
310 mesh_writer.AddPointData(
"Non-particles", particles);
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]);
324 *(this->
mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
337 template<
unsigned DIM>
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
void UpdateParticlesAfterReMesh(NodeMap &rMap)
void OutputCellPopulationParameters(out_stream &rParamsFile)
NodesOnlyMesh< DIM > & rGetMesh()
virtual unsigned GetMaximumNodeIndex()
unsigned GetLocationIndexUsingCell(CellPtr pCell)
NodeBasedCellPopulationWithParticles(NodesOnlyMesh< DIM > &rMesh, std::vector< CellPtr > &rCells, const std::vector< unsigned > locationIndices=std::vector< unsigned >(), bool deleteMesh=false)
std::vector< boost::shared_ptr< AbstractCellWriter< ELEMENT_DIM, SPACE_DIM > > > mCellWriters
#define EXCEPTION(message)
Node< DIM > * GetNode(unsigned index)
static SimulationTime * Instance()
void SetParallelFiles(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
NodeIterator GetNodeIteratorEnd()
void ReMesh(NodeMap &rMap)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
bool IsParticle(unsigned index)
unsigned SolveNodeMapping(unsigned index) const
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
#define EXCEPT_IF_NOT(test)
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
std::set< unsigned > GetParticleIndices()
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
NodesOnlyMesh< DIM > * mpNodesOnlyMesh
virtual void AcceptCellWritersAcrossPopulation()
AbstractMesh< ELEMENT_DIM, SPACE_DIM > & mrMesh
void OutputCellPopulationParameters(out_stream &rParamsFile)
unsigned GetTimeStepsElapsed() const
void SetParticles(const std::set< unsigned > &rParticleIndices)