CellModel.h 5.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
///////////////////////////////////////////////////////////////////////////////
//
// File CellModel.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Cell model base class.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL
#define NEKTAR_SOLVERS_ADRSOLVER_CELLMODELS_CELLMODEL

#include <LibUtilities/BasicUtils/NekFactory.hpp>
40
#include <LibUtilities/BasicUtils/SessionReader.h>
41
42
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <SpatialDomains/SpatialData.h>
43
#include <MultiRegions/ExpList.h>
44
45
#include <StdRegions/StdNodalTriExp.h>
#include <StdRegions/StdNodalTetExp.h>
46
47
48
49
50
51
52
53
54
55
56

namespace Nektar
{
    // Forward declaration
    class CellModel;

    /// A shared pointer to an EquationSystem object
    typedef boost::shared_ptr<CellModel> CellModelSharedPtr;
    /// Datatype of the NekFactory used to instantiate classes derived from
    /// the EquationSystem class.
    typedef LibUtilities::NekFactory< std::string, CellModel,
57
58
                const LibUtilities::SessionReaderSharedPtr&,
                const MultiRegions::ExpListSharedPtr&> CellModelFactory;
59
    CellModelFactory& GetCellModelFactory();
60
61
62
63
64

    /// Cell model base class.
    class CellModel
    {
    public:
65
66
67
        CellModel(const LibUtilities::SessionReaderSharedPtr& pSession,
                const MultiRegions::ExpListSharedPtr& pField);

68
69
        virtual ~CellModel() {}

70
71
72
73
74
75
76
77
78
79
        /// Initialise the cell model storage and set initial conditions
        void Initialise();

        /// Time integrate the cell model by one PDE timestep
        void TimeIntegrate(
                const Array<OneD, const Array<OneD, NekDouble> > &inarray,
                      Array<OneD,       Array<OneD, NekDouble> > &outarray,
                const NekDouble time);

        /// Compute the derivatives of cell model variables
80
        void Update(
81
82
                const Array<OneD, const  Array<OneD, NekDouble> >&inarray,
                      Array<OneD,        Array<OneD, NekDouble> >&outarray,
83
84
85
86
                const NekDouble time)
        {
            v_Update(inarray, outarray, time);
        }
87

88
        /// Print a summary of the cell model
89
90
91
92
        void PrintSummary(std::ostream &out)
        {
            v_PrintSummary(out);
        }
93
94

    protected:
95
96
97
98
        /// Session
        LibUtilities::SessionReaderSharedPtr m_session;
        /// Transmembrane potential field from PDE system
        MultiRegions::ExpListSharedPtr m_field;
99
100
        /// Number of physical points.
        int m_nq;
101
102
103
        /// Number of variables in cell model (inc. transmembrane voltage)
        int m_nvar;
        /// Timestep for pde model
104
        NekDouble m_lastTime;
105
106
        /// Number of substeps to take
        int m_substeps;
107
108
109
110
111
112

        /// Cell model solution variables
        Array<OneD, Array<OneD, NekDouble> > m_cellSol;
        /// Cell model integration workspace
        Array<OneD, Array<OneD, NekDouble> > m_wsp;

113
114
115
116
        /// Flag indicating whether nodal projection in use
        bool m_useNodal;
        /// StdNodalTri for cell model calculations
        StdRegions::StdNodalTriExpSharedPtr m_nodalTri;
117
        StdRegions::StdNodalTetExpSharedPtr m_nodalTet;
118
119
120
        /// Temporary array for nodal projection
        Array<OneD, Array<OneD, NekDouble> > m_nodalTmp;

121
122
123
124
125
126
        /// Indices of cell model variables which are concentrations
        std::vector<int> m_concentrations;
        /// Indices of cell model variables which are gates
        std::vector<int> m_gates;
        /// Storage for gate tau values
        Array<OneD, Array<OneD, NekDouble> > m_gates_tau;
127
128
129
130
131
132
133

        virtual void v_Update(
                const Array<OneD, const  Array<OneD, NekDouble> >&inarray,
                      Array<OneD,        Array<OneD, NekDouble> >&outarray,
                const NekDouble time) = 0;

        virtual void v_PrintSummary(std::ostream &out) = 0;
134
135

        virtual void v_SetInitialConditions() = 0;
136
137
138
139
140
    };

}

#endif /* CELLMODEL_H_ */