GeneralPlaneStimulusCellFactory.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 
00030 #ifndef GENERALPLANESTIMULUSCELLFACTORY_HPP_
00031 #define GENERALPLANESTIMULUSCELLFACTORY_HPP_
00032 
00033 #include "AbstractCardiacCellFactory.hpp"
00034 
00035 template <class CELL, unsigned DIM>
00036 class GeneralPlaneStimulusCellFactory : public AbstractCardiacCellFactory<DIM>
00037 {
00038 private:
00039     // define a new stimulus
00040     SimpleStimulus* mpStimulus;
00041 
00042 public:
00043     GeneralPlaneStimulusCellFactory(unsigned numEleAcross, double meshWidth, bool useMeshWidthAsMag=false) : AbstractCardiacCellFactory<DIM>()
00044     {
00049         if (useMeshWidthAsMag)
00050         {
00051             #define COVERAGE_IGNORE
00052             mpStimulus = new SimpleStimulus(meshWidth, 0.5);
00053             #undef COVERAGE_IGNORE
00054         }
00055         else
00056         {
00057             double stimulus_magnitude=-1e7;//wrt mesh 4 which has 64 elements in 1D
00058             switch(DIM)
00059             {
00060                 case 1:
00061                 {
00062                     stimulus_magnitude*=numEleAcross/(64.0);
00063                     //Justification: elements go half size with each refinement
00064                     stimulus_magnitude*=meshWidth/(0.2);
00065                     break;
00066                 }
00067                 case 2:
00068                 {
00069                     stimulus_magnitude*=numEleAcross/(64.0);
00070                     //Justification: Triangles go quarter size with each refinement, but there are twice as many nodes on boundary
00071                     stimulus_magnitude*=meshWidth/(0.2);
00072                     break;
00073                 }
00074                 default: //3D
00075                 {
00076                     stimulus_magnitude*=numEleAcross/(64.0);
00077                     //Hypothesis: Triangles go eighth size with each refinement, but there are four-times as many nodes on boundary
00078                     stimulus_magnitude*=meshWidth/(0.2);
00079                     break;
00080                 }
00081             }
00082             //std::cout<<"Mag is "<<stimulus_magnitude<<"\n";
00083             mpStimulus = new SimpleStimulus(stimulus_magnitude, 0.5);
00084         }
00085     }
00086 
00087     AbstractCardiacCell* CreateCardiacCellForTissueNode(unsigned node)
00088     {
00089         double x = this->mpMesh->GetNode(node)->GetPoint()[0];
00090         if (x*x<=1e-10)
00091         {
00092             return new CELL(this->mpSolver, this->mpStimulus);
00093         }
00094         else
00095         {
00096             return new CELL(this->mpSolver, this->mpZeroStimulus);
00097         }
00098     }
00099 
00100     ~GeneralPlaneStimulusCellFactory(void)
00101     {
00102         delete mpStimulus;
00103     }
00104 };
00105 
00106 #endif /*GENERALPLANESTIMULUSCELLFACTORY_HPP_*/

Generated on Wed Mar 18 12:51:52 2009 for Chaste by  doxygen 1.5.5