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 =
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;
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());
191 if (shared_elements.size() == 1)
196 return line_tension_parameter_in_calculation;
199 template<
unsigned DIM>
205 template<
unsigned DIM>
211 template<
unsigned DIM>
217 template<
unsigned DIM>
223 template<
unsigned DIM>
229 template<
unsigned DIM>
235 template<
unsigned DIM>
241 template<
unsigned DIM>
247 template<
unsigned DIM>
252 *rParamsFile <<
"\t\t\t<LineTensionParameter>" <<
mLineTensionParameter <<
"</LineTensionParameter>\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)
double mPerimeterContractilityParameter
Node< DIM > * GetNode(unsigned index)
unsigned GetNumNodes() const
virtual void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
virtual double GetVolumeOfElement(unsigned index)
void SetPerimeterContractilityParameter(double perimeterContractilityParameter)
double mAreaElasticityParameter
double mLineTensionParameter
double GetAreaElasticityParameter()
unsigned GetIndex() const
double mBoundaryLineTensionParameter
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