#include <ElectrodesStimulusFactory.hpp>
Inherits AbstractStimulusFactory< DIM >.
Inherited by ZeroNetChargeElectrodes< DIM >.
Public Member Functions | |
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) | |
boost::shared_ptr < AbstractStimulusFunction > | CreateStimulusForNode (unsigned nodeIndex) |
~ElectrodesStimulusFactory () | |
void | SetCompatibleExtracellularStimulus () |
void | GroundSecondElectrode (bool grounded) |
Protected Types | |
typedef LinearBasisFunction< DIM > | BasisFunction |
Protected Member Functions | |
void | CheckForElectrodesIntersection () |
double | ComputeElectrodeTotalFlux (AbstractChasteRegion< DIM > *pRegion, double stimulusMagnitude) |
Protected Attributes | |
std::vector< std::pair < AbstractChasteRegion< DIM > *, AbstractChasteRegion< DIM > * > > & | mrElectrodePairs |
std::vector< double > & | mrMagnitudes |
std::vector< double > & | mrDurations |
std::vector< double > & | mrPeriods |
std::vector< double > & | mrStarts |
std::vector< double > & | mrEnds |
std::vector< double > | mMagnitudesElectrode1 |
std::vector< double > | mMagnitudesElectrode2 |
bool | mGroundSecondElectrode |
Friends | |
class | TestStimulusFactory |
This class implements the specification of tow electrodes with a RegularStimulus applied to them. It makes sure the compatibility conditions is verified by scaling the magnitude of the second electrode according to the flux flowing thorugh each of them.
User needs to pass in a vector of pairs of electrodes and, for each pair, the stimulation parameters. This class will then implement the CreateStimulusForNode accordingly by creating a RegularStimulus object for each node. Each node belonging to any "first electrode" will have an extracellular volume stimulus equals to the value that is passed in, while each node belonging to any "second elecrode" will have an extracellular volume stimulus corrected by the flux (proportional to electrode volume) in such a way that compatibility conditions of the extended bidomain equations are followed.
It is possible to ground all second electrodes by calling GroundSecondElectrode. In this case, the member variable mGroundSecondElectrode will have size > 0 and other classes can behave accordingly (e.g., problem class will set Dirichlet boundary conditions accordingly).
Definition at line 60 of file ElectrodesStimulusFactory.hpp.
typedef LinearBasisFunction<DIM> ElectrodesStimulusFactory< DIM >::BasisFunction [protected] |
typedef for basis function
Definition at line 114 of file ElectrodesStimulusFactory.hpp.
ElectrodesStimulusFactory< DIM >::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 | |||
) | [inline] |
Constructor. Electrodes and stimulation parameters need to be passed in.
rElectrodePairs | the pairs of electrodes | |
rStimulusMagnitudes | the magnitudes of the stimuli (microA / cm^3). First electrode will have magnitude value and second electrode will have -magnitude (before being corrected to ensure equal flux). | |
rDurations | the duration of each stimulus (ms) | |
rPeriods | the period of each stimulus (ms) | |
rStarts | the start time of each stimulus (ms). | |
rEnds | the end of each stimulation (ms) |
Definition at line 36 of file ElectrodesStimulusFactory.cpp.
References EXCEPTION, ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode1, ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode2, and ElectrodesStimulusFactory< DIM >::mrMagnitudes.
ElectrodesStimulusFactory< DIM >::~ElectrodesStimulusFactory | ( | ) | [inline] |
Destructor
Definition at line 65 of file ElectrodesStimulusFactory.cpp.
void ElectrodesStimulusFactory< DIM >::CheckForElectrodesIntersection | ( | ) | [inline, protected] |
Helper method to check if any of the electrodes intersects with the other. it needs to check whether any element that conatins any node of electrode 1 does not conatin also nodes of eledtrode 2
Definition at line 70 of file ElectrodesStimulusFactory.cpp.
References PetscTools::Barrier(), EXCEPTION, AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetDistributedVectorFactory(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNode(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNumNodes(), DistributedVectorFactory::IsGlobalIndexLocal(), AbstractStimulusFactory< DIM >::mpMesh, and ElectrodesStimulusFactory< DIM >::mrElectrodePairs.
Referenced by ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
double ElectrodesStimulusFactory< DIM >::ComputeElectrodeTotalFlux | ( | AbstractChasteRegion< DIM > * | pRegion, | |
double | stimulusMagnitude | |||
) | [inline, protected] |
Helper method to compute electrode flux. This method is the main functionality of this class.
It essentially computes the contribution of each electrode to the RHS vector of the linear system. The loops over elements and gauss points mimicks the ones in AssembleOnElement. Interpolation is done for the value of the magnitude of the electrode.
NOTE that this method assumes the use of a GaussianQuadratureRule with 2 Gauss points (the default value of Chaste FE assemblers).
pRegion | the electrode | |
stimulusMagnitude | the stimulus magnitude |
Definition at line 178 of file ElectrodesStimulusFactory.cpp.
References LinearBasisFunction< ELEMENT_DIM >::ComputeBasisFunctions(), AbstractChasteRegion< SPACE_DIM >::DoesContain(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetElement(), AbstractElement< ELEMENT_DIM, SPACE_DIM >::GetIndex(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetInverseJacobianForElement(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNode(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNodeIteratorBegin(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNodeIteratorEnd(), AbstractElement< ELEMENT_DIM, SPACE_DIM >::GetNumNodes(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNumNodes(), GaussianQuadratureRule< ELEMENT_DIM >::GetNumQuadPoints(), GaussianQuadratureRule< ELEMENT_DIM >::GetWeight(), AbstractStimulusFactory< DIM >::mpMesh, and GaussianQuadratureRule< ELEMENT_DIM >::rGetQuadPoint().
Referenced by ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
boost::shared_ptr< AbstractStimulusFunction > ElectrodesStimulusFactory< DIM >::CreateStimulusForNode | ( | unsigned | nodeIndex | ) | [inline, virtual] |
Creates an appropriate stimuus for each node as to abide compatibility conditions.
nodeIndex | the node index for which to create the stimulus |
Reimplemented from AbstractStimulusFactory< DIM >.
Reimplemented in ZeroNetChargeElectrodes< DIM >.
Definition at line 154 of file ElectrodesStimulusFactory.cpp.
References ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode1, ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode2, ElectrodesStimulusFactory< DIM >::mrDurations, ElectrodesStimulusFactory< DIM >::mrElectrodePairs, ElectrodesStimulusFactory< DIM >::mrEnds, ElectrodesStimulusFactory< DIM >::mrPeriods, and ElectrodesStimulusFactory< DIM >::mrStarts.
void ElectrodesStimulusFactory< DIM >::GroundSecondElectrode | ( | bool | grounded | ) | [inline] |
Allow the user to ground the second electrode
grounded | : true if second electrode is grounded |
Definition at line 109 of file ElectrodesStimulusFactory.cpp.
References ElectrodesStimulusFactory< DIM >::mGroundSecondElectrode.
void ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus | ( | ) | [inline, virtual] |
This method checks whether the users wanted a grounded electrode. If so, it fills in mGroundedRegions accordingly.
If not, it calls ComputeElectrodeTotalFlux and scales the magnitudes of the electrodes stimuli accordingly
Reimplemented from AbstractStimulusFactory< DIM >.
Definition at line 115 of file ElectrodesStimulusFactory.cpp.
References ElectrodesStimulusFactory< DIM >::CheckForElectrodesIntersection(), ElectrodesStimulusFactory< DIM >::ComputeElectrodeTotalFlux(), AbstractStimulusFactory< DIM >::mGroundedRegions, ElectrodesStimulusFactory< DIM >::mGroundSecondElectrode, ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode1, ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode2, AbstractStimulusFactory< DIM >::mpMesh, ElectrodesStimulusFactory< DIM >::mrElectrodePairs, and PetscTools::ReplicateException().
bool ElectrodesStimulusFactory< DIM >::mGroundSecondElectrode [protected] |
Whether the second electrode is grounded
Definition at line 104 of file ElectrodesStimulusFactory.hpp.
Referenced by ElectrodesStimulusFactory< DIM >::GroundSecondElectrode(), and ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
std::vector<double> ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode1 [protected] |
Used to store temporarily magnitudes of electrode 1 for correction
Definition at line 95 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), ElectrodesStimulusFactory< DIM >::CreateStimulusForNode(), ElectrodesStimulusFactory< DIM >::ElectrodesStimulusFactory(), and ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
std::vector<double> ElectrodesStimulusFactory< DIM >::mMagnitudesElectrode2 [protected] |
Used to store temporarily magnitudes of electrode 2 for correction
Definition at line 100 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), ElectrodesStimulusFactory< DIM >::CreateStimulusForNode(), ElectrodesStimulusFactory< DIM >::ElectrodesStimulusFactory(), and ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
std::vector<double>& ElectrodesStimulusFactory< DIM >::mrDurations [protected] |
Vector of stimuli durations (ms). Must be the same size as mrElectrodePairs.
Definition at line 78 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), and ElectrodesStimulusFactory< DIM >::CreateStimulusForNode().
std::vector<std::pair<AbstractChasteRegion<DIM>*, AbstractChasteRegion<DIM>*> >& ElectrodesStimulusFactory< DIM >::mrElectrodePairs [protected] |
Vector of pairs, each pair representing a pair of electrodes.
Definition at line 69 of file ElectrodesStimulusFactory.hpp.
Referenced by ElectrodesStimulusFactory< DIM >::CheckForElectrodesIntersection(), ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), ElectrodesStimulusFactory< DIM >::CreateStimulusForNode(), and ElectrodesStimulusFactory< DIM >::SetCompatibleExtracellularStimulus().
std::vector<double>& ElectrodesStimulusFactory< DIM >::mrEnds [protected] |
Vector of stimuli end times (ms). Must be the same size as mrElectrodePairs.
Definition at line 90 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), and ElectrodesStimulusFactory< DIM >::CreateStimulusForNode().
std::vector<double>& ElectrodesStimulusFactory< DIM >::mrMagnitudes [protected] |
Vector of stimuli magnitudes (microA / cm^3). Must be the same size as mrElectrodePairs.
Definition at line 74 of file ElectrodesStimulusFactory.hpp.
Referenced by ElectrodesStimulusFactory< DIM >::ElectrodesStimulusFactory().
std::vector<double>& ElectrodesStimulusFactory< DIM >::mrPeriods [protected] |
Vector of stimuli periods (ms). Must be the same size as mrElectrodePairs.
Definition at line 82 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), and ElectrodesStimulusFactory< DIM >::CreateStimulusForNode().
std::vector<double>& ElectrodesStimulusFactory< DIM >::mrStarts [protected] |
Vector of stimuli start times (ms). Must be the same size as mrElectrodePairs.
Definition at line 86 of file ElectrodesStimulusFactory.hpp.
Referenced by ZeroNetChargeElectrodes< DIM >::CreateStimulusForNode(), and ElectrodesStimulusFactory< DIM >::CreateStimulusForNode().