AbstractCellPopulation.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "AbstractCellPopulation.hpp"
00030 #include "AbstractOdeBasedCellCycleModel.hpp"
00031 #include "PetscTools.hpp"
00032 
00033 template<unsigned DIM>
00034 AbstractCellPopulation<DIM>::AbstractCellPopulation(std::vector<CellPtr>& rCells,
00035                                     const std::vector<unsigned> locationIndices)
00036     : mCells(rCells.begin(), rCells.end()),
00037       mCellPopulationContainsMesh(false),
00038       mpCellPropertyRegistry(CellPropertyRegistry::Instance()->TakeOwnership()),
00039       mDampingConstantNormal(1.0),
00040       mDampingConstantMutant(1.0),
00041       mOutputCellIdData(false),
00042       mOutputCellMutationStates(false),
00043       mOutputCellAncestors(false),
00044       mOutputCellProliferativeTypes(false),
00045       mOutputCellVariables(false),
00046       mOutputCellCyclePhases(false),
00047       mOutputCellAges(false),
00048       mOutputCellVolumes(false)
00049 {
00050     // There must be at least one cell
00051     assert(!mCells.empty());
00052 
00053     // To avoid double-counting problems, clear the passed-in cells vector
00054     rCells.clear();
00055 
00056     if (!locationIndices.empty())
00057     {
00058         // There must be a one-one correspondence between cells and location indices
00059         if (mCells.size() != locationIndices.size())
00060         {
00061             EXCEPTION("There is not a one-one correspondence between cells and location indices");
00062         }
00063     }
00064 
00065     // Set up the map between location indices and cells
00066     std::list<CellPtr>::iterator it = mCells.begin();
00067     for (unsigned i=0; it != mCells.end(); ++it, ++i)
00068     {
00069         unsigned index = locationIndices.empty() ? i : locationIndices[i]; // assume that the ordering matches
00070         mLocationCellMap[index] = *it;
00071         mCellLocationMap[(*it).get()] = index;
00072 
00073         // Give each cell a pointer to the property registry (we have taken ownership in this constructor).
00074         (*it)->rGetCellPropertyCollection().SetCellPropertyRegistry(mpCellPropertyRegistry.get());
00075     }
00076 
00077     // Initialise cell counts to zero
00082     mCellProliferativeTypeCount = std::vector<unsigned>(NUM_CELL_PROLIFERATIVE_TYPES);
00083     for (unsigned i=0; i<mCellProliferativeTypeCount.size(); i++)
00084     {
00085         mCellProliferativeTypeCount[i] = 0;
00086     }
00087 
00088     mCellCyclePhaseCount = std::vector<unsigned>(NUM_CELL_CYCLE_PHASES);
00089     for (unsigned i=0; i<mCellCyclePhaseCount.size(); i++)
00090     {
00091         mCellCyclePhaseCount[i] = 0;
00092     }
00093 }
00094 
00095 template<unsigned DIM>
00096 AbstractCellPopulation<DIM>::~AbstractCellPopulation()
00097 {
00098 }
00099 
00100 template<unsigned DIM>
00101 void AbstractCellPopulation<DIM>::InitialiseCells()
00102 {
00103     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter=this->Begin(); cell_iter!=this->End(); ++cell_iter)
00104     {
00105         cell_iter->InitialiseCellCycleModel();
00106     }
00107 }
00108 
00109 template<unsigned DIM>
00110 std::list<CellPtr>& AbstractCellPopulation<DIM>::rGetCells()
00111 {
00112     return mCells;
00113 }
00114 
00115 template<unsigned DIM>
00116 bool AbstractCellPopulation<DIM>::IsMeshBasedCellPopulation()
00117 {
00118     return mCellPopulationContainsMesh;
00119 }
00120 
00121 template<unsigned DIM>
00122 unsigned AbstractCellPopulation<DIM>::GetNumRealCells()
00123 {
00124     unsigned counter = 0;
00125     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter=this->Begin(); cell_iter!=this->End(); ++cell_iter)
00126     {
00127         counter++;
00128     }
00129     return counter;
00130 }
00131 
00132 template<unsigned DIM>
00133 void AbstractCellPopulation<DIM>::SetCellAncestorsToLocationIndices()
00134 {
00135     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter=this->Begin(); cell_iter!=this->End(); ++cell_iter)
00136     {
00137         cell_iter->SetAncestor(mCellLocationMap[(*cell_iter).get()]);
00138     }
00139 }
00140 
00141 template<unsigned DIM>
00142 std::set<unsigned> AbstractCellPopulation<DIM>::GetCellAncestors()
00143 {
00144     std::set<unsigned> remaining_ancestors;
00145     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter=this->Begin(); cell_iter!=this->End(); ++cell_iter)
00146     {
00147         remaining_ancestors.insert(cell_iter->GetAncestor());
00148     }
00149     return remaining_ancestors;
00150 }
00151 
00152 template<unsigned DIM>
00153 std::vector<unsigned> AbstractCellPopulation<DIM>::GetCellMutationStateCount()
00154 {
00155     if (!mOutputCellMutationStates)
00156     {
00157         EXCEPTION("Call SetOutputCellMutationStates(true) before using this function");
00158     }
00159 
00160     // An ordering must have been specified for cell mutation states
00161     SetDefaultMutationStateOrdering();
00162 
00163     const std::vector<boost::shared_ptr<AbstractCellProperty> >& r_cell_properties =
00164         mpCellPropertyRegistry->rGetAllCellProperties();
00165 
00166     std::vector<unsigned> cell_mutation_state_count;
00167     for (unsigned i=0; i<r_cell_properties.size(); i++)
00168     {
00169         if (r_cell_properties[i]->IsSubType<AbstractCellMutationState>())
00170         {
00171             cell_mutation_state_count.push_back(r_cell_properties[i]->GetCellCount());
00172         }
00173     }
00174 
00175     return cell_mutation_state_count;
00176 }
00177 
00178 template<unsigned DIM>
00179 const std::vector<unsigned>& AbstractCellPopulation<DIM>::rGetCellProliferativeTypeCount() const
00180 {
00181     if (!mOutputCellProliferativeTypes)
00182     {
00183         EXCEPTION("Call SetOutputCellProliferativeTypes(true) before using this function");
00184     }
00185     return mCellProliferativeTypeCount;
00186 }
00187 
00188 template<unsigned DIM>
00189 const std::vector<unsigned>& AbstractCellPopulation<DIM>::rGetCellCyclePhaseCount() const
00190 {
00191     if (!mOutputCellCyclePhases)
00192     {
00193         EXCEPTION("Call SetOutputCellCyclePhases(true) before using this function");
00194     }
00195     return mCellCyclePhaseCount;
00196 }
00197 
00198 template<unsigned DIM>
00199 CellPtr AbstractCellPopulation<DIM>::GetCellUsingLocationIndex(unsigned index)
00200 {
00201     // Get a pointer to the cell corresponding to this location index
00202     CellPtr p_cell = mLocationCellMap[index];
00203 
00204     // Unless this pointer is null, return the cell
00205     if (p_cell)
00206     {
00207         return p_cell;
00208     }
00209     else
00210     {
00211         EXCEPTION("Location index input argument does not correspond to a Cell");
00212     }
00213 }
00214 
00215 template<unsigned DIM>
00216 unsigned AbstractCellPopulation<DIM>::GetLocationIndexUsingCell(CellPtr pCell)
00217 {
00218     return mCellLocationMap[pCell.get()];
00219 }
00220 
00221 template<unsigned DIM>
00222 boost::shared_ptr<CellPropertyRegistry> AbstractCellPopulation<DIM>::GetCellPropertyRegistry()
00223 {
00224     return mpCellPropertyRegistry;
00225 }
00226 
00227 template<unsigned DIM>
00228 void AbstractCellPopulation<DIM>::SetDefaultMutationStateOrdering()
00229 {
00230     boost::shared_ptr<CellPropertyRegistry> p_registry = GetCellPropertyRegistry();
00231     if (!p_registry->HasOrderingBeenSpecified())
00232     {
00233         std::vector<boost::shared_ptr<AbstractCellProperty> > mutations;
00234         mutations.push_back(p_registry->Get<WildTypeCellMutationState>());
00235         mutations.push_back(p_registry->Get<ApcOneHitCellMutationState>());
00236         mutations.push_back(p_registry->Get<ApcTwoHitCellMutationState>());
00237         mutations.push_back(p_registry->Get<BetaCateninOneHitCellMutationState>());
00238         p_registry->SpecifyOrdering(mutations);
00239     }
00240 }
00241 
00243 //                             Output methods                               //
00245 
00246 
00247 template<unsigned DIM>
00248 void AbstractCellPopulation<DIM>::CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory)
00249 {
00250     OutputFileHandler output_file_handler(rDirectory, cleanOutputDirectory);
00251     mpVizNodesFile = output_file_handler.OpenOutputFile("results.viznodes");
00252     mpVizBoundaryNodesFile = output_file_handler.OpenOutputFile("results.vizboundarynodes");
00253     mpVizCellProliferativeTypesFile = output_file_handler.OpenOutputFile("results.vizcelltypes");
00254 
00255     if (mOutputCellAncestors)
00256     {
00257         mpVizCellAncestorsFile = output_file_handler.OpenOutputFile("results.vizancestors");
00258     }
00259     if (mOutputCellMutationStates)
00260     {
00261         // An ordering must be specified for cell mutation states
00262         SetDefaultMutationStateOrdering();
00263 
00264         mpCellMutationStatesFile = output_file_handler.OpenOutputFile("cellmutationstates.dat");
00265 
00266         *mpCellMutationStatesFile << "Time\t ";
00267 
00268         const std::vector<boost::shared_ptr<AbstractCellProperty> >& r_cell_properties =
00269             mpCellPropertyRegistry->rGetAllCellProperties();
00270 
00271         std::vector<unsigned> cell_mutation_state_count;
00272         for (unsigned i=0; i<r_cell_properties.size(); i++)
00273         {
00274             if (r_cell_properties[i]->IsSubType<AbstractCellMutationState>())
00275             {
00276                 *mpCellMutationStatesFile << r_cell_properties[i]->GetIdentifier() << "\t ";
00277             }
00278         }
00279         *mpCellMutationStatesFile << "\n";
00280     }
00281     if (mOutputCellProliferativeTypes)
00282     {
00283         mpCellProliferativeTypesFile = output_file_handler.OpenOutputFile("celltypes.dat");
00284     }
00285     if (mOutputCellVariables)
00286     {
00287         mpCellVariablesFile = output_file_handler.OpenOutputFile("cellvariables.dat");
00288     }
00289     if (mOutputCellCyclePhases)
00290     {
00291         mpCellCyclePhasesFile = output_file_handler.OpenOutputFile("cellcyclephases.dat");
00292     }
00293     if (mOutputCellAges)
00294     {
00295         mpCellAgesFile = output_file_handler.OpenOutputFile("cellages.dat");
00296     }
00297     if (mOutputCellIdData)
00298     {
00299         mpCellIdFile = output_file_handler.OpenOutputFile("loggedcell.dat");
00300     }
00301 
00302     mDirPath = rDirectory;
00303 #ifdef CHASTE_VTK
00304     mpVtkMetaFile = output_file_handler.OpenOutputFile("results.pvd");
00305     *mpVtkMetaFile << "<?xml version=\"1.0\"?>\n";
00306     *mpVtkMetaFile << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n";
00307     *mpVtkMetaFile << "    <Collection>\n";
00308 #endif //CHASTE_VTK
00309 }
00310 
00311 template<unsigned DIM>
00312 void AbstractCellPopulation<DIM>::CloseOutputFiles()
00313 {
00314     mpVizNodesFile->close();
00315     mpVizBoundaryNodesFile->close();
00316     mpVizCellProliferativeTypesFile->close();
00317 
00318     if (mOutputCellMutationStates)
00319     {
00320         mpCellMutationStatesFile->close();
00321     }
00322     if (mOutputCellProliferativeTypes)
00323     {
00324         mpCellProliferativeTypesFile->close();
00325     }
00326     if (mOutputCellVariables)
00327     {
00328         mpCellVariablesFile->close();
00329     }
00330     if (mOutputCellCyclePhases)
00331     {
00332         mpCellCyclePhasesFile->close();
00333     }
00334     if (mOutputCellAncestors)
00335     {
00336         mpVizCellAncestorsFile->close();
00337     }
00338     if (mOutputCellAges)
00339     {
00340         mpCellAgesFile->close();
00341     }
00342     if (mOutputCellIdData)
00343     {
00344         mpCellIdFile->close();
00345     }
00346 #ifdef CHASTE_VTK
00347     *mpVtkMetaFile << "    </Collection>\n";
00348     *mpVtkMetaFile << "</VTKFile>\n";
00349     mpVtkMetaFile->close();
00350 #endif //CHASTE_VTK
00351 }
00352 
00353 template<unsigned DIM>
00354 void AbstractCellPopulation<DIM>::GenerateCellResults(unsigned locationIndex,
00355                                               std::vector<unsigned>& rCellProliferativeTypeCounter,
00356                                               std::vector<unsigned>& rCellCyclePhaseCounter)
00357 {
00358     unsigned colour = STEM_COLOUR;
00359 
00360     CellPtr p_cell = mLocationCellMap[locationIndex];
00361 
00362     if (mOutputCellCyclePhases)
00363     {
00364         // Update rCellCyclePhaseCounter
00365         switch (p_cell->GetCellCycleModel()->GetCurrentCellCyclePhase())
00366         {
00367             case G_ZERO_PHASE:
00368                 rCellCyclePhaseCounter[0]++;
00369                 break;
00370             case G_ONE_PHASE:
00371                 rCellCyclePhaseCounter[1]++;
00372                 break;
00373             case S_PHASE:
00374                 rCellCyclePhaseCounter[2]++;
00375                 break;
00376             case G_TWO_PHASE:
00377                 rCellCyclePhaseCounter[3]++;
00378                 break;
00379              case M_PHASE:
00380                 rCellCyclePhaseCounter[4]++;
00381                 break;
00382             default:
00383                 NEVER_REACHED;
00384         }
00385     }
00386 
00387     if (mOutputCellAncestors)
00388     {
00389         // Set colour dependent on cell ancestor and write to file
00390         colour = p_cell->GetAncestor();
00391         if (colour == UNSIGNED_UNSET)
00392         {
00393             // Set the file to -1 to mark this case.
00394             colour = 1;
00395             *mpVizCellAncestorsFile << "-";
00396         }
00397         *mpVizCellAncestorsFile << colour << " ";
00398     }
00399 
00400     // Set colour dependent on cell type
00401     switch (p_cell->GetCellCycleModel()->GetCellProliferativeType())
00402     {
00403         case STEM:
00404             colour = STEM_COLOUR;
00405             if (mOutputCellProliferativeTypes)
00406             {
00407                 rCellProliferativeTypeCounter[0]++;
00408             }
00409             break;
00410         case TRANSIT:
00411             colour = TRANSIT_COLOUR;
00412             if (mOutputCellProliferativeTypes)
00413             {
00414                 rCellProliferativeTypeCounter[1]++;
00415             }
00416             break;
00417         case DIFFERENTIATED:
00418             colour = DIFFERENTIATED_COLOUR;
00419             if (mOutputCellProliferativeTypes)
00420             {
00421                 rCellProliferativeTypeCounter[2]++;
00422             }
00423             break;
00424         default:
00425             NEVER_REACHED;
00426     }
00427 
00428     if (mOutputCellMutationStates)
00429     {
00430         // Set colour dependent on cell mutation state
00431         if (!p_cell->GetMutationState()->IsType<WildTypeCellMutationState>())
00432         {
00433             colour = p_cell->GetMutationState()->GetColour();
00434         }
00435         if (p_cell->HasCellProperty<CellLabel>())
00436         {
00437             CellPropertyCollection collection = p_cell->rGetCellPropertyCollection().GetProperties<CellLabel>();
00438             boost::shared_ptr<CellLabel> p_label = boost::static_pointer_cast<CellLabel>(collection.GetProperty());
00439             colour = p_label->GetColour();
00440         }
00441     }
00442 
00443     if (p_cell->HasCellProperty<ApoptoticCellProperty>() || p_cell->HasApoptosisBegun())
00444     {
00445         // For any type of cell set the colour to this if it is undergoing apoptosis
00446         colour = APOPTOSIS_COLOUR;
00447     }
00448 
00449     // Write cell variable data to file if required
00450     if (mOutputCellVariables && dynamic_cast<AbstractOdeBasedCellCycleModel*>(p_cell->GetCellCycleModel()) )
00451     {
00452         // Write location index corresponding to cell
00453         *mpCellVariablesFile << locationIndex << " ";
00454 
00455         // Write cell variables
00456         std::vector<double> proteins = (static_cast<AbstractOdeBasedCellCycleModel*>(p_cell->GetCellCycleModel()))->GetProteinConcentrations();
00457         for (unsigned i=0; i<proteins.size(); i++)
00458         {
00459             *mpCellVariablesFile << proteins[i] << " ";
00460         }
00461     }
00462 
00463     // Write cell age data to file if required
00464     if (mOutputCellAges)
00465     {
00466         // Write location index corresponding to cell
00467         *mpCellAgesFile << locationIndex << " ";
00468 
00469         // Write cell location
00470         c_vector<double, DIM> cell_location = GetLocationOfCellCentre(p_cell);
00471 
00472         for (unsigned i=0; i<DIM; i++)
00473         {
00474             *mpCellAgesFile << cell_location[i] << " ";
00475         }
00476 
00477         // Write cell age
00478         *mpCellAgesFile << p_cell->GetAge() << " ";
00479     }
00480 
00481     *mpVizCellProliferativeTypesFile << colour << " ";
00482 }
00483 
00484 template<unsigned DIM>
00485 void AbstractCellPopulation<DIM>::WriteCellResultsToFiles(std::vector<unsigned>& rCellProliferativeTypeCounter,
00486                                                   std::vector<unsigned>& rCellCyclePhaseCounter)
00487 {
00488     *mpVizCellProliferativeTypesFile << "\n";
00489 
00490     if (mOutputCellAncestors)
00491     {
00492         *mpVizCellAncestorsFile << "\n";
00493     }
00494 
00495     // Write cell mutation state data to file if required
00496     if (mOutputCellMutationStates)
00497     {
00498         std::vector<unsigned> mutation_state_count = GetCellMutationStateCount();
00499 
00500         for (unsigned i=0; i<mutation_state_count.size(); i++)
00501         {
00502             *mpCellMutationStatesFile << mutation_state_count[i] << "\t";
00503         }
00504         *mpCellMutationStatesFile << "\n";
00505     }
00506 
00507     // Write cell type data to file if required
00508     if (mOutputCellProliferativeTypes)
00509     {
00510         for (unsigned i=0; i<mCellProliferativeTypeCount.size(); i++)
00511         {
00512             mCellProliferativeTypeCount[i] = rCellProliferativeTypeCounter[i];
00513             *mpCellProliferativeTypesFile << rCellProliferativeTypeCounter[i] << "\t";
00514         }
00515         *mpCellProliferativeTypesFile << "\n";
00516     }
00517 
00518     if (mOutputCellVariables)
00519     {
00520         *mpCellVariablesFile << "\n";
00521     }
00522 
00523     // Write cell cycle phase data to file if required
00524     if (mOutputCellCyclePhases)
00525     {
00526         for (unsigned i=0; i<mCellCyclePhaseCount.size(); i++)
00527         {
00528             mCellCyclePhaseCount[i] = rCellCyclePhaseCounter[i];
00529             *mpCellCyclePhasesFile << rCellCyclePhaseCounter[i] << "\t";
00530         }
00531         *mpCellCyclePhasesFile << "\n";
00532     }
00533 
00534     // Write cell age data to file if required
00535     if (mOutputCellAges)
00536     {
00537         *mpCellAgesFile << "\n";
00538     }
00539 }
00540 
00541 template<unsigned DIM>
00542 void AbstractCellPopulation<DIM>::WriteTimeAndNodeResultsToFiles()
00543 {
00544     double time = SimulationTime::Instance()->GetTime();
00545 
00546     *mpVizNodesFile << time << "\t";
00547     *mpVizBoundaryNodesFile << time << "\t";
00548 
00549     // Write node data to file
00550     for (unsigned node_index=0; node_index<GetNumNodes(); node_index++)
00551     {
00552         if ( !GetNode(node_index)->IsDeleted())
00553         {
00554             const c_vector<double,DIM>& position = GetNode(node_index)->rGetLocation();
00555 
00556             for (unsigned i=0; i<DIM; i++)
00557             {
00558                 *mpVizNodesFile << position[i] << " ";
00559             }
00560             *mpVizBoundaryNodesFile << GetNode(node_index)->IsBoundaryNode() << " ";
00561         }
00562     }
00563     *mpVizNodesFile << "\n";
00564     *mpVizBoundaryNodesFile << "\n";
00565 }
00566 
00567 template<unsigned DIM>
00568 void AbstractCellPopulation<DIM>::WriteResultsToFiles()
00569 {
00570     WriteTimeAndNodeResultsToFiles();
00571 
00572     double time = SimulationTime::Instance()->GetTime();
00573 
00574     *mpVizCellProliferativeTypesFile << time << "\t";
00575 
00576     if (mOutputCellAncestors)
00577     {
00578         *mpVizCellAncestorsFile << time << "\t";
00579     }
00580     if (mOutputCellMutationStates)
00581     {
00582         *mpCellMutationStatesFile << time << "\t";
00583     }
00584     if (mOutputCellProliferativeTypes)
00585     {
00586         *mpCellProliferativeTypesFile << time << "\t";
00587     }
00588     if (mOutputCellVariables)
00589     {
00590         *mpCellVariablesFile << time << "\t";
00591     }
00592     if (mOutputCellCyclePhases)
00593     {
00594         *mpCellCyclePhasesFile << time << "\t";
00595     }
00596     if (mOutputCellAges)
00597     {
00598         *mpCellAgesFile << time << "\t";
00599     }
00600 
00601     GenerateCellResultsAndWriteToFiles();
00602 
00603     // Write logged cell data if required
00604     if (mOutputCellIdData)
00605     {
00606         WriteCellIdDataToFile();
00607     }
00608 
00609     WriteVtkResultsToFile();
00610 }
00611 
00612 template<unsigned DIM>
00613 void AbstractCellPopulation<DIM>::WriteCellIdDataToFile()
00614 {
00615     // Write time to file
00616     *mpCellIdFile << SimulationTime::Instance()->GetTime();
00617 
00618     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = Begin();
00619          cell_iter != End();
00620          ++cell_iter)
00621     {
00622         unsigned cell_id = cell_iter->GetCellId();
00623         unsigned location_index = mCellLocationMap[(*cell_iter).get()];
00624         *mpCellIdFile << " " << cell_id << " " << location_index;
00625 
00626         c_vector<double, DIM> coords = GetLocationOfCellCentre(*cell_iter);
00627         for (unsigned i=0; i<DIM; i++)
00628         {
00629             *mpCellIdFile << " " << coords[i];
00630         }
00631     }
00632     *mpCellIdFile << "\n";
00633 }
00634 
00635 template<unsigned DIM>
00636 void AbstractCellPopulation<DIM>::OutputCellPopulationInfo(out_stream& rParamsFile)
00637 {
00638     std::string cell_population_type = GetIdentifier();
00639 
00640     *rParamsFile << "\t<" << cell_population_type << ">\n";
00641     OutputCellPopulationParameters(rParamsFile);
00642     *rParamsFile << "\t</" << cell_population_type << ">\n";
00643     *rParamsFile << "\n";
00644     *rParamsFile << "\t<CellCycleModels>\n";
00645 
00650     std::set<std::string> unique_cell_cycle_models;
00651     std::vector<CellPtr> first_cell_with_unique_CCM;
00652     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->Begin();
00653          cell_iter != this->End();
00654          ++cell_iter)
00655     {
00656         std::string identifier = cell_iter->GetCellCycleModel()->GetIdentifier();
00657         if (unique_cell_cycle_models.count(identifier) == 0)
00658         {
00659             unique_cell_cycle_models.insert(identifier);
00660             first_cell_with_unique_CCM.push_back((*cell_iter));
00661         }
00662     }
00663 
00664     // Loop over unique cell-cycle models
00665     for (unsigned i=0; i<first_cell_with_unique_CCM.size(); i++)
00666     {
00667         // Output cell-cycle model details
00668         first_cell_with_unique_CCM[i]->GetCellCycleModel()->OutputCellCycleModelInfo(rParamsFile);
00669     }
00670 
00671     *rParamsFile << "\t</CellCycleModels>\n";
00672 }
00673 
00674 template<unsigned DIM>
00675 void AbstractCellPopulation<DIM>::OutputCellPopulationParameters(out_stream& rParamsFile)
00676 {
00677     *rParamsFile << "\t\t<DampingConstantNormal>" << mDampingConstantNormal << "</DampingConstantNormal>\n";
00678     *rParamsFile << "\t\t<DampingConstantMutant>" << mDampingConstantMutant << "</DampingConstantMutant>\n";
00679     *rParamsFile << "\t\t<OutputCellIdData>" << mOutputCellIdData << "</OutputCellIdData> \n";
00680     *rParamsFile << "\t\t<OutputCellMutationStates>" << mOutputCellMutationStates << "</OutputCellMutationStates> \n";
00681     *rParamsFile << "\t\t<OutputCellAncestors>" << mOutputCellAncestors << "</OutputCellAncestors> \n";
00682     *rParamsFile << "\t\t<OutputCellProliferativeTypes>" << mOutputCellProliferativeTypes << "</OutputCellProliferativeTypes> \n";
00683     *rParamsFile << "\t\t<OutputCellVariables>" << mOutputCellVariables << "</OutputCellVariables> \n";
00684     *rParamsFile << "\t\t<OutputCellCyclePhases>" << mOutputCellCyclePhases << "</OutputCellCyclePhases> \n";
00685     *rParamsFile << "\t\t<OutputCellAges>" << mOutputCellAges << "</OutputCellAges> \n";
00686     *rParamsFile << "\t\t<OutputCellVolumes>" << mOutputCellVolumes << "</OutputCellVolumes> \n";
00687 }
00688 
00690 // Getter methods
00692 
00693 template<unsigned DIM>
00694 double AbstractCellPopulation<DIM>::GetDampingConstantNormal()
00695 {
00696     return mDampingConstantNormal;
00697 }
00698 
00699 template<unsigned DIM>
00700 double AbstractCellPopulation<DIM>::GetDampingConstantMutant()
00701 {
00702     return mDampingConstantMutant;
00703 }
00704 
00705 template<unsigned DIM>
00706 bool AbstractCellPopulation<DIM>::GetOutputCellIdData()
00707 {
00708     return mOutputCellIdData;
00709 }
00710 
00711 template<unsigned DIM>
00712 bool AbstractCellPopulation<DIM>::GetOutputCellMutationStates()
00713 {
00714     return mOutputCellMutationStates;
00715 }
00716 
00717 template<unsigned DIM>
00718 bool AbstractCellPopulation<DIM>::GetOutputCellAncestors()
00719 {
00720     return mOutputCellAncestors;
00721 }
00722 
00723 template<unsigned DIM>
00724 bool AbstractCellPopulation<DIM>::GetOutputCellProliferativeTypes()
00725 {
00726     return mOutputCellProliferativeTypes;
00727 }
00728 
00729 template<unsigned DIM>
00730 bool AbstractCellPopulation<DIM>::GetOutputCellVariables()
00731 {
00732     return mOutputCellVariables;
00733 }
00734 
00735 template<unsigned DIM>
00736 bool AbstractCellPopulation<DIM>::GetOutputCellCyclePhases()
00737 {
00738     return mOutputCellCyclePhases;
00739 }
00740 
00741 template<unsigned DIM>
00742 bool AbstractCellPopulation<DIM>::GetOutputCellAges()
00743 {
00744     return mOutputCellAges;
00745 }
00746 
00747 template<unsigned DIM>
00748 bool AbstractCellPopulation<DIM>::GetOutputCellVolumes()
00749 {
00750     return mOutputCellVolumes;
00751 }
00752 
00754 // Setter methods
00756 
00757 template<unsigned DIM>
00758 void AbstractCellPopulation<DIM>::SetDampingConstantNormal(double dampingConstantNormal)
00759 {
00760     assert(dampingConstantNormal > 0.0);
00761     mDampingConstantNormal = dampingConstantNormal;
00762 }
00763 
00764 template<unsigned DIM>
00765 void AbstractCellPopulation<DIM>::SetDampingConstantMutant(double dampingConstantMutant)
00766 {
00767     assert(dampingConstantMutant > 0.0);
00768     mDampingConstantMutant = dampingConstantMutant;
00769 }
00770 
00771 template<unsigned DIM>
00772 void AbstractCellPopulation<DIM>::SetOutputCellIdData(bool writeCellIdData)
00773 {
00774     mOutputCellIdData = writeCellIdData;
00775 }
00776 
00777 template<unsigned DIM>
00778 void AbstractCellPopulation<DIM>::SetOutputCellMutationStates(bool outputCellMutationStates)
00779 {
00780     mOutputCellMutationStates = outputCellMutationStates;
00781 }
00782 
00783 template<unsigned DIM>
00784 void AbstractCellPopulation<DIM>::SetOutputCellAncestors(bool outputCellAncestors)
00785 {
00786     mOutputCellAncestors = outputCellAncestors;
00787 }
00788 
00789 template<unsigned DIM>
00790 void AbstractCellPopulation<DIM>::SetOutputCellProliferativeTypes(bool outputCellProliferativeTypes)
00791 {
00792     mOutputCellProliferativeTypes = outputCellProliferativeTypes;
00793 }
00794 
00795 template<unsigned DIM>
00796 void AbstractCellPopulation<DIM>::SetOutputCellVariables(bool outputCellVariables)
00797 {
00798     mOutputCellVariables = outputCellVariables;
00799 }
00800 
00801 template<unsigned DIM>
00802 void AbstractCellPopulation<DIM>::SetOutputCellCyclePhases(bool outputCellCyclePhases)
00803 {
00804     mOutputCellCyclePhases = outputCellCyclePhases;
00805 }
00806 
00807 template<unsigned DIM>
00808 void AbstractCellPopulation<DIM>::SetOutputCellAges(bool outputCellAges)
00809 {
00810     mOutputCellAges = outputCellAges;
00811 }
00812 
00813 template<unsigned DIM>
00814 void AbstractCellPopulation<DIM>::SetOutputCellVolumes(bool outputCellVolumes)
00815 {
00816     mOutputCellVolumes = outputCellVolumes;
00817 }
00818 
00820 // Explicit instantiation
00822 
00823 template class AbstractCellPopulation<1>;
00824 template class AbstractCellPopulation<2>;
00825 template class AbstractCellPopulation<3>;

Generated on Mon Apr 18 11:35:27 2011 for Chaste by  doxygen 1.5.5