Nektar++
Functions
Prepacing.cpp File Reference
#include <CardiacEPSolver/CellModels/CellModel.h>
#include <CardiacEPSolver/Stimuli/Stimulus.h>
#include <MultiRegions/ExpList.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 42 of file Prepacing.cpp.

43{
47 std::string vCellModel;
49 std::vector<StimulusSharedPtr> vStimulus;
52 NekDouble vDeltaT;
53 NekDouble vTime;
54 unsigned int nSteps;
55
56 // Create a session reader to read pacing parameters
57 vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
58 vSession->InitSession();
59
60 try
61 {
62 // Construct a field consisting of a single vertex
64 3, 0, 0.0, 0.0, 0.0);
66
67 // Get cell model name and create it
68 vSession->LoadSolverInfo("CELLMODEL", vCellModel, "");
69 ASSERTL0(vCellModel != "", "Cell Model not specified.");
70
71 vCell =
72 GetCellModelFactory().CreateInstance(vCellModel, vSession, vExp);
73 vCell->Initialise();
74
75 // Load the stimuli
76 vStimulus = Stimulus::LoadStimuli(vSession, vExp);
77
78 // Set up solution arrays, workspace and read in parameters
79 vSol[0] = Array<OneD, NekDouble>(1, 0.0);
80 vWsp[0] = Array<OneD, NekDouble>(1, 0.0);
81 vDeltaT = vSession->GetParameter("TimeStep");
82 vTime = 0.0;
83 nSteps = vSession->GetParameter("NumSteps");
84
86 vSession->GetFunction("InitialConditions", "u");
87 vSol[0][0] = e->Evaluate(0.0, 0.0, 0.0, 0.0);
88
89 cout << "#";
90 for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
91 {
92 cout << " " << vCell->GetCellVarName(i);
93 }
94 cout << endl;
95
96 // Time integrate cell model
97 for (unsigned int i = 0; i < nSteps; ++i)
98 {
99 // Compute J_ion
100 vCell->TimeIntegrate(vSol, vWsp, vTime);
101
102 // Add stimuli J_stim
103 for (unsigned int i = 0; i < vStimulus.size(); ++i)
104 {
105 vStimulus[i]->Update(vWsp, vTime);
106 }
107
108 // Time-step with forward Euler
109 Vmath::Svtvp(1, vDeltaT, vWsp[0], 1, vSol[0], 1, vSol[0], 1);
110
111 // Increment time
112 vTime += vDeltaT;
113
114 // Output current solution to stdout
115 cout << vTime << " " << vSol[0][0];
116 for (unsigned int j = 0; j < vCell->GetNumCellVariables(); ++j)
117 {
118 cout << " " << vCell->GetCellSolution(j)[0];
119 }
120 cout << endl;
121 }
122
123 for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
124 {
125 cout << "# " << vCell->GetCellVarName(i) << " "
126 << vCell->GetCellSolution(i)[0] << endl;
127 }
128 }
129 catch (...)
130 {
131 cerr << "An error occured" << endl;
132 }
133
134 return 0;
135}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:125
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:57
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:46
std::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:55
double NekDouble
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
Definition: Vmath.hpp:396

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::GetCellModelFactory(), and Vmath::Svtvp().