Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
Prepacing.cpp File Reference
#include <SpatialDomains/MeshComponents.h>
#include <MultiRegions/ExpList0D.h>
#include <CardiacEPSolver/CellModels/CellModel.h>
#include <CardiacEPSolver/Stimuli/Stimulus.h>
Include dependency graph for Prepacing.cpp:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 9 of file Prepacing.cpp.

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

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 
26  try
27  {
28  // Construct a field consisting of a single vertex
30  ::AllocateSharedPtr(3, 0, 0.0, 0.0, 0.0);
32  ::AllocateSharedPtr(vPoint);
33 
34  // Get cell model name and create it
35  vSession->LoadSolverInfo("CELLMODEL", vCellModel, "");
36  ASSERTL0(vCellModel != "", "Cell Model not specified.");
37 
39  vCellModel, vSession, vExp);
40  vCell->Initialise();
41 
42  // Load the stimuli
43  vStimulus = Stimulus::LoadStimuli(vSession, vExp);
44 
45  // Set up solution arrays, workspace and read in parameters
46  vSol[0] = Array<OneD, NekDouble>(1, 0.0);
47  vWsp[0] = Array<OneD, NekDouble>(1, 0.0);
48  vDeltaT = vSession->GetParameter("TimeStep");
49  vTime = 0.0;
50  nSteps = vSession->GetParameter("NumSteps");
51 
53  vSession->GetFunction("InitialConditions", "u");
54  vSol[0][0] = e->Evaluate(0.0, 0.0, 0.0, 0.0);
55 
56  cout << "#";
57  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
58  {
59  cout << " " << vCell->GetCellVarName(i);
60  }
61  cout << endl;
62 
63  // Time integrate cell model
64  for (unsigned int i = 0; i < nSteps; ++i)
65  {
66  // Compute J_ion
67  vCell->TimeIntegrate(vSol, vWsp, vTime);
68 
69  // Add stimuli J_stim
70  for (unsigned int i = 0; i < vStimulus.size(); ++i)
71  {
72  vStimulus[i]->Update(vWsp, vTime);
73  }
74 
75  // Time-step with forward Euler
76  Vmath::Svtvp(1, vDeltaT, vWsp[0], 1, vSol[0], 1, vSol[0], 1);
77 
78  // Increment time
79  vTime += vDeltaT;
80 
81  // Output current solution to stdout
82  cout << vTime << " " << vSol[0][0];
83  for (unsigned int j = 0; j < vCell->GetNumCellVariables(); ++j)
84  {
85  cout << " " << vCell->GetCellSolution(j)[0];
86  }
87  cout << endl;
88  }
89 
90  for (unsigned int i = 0; i < vCell->GetNumCellVariables(); ++i)
91  {
92  cout << "# " << vCell->GetCellVarName(i) << " "
93  << vCell->GetCellSolution(i)[0] << endl;
94  }
95  }
96  catch (...)
97  {
98  cerr << "An error occured" << endl;
99  }
100 
101  return 0;
102 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
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
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
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:51
boost::shared_ptr< CellModel > CellModelSharedPtr
A shared pointer to an EquationSystem object.
Definition: CellModel.h:56
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
double NekDouble
boost::shared_ptr< Equation > EquationSharedPtr
CellModelFactory & GetCellModelFactory()
Definition: CellModel.cpp:47
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60