49 Loki::NoDestroy > Type;
50 return Type::Instance();
73 m_substeps = pSession->GetParameter(
"Substeps");
79 std::set<enum LibUtilities::ShapeType> s;
80 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
82 s.insert(
m_field->GetExp(i)->DetShapeType());
97 m_nq = pField->GetNcoeffs();
98 int order =
m_field->GetExp(0)->GetBasis(0)->GetNumModes();
118 m_nq = pField->GetTotPoints();
128 ASSERTL1(
m_nvar > 0,
"Cell model must have at least 1 variable.");
132 for (
unsigned int i = 0; i <
m_nvar; ++i)
138 for (
unsigned int i = 0; i <
m_gates.size(); ++i)
143 if (
m_session->DefinesFunction(
"CellModelInitialConditions"))
168 int nvar = inarray.num_elements();
178 for (
unsigned int k = 0; k < nvar; ++k)
187 for (
unsigned int k = 0; k < nvar; ++k)
189 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
191 phys_offset =
m_field->GetPhys_Offset(i);
192 coef_offset =
m_field->GetCoeff_Offset(i);
195 m_field->GetExp(0)->FwdTrans(inarray[k] + phys_offset, tmpCoeffs);
200 m_field->GetExp(0)->FwdTrans(inarray[k] + phys_offset, tmpCoeffs);
219 for (
unsigned int i = 0; i <
m_substeps - 1; ++i)
230 for (
unsigned int j = 0; j <
m_gates.size(); ++j)
248 for (
unsigned int k = 0; k < nvar; ++k)
250 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
252 int phys_offset =
m_field->GetPhys_Offset(i);
253 int coef_offset =
m_field->GetCoeff_Offset(i);
257 m_field->GetExp(0)->BwdTrans(tmpCoeffs, tmp=outarray[k] + phys_offset);
262 m_field->GetExp(0)->BwdTrans(tmpCoeffs, tmp=outarray[k] + phys_offset);
279 for (
unsigned int j = 0; j <
m_gates.size(); ++j)
299 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
301 int coef_offset =
m_field->GetCoeff_Offset(i);
327 const bool root = (
m_session->GetComm()->GetRank() == 0);
328 const std::string fncName =
"CellModelInitialConditions";
329 const int nvar =
m_cellSol[0].num_elements();
339 cout <<
"Cell model initial conditions: " << endl;
343 std::set<std::string> filelist;
344 for (j = 1; j < nvar; ++j)
349 if (
m_session->GetFunctionType(fncName, varName) ==
352 filelist.insert(
m_session->GetFunctionFilename(fncName,
358 typedef std::vector<LibUtilities::FieldDefinitionsSharedPtr> FDef;
359 typedef std::vector<std::vector<NekDouble> > FData;
360 std::map<std::string, FDef> FieldDef;
361 std::map<std::string, FData> FieldData;
364 std::set<std::string>::const_iterator setIt;
368 for (setIt = filelist.begin(); setIt != filelist.end(); ++setIt)
372 cout <<
" - Reading file: " << *setIt << endl;
374 FieldDef[*setIt] = FDef(0);
375 FieldData[*setIt] = FData(0);
376 fld->Import(*setIt, FieldDef[*setIt], FieldData[*setIt],
381 iter = fieldMetaDataMap.find(
"Time");
382 if(iter != fieldMetaDataMap.end())
390 for(j = 1; j <
m_cellSol.num_elements(); ++j)
396 if (
m_session->GetFunctionType(fncName, varName) ==
399 const std::string file =
400 m_session->GetFunctionFilename(fncName, varName);
404 cout <<
" - Field " << varName <<
": from file "
409 for(
int i = 0; i < FieldDef[file].size(); ++i)
411 m_field->ExtractDataToCoeffs(FieldDef[file][i],
421 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
423 int coef_offset =
m_field->GetCoeff_Offset(i);
424 if (
m_field->GetExp(0)->DetShapeType() ==
442 else if (
m_session->GetFunctionType(fncName, varName) ==
446 m_session->GetFunction(fncName, varName);
450 cout <<
" - Field " << varName <<
": "
451 << equ->GetExpression() << endl;
454 const unsigned int nphys =
m_field->GetNpoints();
465 equ->Evaluate(x0, x1, x2, phys);
466 for (
unsigned int i = 0; i <
m_field->GetNumElmts(); ++i)
468 int phys_offset =
m_field->GetPhys_Offset(i);
469 int coef_offset =
m_field->GetCoeff_Offset(i);
470 if (
m_field->GetExp(0)->DetShapeType() ==
474 phys + phys_offset, tmpCoeffs);
482 phys + phys_offset, tmpCoeffs);
LibUtilities::NekFactory< std::string, CellModel, const LibUtilities::SessionReaderSharedPtr &, const MultiRegions::ExpListSharedPtr & > CellModelFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
void TimeIntegrate(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Time integrate the cell model by one PDE timestep.
#define ASSERTL0(condition, msg)
Principle Modified Functions .
int m_nq
Number of physical points.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::string GetCellVarName(unsigned int idx)
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
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Principle Modified Functions .
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
StdRegions::StdNodalTriExpSharedPtr m_nodalTri
StdNodalTri for cell model calculations.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
std::map< std::string, std::string > FieldMetaDataMap
StdRegions::StdNodalTetExpSharedPtr m_nodalTet
Gauss Radau pinned at x=-1, .
Array< OneD, Array< OneD, NekDouble > > m_wsp
Cell model integration workspace.
NekDouble m_lastTime
Timestep for pde model.
CellModel(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
std::vector< int > m_concentrations
Indices of cell model variables which are concentrations.
virtual void v_SetInitialConditions()=0
Array< OneD, Array< OneD, NekDouble > > m_gates_tau
Storage for gate tau values.
Principle Modified Functions .
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Vexp(int n, const T *x, const int incx, T *y, const int incy)
Array< OneD, Array< OneD, NekDouble > > m_cellSol
Cell model solution variables.
Defines a specification for a set of points.
int m_nvar
Number of variables in cell model (inc. transmembrane voltage)
boost::shared_ptr< FieldIO > FieldIOSharedPtr
std::vector< int > m_gates
Indices of cell model variables which are gates.
void Initialise()
Initialise the cell model storage and set initial conditions.
3D Evenly-spaced points on a Tetrahedron
boost::shared_ptr< Equation > EquationSharedPtr
CellModelFactory & GetCellModelFactory()
Array< OneD, NekDouble > GetCellSolutionCoeffs(unsigned int idx)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Array< OneD, Array< OneD, NekDouble > > m_nodalTmp
Temporary array for nodal projection.
void Update(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the derivatives of cell model variables.
bool m_useNodal
Flag indicating whether nodal projection in use.
Gauss Radau pinned at x=-1, .
Array< OneD, NekDouble > GetCellSolution(unsigned int idx)
2D Evenly-spaced points on a Triangle
void Zero(int n, T *x, const int incx)
Zero vector.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Describes the specification for a Basis.
1D Gauss-Lobatto-Legendre quadrature points
int m_substeps
Number of substeps to take.
LibUtilities::SessionReaderSharedPtr m_session
Session.
Provides a generic Factory class.