Nektar++
Functions
Prepacing.cpp File Reference
#include <SpatialDomains/MeshComponents.h>
#include <MultiRegions/ExpList.h>
#include <CardiacEPSolver/CellModels/CellModel.h>
#include <CardiacEPSolver/Stimuli/Stimulus.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 9 of file Prepacing.cpp.

10 {
14  std::string vCellModel;
15  CellModelSharedPtr vCell;
16  std::vector<StimulusSharedPtr> vStimulus;
19  NekDouble vDeltaT;
20  NekDouble vTime;
21  unsigned int nSteps;
22 
23  // Create a session reader to read pacing parameters
24  vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
25  vSession->InitSession();
26 
27  try
28  {
29  // Construct a field consisting of a single vertex
31  ::AllocateSharedPtr(3, 0, 0.0, 0.0, 0.0);
33  ::AllocateSharedPtr(vPoint);
34 
35  // Get cell model name and create it
36  vSession->LoadSolverInfo("CELLMODEL", vCellModel, "");
37  ASSERTL0(vCellModel != "", "Cell Model not specified.");
38 
40  vCellModel, vSession, vExp);
41  vCell->Initialise();
42 
43  // Load the stimuli
44  vStimulus = Stimulus::LoadStimuli(vSession, vExp);
45 
46  // Set up solution arrays, workspace and read in parameters
47  vSol[0] = Array<OneD, NekDouble>(1, 0.0);
48  vWsp[0] = Array<OneD, NekDouble>(1, 0.0);
49  vDeltaT = vSession->GetParameter("TimeStep");
50  vTime = 0.0;
51  nSteps = vSession->GetParameter("NumSteps");
52 
54  vSession->GetFunction("InitialConditions", "u");
55  vSol[0][0] = e->Evaluate(0.0, 0.0, 0.0, 0.0);
56 
57  cout << "#";
58  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
59  {
60  cout << " " << vCell->GetCellVarName(i);
61  }
62  cout << endl;
63 
64  // Time integrate cell model
65  for (unsigned int i = 0; i < nSteps; ++i)
66  {
67  // Compute J_ion
68  vCell->TimeIntegrate(vSol, vWsp, vTime);
69 
70  // Add stimuli J_stim
71  for (unsigned int i = 0; i < vStimulus.size(); ++i)
72  {
73  vStimulus[i]->Update(vWsp, vTime);
74  }
75 
76  // Time-step with forward Euler
77  Vmath::Svtvp(1, vDeltaT, vWsp[0], 1, vSol[0], 1, vSol[0], 1);
78 
79  // Increment time
80  vTime += vDeltaT;
81 
82  // Output current solution to stdout
83  cout << vTime << " " << vSol[0][0];
84  for (unsigned int j = 0; j < vCell->GetNumCellVariables(); ++j)
85  {
86  cout << " " << vCell->GetCellSolution(j)[0];
87  }
88  cout << endl;
89  }
90 
91  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
92  {
93  cout << "# " << vCell->GetCellVarName(i) << " "
94  << vCell->GetCellSolution(i)[0] << endl;
95  }
96  }
97  catch (...)
98  {
99  cerr << "An error occured" << endl;
100  }
101 
102  return 0;
103 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:145
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:131
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
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.cpp:565

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