Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FitzhughNagumo.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File FitzhughNagumo.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: FitzhughNagumo phenomological cell model.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <iostream>
37 #include <string>
38 
41 
42 namespace Nektar
43 {
44  /**
45  * Registers the class with the Factory.
46  */
49  "FitzHughNagumo",
51  "Phenomological model of squid nerve cell.");
52 
55  const MultiRegions::ExpListSharedPtr& pField)
56  : CellModel(pSession, pField)
57  {
58  pSession->LoadParameter("beta", m_beta, 0.0);
59  pSession->LoadParameter("epsilon", m_epsilon, 1.0);
60 
62 
63  m_nvar = 2;
64  m_concentrations.push_back(1);
65  }
66 
67 
69  const Array<OneD, const Array<OneD, NekDouble> >&inarray,
70  Array<OneD, Array<OneD, NekDouble> >&outarray,
71  const NekDouble time)
72  {
73  NekDouble m_gamma = 0.5;
74 
75  // compute u^2: m_u = u*u
76  Vmath::Vmul(m_nq, &inarray[0][0], 1, &inarray[0][0], 1, &m_uuu[0], 1);
77 
78  // compute u^3: m_u = u*u*u
79  Vmath::Vmul(m_nq, &inarray[0][0], 1, &m_uuu[0], 1, &m_uuu[0], 1);
80 
81  // For u: (1/m_epsilon)*( u*-u*u*u/3 - v )
82  // physfield = u - (1.0/3.0)*u*u*u
83  Vmath::Svtvp(m_nq, (-1.0/3.0), &m_uuu[0], 1, &inarray[0][0], 1, &outarray[0][0], 1);
84 
85  Vmath::Vsub(m_nq, &inarray[1][0], 1, &outarray[0][0], 1, &outarray[0][0], 1);
86  Vmath::Smul(m_nq, -1.0/m_epsilon, &outarray[0][0], 1, &outarray[0][0], 1);
87 
88  // For v: m_epsilon*( u + m_beta - m_gamma*v )
89  Vmath::Svtvp(m_nq, -1.0*m_gamma, &inarray[1][0], 1, &inarray[0][0], 1, &outarray[1][0], 1);
90  Vmath::Sadd(m_nq, m_beta, &outarray[1][0], 1, &outarray[1][0], 1);
91  Vmath::Smul(m_nq, m_epsilon, &outarray[1][0], 1, &outarray[1][0], 1);
92  }
93 
94  /**
95  *
96  */
98  {
99  SolverUtils::AddSummaryItem(s, "Cell model","FitzHugh-Nagumo");
100  SolverUtils::AddSummaryItem(s, "Cell model beta", m_beta);
101  }
102 
103 
104  /**
105  *
106  */
108  {
109  Vmath::Fill(m_nq, 0.0, m_cellSol[0], 1);
110  Vmath::Fill(m_nq, 0.0, m_cellSol[1], 1);
111  }
112 
113 }
Array< OneD, NekDouble > m_uuu
Temporary space for storing when computing reaction term.
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
int m_nq
Number of physical points.
Definition: CellModel.h:117
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:471
Cell model base class.
Definition: CellModel.h:65
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: CellModel.h:51
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
static CellModelSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Creates an instance of this class.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:139
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:50
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Definition: CellModel.h:126
int m_nvar
Number of variables in cell model (inc. transmembrane voltage)
Definition: CellModel.h:119
double NekDouble
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.cpp:301
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:45
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:329
static std::string className
Name of class.
virtual void v_GenerateSummary(SummaryList &s)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:169
CellModelFitzHughNagumo(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215