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