61 EXCEPTION(
"FarhadifarForce is to be used with a VertexBasedCellPopulation only");
66 unsigned num_nodes = p_cell_population->
GetNumNodes();
74 bool using_target_area_modifier = p_cell_population->
Begin()->GetCellData()->HasItem(
"target area");
77 std::vector<double> element_areas(num_elements);
78 std::vector<double> element_perimeters(num_elements);
79 std::vector<double> target_areas(num_elements);
84 unsigned elem_index = elem_iter->GetIndex();
88 if (using_target_area_modifier)
90 target_areas[elem_index] = p_cell_population->
GetCellUsingLocationIndex(elem_index)->GetCellData()->GetItem(
"target area");
94 target_areas[elem_index] = mTargetAreaParameter;
99 for (
unsigned node_index=0; node_index<num_nodes; node_index++)
115 c_vector<double, DIM> area_elasticity_contribution = zero_vector<double>(DIM);
116 c_vector<double, DIM> perimeter_contractility_contribution = zero_vector<double>(DIM);
117 c_vector<double, DIM> line_tension_contribution = zero_vector<double>(DIM);
123 for (std::set<unsigned>::iterator iter = containing_elem_indices.begin();
124 iter != containing_elem_indices.end();
129 unsigned elem_index = p_element->
GetIndex();
130 unsigned num_nodes_elem = p_element->
GetNumNodes();
136 c_vector<double, DIM> element_area_gradient =
138 area_elasticity_contribution -= GetAreaElasticityParameter()*(element_areas[elem_index] -
139 target_areas[elem_index])*element_area_gradient;
142 unsigned previous_node_local_index = (num_nodes_elem+local_index-1)%num_nodes_elem;
145 unsigned next_node_local_index = (local_index+1)%num_nodes_elem;
150 double previous_edge_line_tension_parameter = GetLineTensionParameter(p_previous_node, p_this_node, *p_cell_population);
151 double next_edge_line_tension_parameter = GetLineTensionParameter(p_this_node, p_next_node, *p_cell_population);
154 c_vector<double, DIM> previous_edge_gradient =
159 line_tension_contribution -= previous_edge_line_tension_parameter*previous_edge_gradient +
160 next_edge_line_tension_parameter*next_edge_gradient;
163 c_vector<double, DIM> element_perimeter_gradient;
164 element_perimeter_gradient = previous_edge_gradient + next_edge_gradient;
165 perimeter_contractility_contribution -= GetPerimeterContractilityParameter()* element_perimeters[elem_index]*
166 element_perimeter_gradient;
169 c_vector<double, DIM> force_on_node = area_elasticity_contribution + perimeter_contractility_contribution + line_tension_contribution;
182 std::set<unsigned> shared_elements;
183 std::set_intersection(elements_containing_nodeA.begin(),
184 elements_containing_nodeA.end(),
185 elements_containing_nodeB.begin(),
186 elements_containing_nodeB.end(),
187 std::inserter(shared_elements, shared_elements.begin()));
190 assert(!shared_elements.empty());
194 double line_tension_parameter_in_calculation = GetLineTensionParameter()/2.0;
197 if (shared_elements.size() == 1)
199 line_tension_parameter_in_calculation = GetBoundaryLineTensionParameter();
202 return line_tension_parameter_in_calculation;