00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "AveragedSourcePde.hpp"
00030 #include "ApoptoticCellProperty.hpp"
00031
00032 template<unsigned DIM>
00033 AveragedSourcePde<DIM>::AveragedSourcePde(MeshBasedCellPopulation<DIM>& rCellPopulation, double coefficient)
00034 : mrCellPopulation(rCellPopulation),
00035 mCoefficient(coefficient)
00036 {
00037 }
00038
00039 template<unsigned DIM>
00040 void AveragedSourcePde<DIM>::SetupSourceTerms(TetrahedralMesh<DIM,DIM>& rCoarseMesh)
00041 {
00042
00043 mCellDensityOnCoarseElements.resize(rCoarseMesh.GetNumElements());
00044 for (unsigned elem_index=0; elem_index<mCellDensityOnCoarseElements.size(); elem_index++)
00045 {
00046 mCellDensityOnCoarseElements[elem_index] = 0.0;
00047 }
00048
00049
00050 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = mrCellPopulation.Begin();
00051 cell_iter != mrCellPopulation.End();
00052 ++cell_iter)
00053 {
00054 const ChastePoint<DIM>& r_position_of_cell = mrCellPopulation.GetLocationOfCellCentre(*cell_iter);
00055 unsigned elem_index = rCoarseMesh.GetContainingElementIndex(r_position_of_cell);
00056
00057 bool cell_is_apoptotic = cell_iter->template HasCellProperty<ApoptoticCellProperty>();
00058
00059 if (!cell_is_apoptotic)
00060 {
00061 mCellDensityOnCoarseElements[elem_index] += 1.0;
00062 }
00063 }
00064
00065
00066 c_matrix<double, DIM, DIM> jacobian;
00067 double det;
00068 for (unsigned elem_index=0; elem_index<mCellDensityOnCoarseElements.size(); elem_index++)
00069 {
00070 rCoarseMesh.GetElement(elem_index)->CalculateJacobian(jacobian, det);
00071 mCellDensityOnCoarseElements[elem_index] /= rCoarseMesh.GetElement(elem_index)->GetVolume(det);
00072 }
00073 }
00074
00075 template<unsigned DIM>
00076 double AveragedSourcePde<DIM>::ComputeConstantInUSourceTerm(const ChastePoint<DIM>& rX)
00077 {
00078 return 0.0;
00079 }
00080
00081 template<unsigned DIM>
00082 double AveragedSourcePde<DIM>::ComputeLinearInUCoeffInSourceTerm(const ChastePoint<DIM>& rX, Element<DIM,DIM>* pElement)
00083 {
00084 assert(!mCellDensityOnCoarseElements.empty());
00085 return mCoefficient*mCellDensityOnCoarseElements[pElement->GetIndex()];
00086 }
00087
00088 template<unsigned DIM>
00089 c_matrix<double,DIM,DIM> AveragedSourcePde<DIM>::ComputeDiffusionTerm(const ChastePoint<DIM>& rX)
00090 {
00091 return identity_matrix<double>(DIM);
00092 }
00093
00094
00096
00098
00099 template class AveragedSourcePde<1>;
00100 template class AveragedSourcePde<2>;
00101 template class AveragedSourcePde<3>;