36 #include "FarhadifarForce.hpp"
38 template<
unsigned DIM>
41 mAreaElasticityParameter(1.0),
42 mPerimeterContractilityParameter(0.04),
43 mLineTensionParameter(0.12),
44 mBoundaryLineTensionParameter(0.12)
48 template<
unsigned DIM>
53 template<
unsigned DIM>
60 EXCEPTION(
"FarhadifarForce is to be used with a VertexBasedCellPopulation only");
65 unsigned num_nodes = p_cell_population->
GetNumNodes();
69 std::vector<double> element_areas(num_elements);
70 std::vector<double> element_perimeters(num_elements);
71 std::vector<double> target_areas(num_elements);
76 unsigned elem_index = elem_iter->GetIndex();
85 target_areas[elem_index] = p_cell_population->
GetCellUsingLocationIndex(elem_index)->GetCellData()->GetItem(
"target area");
89 EXCEPTION(
"You need to add an AbstractTargetAreaModifier to the simulation in order to use a FarhadifarForce");
94 for (
unsigned node_index=0; node_index<num_nodes; node_index++)
110 c_vector<double, DIM> area_elasticity_contribution = zero_vector<double>(DIM);
111 c_vector<double, DIM> perimeter_contractility_contribution = zero_vector<double>(DIM);
112 c_vector<double, DIM> line_tension_contribution = zero_vector<double>(DIM);
115 std::set<unsigned> containing_elem_indices = p_cell_population->
GetNode(node_index)->rGetContainingElementIndices();
118 for (std::set<unsigned>::iterator iter = containing_elem_indices.begin();
119 iter != containing_elem_indices.end();
124 unsigned elem_index = p_element->
GetIndex();
125 unsigned num_nodes_elem = p_element->
GetNumNodes();
131 c_vector<double, DIM> element_area_gradient =
133 area_elasticity_contribution -= GetAreaElasticityParameter()*(element_areas[elem_index] -
134 target_areas[elem_index])*element_area_gradient;
137 unsigned previous_node_local_index = (num_nodes_elem+local_index-1)%num_nodes_elem;
140 unsigned next_node_local_index = (local_index+1)%num_nodes_elem;
145 double previous_edge_line_tension_parameter = GetLineTensionParameter(p_previous_node, p_this_node, *p_cell_population);
146 double next_edge_line_tension_parameter = GetLineTensionParameter(p_this_node, p_next_node, *p_cell_population);
149 c_vector<double, DIM> previous_edge_gradient =
154 line_tension_contribution -= previous_edge_line_tension_parameter*previous_edge_gradient +
155 next_edge_line_tension_parameter*next_edge_gradient;
158 c_vector<double, DIM> element_perimeter_gradient = previous_edge_gradient + next_edge_gradient;
159 perimeter_contractility_contribution -= GetPerimeterContractilityParameter()* element_perimeters[elem_index]*
160 element_perimeter_gradient;
163 c_vector<double, DIM> force_on_node = area_elasticity_contribution + perimeter_contractility_contribution + line_tension_contribution;
164 p_cell_population->
GetNode(node_index)->AddAppliedForceContribution(force_on_node);
168 template<
unsigned DIM>
176 std::set<unsigned> shared_elements;
177 std::set_intersection(elements_containing_nodeA.begin(),
178 elements_containing_nodeA.end(),
179 elements_containing_nodeB.begin(),
180 elements_containing_nodeB.end(),
181 std::inserter(shared_elements, shared_elements.begin()));
184 assert(!shared_elements.empty());
188 double line_tension_parameter_in_calculation = GetLineTensionParameter()/2.0;
191 if (shared_elements.size() == 1)
193 line_tension_parameter_in_calculation = GetBoundaryLineTensionParameter();
196 return line_tension_parameter_in_calculation;
199 template<
unsigned DIM>
202 return mAreaElasticityParameter;
205 template<
unsigned DIM>
208 return mPerimeterContractilityParameter;
211 template<
unsigned DIM>
214 return mLineTensionParameter;
217 template<
unsigned DIM>
220 return mBoundaryLineTensionParameter;
223 template<
unsigned DIM>
226 mAreaElasticityParameter = areaElasticityParameter;
229 template<
unsigned DIM>
232 mPerimeterContractilityParameter = perimeterContractilityParameter;
235 template<
unsigned DIM>
238 mLineTensionParameter = lineTensionParameter;
241 template<
unsigned DIM>
244 mBoundaryLineTensionParameter = boundaryLineTensionParameter;
247 template<
unsigned DIM>
250 *rParamsFile <<
"\t\t\t<AreaElasticityParameter>" << mAreaElasticityParameter <<
"</AreaElasticityParameter>\n";
251 *rParamsFile <<
"\t\t\t<PerimeterContractilityParameter>" << mPerimeterContractilityParameter <<
"</PerimeterContractilityParameter>\n";
252 *rParamsFile <<
"\t\t\t<LineTensionParameter>" << mLineTensionParameter <<
"</LineTensionParameter>\n";
253 *rParamsFile <<
"\t\t\t<BoundaryLineTensionParameter>" << mBoundaryLineTensionParameter <<
"</BoundaryLineTensionParameter>\n";
void SetAreaElasticityParameter(double areaElasticityParameter)
void OutputForceParameters(out_stream &rParamsFile)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
unsigned GetNumElements()
#define EXCEPTION(message)
double GetLineTensionParameter()
std::set< unsigned > & rGetContainingElementIndices()
c_vector< double, SPACE_DIM > GetNextEdgeGradientOfElementAtNode(VertexElement< ELEMENT_DIM, SPACE_DIM > *pElement, unsigned localIndex)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
MutableVertexMesh< DIM, DIM > & rGetMesh()
VertexElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
Node< DIM > * GetNode(unsigned index)
unsigned GetNumNodes() const
virtual void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
virtual double GetVolumeOfElement(unsigned index)
void SetPerimeterContractilityParameter(double perimeterContractilityParameter)
double GetAreaElasticityParameter()
unsigned GetIndex() const
double GetPerimeterContractilityParameter()
void SetLineTensionParameter(double lineTensionParameter)
c_vector< double, SPACE_DIM > GetAreaGradientOfElementAtNode(VertexElement< ELEMENT_DIM, SPACE_DIM > *pElement, unsigned localIndex)
unsigned GetNodeLocalIndex(unsigned globalIndex) const
double GetBoundaryLineTensionParameter()
VertexElementIterator GetElementIteratorEnd()
virtual double GetSurfaceAreaOfElement(unsigned index)
virtual ~FarhadifarForce()
VertexElement< DIM, DIM > * GetElement(unsigned elementIndex)
void SetBoundaryLineTensionParameter(double boundaryLineTensionParameter)
virtual void OutputForceParameters(out_stream &rParamsFile)=0