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 "NagaiHondaDifferentialAdhesionForce.hpp" 00037 #include "CellLabel.hpp" 00038 00039 template<unsigned DIM> 00040 NagaiHondaDifferentialAdhesionForce<DIM>::NagaiHondaDifferentialAdhesionForce() 00041 : NagaiHondaForce<DIM>(), 00042 mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(1.0), 00043 mNagaiHondaLabelledCellCellAdhesionEnergyParameter(1.0), 00044 mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(1.0) 00045 { 00046 } 00047 00048 template<unsigned DIM> 00049 NagaiHondaDifferentialAdhesionForce<DIM>::~NagaiHondaDifferentialAdhesionForce() 00050 { 00051 } 00052 00053 template<unsigned DIM> 00054 double NagaiHondaDifferentialAdhesionForce<DIM>::GetAdhesionParameter(Node<DIM>* pNodeA, 00055 Node<DIM>* pNodeB, 00056 VertexBasedCellPopulation<DIM>& rVertexCellPopulation) 00057 { 00058 // Find the indices of the elements owned by each node 00059 std::set<unsigned> elements_containing_nodeA = pNodeA->rGetContainingElementIndices(); 00060 std::set<unsigned> elements_containing_nodeB = pNodeB->rGetContainingElementIndices(); 00061 00062 // Find common elements 00063 std::set<unsigned> shared_elements; 00064 std::set_intersection(elements_containing_nodeA.begin(), 00065 elements_containing_nodeA.end(), 00066 elements_containing_nodeB.begin(), 00067 elements_containing_nodeB.end(), 00068 std::inserter(shared_elements, shared_elements.begin())); 00069 00070 // Check that the nodes have a common edge 00071 assert(!shared_elements.empty()); 00072 00073 // If the edge corresponds to a single element, then the cell is on the boundary 00074 if (shared_elements.size() == 1) 00075 { 00076 unsigned element_index = *(shared_elements.begin()); 00077 00078 // Get cell associated with this element 00079 CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index); 00080 00081 if (p_cell->template HasCellProperty<CellLabel>()) 00082 { 00083 // This cell is labelled 00084 return this->GetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(); 00085 } 00086 else 00087 { 00088 // This cell is not labelled 00089 return this->GetNagaiHondaCellBoundaryAdhesionEnergyParameter(); 00090 } 00091 } 00092 else 00093 { 00094 // Work out the number of labelled cells: 0,1 or 2 00095 unsigned num_labelled_cells = 0; 00096 for (std::set<unsigned>::iterator iter = shared_elements.begin(); 00097 iter != shared_elements.end(); 00098 ++iter) 00099 { 00100 unsigned element_index = *(iter); 00101 00102 // Get cell associated with this element 00103 CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index); 00104 00105 if (p_cell->template HasCellProperty<CellLabel>()) 00106 { 00107 num_labelled_cells++; 00108 } 00109 } 00110 00111 if (num_labelled_cells == 2) 00112 { 00113 // Both cells are labelled 00114 return this->GetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(); 00115 } 00116 else if (num_labelled_cells == 1) 00117 { 00118 // One cell is labelled 00119 return this->GetNagaiHondaLabelledCellCellAdhesionEnergyParameter(); 00120 } 00121 else 00122 { 00123 // Neither cell is labelled 00124 assert(num_labelled_cells == 0); 00125 return this->GetNagaiHondaCellCellAdhesionEnergyParameter(); 00126 } 00127 } 00128 } 00129 00130 template<unsigned DIM> 00131 double NagaiHondaDifferentialAdhesionForce<DIM>::GetNagaiHondaLabelledCellCellAdhesionEnergyParameter() 00132 { 00133 return mNagaiHondaLabelledCellCellAdhesionEnergyParameter; 00134 } 00135 00136 template<unsigned DIM> 00137 double NagaiHondaDifferentialAdhesionForce<DIM>::GetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter() 00138 { 00139 return mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter; 00140 } 00141 00142 template<unsigned DIM> 00143 double NagaiHondaDifferentialAdhesionForce<DIM>::GetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter() 00144 { 00145 return mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter; 00146 } 00147 00148 template<unsigned DIM> 00149 void NagaiHondaDifferentialAdhesionForce<DIM>::SetNagaiHondaLabelledCellCellAdhesionEnergyParameter(double labelledCellCellAdhesionEnergyParameter) 00150 { 00151 mNagaiHondaLabelledCellCellAdhesionEnergyParameter = labelledCellCellAdhesionEnergyParameter; 00152 } 00153 00154 template<unsigned DIM> 00155 void NagaiHondaDifferentialAdhesionForce<DIM>::SetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(double labelledCellLabelledCellAdhesionEnergyParameter) 00156 { 00157 mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter = labelledCellLabelledCellAdhesionEnergyParameter; 00158 } 00159 00160 template<unsigned DIM> 00161 void NagaiHondaDifferentialAdhesionForce<DIM>::SetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(double labelledCellBoundaryAdhesionEnergyParameter) 00162 { 00163 mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter = labelledCellBoundaryAdhesionEnergyParameter; 00164 } 00165 00166 template<unsigned DIM> 00167 void NagaiHondaDifferentialAdhesionForce<DIM>::OutputForceParameters(out_stream& rParamsFile) 00168 { 00169 // Output member variables 00170 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter> \n"; 00171 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellCellAdhesionEnergyParameter> \n"; 00172 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter>" << mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter << "</NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter> \n"; 00173 00174 // Call method on direct parent class 00175 NagaiHondaForce<DIM>::OutputForceParameters(rParamsFile); 00176 } 00177 00179 // Explicit instantiation 00181 00182 template class NagaiHondaDifferentialAdhesionForce<1>; 00183 template class NagaiHondaDifferentialAdhesionForce<2>; 00184 template class NagaiHondaDifferentialAdhesionForce<3>; 00185 00186 // Serialization for Boost >= 1.36 00187 #include "SerializationExportWrapperForCpp.hpp" 00188 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NagaiHondaDifferentialAdhesionForce)