Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
WelikyOsterForce.cpp
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#include "WelikyOsterForce.hpp"
37
38template<unsigned DIM>
40 : AbstractForce<DIM>(),
41 mWelikyOsterAreaParameter(1.0),
42 mWelikyOsterPerimeterParameter(1.0)
43{
44}
45
46template<unsigned DIM>
50
51template <unsigned DIM>
53{
54 // This method only works in 2D at present
55 if constexpr (DIM == 2)
56 {
57 // Throw an exception message if not using a VertexBasedCellPopulation
58 if (dynamic_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation) == nullptr)
59 {
60 EXCEPTION("WelikyOsterForce is to be used with a VertexBasedCellPopulation only");
61 }
62
63 // Helper variable that is a static cast of the cell population
64 VertexBasedCellPopulation<DIM>* p_cell_population = static_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation);
65
66 /*
67 * The force on each node is given by the interaction between the area and
68 * the perimeter of the element containing the node.
69 */
70
71 // Iterate over elements in the cell population
72 for (typename VertexMesh<DIM,DIM>::VertexElementIterator element_iter = p_cell_population->rGetMesh().GetElementIteratorBegin();
73 element_iter != p_cell_population->rGetMesh().GetElementIteratorEnd();
74 ++element_iter)
75 {
76 unsigned element_index = element_iter->GetIndex();
77
78 /******** Start of deformation force calculation ********/
79
80 // Compute the area of this element
81 double element_area = p_cell_population->rGetMesh().GetVolumeOfElement(element_index);
82
83 double deformation_coefficient = GetWelikyOsterAreaParameter()/element_area;
84
85 /******** End of deformation force calculation *************/
86
87 /******** Start of membrane force calculation ***********/
88
89 // Compute the perimeter of the element
90 double element_perimeter = p_cell_population->rGetMesh().GetSurfaceAreaOfElement(element_index);
91
92 double membrane_surface_tension_coefficient = GetWelikyOsterPerimeterParameter()*element_perimeter;
93
94 /******** End of membrane force calculation **********/
95
96 unsigned num_nodes = element_iter->GetNumNodes();
97 for (unsigned node_local_index = 0; node_local_index < num_nodes; node_local_index++)
98 {
99 unsigned node_global_index = element_iter->GetNodeGlobalIndex(node_local_index);
100
101 c_vector<double, DIM> current_node = element_iter->GetNodeLocation(node_local_index);
102 c_vector<double, DIM> next_node = element_iter->GetNodeLocation((node_local_index + 1)%(element_iter->GetNumNodes()));
103 c_vector<double, DIM> previous_node = element_iter->GetNodeLocation((node_local_index + element_iter->GetNumNodes() - 1)%(element_iter->GetNumNodes()));
104
105 c_vector<double, DIM> clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, previous_node);
106 clockwise_unit_vector /= norm_2(clockwise_unit_vector);
107
108 c_vector<double, DIM> anti_clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, next_node);
109 anti_clockwise_unit_vector /= norm_2(anti_clockwise_unit_vector);
110
111 // Calculate the outward normal at the node
112 c_vector<double, DIM> outward_normal = -0.5*clockwise_unit_vector - 0.5*anti_clockwise_unit_vector;
113 outward_normal /= norm_2(outward_normal);
114
115 c_vector<double, DIM> deformation_contribution = deformation_coefficient * outward_normal;
116
117 c_vector<double, DIM> membrane_surface_tension_contribution = membrane_surface_tension_coefficient * (clockwise_unit_vector + anti_clockwise_unit_vector);
118
119 c_vector<double, DIM> force_on_node = deformation_contribution + membrane_surface_tension_contribution;
120
121 p_cell_population->GetNode(node_global_index)->AddAppliedForceContribution(force_on_node);
122 }
123 }
124 }
125 else
126 {
128 }
129}
130
131template<unsigned DIM>
133{
134 return mWelikyOsterAreaParameter;
135}
136
137template<unsigned DIM>
139{
140 return mWelikyOsterPerimeterParameter;
141}
142
143template<unsigned DIM>
144void WelikyOsterForce<DIM>::SetWelikyOsterAreaParameter(double welikyOsterAreaParameter)
145{
146 mWelikyOsterAreaParameter = welikyOsterAreaParameter;
147}
148
149template<unsigned DIM>
150void WelikyOsterForce<DIM>::SetWelikyOsterPerimeterParameter(double welikyOsterPerimeterParameter)
151{
152 mWelikyOsterPerimeterParameter = welikyOsterPerimeterParameter;
153}
154
155template<unsigned DIM>
157{
158 *rParamsFile << "\t\t\t<WelikyOsterAreaParameter>" << mWelikyOsterAreaParameter << "</WelikyOsterAreaParameter>\n";
159 *rParamsFile << "\t\t\t<WelikyOsterPerimeterParameter>" << mWelikyOsterPerimeterParameter << "</WelikyOsterPerimeterParameter>\n";
160
161 // Call method on direct parent class
163}
164
165// Explicit instantiation
166template class WelikyOsterForce<1>;
167template class WelikyOsterForce<2>;
168template class WelikyOsterForce<3>;
169
170// Serialization for Boost >= 1.36
#define EXCEPTION(message)
#define NEVER_REACHED
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputForceParameters(out_stream &rParamsFile)=0
void AddAppliedForceContribution(const c_vector< double, SPACE_DIM > &rForceContribution)
Definition Node.cpp:224
MutableVertexMesh< DIM, DIM > & rGetMesh()
Node< DIM > * GetNode(unsigned index)
virtual c_vector< double, SPACE_DIM > GetVectorFromAtoB(const c_vector< double, SPACE_DIM > &rLocationA, const c_vector< double, SPACE_DIM > &rLocationB)
VertexElementIterator GetElementIteratorEnd()
virtual double GetSurfaceAreaOfElement(unsigned index)
VertexElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
virtual double GetVolumeOfElement(unsigned index)
void SetWelikyOsterPerimeterParameter(double welikyOsterPerimeterParameter)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
void SetWelikyOsterAreaParameter(double welikyOsterAreaParameter)
void OutputForceParameters(out_stream &rParamsFile)
double GetWelikyOsterAreaParameter()
double GetWelikyOsterPerimeterParameter()