WelikyOsterForce.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 #include "WelikyOsterForce.hpp"
00029 
00030 template<unsigned DIM>
00031 WelikyOsterForce<DIM>::WelikyOsterForce()
00032    : AbstractForce<DIM>(),
00033      mWelikyOsterAreaParameter(1.0),
00034      mWelikyOsterPerimeterParameter(1.0)
00035 {
00036 }
00037 
00038 template<unsigned DIM>
00039 WelikyOsterForce<DIM>::~WelikyOsterForce()
00040 {
00041 }
00042 
00043 template<unsigned DIM>
00044 void WelikyOsterForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00045                                                  AbstractCellPopulation<DIM>& rCellPopulation)
00046 {
00047     // Make sure that we are in the correct dimension - this code will be eliminated at compile time
00048     assert(DIM == 2); // this method only works in 2D at present
00049 
00050     // Throw an exception message if not using a VertexBasedCellPopulation
00051     if (dynamic_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL)
00052     {
00053         EXCEPTION("WelikyOsterForce is to be used with a VertexBasedCellPopulation only");
00054     }
00055 
00056     // Helper variable that is a static cast of the cell population
00057     VertexBasedCellPopulation<DIM>* p_cell_population = static_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation);
00058 
00059     /*
00060      * The force on each node is given by the interaction between the area and
00061      * the perimeter of the element containing the node.
00062      */
00063 
00064     // Iterate over elements in the cell population
00065     for (typename VertexMesh<DIM,DIM>::VertexElementIterator element_iter = p_cell_population->rGetMesh().GetElementIteratorBegin();
00066              element_iter != p_cell_population->rGetMesh().GetElementIteratorEnd();
00067              ++element_iter)
00068     {
00069         unsigned element_index = element_iter->GetIndex();
00070 
00071         /******** Start of deformation force calculation ********/
00072 
00073         // Compute the area of this element
00074         double element_area = p_cell_population->rGetMesh().GetVolumeOfElement(element_index);
00075 
00076         double deformation_coefficient = GetWelikyOsterAreaParameter()/element_area;
00077 
00078         /******** End of deformation force calculation *************/
00079 
00080         /******** Start of membrane force calculation ***********/
00081 
00082         // Compute the perimeter of the element
00083         double element_perimeter = p_cell_population->rGetMesh().GetSurfaceAreaOfElement(element_index);
00084 
00085         double membrane_surface_tension_coefficient = GetWelikyOsterPerimeterParameter()*element_perimeter;
00086 
00087         /******** End of membrane force calculation **********/
00088 
00089         unsigned num_nodes = element_iter->GetNumNodes();
00090            for (unsigned node_local_index = 0; node_local_index < num_nodes; node_local_index++)
00091         {
00092             unsigned node_global_index = element_iter->GetNodeGlobalIndex(node_local_index);
00093 
00094             c_vector<double, DIM> current_node = element_iter->GetNodeLocation(node_local_index);
00095             c_vector<double, DIM> next_node = element_iter->GetNodeLocation((node_local_index + 1)%(element_iter->GetNumNodes()));
00096             c_vector<double, DIM> previous_node = element_iter->GetNodeLocation((node_local_index + element_iter->GetNumNodes() - 1)%(element_iter->GetNumNodes()));
00097 
00098             c_vector<double, DIM> clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, previous_node);
00099             clockwise_unit_vector /= norm_2(clockwise_unit_vector);
00100             c_vector<double, DIM> anti_clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, next_node);
00101             anti_clockwise_unit_vector /= norm_2(anti_clockwise_unit_vector);
00102 
00103             // Calculate the outward normal at the node
00104             c_vector<double, DIM> outward_normal = -0.5*clockwise_unit_vector - 0.5*anti_clockwise_unit_vector;
00105             outward_normal /= norm_2(outward_normal);
00106 
00107             c_vector<double, DIM> deformation_contribution = deformation_coefficient * outward_normal;
00108 
00109             c_vector<double, DIM> membrane_surface_tension_contribution = membrane_surface_tension_coefficient * (clockwise_unit_vector + anti_clockwise_unit_vector);
00110 
00111             c_vector<double, DIM> force_on_node = deformation_contribution +
00112                                                   membrane_surface_tension_contribution;
00113 
00114             rForces[node_global_index] += force_on_node;
00115         }
00116     }
00117 }
00118 
00119 template<unsigned DIM>
00120 double WelikyOsterForce<DIM>::GetWelikyOsterAreaParameter()
00121 {
00122     return mWelikyOsterAreaParameter;
00123 }
00124 
00125 template<unsigned DIM>
00126 double WelikyOsterForce<DIM>::GetWelikyOsterPerimeterParameter()
00127 {
00128     return mWelikyOsterPerimeterParameter;
00129 }
00130 
00131 template<unsigned DIM>
00132 void WelikyOsterForce<DIM>::SetWelikyOsterAreaParameter(double welikyOsterAreaParameter)
00133 {
00134     mWelikyOsterAreaParameter = welikyOsterAreaParameter;
00135 }
00136 
00137 template<unsigned DIM>
00138 void WelikyOsterForce<DIM>::SetWelikyOsterPerimeterParameter(double welikyOsterPerimeterParameter)
00139 {
00140     mWelikyOsterPerimeterParameter = welikyOsterPerimeterParameter;
00141 }
00142 
00143 template<unsigned DIM>
00144 void WelikyOsterForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00145 {
00146     *rParamsFile << "\t\t\t<WelikyOsterAreaParameter>" << mWelikyOsterAreaParameter << "</WelikyOsterAreaParameter> \n";
00147     *rParamsFile << "\t\t\t<WelikyOsterPerimeterParameter>" << mWelikyOsterPerimeterParameter << "</WelikyOsterPerimeterParameter> \n";
00148 
00149     // Call method on direct parent class
00150     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00151 }
00152 
00154 // Explicit instantiation
00156 
00157 template class WelikyOsterForce<1>;
00158 template class WelikyOsterForce<2>;
00159 template class WelikyOsterForce<3>;
00160 
00161 
00162 // Serialization for Boost >= 1.36
00163 #include "SerializationExportWrapperForCpp.hpp"
00164 EXPORT_TEMPLATE_CLASS_SAME_DIMS(WelikyOsterForce)

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