Nektar++
Prepacing.cpp
Go to the documentation of this file.
5 
6 using namespace Nektar;
7 
8 int main(int argc, char *argv[])
9 {
13  std::string vCellModel;
14  CellModelSharedPtr vCell;
15  std::vector<StimulusSharedPtr> vStimulus;
18  NekDouble vDeltaT;
19  NekDouble vTime;
20  unsigned int nSteps;
21 
22  // Create a session reader to read pacing parameters
23  vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
24 
25  try
26  {
27  // Construct a field consisting of a single vertex
29  ::AllocateSharedPtr(3, 0, 0.0, 0.0, 0.0);
31  ::AllocateSharedPtr(vPoint);
32 
33  // Get cell model name and create it
34  vSession->LoadSolverInfo("CELLMODEL", vCellModel, "");
35  ASSERTL0(vCellModel != "", "Cell Model not specified.");
36 
38  vCellModel, vSession, vExp);
39  vCell->Initialise();
40 
41  // Load the stimuli
42  vStimulus = Stimulus::LoadStimuli(vSession, vExp);
43 
44  // Set up solution arrays, workspace and read in parameters
45  vSol[0] = Array<OneD, NekDouble>(1, 0.0);
46  vWsp[0] = Array<OneD, NekDouble>(1, 0.0);
47  vDeltaT = vSession->GetParameter("TimeStep");
48  vTime = 0.0;
49  nSteps = vSession->GetParameter("NumSteps");
50 
52  vSession->GetFunction("InitialConditions", "u");
53  vSol[0][0] = e->Evaluate(0.0, 0.0, 0.0, 0.0);
54 
55  cout << "#";
56  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
57  {
58  cout << " " << vCell->GetCellVarName(i);
59  }
60  cout << endl;
61 
62  // Time integrate cell model
63  for (unsigned int i = 0; i < nSteps; ++i)
64  {
65  // Compute J_ion
66  vCell->TimeIntegrate(vSol, vWsp, vTime);
67 
68  // Add stimuli J_stim
69  for (unsigned int i = 0; i < vStimulus.size(); ++i)
70  {
71  vStimulus[i]->Update(vWsp, vTime);
72  }
73 
74  // Time-step with forward Euler
75  Vmath::Svtvp(1, vDeltaT, vWsp[0], 1, vSol[0], 1, vSol[0], 1);
76 
77  // Increment time
78  vTime += vDeltaT;
79 
80  // Output current solution to stdout
81  cout << vTime << " " << vSol[0][0];
82  for (unsigned int j = 0; j < vCell->GetNumCellVariables(); ++j)
83  {
84  cout << " " << vCell->GetCellSolution(j)[0];
85  }
86  cout << endl;
87  }
88 
89  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
90  {
91  cout << "# " << vCell->GetCellVarName(i) << " "
92  << vCell->GetCellSolution(i)[0] << endl;
93  }
94  }
95  catch (...)
96  {
97  cerr << "An error occured" << endl;
98  }
99 
100  return 0;
101 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
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.cpp:471
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
boost::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:56
static std::vector< StimulusSharedPtr > LoadStimuli(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: Stimulus.cpp:93
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
int main(int argc, char *argv[])
Definition: Prepacing.cpp:8
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Definition: ExpList.h:1340
double NekDouble
boost::shared_ptr< Equation > EquationSharedPtr
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:45
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60