Chaste  Release::3.4
NagaiHondaDifferentialAdhesionForce.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, 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 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "NagaiHondaDifferentialAdhesionForce.hpp"
37 #include "CellLabel.hpp"
38 
39 template<unsigned DIM>
41  : NagaiHondaForce<DIM>(),
42  mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(1.0),
43  mNagaiHondaLabelledCellCellAdhesionEnergyParameter(1.0),
44  mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(1.0)
45 {
46 }
47 
48 template<unsigned DIM>
50 {
51 }
52 
53 template<unsigned DIM>
55  Node<DIM>* pNodeB,
56  VertexBasedCellPopulation<DIM>& rVertexCellPopulation)
57 {
58  // Find the indices of the elements owned by each node
59  std::set<unsigned> elements_containing_nodeA = pNodeA->rGetContainingElementIndices();
60  std::set<unsigned> elements_containing_nodeB = pNodeB->rGetContainingElementIndices();
61 
62  // Find common elements
63  std::set<unsigned> shared_elements;
64  std::set_intersection(elements_containing_nodeA.begin(),
65  elements_containing_nodeA.end(),
66  elements_containing_nodeB.begin(),
67  elements_containing_nodeB.end(),
68  std::inserter(shared_elements, shared_elements.begin()));
69 
70  // Check that the nodes have a common edge
71  assert(!shared_elements.empty());
72 
73  // If the edge corresponds to a single element, then the cell is on the boundary
74  if (shared_elements.size() == 1)
75  {
76  unsigned element_index = *(shared_elements.begin());
77 
78  // Get cell associated with this element
79  CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index);
80 
81  if (p_cell->template HasCellProperty<CellLabel>())
82  {
83  // This cell is labelled
84  return this->GetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter();
85  }
86  else
87  {
88  // This cell is not labelled
89  return this->GetNagaiHondaCellBoundaryAdhesionEnergyParameter();
90  }
91  }
92  else
93  {
94  // Work out the number of labelled cells: 0,1 or 2
95  unsigned num_labelled_cells = 0;
96  for (std::set<unsigned>::iterator iter = shared_elements.begin();
97  iter != shared_elements.end();
98  ++iter)
99  {
100  unsigned element_index = *(iter);
101 
102  // Get cell associated with this element
103  CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index);
104 
105  if (p_cell->template HasCellProperty<CellLabel>())
106  {
107  num_labelled_cells++;
108  }
109  }
110 
111  if (num_labelled_cells == 2)
112  {
113  // Both cells are labelled
114  return this->GetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter();
115  }
116  else if (num_labelled_cells == 1)
117  {
118  // One cell is labelled
119  return this->GetNagaiHondaLabelledCellCellAdhesionEnergyParameter();
120  }
121  else
122  {
123  // Neither cell is labelled
124  assert(num_labelled_cells == 0);
125  return this->GetNagaiHondaCellCellAdhesionEnergyParameter();
126  }
127  }
128 }
129 
130 template<unsigned DIM>
132 {
133  return mNagaiHondaLabelledCellCellAdhesionEnergyParameter;
134 }
135 
136 template<unsigned DIM>
138 {
139  return mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter;
140 }
141 
142 template<unsigned DIM>
144 {
145  return mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter;
146 }
147 
148 template<unsigned DIM>
150 {
151  mNagaiHondaLabelledCellCellAdhesionEnergyParameter = labelledCellCellAdhesionEnergyParameter;
152 }
153 
154 template<unsigned DIM>
156 {
157  mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter = labelledCellLabelledCellAdhesionEnergyParameter;
158 }
159 
160 template<unsigned DIM>
162 {
163  mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter = labelledCellBoundaryAdhesionEnergyParameter;
164 }
165 
166 template<unsigned DIM>
168 {
169  // Output member variables
170  *rParamsFile << "\t\t\t<NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter> \n";
171  *rParamsFile << "\t\t\t<NagaiHondaLabelledCellCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellCellAdhesionEnergyParameter> \n";
172  *rParamsFile << "\t\t\t<NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter>" << mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter << "</NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter> \n";
173 
174  // Call method on direct parent class
176 }
177 
178 // Explicit instantiation
182 
183 // Serialization for Boost >= 1.36
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
Definition: Node.hpp:58
std::set< unsigned > & rGetContainingElementIndices()
Definition: Node.cpp:301
void SetNagaiHondaLabelledCellCellAdhesionEnergyParameter(double labelledCellCellAdhesionEnergyParameter)
void OutputForceParameters(out_stream &rParamsFile)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void SetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(double labelledCellLabelledCellAdhesionEnergyParameter)
void SetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(double labelledCellBoundaryAdhesionEnergyParameter)
virtual double GetAdhesionParameter(Node< DIM > *pNodeA, Node< DIM > *pNodeB, VertexBasedCellPopulation< DIM > &rVertexCellPopulation)