36#include "AveragedSourceParabolicPde.hpp"
37#include "ApoptoticCellProperty.hpp"
41 double constantSourceCoefficient,
42 double linearSourceCoefficient,
43 double diffusionCoefficient,
44 double duDtCoefficient,
45 bool scaleByCellVolume)
46 : mrCellPopulation(rCellPopulation),
47 mConstantSourceCoefficient(constantSourceCoefficient),
48 mLinearSourceCoefficient(linearSourceCoefficient),
49 mDiffusionCoefficient(diffusionCoefficient),
50 mDuDtCoefficient(duDtCoefficient),
51 mScaleByCellVolume(scaleByCellVolume)
58 return mrCellPopulation;
64 return mConstantSourceCoefficient;
70 return mLinearSourceCoefficient;
76 return mDiffusionCoefficient;
82 return mDuDtCoefficient;
88 return mScaleByCellVolume;
96 for (
double & mCellDensityOnCoarseElement : mCellDensityOnCoarseElements)
98 mCellDensityOnCoarseElement = 0.0;
103 cell_iter != mrCellPopulation.End();
106 unsigned elem_index = 0;
107 const ChastePoint<DIM>& r_position_of_cell = mrCellPopulation.GetLocationOfCellCentre(*cell_iter);
109 if (pCellPdeElementMap !=
nullptr)
111 elem_index = (*pCellPdeElementMap)[*cell_iter];
119 bool cell_is_apoptotic = cell_iter->template HasCellProperty<ApoptoticCellProperty>();
121 if (!cell_is_apoptotic)
123 double cell_weight = 1.0;
125 if (mScaleByCellVolume)
128 cell_weight = mrCellPopulation.GetVolumeOfCell(*cell_iter);
130 if (cell_weight <1e-6)
132 EXCEPTION(
"The volume of one of the cells is " << cell_weight <<
133 " and you are scaling by cell volume. Either turn scaling off or use"
134 " a cell model with non zero areas (i.e. a Bounded Voronoi Tesselation model).");
138 mCellDensityOnCoarseElements[elem_index] += cell_weight;
143 c_matrix<double, DIM, DIM> jacobian;
145 for (
unsigned elem_index=0; elem_index<mCellDensityOnCoarseElements.size(); elem_index++)
147 rCoarseMesh.
GetElement(elem_index)->CalculateJacobian(jacobian, det);
148 mCellDensityOnCoarseElements[elem_index] /= rCoarseMesh.
GetElement(elem_index)->GetVolume(det);
152template<
unsigned DIM>
155 return mDuDtCoefficient;
158template<
unsigned DIM>
161 assert(!mCellDensityOnCoarseElements.empty());
164 double source_term = (mLinearSourceCoefficient * u + mConstantSourceCoefficient) * mCellDensityOnCoarseElements[pElement->
GetIndex()];
170template<
unsigned DIM>
177template<
unsigned DIM>
180 return mDiffusionCoefficient*identity_matrix<double>(DIM);
183template<
unsigned DIM>
186 return this->mCellDensityOnCoarseElements[elementIndex];
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
unsigned GetIndex() const
unsigned GetContainingElementIndex(const ChastePoint< SPACE_DIM > &rTestPoint, bool strict=false, std::set< unsigned > testElements=std::set< unsigned >(), bool onlyTryWithTestElements=false)
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
virtual unsigned GetNumElements() const
double ComputeSourceTerm(const ChastePoint< DIM > &rX, double u, Element< DIM, DIM > *pElement) override
double GetConstantCoefficient() const
double ComputeDuDtCoefficientFunction(const ChastePoint< DIM > &rX) override
bool GetScaleByCellVolume() const
double GetDiffusionCoefficient() const
c_matrix< double, DIM, DIM > ComputeDiffusionTerm(const ChastePoint< DIM > &rX, Element< DIM, DIM > *pElement=nullptr) override
AveragedSourceParabolicPde(AbstractCellPopulation< DIM, DIM > &rCellPopulation, double constantSourceCoefficient=0.0, double linearSourceCoefficient=0.0, double diffusionCoefficient=1.0, double duDtCoefficient=1.0, bool scaleByCellVolume=false)
double GetDuDtCoefficient() const
double GetUptakeRateForElement(unsigned elementIndex)
double ComputeSourceTermAtNode(const Node< DIM > &rNode, double u) override
const AbstractCellPopulation< DIM > & rGetCellPopulation() const
virtual void SetupSourceTerms(TetrahedralMesh< DIM, DIM > &rCoarseMesh, std::map< CellPtr, unsigned > *pCellPdeElementMap=nullptr)
double GetLinearCoefficient() const