VertexCryptBoundaryForce.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 
00029 #include "VertexCryptBoundaryForce.hpp"
00030 #include "MathsCustomFunctions.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     // Throw an exception message if not using a VertexBasedCellPopulation
00054     if (dynamic_cast<VertexBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL)
00055     {
00056         EXCEPTION("VertexCryptBoundaryForce is to be used with VertexBasedCellPopulations only");
00057     }
00058 
00059     // Iterate over nodes
00060     for (typename AbstractMesh<DIM,DIM>::NodeIterator node_iter = p_cell_population->rGetMesh().GetNodeIteratorBegin();
00061          node_iter != p_cell_population->rGetMesh().GetNodeIteratorEnd();
00062          ++node_iter)
00063     {
00064         double y = node_iter->rGetLocation()[1]; // y-coordinate of node
00065 
00066         // If the node lies below the line y=0, then add the boundary force contribution to rForces
00067         if (y < 0.0)
00068         {
00069             c_vector<double, DIM> boundary_force = zero_vector<double>(DIM);
00070             boundary_force[1] = mForceStrength*SmallPow(y, 2);
00071 
00072             rForces[node_iter->GetIndex()] += boundary_force;
00073         }
00074     }
00075 }
00076 
00077 template<unsigned DIM>
00078 double VertexCryptBoundaryForce<DIM>::GetForceStrength() const
00079 {
00080     return mForceStrength;
00081 }
00082 
00083 template<unsigned DIM>
00084 void VertexCryptBoundaryForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00085 {
00086     *rParamsFile << "\t\t\t<ForceStrength>" << mForceStrength << "</ForceStrength>\n";
00087 
00088     // Call method on direct parent class
00089     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00090 }
00091 
00093 // Explicit instantiation
00095 
00096 template class VertexCryptBoundaryForce<1>;
00097 template class VertexCryptBoundaryForce<2>;
00098 template class VertexCryptBoundaryForce<3>;
00099 
00100 
00101 // Serialization for Boost >= 1.36
00102 #include "SerializationExportWrapperForCpp.hpp"
00103 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexCryptBoundaryForce)
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3