VertexCryptBoundaryForce.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 
00029 #include "VertexCryptBoundaryForce.hpp"
00030 #include "UblasCustomFunctions.hpp"
00031 
00032 template<unsigned DIM>
00033 VertexCryptBoundaryForce<DIM>::VertexCryptBoundaryForce(double forceStrength)
00034    : AbstractForce<DIM>(),
00035      mForceStrength(forceStrength)
00036 {
00037     // We don't want the force to act in the wrong direction
00038     assert(mForceStrength > 0.0);
00039 }
00040 
00041 template<unsigned DIM>
00042 VertexCryptBoundaryForce<DIM>::~VertexCryptBoundaryForce()
00043 {
00044 }
00045 
00046 template<unsigned DIM>
00047 void VertexCryptBoundaryForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00048                                                          AbstractCellPopulation<DIM>& rCellPopulation)
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     // Iterate over nodes
00054     for (typename AbstractMesh<DIM,DIM>::NodeIterator node_iter = p_cell_population->rGetMesh().GetNodeIteratorBegin();
00055          node_iter != p_cell_population->rGetMesh().GetNodeIteratorEnd();
00056          ++node_iter)
00057     {
00058         double y = node_iter->rGetLocation()[1]; // y-coordinate of node
00059 
00060         // If the node lies below the line y=0, then add the boundary force contribution to rForces
00061         if (y < 0.0)
00062         {
00063             c_vector<double, DIM> boundary_force = zero_vector<double>(DIM);
00064             boundary_force[1] = mForceStrength*SmallPow(y, 2);
00065 
00066             rForces[node_iter->GetIndex()] += boundary_force;
00067         }
00068     }
00069 }
00070 
00071 template<unsigned DIM>
00072 double VertexCryptBoundaryForce<DIM>::GetForceStrength() const
00073 {
00074     return mForceStrength;
00075 }
00076 
00077 template<unsigned DIM>
00078 void VertexCryptBoundaryForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00079 {
00080     *rParamsFile <<  "\t\t\t<ForceStrength>"<<  mForceStrength << "</ForceStrength> \n" ;
00081 
00082     // Call direct parent class
00083     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00084 }
00085 
00087 // Explicit instantiation
00089 
00090 template class VertexCryptBoundaryForce<1>;
00091 template class VertexCryptBoundaryForce<2>;
00092 template class VertexCryptBoundaryForce<3>;
00093 
00094 
00095 // Serialization for Boost >= 1.36
00096 #include "SerializationExportWrapperForCpp.hpp"
00097 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexCryptBoundaryForce)

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