ChemotacticForce.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 
00030 #include "ChemotacticForce.hpp"
00031 #include "CellwiseDataGradient.hpp"
00032 
00033 template<unsigned DIM>
00034 ChemotacticForce<DIM>::ChemotacticForce()
00035     : AbstractForce<DIM>()
00036 {
00037 }
00038 
00039 template<unsigned DIM>
00040 ChemotacticForce<DIM>::~ChemotacticForce()
00041 {
00042 }
00043 
00044 template<unsigned DIM>
00045 double ChemotacticForce<DIM>::GetChemotacticForceMagnitude(const double concentration, const double concentrationGradientMagnitude)
00046 {
00047     return concentration; // temporary force law - can be changed to something realistic
00048                           // without tests failing
00049 }
00050 
00051 template<unsigned DIM>
00052 void ChemotacticForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00053                                                  AbstractCellPopulation<DIM>& rCellPopulation)
00054 {
00055     CellwiseDataGradient<DIM> gradients;
00056     gradients.SetupGradients();
00057 
00058     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
00059          cell_iter != rCellPopulation.End();
00060          ++cell_iter)
00061     {
00062         // Only labelled cells move chemotactically
00063         if (cell_iter->template HasCellProperty<CellLabel>())
00064         {
00065             unsigned node_global_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
00066 
00067             c_vector<double,DIM>& r_gradient = gradients.rGetGradient(node_global_index);
00068             double nutrient_concentration = CellwiseData<DIM>::Instance()->GetValue(*cell_iter, 0);
00069             double magnitude_of_gradient = norm_2(r_gradient);
00070 
00071             double force_magnitude = GetChemotacticForceMagnitude(nutrient_concentration, magnitude_of_gradient);
00072 
00073             // force += chi * gradC/|gradC|
00074             if (magnitude_of_gradient > 0)
00075             {
00076                 rForces[node_global_index] += (force_magnitude/magnitude_of_gradient)*r_gradient;
00077             }
00078             // else Fc=0
00079         }
00080     }
00081 }
00082 
00083 template<unsigned DIM>
00084 void ChemotacticForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00085 {
00086     // No parameters to include
00087 
00088     // Call method on direct parent class
00089     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00090 }
00091 
00093 // Explicit instantiation
00095 
00096 template class ChemotacticForce<1>;
00097 template class ChemotacticForce<2>;
00098 template class ChemotacticForce<3>;
00099 
00100 // Serialization for Boost >= 1.36
00101 #include "SerializationExportWrapperForCpp.hpp"
00102 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChemotacticForce)

Generated on Tue May 31 14:31:40 2011 for Chaste by  doxygen 1.5.5