LifeV
StimulusPMJ.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3  *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23  *******************************************************************************
24  */
25 //@HEADER
26 /*!
27  @file
28  @brief Class for applying cardiac stimulus at Purkinje-muscle junctions
29 
30  @date 11-2013
31  @author Toni Lassila <toni.lassila@epfl.ch>
32 
33  @last update 11-2013
34 
35  */
36 
37 #include <lifev/electrophysiology/stimulus/StimulusPMJ.hpp>
38 
39 namespace LifeV
40 {
41 
42 // ===================================================
43 //! Constructors
44 // ===================================================
46  M_radius ( 0 ),
48  M_problemFolder ( "./" )
49 {
50 
51 }
52 
53 // ===================================================
54 //! Setters
55 // ===================================================
56 void StimulusPMJ::setPMJFromFile ( std::string fileName )
57 {
58  std::ifstream fin;
59 
60  fin.open ( fileName.c_str() );
61  while ( !fin.fail() )
62  {
63  StimulusPMJ_Activation junction;
64  fin >> junction.x;
65  fin >> junction.y;
66  fin >> junction.z;
67  fin >> junction.time;
68  fin >> junction.duration;
69  M_activationData.push_back ( junction );
70  }
71  fin.close();
72 }
73 
74 void StimulusPMJ::setPMJAddJunction ( Real x, Real y, Real z, Real time, Real duration )
75 {
76  StimulusPMJ_Activation junction;
77  junction.x = x;
78  junction.y = y;
79  junction.z = z;
80  junction.time = time;
81  junction.duration = duration;
82  M_activationData.push_back ( junction );
83 }
84 
85 // ===================================================
86 //! Methods
87 // ===================================================
88 Real StimulusPMJ::appliedCurrent ( const Real& t, const Real& x, const Real& y, const Real& z, const ID& /*i*/ )
89 {
90  Real current = 0;
91  const Real volumeOfBall = (4. / 3.) * M_PI * M_radius * M_radius * M_radius;
92 
93  for (activationData_type::iterator it = M_activationData.begin(); it != M_activationData.end(); ++it)
94  {
95  Real distance = std::sqrt ( (x - it->x) * (x - it->x) + (y - it->y) * (y - it->y) + (z - it->z) * (z - it->z) );
96 
97 
98  if (distance <= M_radius && t >= (it->time) && t <= (it->time + it->duration) )
99  {
100  current += M_totalCurrent / volumeOfBall;
101  }
102  }
103 
104  return current;
105 }
106 
108 {
109  std::cout << "\n\n\t\tPMJ activation Informations\n\n";
110 
111  std::cout << "\n\t\tList of parameters:\n\n";
112 
113  std::cout << "Radius current application: " << M_radius << std::endl;
114  std::cout << "Total current: " << M_totalCurrent << std::endl;
115  std::cout << "Problem folder: " << M_problemFolder << std::endl;
116  std::cout << "\n\t\t End of PMJ activation Informations\n\n\n";
117 }
118 
119 }
void setPMJAddJunction(Real x, Real y, Real z, Real time, Real duration)
Definition: StimulusPMJ.cpp:74
void setPMJFromFile(std::string fileName)
Setters.
Definition: StimulusPMJ.cpp:56
Real appliedCurrent(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Methods.
Definition: StimulusPMJ.cpp:88
#define M_PI
Definition: winmath.h:20
void updateInverseJacobian(const UInt &iQuadPt)
uint32_type ID
IDs.
Definition: LifeV.hpp:194
std::vector< StimulusPMJ_Activation > activationData_type
Definition: StimulusPMJ.hpp:63
StimulusPMJ()
Empty Constructor.
Definition: StimulusPMJ.cpp:45
double Real
Generic real data.
Definition: LifeV.hpp:175
activationData_type M_activationData