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 // 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: Cell model base class.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL
37 #define NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL
38 
42 //#include <SpatialDomains/SpatialData.h>
43 #include <MultiRegions/ExpList.h>
46 #include <SolverUtils/Core/Misc.h>
47 
48 namespace Nektar
49 {
50  // Forward declaration
51  class CellModel;
52 
53  typedef std::vector<std::pair<std::string, std::string> > SummaryList;
54 
55  /// A shared pointer to an EquationSystem object
56  typedef boost::shared_ptr<CellModel> CellModelSharedPtr;
57  /// Datatype of the NekFactory used to instantiate classes derived from
58  /// the EquationSystem class.
59  typedef LibUtilities::NekFactory< std::string, CellModel,
62  CellModelFactory& GetCellModelFactory();
63 
64  /// Cell model base class.
65  class CellModel
66  {
67  public:
68  CellModel(const LibUtilities::SessionReaderSharedPtr& pSession,
69  const MultiRegions::ExpListSharedPtr& pField);
70 
71  virtual ~CellModel() {}
72 
73  /// Initialise the cell model storage and set initial conditions
74  void Initialise();
75 
76  /// Time integrate the cell model by one PDE timestep
77  void TimeIntegrate(
78  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
79  Array<OneD, Array<OneD, NekDouble> > &outarray,
80  const NekDouble time);
81 
82  /// Compute the derivatives of cell model variables
83  void Update(
84  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
92  void GenerateSummary(SummaryList& s)
93  {
95  }
96 
97  unsigned int GetNumCellVariables()
98  {
99  return m_nvar;
100  }
101 
102  std::string GetCellVarName(unsigned int idx)
103  {
104  return v_GetCellVarName(idx);
105  }
106 
108 
109  Array<OneD, NekDouble> GetCellSolution(unsigned int idx);
110 
111  protected:
112  /// Session
113  LibUtilities::SessionReaderSharedPtr m_session;
114  /// Transmembrane potential field from PDE system
116  /// Number of physical points.
117  int m_nq;
118  /// Number of variables in cell model (inc. transmembrane voltage)
119  int m_nvar;
120  /// Timestep for pde model
122  /// Number of substeps to take
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(unsigned int 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 }
163 
164 #endif /* CELLMODEL_H_ */
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
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:161
int m_nq
Number of physical points.
Definition: CellModel.h:117
std::string GetCellVarName(unsigned int idx)
Definition: CellModel.h:102
virtual std::string v_GetCellVarName(unsigned int idx)
Definition: CellModel.h:152
Cell model base class.
Definition: CellModel.h:65
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: CellModel.h:51
StdRegions::StdNodalTriExpSharedPtr m_nodalTri
StdNodalTri for cell model calculations.
Definition: CellModel.h:133
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
Definition: CellModel.h:115
boost::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
boost::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:56
StdRegions::StdNodalTetExpSharedPtr m_nodalTet
Definition: CellModel.h:134
Array< OneD, Array< OneD, NekDouble > > m_wsp
Cell model integration workspace.
Definition: CellModel.h:128
void GenerateSummary(SummaryList &s)
Print a summary of the cell model.
Definition: CellModel.h:92
NekDouble m_lastTime
Timestep for pde model.
Definition: CellModel.h:121
unsigned int GetNumCellVariables()
Definition: CellModel.h:97
CellModel(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: CellModel.cpp:67
virtual void v_Update(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)=0
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
Definition: CellModel.h:139
virtual void v_SetInitialConditions()=0
Array< OneD, Array< OneD, NekDouble > > m_gates_tau
Storage for gate tau values.
Definition: CellModel.h:143
virtual ~CellModel()
Definition: CellModel.h:71
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Definition: ExpList.h:1340
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
std::vector< int > m_gates
Indices of cell model variables which are gates.
Definition: CellModel.h:141
double NekDouble
boost::shared_ptr< StdNodalTetExp > StdNodalTetExpSharedPtr
void Initialise()
Initialise the cell model storage and set initial conditions.
Definition: CellModel.cpp:126
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:45
Array< OneD, NekDouble > GetCellSolutionCoeffs(unsigned int idx)
Definition: CellModel.cpp:290
Array< OneD, Array< OneD, NekDouble > > m_nodalTmp
Temporary array for nodal projection.
Definition: CellModel.h:136
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:83
bool m_useNodal
Flag indicating whether nodal projection in use.
Definition: CellModel.h:131
virtual void v_GenerateSummary(SummaryList &s)=0
Array< OneD, NekDouble > GetCellSolution(unsigned int idx)
Definition: CellModel.cpp:320
int m_substeps
Number of substeps to take.
Definition: CellModel.h:123
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: CellModel.h:113
Provides a generic Factory class.
Definition: NekFactory.hpp:116