36 #include "VolumeConstraintPottsUpdateRule.hpp"
38 template<
unsigned DIM>
41 mDeformationEnergyParameter(0.5),
42 mMatureCellTargetVolume(16.0)
47 template<
unsigned DIM>
52 template<
unsigned DIM>
54 unsigned targetNodeIndex,
59 std::set<unsigned> containing_elements = rCellPopulation.
GetNode(currentNodeIndex)->rGetContainingElementIndices();
60 std::set<unsigned> new_location_containing_elements = rCellPopulation.
GetNode(targetNodeIndex)->rGetContainingElementIndices();
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);
101 template<
unsigned DIM>
104 return mDeformationEnergyParameter;
107 template<
unsigned DIM>
110 mDeformationEnergyParameter = deformationEnergyParameter;
113 template<
unsigned DIM>
116 return mMatureCellTargetVolume;
119 template<
unsigned DIM>
122 assert(matureCellTargetVolume >= 0.0);
123 mMatureCellTargetVolume = matureCellTargetVolume;
126 template<
unsigned DIM>
129 *rParamsFile <<
"\t\t\t<DeformationEnergyParameter>" << mDeformationEnergyParameter <<
"</DeformationEnergyParameter>\n";
130 *rParamsFile <<
"\t\t\t<MatureCellTargetVolume>" << mMatureCellTargetVolume <<
"</MatureCellTargetVolume>\n";
void SetMatureCellTargetVolume(double matureCellTargetVolume)
Node< DIM > * GetNode(unsigned index)
PottsMesh< DIM > & rGetMesh()
#define EXCEPTION(message)
~VolumeConstraintPottsUpdateRule()
double GetDeformationEnergyParameter()
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputUpdateRuleParameters(out_stream &rParamsFile)=0
void SetDeformationEnergyParameter(double deformationEnergyParameter)
VolumeConstraintPottsUpdateRule()
void OutputUpdateRuleParameters(out_stream &rParamsFile)
double EvaluateHamiltonianContribution(unsigned currentNodeIndex, unsigned targetNodeIndex, PottsBasedCellPopulation< DIM > &rCellPopulation)
double GetMatureCellTargetVolume() const