54 unsigned targetNodeIndex,
62 bool current_node_contained = !containing_elements.empty();
63 bool target_node_contained = !new_location_containing_elements.empty();
66 assert(new_location_containing_elements.size() < 2);
68 if (!current_node_contained && !target_node_contained)
70 EXCEPTION(
"At least one of the current node or target node must be in an element.");
73 if (current_node_contained && target_node_contained)
75 if (*(new_location_containing_elements.begin()) == *(containing_elements.begin()))
77 EXCEPTION(
"The current node and target node must not be in the same element.");
81 if (current_node_contained)
83 unsigned current_element = (*containing_elements.begin());
84 double current_volume = rCellPopulation.
rGetMesh().GetVolumeOfElement(current_element);
85 double current_volume_difference = current_volume - mMatureCellTargetVolume;
87 delta_H += mDeformationEnergyParameter*((current_volume_difference + 1.0)*(current_volume_difference + 1.0) - current_volume_difference*current_volume_difference);
89 if (target_node_contained)
91 unsigned target_element = (*new_location_containing_elements.begin());
92 double target_volume = rCellPopulation.
rGetMesh().GetVolumeOfElement(target_element);
93 double target_volume_difference = target_volume - mMatureCellTargetVolume;
95 delta_H += mDeformationEnergyParameter*((target_volume_difference - 1.0)*(target_volume_difference - 1.0) - target_volume_difference*target_volume_difference);