Chaste  Release::2017.1
ElectrodesStimulusFactory.hpp
1 /*
2 
3 Copyright (c) 2005-2017, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef ELECTRODESSTIMULSUFACTORY_HPP_
37 #define ELECTRODESSTIMULSUFACTORY_HPP_
38 
39 #include <boost/shared_ptr.hpp>
40 #include "ChasteSerialization.hpp"
41 #include <boost/serialization/split_member.hpp>
42 #include <boost/serialization/shared_ptr.hpp>
43 
44 #include "AbstractTetrahedralMesh.hpp"
45 #include "DistributedVector.hpp"
46 #include "AbstractChasteRegion.hpp"
47 #include "AbstractStimulusFactory.hpp"
48 #include "LinearBasisFunction.hpp"
49 
66 template<unsigned DIM>
68 {
69 protected:
70 
71  friend class TestStimulusFactory;//for testing
72 
76  std::vector<std::pair<AbstractChasteRegion<DIM>*, AbstractChasteRegion<DIM>*> >& mrElectrodePairs;
77 
81  std::vector<double>& mrMagnitudes;
85  std::vector<double>& mrDurations;
89  std::vector<double>& mrPeriods;
93  std::vector<double>& mrStarts;
97  std::vector<double>& mrEnds;
98 
102  std::vector<double> mMagnitudesElectrode1;
103 
107  std::vector<double> mMagnitudesElectrode2;
108 
109 
112 
119 
122 
123 
137  double ComputeElectrodeTotalFlux(AbstractChasteRegion<DIM>* pRegion, double stimulusMagnitude);
138 
139 
140 public:
141 
142 
153  ElectrodesStimulusFactory(std::vector<std::pair<AbstractChasteRegion<DIM>*, AbstractChasteRegion<DIM>*> >& rElectrodePairs,
154  std::vector<double>& rStimulusMagnitudes,
155  std::vector<double>& rDurations,
156  std::vector<double>& rPeriods,
157  std::vector<double>& rStarts,
158  std::vector<double>& rEnds);
159 
165  boost::shared_ptr<AbstractStimulusFunction> CreateStimulusForNode(Node<DIM>* pNode);
166 
171 
179 
185  void GroundSecondElectrode(bool grounded);
186 };
187 
188 #endif /*ELECTRODESSTIMULSUFACTORY_HPP_*/
std::vector< double > & mrDurations
std::vector< double > mMagnitudesElectrode2
Definition: Node.hpp:58
ElectrodesStimulusFactory(std::vector< std::pair< AbstractChasteRegion< DIM > *, AbstractChasteRegion< DIM > * > > &rElectrodePairs, std::vector< double > &rStimulusMagnitudes, std::vector< double > &rDurations, std::vector< double > &rPeriods, std::vector< double > &rStarts, std::vector< double > &rEnds)
std::vector< double > & mrMagnitudes
double ComputeElectrodeTotalFlux(AbstractChasteRegion< DIM > *pRegion, double stimulusMagnitude)
std::vector< double > mMagnitudesElectrode1
std::vector< std::pair< AbstractChasteRegion< DIM > *, AbstractChasteRegion< DIM > * > > & mrElectrodePairs
LinearBasisFunction< DIM > BasisFunction
boost::shared_ptr< AbstractStimulusFunction > CreateStimulusForNode(Node< DIM > *pNode)