LinearSpringWithVariableSpringConstantsForce.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "LinearSpringWithVariableSpringConstantsForce.hpp"
00030 #include "MeshBasedTissue.hpp"
00031 #include "IngeWntSwatCellCycleModel.hpp"
00032 #include "VoronoiTessellation.hpp"
00033 
00034 template<unsigned DIM>
00035 LinearSpringWithVariableSpringConstantsForce<DIM>::LinearSpringWithVariableSpringConstantsForce()
00036     : GeneralisedLinearSpringForce<DIM>(),
00037       mUseEdgeBasedSpringConstant(false),
00038       mUseMutantSprings(false),
00039       mMutantMutantMultiplier(DOUBLE_UNSET),
00040       mNormalMutantMultiplier(DOUBLE_UNSET),
00041       mUseBCatSprings(false),
00042       mUseApoptoticSprings(false)
00043 {
00044 }
00045 
00046 template<unsigned DIM>
00047 LinearSpringWithVariableSpringConstantsForce<DIM>::~LinearSpringWithVariableSpringConstantsForce()
00048 {
00049 }
00050 
00051 template<unsigned DIM>
00052 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetEdgeBasedSpringConstant(bool useEdgeBasedSpringConstant)
00053 {
00054     assert(DIM == 2);
00055     mUseEdgeBasedSpringConstant = useEdgeBasedSpringConstant;
00056 }
00057 
00058 template<unsigned DIM>
00059 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier, double normalMutantMultiplier)
00060 {
00061     mUseMutantSprings = useMutantSprings;
00062     mMutantMutantMultiplier = mutantMutantMultiplier;
00063     mNormalMutantMultiplier = normalMutantMultiplier;
00064 }
00065 
00066 template<unsigned DIM>
00067 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCateninSprings(bool useBCatSprings)
00068 {
00069     mUseBCatSprings = useBCatSprings;
00070 }
00071 
00072 template<unsigned DIM>
00073 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSprings(bool useApoptoticSprings)
00074 {
00075     mUseApoptoticSprings = useApoptoticSprings;
00076 }
00077 
00078 template<unsigned DIM>
00079 double LinearSpringWithVariableSpringConstantsForce<DIM>::VariableSpringConstantMultiplicationFactor(
00080     unsigned nodeAGlobalIndex,
00081     unsigned nodeBGlobalIndex,
00082     AbstractTissue<DIM>& rTissue,
00083     bool isCloserThanRestLength)
00084 {
00085     double multiplication_factor = GeneralisedLinearSpringForce<DIM>::VariableSpringConstantMultiplicationFactor(nodeAGlobalIndex,
00086                                                                                                             nodeBGlobalIndex,
00087                                                                                                             rTissue,
00088                                                                                                             isCloserThanRestLength);
00089 
00090     TissueCell& r_cell_A = rTissue.rGetCellUsingLocationIndex(nodeAGlobalIndex);
00091     TissueCell& r_cell_B = rTissue.rGetCellUsingLocationIndex(nodeBGlobalIndex);
00092 
00093     if (mUseEdgeBasedSpringConstant)
00094     {
00095         assert(rTissue.HasMesh());
00096         assert(!mUseBCatSprings);   // don't want to do both (both account for edge length)
00097 
00098         VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00099 
00100         multiplication_factor = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex)*sqrt(3);
00101     }
00102 
00103     if (mUseMutantSprings)
00104     {
00105         unsigned number_of_mutants=0;
00106 
00107         if (r_cell_A.GetMutationState() == APC_TWO_HIT || r_cell_A.GetMutationState() == BETA_CATENIN_ONE_HIT)
00108         {
00109             // If cell A is mutant
00110             number_of_mutants++;
00111         }
00112 
00113         if (r_cell_B.GetMutationState() == APC_TWO_HIT || r_cell_B.GetMutationState() == BETA_CATENIN_ONE_HIT)
00114         {
00115             // If cell B is mutant
00116             number_of_mutants++;
00117         }
00118 
00119         switch (number_of_mutants)
00120         {
00121             case 1u:
00122             {
00123                 multiplication_factor *= mNormalMutantMultiplier;
00124                 break;
00125             }
00126             case 2u:
00127             {
00128                 multiplication_factor *= mMutantMutantMultiplier;
00129                 break;
00130             }
00131         }
00132     }
00133 
00134     if (mUseBCatSprings)
00135     {
00136         assert(rTissue.HasMesh());
00137         // If using beta-cat dependent springs, both cell-cycle models has better be IngeWntSwatCellCycleModel
00138         IngeWntSwatCellCycleModel *p_model_A = dynamic_cast<IngeWntSwatCellCycleModel*>(r_cell_A.GetCellCycleModel());
00139         IngeWntSwatCellCycleModel *p_model_B = dynamic_cast<IngeWntSwatCellCycleModel*>(r_cell_B.GetCellCycleModel());
00140 
00141         assert(!mUseEdgeBasedSpringConstant);   // This already adapts for edge lengths - don't want to do it twice.
00142         double beta_cat_cell_1 = p_model_A->GetMembraneBoundBetaCateninLevel();
00143         double beta_cat_cell_2 = p_model_B->GetMembraneBoundBetaCateninLevel();
00144 
00145         VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00146 
00147         double perim_cell_1 = tess.GetFacePerimeter(nodeAGlobalIndex);
00148         double perim_cell_2 = tess.GetFacePerimeter(nodeBGlobalIndex);
00149         double edge_length_between_1_and_2 = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex);
00150 
00151         double beta_cat_on_cell_1_edge = beta_cat_cell_1 *  edge_length_between_1_and_2 / perim_cell_1;
00152         double beta_cat_on_cell_2_edge = beta_cat_cell_2 *  edge_length_between_1_and_2 / perim_cell_2;
00153 
00154         double min_beta_Cat_of_two_cells = std::min(beta_cat_on_cell_1_edge, beta_cat_on_cell_2_edge);
00155 
00156         double beta_cat_scaling_factor = TissueConfig::Instance()->GetBetaCatSpringScaler();
00157         multiplication_factor *= min_beta_Cat_of_two_cells / beta_cat_scaling_factor;
00158     }
00159 
00160     if (mUseApoptoticSprings)
00161     {
00162         if (r_cell_A.GetCellType()==APOPTOTIC || r_cell_B.GetCellType()==APOPTOTIC)
00163         {
00164             double spring_a_stiffness = 2.0*TissueConfig::Instance()->GetSpringStiffness();
00165             double spring_b_stiffness = 2.0*TissueConfig::Instance()->GetSpringStiffness();
00166 
00167             if (r_cell_A.GetCellType()==APOPTOTIC)
00168             {
00169                 if (!isCloserThanRestLength) // if under tension
00170                 {
00171                     spring_a_stiffness = TissueConfig::Instance()->GetApoptoticSpringTensionStiffness();
00172                 }
00173                 else // if under compression
00174                 {
00175                     spring_a_stiffness = TissueConfig::Instance()->GetApoptoticSpringCompressionStiffness();
00176                 }
00177             }
00178             if (r_cell_B.GetCellType()==APOPTOTIC)
00179             {
00180                 if (!isCloserThanRestLength) // if under tension
00181                 {
00182                     spring_b_stiffness = TissueConfig::Instance()->GetApoptoticSpringTensionStiffness();
00183                 }
00184                 else // if under compression
00185                 {
00186                     spring_b_stiffness = TissueConfig::Instance()->GetApoptoticSpringCompressionStiffness();
00187                 }
00188             }
00189 
00190             multiplication_factor *= 1.0 / (( 1.0/spring_a_stiffness + 1.0/spring_b_stiffness)*TissueConfig::Instance()->GetSpringStiffness());
00191         }
00192     }
00193 
00194     return multiplication_factor;
00195 }
00196 
00197 template<unsigned DIM>
00198 void LinearSpringWithVariableSpringConstantsForce<DIM>::AddForceContribution(
00199     std::vector<c_vector<double, DIM> >& rForces,
00200     AbstractTissue<DIM>& rTissue)
00201 {
00202     for (typename MeshBasedTissue<DIM>::SpringIterator spring_iterator=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsBegin();
00203         spring_iterator!=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsEnd();
00204         ++spring_iterator)
00205     {
00206         unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00207         unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00208 
00209         c_vector<double, DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rTissue);
00210 
00211         rForces[nodeB_global_index] -= force;
00212         rForces[nodeA_global_index] += force;
00213     }
00214 }
00215 
00216 
00218 // Explicit instantiation
00220 
00221 template class LinearSpringWithVariableSpringConstantsForce<1>;
00222 template class LinearSpringWithVariableSpringConstantsForce<2>;
00223 template class LinearSpringWithVariableSpringConstantsForce<3>;

Generated on Tue Aug 4 16:10:21 2009 for Chaste by  doxygen 1.5.5