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 {    
00038     // Edge-based springs
00039     mUseEdgeBasedSpringConstant = false;
00040 
00041     // Cell-type dependent springs
00042     mUseMutantSprings = false;
00043     mMutantMutantMultiplier = DOUBLE_UNSET;
00044     mNormalMutantMultiplier = DOUBLE_UNSET;
00045 
00046     // Beta-cat springs
00047     mUseBCatSprings = false;
00048 
00049     // Apoptotic springs
00050     mUseApoptoticSprings = false;
00051 }
00052 
00053 template<unsigned DIM>
00054 LinearSpringWithVariableSpringConstantsForce<DIM>::~LinearSpringWithVariableSpringConstantsForce()
00055 {
00056 }
00057 
00058 template<unsigned DIM>
00059 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetEdgeBasedSpringConstant(bool useEdgeBasedSpringConstant)
00060 {
00061     assert(DIM == 2);
00062     mUseEdgeBasedSpringConstant = useEdgeBasedSpringConstant;
00063 }
00064 
00065 template<unsigned DIM>
00066 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier, double normalMutantMultiplier)
00067 {
00068     mUseMutantSprings = useMutantSprings;
00069     mMutantMutantMultiplier = mutantMutantMultiplier;
00070     mNormalMutantMultiplier = normalMutantMultiplier;
00071 }
00072 
00073 template<unsigned DIM>
00074 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCateninSprings(bool useBCatSprings)
00075 {
00076     mUseBCatSprings = useBCatSprings;
00077 }
00078 
00079 template<unsigned DIM>
00080 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSprings(bool useApoptoticSprings)
00081 {
00082     mUseApoptoticSprings = useApoptoticSprings;
00083 }
00084 
00085 template<unsigned DIM>
00086 double LinearSpringWithVariableSpringConstantsForce<DIM>::VariableSpringConstantMultiplicationFactor(
00087     unsigned nodeAGlobalIndex, 
00088     unsigned nodeBGlobalIndex,
00089     AbstractTissue<DIM>& rTissue, 
00090     bool isCloserThanRestLength)
00091 {
00092     double multiplication_factor = GeneralisedLinearSpringForce<DIM>::VariableSpringConstantMultiplicationFactor(nodeAGlobalIndex,
00093                                                                                                             nodeBGlobalIndex,
00094                                                                                                             rTissue,
00095                                                                                                             isCloserThanRestLength);
00096     
00097     TissueCell& r_cell_A = rTissue.rGetCellUsingLocationIndex(nodeAGlobalIndex);
00098     TissueCell& r_cell_B = rTissue.rGetCellUsingLocationIndex(nodeBGlobalIndex);
00099     
00100     if (mUseEdgeBasedSpringConstant)
00101     {
00102         assert(rTissue.HasMesh());
00103         assert(!mUseBCatSprings);   // don't want to do both (both account for edge length)
00104 
00105         VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00106 
00107         multiplication_factor = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex)*sqrt(3);
00108     }
00109 
00110     if (mUseMutantSprings)
00111     {
00112         unsigned number_of_mutants=0;
00113 
00114         if (r_cell_A.GetMutationState() == APC_TWO_HIT || r_cell_A.GetMutationState() == BETA_CATENIN_ONE_HIT)
00115         {
00116             // If cell A is mutant
00117             number_of_mutants++;
00118         }
00119 
00120         if (r_cell_B.GetMutationState() == APC_TWO_HIT || r_cell_B.GetMutationState() == BETA_CATENIN_ONE_HIT)
00121         {
00122             // If cell B is mutant
00123             number_of_mutants++;
00124         }
00125 
00126         switch (number_of_mutants)
00127         {
00128             case 1u:
00129             {
00130                 multiplication_factor *= mNormalMutantMultiplier;
00131                 break;
00132             }
00133             case 2u:
00134             {
00135                 multiplication_factor *= mMutantMutantMultiplier;
00136                 break;
00137             }
00138         }
00139     }
00140 
00141     if (mUseBCatSprings)
00142     {
00143         assert(rTissue.HasMesh());
00144         // If using beta-cat dependent springs, both cell-cycle models has better be IngeWntSwatCellCycleModel
00145         IngeWntSwatCellCycleModel* p_model_A = dynamic_cast<IngeWntSwatCellCycleModel*>(r_cell_A.GetCellCycleModel());
00146         IngeWntSwatCellCycleModel* p_model_B = dynamic_cast<IngeWntSwatCellCycleModel*>(r_cell_B.GetCellCycleModel());
00147 
00148         assert(!mUseEdgeBasedSpringConstant);   // This already adapts for edge lengths - don't want to do it twice.
00149         double beta_cat_cell_1 = p_model_A->GetMembraneBoundBetaCateninLevel();
00150         double beta_cat_cell_2 = p_model_B->GetMembraneBoundBetaCateninLevel();
00151 
00152         VoronoiTessellation<DIM>& tess = (static_cast<MeshBasedTissue<DIM>*>(&rTissue))->rGetVoronoiTessellation();
00153 
00154         double perim_cell_1 = tess.GetFacePerimeter(nodeAGlobalIndex);
00155         double perim_cell_2 = tess.GetFacePerimeter(nodeBGlobalIndex);
00156         double edge_length_between_1_and_2 = tess.GetEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex);
00157 
00158         double beta_cat_on_cell_1_edge = beta_cat_cell_1 *  edge_length_between_1_and_2 / perim_cell_1;
00159         double beta_cat_on_cell_2_edge = beta_cat_cell_2 *  edge_length_between_1_and_2 / perim_cell_2;
00160 
00161         double min_beta_Cat_of_two_cells = std::min(beta_cat_on_cell_1_edge, beta_cat_on_cell_2_edge);
00162 
00163         double beta_cat_scaling_factor = CancerParameters::Instance()->GetBetaCatSpringScaler();
00164         multiplication_factor *= min_beta_Cat_of_two_cells / beta_cat_scaling_factor;
00165     }
00166 
00167     if (mUseApoptoticSprings)
00168     {
00169         if (r_cell_A.GetCellType()==APOPTOTIC || r_cell_B.GetCellType()==APOPTOTIC)
00170         {
00171             double spring_a_stiffness = 2.0*CancerParameters::Instance()->GetSpringStiffness();
00172             double spring_b_stiffness = 2.0*CancerParameters::Instance()->GetSpringStiffness();
00173 
00174             if (r_cell_A.GetCellType()==APOPTOTIC)
00175             {
00176                 if (!isCloserThanRestLength) // if under tension
00177                 {
00178                     spring_a_stiffness = CancerParameters::Instance()->GetApoptoticSpringTensionStiffness();
00179                 }
00180                 else // if under compression
00181                 {
00182                     spring_a_stiffness = CancerParameters::Instance()->GetApoptoticSpringCompressionStiffness();
00183                 }
00184             }
00185             if (r_cell_B.GetCellType()==APOPTOTIC)
00186             {
00187                 if (!isCloserThanRestLength) // if under tension
00188                 {
00189                     spring_b_stiffness = CancerParameters::Instance()->GetApoptoticSpringTensionStiffness();
00190                 }
00191                 else // if under compression
00192                 {
00193                     spring_b_stiffness = CancerParameters::Instance()->GetApoptoticSpringCompressionStiffness();
00194                 }
00195             }
00196 
00197             multiplication_factor *= 1.0 / (( 1.0/spring_a_stiffness + 1.0/spring_b_stiffness)*CancerParameters::Instance()->GetSpringStiffness());
00198         }
00199     }
00200     
00201     return multiplication_factor;
00202 }
00203 
00204 template<unsigned DIM>
00205 void LinearSpringWithVariableSpringConstantsForce<DIM>::AddForceContribution(
00206     std::vector<c_vector<double, DIM> >& rForces,
00207     AbstractTissue<DIM>& rTissue)
00208 {
00209     for (typename MeshBasedTissue<DIM>::SpringIterator spring_iterator=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsBegin();
00210         spring_iterator!=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsEnd();
00211         ++spring_iterator)
00212     {
00213         unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00214         unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00215 
00216         c_vector<double, DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rTissue);
00217 
00218         rForces[nodeB_global_index] -= force;
00219         rForces[nodeA_global_index] += force;
00220     }
00221 }
00222 
00223 
00225 // Explicit instantiation
00227 
00228 template class LinearSpringWithVariableSpringConstantsForce<1>;
00229 template class LinearSpringWithVariableSpringConstantsForce<2>;
00230 template class LinearSpringWithVariableSpringConstantsForce<3>;

Generated on Wed Mar 18 12:51:50 2009 for Chaste by  doxygen 1.5.5