36 #include "NodeBasedCellPopulationWithParticles.hpp" 37 #include "VtkMeshWriter.hpp" 38 #include "CellAgesWriter.hpp" 39 #include "CellAncestorWriter.hpp" 40 #include "CellProliferativePhasesWriter.hpp" 41 #include "CellProliferativeTypesWriter.hpp" 42 #include "CellVolumesWriter.hpp" 43 #include "CellMutationStatesCountWriter.hpp" 45 template<
unsigned DIM>
47 std::vector<CellPtr>& rCells,
48 const std::vector<unsigned> locationIndices,
53 if (!locationIndices.empty())
56 std::set<unsigned> node_indices;
57 std::set<unsigned> location_indices;
58 std::set<unsigned> particle_indices;
64 node_indices.insert(node_iter->GetIndex());
66 for (
unsigned i=0; i<locationIndices.size(); i++)
68 location_indices.insert(locationIndices[i]);
71 std::set_difference(node_indices.begin(), node_indices.end(),
72 location_indices.begin(), location_indices.end(),
73 std::inserter(particle_indices, particle_indices.begin()));
84 (*node_iter).SetIsParticle(
false);
90 template<
unsigned DIM>
96 template<
unsigned DIM>
99 return this->
GetNode(index)->IsParticle();
102 template<
unsigned DIM>
105 std::set<unsigned> particle_indices;
108 node_iter != this->
mrMesh.GetNodeIteratorEnd();
111 if (node_iter->IsParticle())
113 particle_indices.insert(node_iter->GetIndex());
117 return particle_indices;
120 template<
unsigned DIM>
124 node_iter != this->
mrMesh.GetNodeIteratorEnd();
127 if (rParticleIndices.find(node_iter->GetIndex()) != rParticleIndices.end())
129 node_iter->SetIsParticle(
true);
135 template<
unsigned DIM>
140 template<
unsigned DIM>
147 assert(p_created_cell == pNewCell);
151 this->
GetNode(node_index)->SetRadius(0.5);
152 this->
GetNode(node_index)->SetIsParticle(
false);
155 return p_created_cell;
158 template<
unsigned DIM>
161 std::map<unsigned, bool> validated_nodes;
163 node_iter != this->
mrMesh.GetNodeIteratorEnd();
166 validated_nodes[node_iter->GetIndex()] = node_iter->IsParticle();
177 EXCEPTION(
"Node " << node_index <<
" is labelled as a particle and has a cell attached");
179 validated_nodes[node_index] =
true;
182 for (std::map<unsigned, bool>::iterator map_iter = validated_nodes.begin();
183 map_iter != validated_nodes.end();
186 if (!map_iter->second)
188 EXCEPTION(
"Node " << map_iter->first <<
" does not appear to be a particle or has a cell associated with it");
193 template<
unsigned DIM>
201 if (! this->
IsParticle(node_iter->GetIndex()))
214 template<
unsigned DIM>
219 std::stringstream time;
228 std::vector<double> rank(num_nodes);
229 std::vector<double> particles(num_nodes);
231 unsigned num_cell_data_items = 0;
232 std::vector<std::string> cell_data_names;
237 num_cell_data_items = this->
Begin()->GetCellData()->GetNumItems();
238 cell_data_names = this->
Begin()->GetCellData()->GetKeys();
241 std::vector<std::vector<double> > cell_data;
242 for (
unsigned var=0; var<num_cell_data_items; var++)
244 std::vector<double> cell_data_var(num_nodes);
245 cell_data.push_back(cell_data_var);
258 std::vector<double> vtk_cell_data(num_nodes);
262 node_iter != this->
mrMesh.GetNodeIteratorEnd();
265 unsigned node_index = node_iter->GetIndex();
270 vtk_cell_data[node_index] = -2.0;
276 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
280 mesh_writer.AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
285 cell_iter != this->
End();
292 for (
unsigned var=0; var<num_cell_data_items; var++)
294 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
300 mesh_writer.AddPointData(
"Process rank", rank);
304 node_iter != this->
mrMesh.GetNodeIteratorEnd();
307 unsigned node_index = node_iter->GetIndex();
311 mesh_writer.AddPointData(
"Non-particles", particles);
313 if (num_cell_data_items > 0)
315 for (
unsigned var=0; var<cell_data.size(); var++)
317 mesh_writer.AddPointData(cell_data_names[var], cell_data[var]);
325 *(this->
mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
338 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()
unsigned GetTimeStepsElapsed() const
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)
void SetParticles(const std::set< unsigned > &rParticleIndices)