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>
45 #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,
62 
63  /// Cell model base class.
64  class CellModel
65  {
66  public:
68  const MultiRegions::ExpListSharedPtr& pField);
69 
70  virtual ~CellModel() {}
71 
72  /// Initialise the cell model storage and set initial conditions
73  void Initialise();
74 
75  /// Time integrate the cell model by one PDE timestep
76  void TimeIntegrate(
77  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
78  Array<OneD, Array<OneD, NekDouble> > &outarray,
79  const NekDouble time);
80 
81  /// Compute the derivatives of cell model variables
82  void Update(
83  const Array<OneD, const Array<OneD, NekDouble> >&inarray,
84  Array<OneD, Array<OneD, NekDouble> >&outarray,
85  const NekDouble time)
86  {
87  v_Update(inarray, outarray, time);
88  }
89 
90  /// Print a summary of the cell model
92  {
94  }
95 
96  unsigned int GetNumCellVariables()
97  {
98  return m_nvar;
99  }
100 
101  std::string GetCellVarName(unsigned int idx)
102  {
103  return v_GetCellVarName(idx);
104  }
105 
107 
108  Array<OneD, NekDouble> GetCellSolution(unsigned int idx);
109 
110  protected:
111  /// Session
113  /// Transmembrane potential field from PDE system
115  /// Number of physical points.
116  int m_nq;
117  /// Number of variables in cell model (inc. transmembrane voltage)
118  int m_nvar;
119  /// Timestep for pde model
121  /// Number of substeps to take
123 
124  /// Cell model solution variables
126  /// Cell model integration workspace
128 
129  /// Flag indicating whether nodal projection in use
131  /// StdNodalTri for cell model calculations
134  /// Temporary array for nodal projection
136 
137  /// Indices of cell model variables which are concentrations
138  std::vector<int> m_concentrations;
139  /// Indices of cell model variables which are gates
140  std::vector<int> m_gates;
141  /// Storage for gate tau values
143 
144  virtual void v_Update(
145  const Array<OneD, const Array<OneD, NekDouble> >&inarray,
146  Array<OneD, Array<OneD, NekDouble> >&outarray,
147  const NekDouble time) = 0;
148 
149  virtual void v_GenerateSummary(SummaryList& s) = 0;
150 
151  virtual std::string v_GetCellVarName(unsigned int idx)
152  {
153  return "Var" + boost::lexical_cast<std::string>(idx);
154  }
155 
156  virtual void v_SetInitialConditions() = 0;
157 
158  void LoadCellModel();
159  };
160 
161 }
162 
163 #endif /* CELLMODEL_H_ */
Cell model base class.
Definition: CellModel.h:65
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Definition: CellModel.h:125
int m_nq
Number of physical points.
Definition: CellModel.h:116
void Initialise()
Initialise the cell model storage and set initial conditions.
Definition: CellModel.cpp:125
unsigned int GetNumCellVariables()
Definition: CellModel.h:96
virtual std::string v_GetCellVarName(unsigned int idx)
Definition: CellModel.h:151
int m_substeps
Number of substeps to take.
Definition: CellModel.h:122
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:82
Array< OneD, Array< OneD, NekDouble > > m_wsp
Cell model integration workspace.
Definition: CellModel.h:127
std::string GetCellVarName(unsigned int idx)
Definition: CellModel.h:101
bool m_useNodal
Flag indicating whether nodal projection in use.
Definition: CellModel.h:130
NekDouble m_lastTime
Timestep for pde model.
Definition: CellModel.h:120
virtual ~CellModel()
Definition: CellModel.h:70
StdRegions::StdNodalTetExpSharedPtr m_nodalTet
Definition: CellModel.h:133
Array< OneD, Array< OneD, NekDouble > > m_nodalTmp
Temporary array for nodal projection.
Definition: CellModel.h:135
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
Definition: CellModel.h:114
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:138
virtual void v_GenerateSummary(SummaryList &s)=0
void GenerateSummary(SummaryList &s)
Print a summary of the cell model.
Definition: CellModel.h:91
std::vector< int > m_gates
Indices of cell model variables which are gates.
Definition: CellModel.h:140
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)=0
Array< OneD, NekDouble > GetCellSolution(unsigned int idx)
Definition: CellModel.cpp:319
virtual void v_SetInitialConditions()=0
StdRegions::StdNodalTriExpSharedPtr m_nodalTri
StdNodalTri for cell model calculations.
Definition: CellModel.h:132
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: CellModel.h:112
CellModel(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: CellModel.cpp:66
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:160
Array< OneD, NekDouble > GetCellSolutionCoeffs(unsigned int idx)
Definition: CellModel.cpp:289
Array< OneD, Array< OneD, NekDouble > > m_gates_tau
Storage for gate tau values.
Definition: CellModel.h:142
int m_nvar
Number of variables in cell model (inc. transmembrane voltage)
Definition: CellModel.h:118
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:46
std::shared_ptr< StdNodalTetExp > StdNodalTetExpSharedPtr
std::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:46
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: CellModel.h:50
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:60
std::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:55
double NekDouble