Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
ImmersedBoundaryCellPopulation.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef IMMERSEDBOUNDARYCELLPOPULATION_HPP_
37#define IMMERSEDBOUNDARYCELLPOPULATION_HPP_
38
39#include "AbstractOffLatticeCellPopulation.hpp"
40#include "ImmersedBoundaryMesh.hpp"
41
42#include <boost/serialization/base_object.hpp>
43#include <boost/serialization/set.hpp>
44#include <boost/serialization/vector.hpp>
46
47template <unsigned DIM>
49
56template <unsigned DIM>
58{
59private:
62
65
71
77
83 boost::shared_ptr<AbstractImmersedBoundaryDivisionRule<DIM> > mpImmersedBoundaryDivisionRule;
84
90
93
96
99
102
105
111
118 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
119
120 friend class boost::serialization::access;
133 template <class Archive>
134 void serialize(Archive& archive, const unsigned int version)
135 {
136 archive& boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
139 archive& mInteractionDistance;
140 archive& mReMeshFrequency;
143 }
144
153 double Delta1D(double dist, double spacing);
154
161
166 void Validate();
167
168public:
186 std::vector<CellPtr>& rCells,
187 bool deleteMesh = false,
188 bool validate = true,
189 const std::vector<unsigned> locationIndices = std::vector<unsigned>());
190
197
202
209 double GetDampingConstant(unsigned nodeIndex);
210
215
220
228 ImmersedBoundaryElement<DIM, DIM>* GetElement(unsigned elementIndex);
229
239 ImmersedBoundaryElement<DIM - 1, DIM>* GetLamina(unsigned laminaIndex);
240
244 unsigned GetNumElements();
245
249 unsigned GetNumLaminas();
250
256 unsigned GetNumNodes();
257
263 void SetInteractionDistance(double newDistance);
264
268 double GetInteractionDistance() const;
269
276 void SetReMeshFrequency(unsigned newFrequency);
277
281 unsigned GetReMeshFrequency() const;
282
289 void SetThrowsStepSizeException(bool throws);
290
294 bool ThrowsStepSizeException() const;
295
299 double GetIntrinsicSpacing() const;
300
307 void SetCellRearrangementThreshold(double newThreshold);
308
312 double GetCellRearrangementThreshold() const;
313
325 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
326
334 Node<DIM>* GetNode(unsigned index);
335
346 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
347
355 unsigned AddNode(Node<DIM>* pNewNode);
356
362 void UpdateNodeLocations(double dt);
363
372 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
373
382 CellPtr pCell);
383
395 CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell = CellPtr());
396
405 unsigned RemoveDeadCells();
406
413 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
414
423 void Update(bool hasHadBirthsOrDeaths = true);
424
432 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
433
439 virtual void AcceptPopulationWriter(
440 boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
441
447 virtual void AcceptPopulationEventWriter(
448 boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
449
455 virtual void AcceptPopulationCountWriter(
456 boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
457
464 virtual void AcceptCellWriter(
465 boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter,
466 CellPtr pCell);
467
475 double GetVolumeOfCell(CellPtr pCell);
476
482 void OutputCellPopulationParameters(out_stream& rParamsFile);
483
494 double GetWidth(const unsigned& rDimension);
495
503 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
504
515
526 virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
527
545 virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
546 std::string& rVariableName,
547 bool dirichletBoundaryConditionApplies = false,
548 double dirichletBoundaryValue = 0.0);
549
553 boost::shared_ptr<AbstractImmersedBoundaryDivisionRule<DIM> > GetImmersedBoundaryDivisionRule();
554
561 boost::shared_ptr<AbstractImmersedBoundaryDivisionRule<DIM> > pImmersedBoundaryDivisionRule);
562
568
574 bool IsCellOnBoundary(CellPtr pCell);
575
581 void SetIfPopulationHasActiveSources(bool hasActiveSources);
582
588 void SetOutputNodeRegionToVtk(bool outputNodeRegionsToVtk);
589
601 virtual void CheckForStepSizeException(
602 unsigned nodeIndex,
603 c_vector<double, DIM>& rDisplacement,
604 double dt);
605
616 virtual double GetDefaultTimeStep();
617};
618
621
622namespace boost
623{
624namespace serialization
625{
629 template <class Archive, unsigned DIM>
630 inline void save_construct_data(
631 Archive& ar, const ImmersedBoundaryCellPopulation<DIM>* t, const unsigned int file_version)
632 {
633 // Save data required to construct instance
634 const ImmersedBoundaryMesh<DIM, DIM>* p_mesh = &(t->rGetMesh());
635 ar& p_mesh;
636 ar& t->DoesPopulationHaveActiveSources();
637 ar& t->GetInteractionDistance();
638 ar& t->GetReMeshFrequency();
639 ar& t->ThrowsStepSizeException();
640 ar& t->GetCellRearrangementThreshold();
641 }
642
647 template <class Archive, unsigned DIM>
648 inline void load_construct_data(
649 Archive& ar, ImmersedBoundaryCellPopulation<DIM>* t, const unsigned int file_version)
650 {
651 // Retrieve data from archive required to construct new instance
653 ar >> p_mesh;
654 bool hasActiveSources = false;
655 ar >> hasActiveSources;
656 double interactionDistance = 0.0;
657 ar >> interactionDistance;
658 unsigned int reMeshFrequency = 1;
659 ar >> reMeshFrequency;
660 bool throwStepSizeException = false;
661 ar >> throwStepSizeException;
662 double cellRearrangementThreshold = 0.5;
663 ar >> cellRearrangementThreshold;
664
665 // Invoke inplace constructor to initialise instance
666 ::new (t) ImmersedBoundaryCellPopulation<DIM>(*p_mesh);
667 t->SetIfPopulationHasActiveSources(hasActiveSources);
668 t->SetInteractionDistance(interactionDistance);
669 t->SetReMeshFrequency(reMeshFrequency);
670 t->SetThrowsStepSizeException(true);
671 t->SetCellRearrangementThreshold(cellRearrangementThreshold);
672 }
673}
674} // namespace ...
675
676#endif /*IMMERSEDBOUNDARYCELLPOPULATION_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
double Delta1D(double dist, double spacing)
boost::shared_ptr< AbstractImmersedBoundaryDivisionRule< DIM > > mpImmersedBoundaryDivisionRule
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< DIM, DIM > > pPopulationEventWriter)
ImmersedBoundaryMesh< DIM, DIM > & rGetMesh()
boost::shared_ptr< AbstractImmersedBoundaryDivisionRule< DIM > > GetImmersedBoundaryDivisionRule()
ImmersedBoundaryElement< DIM - 1, DIM > * GetLamina(unsigned laminaIndex)
ImmersedBoundaryElement< DIM, DIM > * GetElementCorrespondingToCell(CellPtr pCell)
ImmersedBoundaryElement< DIM, DIM > * GetElement(unsigned elementIndex)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
void Update(bool hasHadBirthsOrDeaths=true)
void SetCellRearrangementThreshold(double newThreshold)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex)
void SetImmersedBoundaryDivisionRule(boost::shared_ptr< AbstractImmersedBoundaryDivisionRule< DIM > > pImmersedBoundaryDivisionRule)
void SetOutputNodeRegionToVtk(bool outputNodeRegionsToVtk)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
void SetNode(unsigned index, ChastePoint< DIM > &rNewLocation)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
ImmersedBoundaryMesh< DIM, DIM > * mpImmersedBoundaryMesh
void SetIfPopulationHasActiveSources(bool hasActiveSources)
void serialize(Archive &archive, const unsigned int version)
virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector< double, DIM > &rDisplacement, double dt)
double GetWidth(const unsigned &rDimension)
Definition Node.hpp:59