WelikyOsterForce.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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     // Helper variable that is a static cast of the cell population
00051     VertexBasedCellPopulation<DIM>* p_cell_population = static_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation);
00052 
00053     /*
00054      * The force on each node is given by the interaction between the area and
00055      * the perimeter of the element containing the node.
00056      */
00057 
00058     // Iterate over elements in the cell population
00059     for (typename VertexMesh<DIM,DIM>::VertexElementIterator element_iter = p_cell_population->rGetMesh().GetElementIteratorBegin();
00060              element_iter != p_cell_population->rGetMesh().GetElementIteratorEnd();
00061              ++element_iter)
00062     {
00063         unsigned element_index = element_iter->GetIndex();
00064 
00065         /******** Start of deformation force calculation ********/
00066 
00067         // Compute the area of this element
00068         double element_area = p_cell_population->rGetMesh().GetVolumeOfElement(element_index);
00069 
00070         double deformation_coefficient = GetWelikyOsterAreaParameter()/element_area;
00071 
00072         /******** End of deformation force calculation *************/
00073 
00074         /******** Start of membrane force calculation ***********/
00075 
00076         // Compute the perimeter of the element
00077         double element_perimeter = p_cell_population->rGetMesh().GetSurfaceAreaOfElement(element_index);
00078 
00079         double membrane_surface_tension_coefficient = GetWelikyOsterPerimeterParameter()*element_perimeter;
00080 
00081         /******** End of membrane force calculation **********/
00082 
00083         unsigned num_nodes = element_iter->GetNumNodes();
00084            for (unsigned node_local_index = 0; node_local_index < num_nodes; node_local_index++)
00085         {
00086             unsigned node_global_index = element_iter->GetNodeGlobalIndex(node_local_index);
00087 
00088             c_vector<double, DIM> current_node = element_iter->GetNodeLocation(node_local_index);
00089             c_vector<double, DIM> next_node = element_iter->GetNodeLocation((node_local_index + 1)%(element_iter->GetNumNodes()));
00090             c_vector<double, DIM> previous_node = element_iter->GetNodeLocation((node_local_index + element_iter->GetNumNodes() - 1)%(element_iter->GetNumNodes()));
00091 
00092             c_vector<double, DIM> clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, previous_node);
00093             clockwise_unit_vector /= norm_2(clockwise_unit_vector);
00094             c_vector<double, DIM> anti_clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, next_node);
00095             anti_clockwise_unit_vector /= norm_2(anti_clockwise_unit_vector);
00096 
00097             // Calculate the outward normal at the node
00098             c_vector<double, DIM> outward_normal = -0.5*clockwise_unit_vector - 0.5*anti_clockwise_unit_vector;
00099             outward_normal /= norm_2(outward_normal);
00100 
00101             c_vector<double, DIM> deformation_contribution = deformation_coefficient * outward_normal;
00102 
00103             c_vector<double, DIM> membrane_surface_tension_contribution = membrane_surface_tension_coefficient * (clockwise_unit_vector + anti_clockwise_unit_vector);
00104 
00105             c_vector<double, DIM> force_on_node = deformation_contribution +
00106                                                   membrane_surface_tension_contribution;
00107 
00108             rForces[node_global_index] += force_on_node;
00109         }
00110     }
00111 }
00112 
00113 template<unsigned DIM>
00114 double WelikyOsterForce<DIM>::GetWelikyOsterAreaParameter()
00115 {
00116     return mWelikyOsterAreaParameter;
00117 }
00118 
00119 template<unsigned DIM>
00120 double WelikyOsterForce<DIM>::GetWelikyOsterPerimeterParameter()
00121 {
00122     return mWelikyOsterPerimeterParameter;
00123 }
00124 
00125 template<unsigned DIM>
00126 void WelikyOsterForce<DIM>::SetWelikyOsterAreaParameter(double welikyOsterAreaParameter)
00127 {
00128     mWelikyOsterAreaParameter = welikyOsterAreaParameter;
00129 }
00130 
00131 template<unsigned DIM>
00132 void WelikyOsterForce<DIM>::SetWelikyOsterPerimeterParameter(double welikyOsterPerimeterParameter)
00133 {
00134     mWelikyOsterPerimeterParameter = welikyOsterPerimeterParameter;
00135 }
00136 
00137 template<unsigned DIM>
00138 void WelikyOsterForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00139 {
00140     *rParamsFile <<  "\t\t\t<WelikyOsterAreaParameter>"<<  mWelikyOsterAreaParameter << "</WelikyOsterAreaParameter> \n" ;
00141     *rParamsFile <<  "\t\t\t<WelikyOsterPerimeterParameter>"<<  mWelikyOsterPerimeterParameter << "</WelikyOsterPerimeterParameter> \n" ;
00142 
00143     // Call direct parent class
00144     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00145 }
00146 
00148 // Explicit instantiation
00150 
00151 template class WelikyOsterForce<1>;
00152 template class WelikyOsterForce<2>;
00153 template class WelikyOsterForce<3>;
00154 
00155 
00156 // Serialization for Boost >= 1.36
00157 #include "SerializationExportWrapperForCpp.hpp"
00158 EXPORT_TEMPLATE_CLASS_SAME_DIMS(WelikyOsterForce)

Generated on Mon Nov 1 12:35:16 2010 for Chaste by  doxygen 1.5.5