Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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,
63 
64  /// Cell model base class.
65  class CellModel
66  {
67  public:
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
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 
107  Array<OneD, NekDouble> GetCellSolutionCoeffs(unsigned int idx);
108 
109  Array<OneD, NekDouble> GetCellSolution(unsigned int idx);
110 
111  protected:
112  /// 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
126  Array<OneD, Array<OneD, NekDouble> > m_cellSol;
127  /// Cell model integration workspace
128  Array<OneD, Array<OneD, NekDouble> > m_wsp;
129 
130  /// Flag indicating whether nodal projection in use
132  /// StdNodalTri for cell model calculations
135  /// Temporary array for nodal projection
136  Array<OneD, Array<OneD, NekDouble> > m_nodalTmp;
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
143  Array<OneD, Array<OneD, NekDouble> > m_gates_tau;
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_ */