Nektar++
CellModel.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CellModel.h
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Cell model base class.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL
36 #define NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL
37 
41 //#include <SpatialDomains/SpatialData.h>
42 #include <MultiRegions/ExpList.h>
43 #include <SolverUtils/Core/Misc.h>
46 
47 namespace Nektar
48 {
49 // Forward declaration
50 class CellModel;
51 
52 typedef std::vector<std::pair<std::string, std::string>> SummaryList;
53 
54 /// A shared pointer to an EquationSystem object
55 typedef std::shared_ptr<CellModel> CellModelSharedPtr;
56 /// Datatype of the NekFactory used to instantiate classes derived from
57 /// the EquationSystem class.
58 typedef LibUtilities::NekFactory<std::string, CellModel,
63 
64 /// Cell model base class.
65 class CellModel
66 {
67 public:
69  const MultiRegions::ExpListSharedPtr &pField);
70 
71  virtual ~CellModel()
72  {
73  }
74 
75  /// Initialise the cell model storage and set initial conditions
76  void Initialise();
77 
78  /// Time integrate the cell model by one PDE timestep
79  void TimeIntegrate(const Array<OneD, const Array<OneD, NekDouble>> &inarray,
80  Array<OneD, Array<OneD, NekDouble>> &outarray,
81  const NekDouble time);
82 
83  /// Compute the derivatives of cell model variables
84  void Update(const Array<OneD, const Array<OneD, NekDouble>> &inarray,
85  Array<OneD, Array<OneD, NekDouble>> &outarray,
86  const NekDouble time)
87  {
88  v_Update(inarray, outarray, time);
89  }
90 
91  /// Print a summary of the cell model
93  {
95  }
96 
98  {
99  return m_nvar;
100  }
101 
102  std::string GetCellVarName(size_t idx)
103  {
104  return v_GetCellVarName(idx);
105  }
106 
108 
110 
111 protected:
112  /// Session
114  /// Transmembrane potential field from PDE system
116  /// Number of physical points.
117  size_t m_nq;
118  /// Number of variables in cell model (inc. transmembrane voltage)
119  size_t m_nvar;
120  /// Timestep for pde model
122  /// Number of substeps to take
123  size_t m_substeps;
124 
125  /// Cell model solution variables
127  /// Cell model integration workspace
129 
130  /// Flag indicating whether nodal projection in use
132  /// StdNodalTri for cell model calculations
135  /// Temporary array for nodal projection
137 
138  /// Indices of cell model variables which are concentrations
139  std::vector<int> m_concentrations;
140  /// Indices of cell model variables which are gates
141  std::vector<int> m_gates;
142  /// Storage for gate tau values
144 
145  virtual void v_Update(
146  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
147  Array<OneD, Array<OneD, NekDouble>> &outarray,
148  const NekDouble time) = 0;
149 
150  virtual void v_GenerateSummary(SummaryList &s) = 0;
151 
152  virtual std::string v_GetCellVarName(size_t idx)
153  {
154  return "Var" + boost::lexical_cast<std::string>(idx);
155  }
156 
157  virtual void v_SetInitialConditions() = 0;
158 
159  void LoadCellModel();
160 };
161 
162 } // namespace Nektar
163 
164 #endif /* CELLMODEL_H_ */
Cell model base class.
Definition: CellModel.h:66
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Definition: CellModel.h:126
void TimeIntegrate(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Time integrate the cell model by one PDE timestep.
Definition: CellModel.cpp:164
void Initialise()
Initialise the cell model storage and set initial conditions.
Definition: CellModel.cpp:129
Array< OneD, Array< OneD, NekDouble > > m_wsp
Cell model integration workspace.
Definition: CellModel.h:128
bool m_useNodal
Flag indicating whether nodal projection in use.
Definition: CellModel.h:131
Array< OneD, NekDouble > GetCellSolutionCoeffs(size_t idx)
Definition: CellModel.cpp:310
NekDouble m_lastTime
Timestep for pde model.
Definition: CellModel.h:121
virtual ~CellModel()
Definition: CellModel.h:71
void Update(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the derivatives of cell model variables.
Definition: CellModel.h:84
size_t m_substeps
Number of substeps to take.
Definition: CellModel.h:123
virtual std::string v_GetCellVarName(size_t idx)
Definition: CellModel.h:152
StdRegions::StdNodalTetExpSharedPtr m_nodalTet
Definition: CellModel.h:134
Array< OneD, Array< OneD, NekDouble > > m_nodalTmp
Temporary array for nodal projection.
Definition: CellModel.h:136
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
Definition: CellModel.h:115
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:139
virtual void v_GenerateSummary(SummaryList &s)=0
void GenerateSummary(SummaryList &s)
Print a summary of the cell model.
Definition: CellModel.h:92
std::vector< int > m_gates
Indices of cell model variables which are gates.
Definition: CellModel.h:141
Array< OneD, NekDouble > GetCellSolution(size_t idx)
Definition: CellModel.cpp:342
virtual void v_SetInitialConditions()=0
StdRegions::StdNodalTriExpSharedPtr m_nodalTri
StdNodalTri for cell model calculations.
Definition: CellModel.h:133
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)=0
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: CellModel.h:113
size_t m_nq
Number of physical points.
Definition: CellModel.h:117
size_t m_nvar
Number of variables in cell model (inc. transmembrane voltage)
Definition: CellModel.h:119
CellModel(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: CellModel.cpp:66
Array< OneD, Array< OneD, NekDouble > > m_gates_tau
Storage for gate tau values.
Definition: CellModel.h:143
size_t GetNumCellVariables()
Definition: CellModel.h:97
std::string GetCellVarName(size_t idx)
Definition: CellModel.h:102
Provides a generic Factory class.
Definition: NekFactory.hpp:105
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:48
std::shared_ptr< StdNodalTetExp > StdNodalTetExpSharedPtr
std::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:46
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: CellModel.h:50
std::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:55
LibUtilities::NekFactory< std::string, CellModel, const LibUtilities::SessionReaderSharedPtr &, const MultiRegions::ExpListSharedPtr & > CellModelFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
Definition: CellModel.h:61
double NekDouble