Chaste Commit::6e4f5fe395bca70eb7641cf6e0e87f450383ca5a
CellPopulationAreaWriter.cpp
1/*
2
3Copyright (c) 2005-2026, 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#include "CellPopulationAreaWriter.hpp"
37
38#include "MeshBasedCellPopulation.hpp"
39#include "CaBasedCellPopulation.hpp"
40#include "NodeBasedCellPopulation.hpp"
41#include "PottsBasedCellPopulation.hpp"
42#include "VertexBasedCellPopulation.hpp"
43#include "ImmersedBoundaryCellPopulation.hpp"
44
45#include "ApoptoticCellProperty.hpp"
46
47template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
52
53template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
55 [[maybe_unused]] MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>* pCellPopulation) // [[maybe_unused]] due to unused-but-set-parameter warning in GCC 7,8,9
56{
57 if constexpr ((SPACE_DIM == 2) || (SPACE_DIM == 3))
58 {
59 VertexMesh<ELEMENT_DIM, SPACE_DIM>* voronoi_tessellation = pCellPopulation->GetVoronoiTessellation();
60
61 assert(voronoi_tessellation != nullptr);
62
63 // Don't use the Voronoi tessellation to calculate the total area of the mesh because it gives huge areas for boundary cells
64 double total_area = static_cast<MutableMesh<ELEMENT_DIM,SPACE_DIM>&>((pCellPopulation->rGetMesh())).GetVolume();
65 double apoptotic_area = 0.0;
66
67 // Loop over elements of mpVoronoiTessellation
68 for (typename VertexMesh<ELEMENT_DIM,SPACE_DIM>::VertexElementIterator elem_iter = voronoi_tessellation->GetElementIteratorBegin();
69 elem_iter != voronoi_tessellation->GetElementIteratorEnd();
70 ++elem_iter)
71 {
72 // Get index of this element in mpVoronoiTessellation
73 unsigned elem_index = elem_iter->GetIndex();
74
75 // Get the index of the corresponding node in mrMesh
76 unsigned node_index = voronoi_tessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
77
78 // Discount ghost nodes
79 if (!pCellPopulation->IsGhostNode(node_index))
80 {
81 // Get the cell corresponding to this node
82 CellPtr p_cell = pCellPopulation->GetCellUsingLocationIndex(node_index);
83
84 // Only bother calculating the area/volume of apoptotic cells
85 bool cell_is_apoptotic = p_cell->HasCellProperty<ApoptoticCellProperty>();
86 if (cell_is_apoptotic)
87 {
88 double cell_volume = voronoi_tessellation->GetVolumeOfElement(elem_index);
89 apoptotic_area += cell_volume;
90 }
91 }
92 }
93 *this->mpOutStream << total_area << " " << apoptotic_area;
94 }
95 else
96 {
98 }
99}
100
101template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
103{
104 EXCEPTION("CellPopulationAreaWriter cannot be used with a CaBasedCellPopulation");
105}
106
107template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
109{
110 EXCEPTION("CellPopulationAreaWriter cannot be used with a NodeBasedCellPopulation");
111}
112
113template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
115{
116 EXCEPTION("CellPopulationAreaWriter cannot be used with a PottsBasedCellPopulation");
117}
118
119template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
121{
122 EXCEPTION("CellPopulationAreaWriter cannot be used with a VertexBasedCellPopulation");
123}
124
125template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
127{
128 EXCEPTION("CellPopulationAreaWriter cannot be used with a ImmersedBoundaryCellPopulation");
129}
130
131// Explicit instantiation
132template class CellPopulationAreaWriter<1,1>;
133template class CellPopulationAreaWriter<1,2>;
134template class CellPopulationAreaWriter<2,2>;
135template class CellPopulationAreaWriter<1,3>;
136template class CellPopulationAreaWriter<2,3>;
137template class CellPopulationAreaWriter<3,3>;
138
140// Declare identifier for the serializer
#define EXCEPTION(message)
#define NEVER_REACHED
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
virtual void Visit(MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > *pCellPopulation)
VertexElementIterator GetElementIteratorEnd()
VertexElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
unsigned GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(unsigned elementIndex)
virtual double GetVolumeOfElement(unsigned index)