LinearSpringWithVariableSpringConstantsForce.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "LinearSpringWithVariableSpringConstantsForce.hpp"
00030 #include "MeshBasedTissue.hpp"
00031 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
00032 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
00033 #include "VoronoiTessellation.hpp"
00034
00035 template<unsigned DIM>
00036 LinearSpringWithVariableSpringConstantsForce<DIM>::LinearSpringWithVariableSpringConstantsForce()
00037 : GeneralisedLinearSpringForce<DIM>(),
00038 mUseEdgeBasedSpringConstant(false),
00039 mUseMutantSprings(false),
00040 mMutantMutantMultiplier(DOUBLE_UNSET),
00041 mNormalMutantMultiplier(DOUBLE_UNSET),
00042 mUseBCatSprings(false),
00043 mUseApoptoticSprings(false)
00044 {
00045 }
00046
00047 template<unsigned DIM>
00048 LinearSpringWithVariableSpringConstantsForce<DIM>::~LinearSpringWithVariableSpringConstantsForce()
00049 {
00050 }
00051
00052 template<unsigned DIM>
00053 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetEdgeBasedSpringConstant(bool useEdgeBasedSpringConstant)
00054 {
00055 assert(DIM == 2);
00056 mUseEdgeBasedSpringConstant = useEdgeBasedSpringConstant;
00057 }
00058
00059 template<unsigned DIM>
00060 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier, double normalMutantMultiplier)
00061 {
00062 mUseMutantSprings = useMutantSprings;
00063 mMutantMutantMultiplier = mutantMutantMultiplier;
00064 mNormalMutantMultiplier = normalMutantMultiplier;
00065 }
00066
00067 template<unsigned DIM>
00068 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCateninSprings(bool useBCatSprings)
00069 {
00070 mUseBCatSprings = useBCatSprings;
00071 }
00072
00073 template<unsigned DIM>
00074 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSprings(bool useApoptoticSprings)
00075 {
00076 mUseApoptoticSprings = useApoptoticSprings;
00077 }
00078
00079 template<unsigned DIM>
00080 double LinearSpringWithVariableSpringConstantsForce<DIM>::VariableSpringConstantMultiplicationFactor(
00081 unsigned nodeAGlobalIndex,
00082 unsigned nodeBGlobalIndex,
00083 AbstractTissue<DIM>& rTissue,
00084 bool isCloserThanRestLength)
00085 {
00086
00087 TissueConfig* p_config = TissueConfig::Instance();
00088
00089 double multiplication_factor = GeneralisedLinearSpringForce<DIM>::VariableSpringConstantMultiplicationFactor(nodeAGlobalIndex,
00090 nodeBGlobalIndex,
00091 rTissue,
00092 isCloserThanRestLength);
00093
00094 TissueCell& r_cell_A = rTissue.rGetCellUsingLocationIndex(nodeAGlobalIndex);
00095 TissueCell& r_cell_B = rTissue.rGetCellUsingLocationIndex(nodeBGlobalIndex);
00096
00097 if (mUseEdgeBasedSpringConstant)
00098 {
00099 assert(rTissue.HasMesh());
00100 assert(!mUseBCatSprings);
00101
00102 VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00103
00104 multiplication_factor = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex)*sqrt(3);
00105 }
00106
00107 if (mUseMutantSprings)
00108 {
00109 unsigned number_of_mutants=0;
00110
00111 if (r_cell_A.GetMutationState()->IsType<ApcTwoHitCellMutationState>() || r_cell_A.GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00112 {
00113
00114 number_of_mutants++;
00115 }
00116
00117 if (r_cell_B.GetMutationState()->IsType<ApcTwoHitCellMutationState>() || r_cell_B.GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00118 {
00119
00120 number_of_mutants++;
00121 }
00122
00123 switch (number_of_mutants)
00124 {
00125 case 1u:
00126 {
00127 multiplication_factor *= mNormalMutantMultiplier;
00128 break;
00129 }
00130 case 2u:
00131 {
00132 multiplication_factor *= mMutantMutantMultiplier;
00133 break;
00134 }
00135 }
00136 }
00137
00138 if (mUseBCatSprings)
00139 {
00140 assert(rTissue.HasMesh());
00141
00142 AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_A = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(r_cell_A.GetCellCycleModel());
00143 AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_B = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(r_cell_B.GetCellCycleModel());
00144
00145 assert(!mUseEdgeBasedSpringConstant);
00146 double beta_cat_cell_1 = p_model_A->GetMembraneBoundBetaCateninLevel();
00147 double beta_cat_cell_2 = p_model_B->GetMembraneBoundBetaCateninLevel();
00148
00149 VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00150
00151 double perim_cell_1 = tess.GetFacePerimeter(nodeAGlobalIndex);
00152 double perim_cell_2 = tess.GetFacePerimeter(nodeBGlobalIndex);
00153 double edge_length_between_1_and_2 = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex);
00154
00155 double beta_cat_on_cell_1_edge = beta_cat_cell_1 * edge_length_between_1_and_2 / perim_cell_1;
00156 double beta_cat_on_cell_2_edge = beta_cat_cell_2 * edge_length_between_1_and_2 / perim_cell_2;
00157
00158 double min_beta_Cat_of_two_cells = std::min(beta_cat_on_cell_1_edge, beta_cat_on_cell_2_edge);
00159
00160 double beta_cat_scaling_factor = p_config->GetBetaCatSpringScaler();
00161 multiplication_factor *= min_beta_Cat_of_two_cells / beta_cat_scaling_factor;
00162 }
00163
00164 if (mUseApoptoticSprings)
00165 {
00166 if (r_cell_A.GetCellProliferativeType()==APOPTOTIC || r_cell_B.GetCellProliferativeType()==APOPTOTIC)
00167 {
00168 double spring_a_stiffness = 2.0 * p_config->GetSpringStiffness();
00169 double spring_b_stiffness = 2.0 * p_config->GetSpringStiffness();
00170
00171 if (r_cell_A.GetCellProliferativeType()==APOPTOTIC)
00172 {
00173 if (!isCloserThanRestLength)
00174 {
00175 spring_a_stiffness = p_config->GetApoptoticSpringTensionStiffness();
00176 }
00177 else
00178 {
00179 spring_a_stiffness = p_config->GetApoptoticSpringCompressionStiffness();
00180 }
00181 }
00182 if (r_cell_B.GetCellProliferativeType()==APOPTOTIC)
00183 {
00184 if (!isCloserThanRestLength)
00185 {
00186 spring_b_stiffness = p_config->GetApoptoticSpringTensionStiffness();
00187 }
00188 else
00189 {
00190 spring_b_stiffness = p_config->GetApoptoticSpringCompressionStiffness();
00191 }
00192 }
00193
00194 multiplication_factor /= (1.0/spring_a_stiffness + 1.0/spring_b_stiffness)*p_config->GetSpringStiffness();
00195 }
00196 }
00197
00198 return multiplication_factor;
00199 }
00200
00201 template<unsigned DIM>
00202 void LinearSpringWithVariableSpringConstantsForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00203 AbstractTissue<DIM>& rTissue)
00204 {
00205 MeshBasedTissue<DIM>* p_static_cast_tissue = static_cast<MeshBasedTissue<DIM>*>(&rTissue);
00206
00207 for (typename MeshBasedTissue<DIM>::SpringIterator spring_iterator = p_static_cast_tissue->SpringsBegin();
00208 spring_iterator != p_static_cast_tissue->SpringsEnd();
00209 ++spring_iterator)
00210 {
00211 unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00212 unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00213
00214 c_vector<double, DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rTissue);
00215
00216 rForces[nodeB_global_index] -= force;
00217 rForces[nodeA_global_index] += force;
00218 }
00219 }
00220
00221
00223
00225
00226 template class LinearSpringWithVariableSpringConstantsForce<1>;
00227 template class LinearSpringWithVariableSpringConstantsForce<2>;
00228 template class LinearSpringWithVariableSpringConstantsForce<3>;
00229
00230
00231
00232 #include "SerializationExportWrapperForCpp.hpp"
00233 EXPORT_TEMPLATE_CLASS_SAME_DIMS(LinearSpringWithVariableSpringConstantsForce)