Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #include "WelikyOsterForce.hpp" 00037 00038 template<unsigned DIM> 00039 WelikyOsterForce<DIM>::WelikyOsterForce() 00040 : AbstractForce<DIM>(), 00041 mWelikyOsterAreaParameter(1.0), 00042 mWelikyOsterPerimeterParameter(1.0) 00043 { 00044 } 00045 00046 template<unsigned DIM> 00047 WelikyOsterForce<DIM>::~WelikyOsterForce() 00048 { 00049 } 00050 00051 template<unsigned DIM> 00052 void WelikyOsterForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces, 00053 AbstractCellPopulation<DIM>& rCellPopulation) 00054 { 00055 // Make sure that we are in the correct dimension - this code will be eliminated at compile time 00056 assert(DIM == 2); // this method only works in 2D at present 00057 00058 // Throw an exception message if not using a VertexBasedCellPopulation 00059 if (dynamic_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL) 00060 { 00061 EXCEPTION("WelikyOsterForce is to be used with a VertexBasedCellPopulation only"); 00062 } 00063 00064 // Helper variable that is a static cast of the cell population 00065 VertexBasedCellPopulation<DIM>* p_cell_population = static_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation); 00066 00067 /* 00068 * The force on each node is given by the interaction between the area and 00069 * the perimeter of the element containing the node. 00070 */ 00071 00072 // Iterate over elements in the cell population 00073 for (typename VertexMesh<DIM,DIM>::VertexElementIterator element_iter = p_cell_population->rGetMesh().GetElementIteratorBegin(); 00074 element_iter != p_cell_population->rGetMesh().GetElementIteratorEnd(); 00075 ++element_iter) 00076 { 00077 unsigned element_index = element_iter->GetIndex(); 00078 00079 /******** Start of deformation force calculation ********/ 00080 00081 // Compute the area of this element 00082 double element_area = p_cell_population->rGetMesh().GetVolumeOfElement(element_index); 00083 00084 double deformation_coefficient = GetWelikyOsterAreaParameter()/element_area; 00085 00086 /******** End of deformation force calculation *************/ 00087 00088 /******** Start of membrane force calculation ***********/ 00089 00090 // Compute the perimeter of the element 00091 double element_perimeter = p_cell_population->rGetMesh().GetSurfaceAreaOfElement(element_index); 00092 00093 double membrane_surface_tension_coefficient = GetWelikyOsterPerimeterParameter()*element_perimeter; 00094 00095 /******** End of membrane force calculation **********/ 00096 00097 unsigned num_nodes = element_iter->GetNumNodes(); 00098 for (unsigned node_local_index = 0; node_local_index < num_nodes; node_local_index++) 00099 { 00100 unsigned node_global_index = element_iter->GetNodeGlobalIndex(node_local_index); 00101 00102 c_vector<double, DIM> current_node = element_iter->GetNodeLocation(node_local_index); 00103 c_vector<double, DIM> next_node = element_iter->GetNodeLocation((node_local_index + 1)%(element_iter->GetNumNodes())); 00104 c_vector<double, DIM> previous_node = element_iter->GetNodeLocation((node_local_index + element_iter->GetNumNodes() - 1)%(element_iter->GetNumNodes())); 00105 00106 c_vector<double, DIM> clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, previous_node); 00107 clockwise_unit_vector /= norm_2(clockwise_unit_vector); 00108 00109 c_vector<double, DIM> anti_clockwise_unit_vector = p_cell_population->rGetMesh().GetVectorFromAtoB(current_node, next_node); 00110 anti_clockwise_unit_vector /= norm_2(anti_clockwise_unit_vector); 00111 00112 // Calculate the outward normal at the node 00113 c_vector<double, DIM> outward_normal = -0.5*clockwise_unit_vector - 0.5*anti_clockwise_unit_vector; 00114 outward_normal /= norm_2(outward_normal); 00115 00116 c_vector<double, DIM> deformation_contribution = deformation_coefficient * outward_normal; 00117 00118 c_vector<double, DIM> membrane_surface_tension_contribution = membrane_surface_tension_coefficient * (clockwise_unit_vector + anti_clockwise_unit_vector); 00119 00120 c_vector<double, DIM> force_on_node = deformation_contribution + membrane_surface_tension_contribution; 00121 00122 rForces[node_global_index] += force_on_node; 00123 } 00124 } 00125 } 00126 00127 template<unsigned DIM> 00128 double WelikyOsterForce<DIM>::GetWelikyOsterAreaParameter() 00129 { 00130 return mWelikyOsterAreaParameter; 00131 } 00132 00133 template<unsigned DIM> 00134 double WelikyOsterForce<DIM>::GetWelikyOsterPerimeterParameter() 00135 { 00136 return mWelikyOsterPerimeterParameter; 00137 } 00138 00139 template<unsigned DIM> 00140 void WelikyOsterForce<DIM>::SetWelikyOsterAreaParameter(double welikyOsterAreaParameter) 00141 { 00142 mWelikyOsterAreaParameter = welikyOsterAreaParameter; 00143 } 00144 00145 template<unsigned DIM> 00146 void WelikyOsterForce<DIM>::SetWelikyOsterPerimeterParameter(double welikyOsterPerimeterParameter) 00147 { 00148 mWelikyOsterPerimeterParameter = welikyOsterPerimeterParameter; 00149 } 00150 00151 template<unsigned DIM> 00152 void WelikyOsterForce<DIM>::OutputForceParameters(out_stream& rParamsFile) 00153 { 00154 *rParamsFile << "\t\t\t<WelikyOsterAreaParameter>" << mWelikyOsterAreaParameter << "</WelikyOsterAreaParameter>\n"; 00155 *rParamsFile << "\t\t\t<WelikyOsterPerimeterParameter>" << mWelikyOsterPerimeterParameter << "</WelikyOsterPerimeterParameter>\n"; 00156 00157 // Call method on direct parent class 00158 AbstractForce<DIM>::OutputForceParameters(rParamsFile); 00159 } 00160 00162 // Explicit instantiation 00164 00165 template class WelikyOsterForce<1>; 00166 template class WelikyOsterForce<2>; 00167 template class WelikyOsterForce<3>; 00168 00169 // Serialization for Boost >= 1.36 00170 #include "SerializationExportWrapperForCpp.hpp" 00171 EXPORT_TEMPLATE_CLASS_SAME_DIMS(WelikyOsterForce)