Chaste Commit::8b5d759ac2eb95e67ae57699734101efccb0a0a9
ChemotacticForce.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "ChemotacticForce.hpp"
37
38#include "CellwiseDataGradient.hpp"
39#include "CellLabel.hpp"
40
41template<unsigned DIM>
46
47template<unsigned DIM>
51
52template<unsigned DIM>
53double ChemotacticForce<DIM>::GetChemotacticForceMagnitude(const double concentration, const double concentrationGradientMagnitude)
54{
55 return concentration; // temporary force law - can be changed to something realistic
56 // without tests failing
57}
58
59template<unsigned DIM>
61{
63 gradients.SetupGradients(rCellPopulation, "nutrient");
64
65 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
66 cell_iter != rCellPopulation.End();
67 ++cell_iter)
68 {
69 // Only labelled cells move chemotactically
70 if (cell_iter->template HasCellProperty<CellLabel>())
71 {
72 unsigned node_global_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
73
74 c_vector<double,DIM>& r_gradient = gradients.rGetGradient(node_global_index);
75 double nutrient_concentration = cell_iter->GetCellData()->GetItem("nutrient");
76 double magnitude_of_gradient = norm_2(r_gradient);
77
78 double force_magnitude = GetChemotacticForceMagnitude(nutrient_concentration, magnitude_of_gradient);
79
80 // force += chi * gradC/|gradC|
81 if (magnitude_of_gradient > 0)
82 {
83 c_vector<double,DIM> force = (force_magnitude/magnitude_of_gradient)*r_gradient;
84 rCellPopulation.GetNode(node_global_index)->AddAppliedForceContribution(force);
85 }
86 // else Fc=0
87 }
88 }
89}
90
91template<unsigned DIM>
93{
94 // No parameters to include
95
96 // Call method on direct parent class
98}
99
100// Explicit instantiation
101template class ChemotacticForce<1>;
102template class ChemotacticForce<2>;
103template class ChemotacticForce<3>;
104
105// Serialization for Boost >= 1.36
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual Node< SPACE_DIM > * GetNode(unsigned index)=0
unsigned GetLocationIndexUsingCell(CellPtr pCell)
virtual void OutputForceParameters(out_stream &rParamsFile)=0
void SetupGradients(AbstractCellPopulation< DIM > &rCellPopulation, const std::string &rItemName)
c_vector< double, DIM > & rGetGradient(unsigned nodeIndex)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
void OutputForceParameters(out_stream &rParamsFile)
double GetChemotacticForceMagnitude(const double concentration, const double concentrationGradientMagnitude)