72 m_substeps = pSession->GetParameter(
"Substeps");
78 std::set<enum LibUtilities::ShapeType> s;
79 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
81 s.insert(m_field->GetExp(i)->DetShapeType());
96 m_nq = pField->GetNcoeffs();
97 int order = m_field->GetExp(0)->GetBasis(0)->GetNumModes();
107 LibUtilities::eGaussRadauMAlpha1Beta0));
111 LibUtilities::eGaussRadauMAlpha2Beta0));
122 m_nq = pField->GetTotPoints();
129 void CellModel::Initialise()
131 ASSERTL1(m_nvar > 0,
"Cell model must have at least 1 variable.");
135 for (
size_t i = 0; i < m_nvar; ++i)
141 for (
size_t i = 0; i < m_gates.size(); ++i)
146 if (m_session->DefinesFunction(
"CellModelInitialConditions"))
152 v_SetInitialConditions();
164 void CellModel::TimeIntegrate(
170 size_t nvar = inarray.size();
177 if (!m_nodalTmp.size())
180 for (
size_t k = 0; k < nvar; ++k)
188 max(m_nodalTri->GetNcoeffs(), m_nodalTet->GetNcoeffs()));
190 for (
size_t k = 0; k < nvar; ++k)
192 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
194 phys_offset = m_field->GetPhys_Offset(i);
195 coef_offset = m_field->GetCoeff_Offset(i);
196 if (m_field->GetExp(0)->DetShapeType() ==
199 m_field->GetExp(0)->FwdTrans(inarray[k] + phys_offset,
201 m_nodalTri->ModalToNodal(tmpCoeffs,
202 tmp = m_nodalTmp[k] + coef_offset);
206 m_field->GetExp(0)->FwdTrans(inarray[k] + phys_offset,
208 m_nodalTet->ModalToNodal(tmpCoeffs,
209 tmp = m_nodalTmp[k] + coef_offset);
223 NekDouble delta_t = (time - m_lastTime) / m_substeps;
226 for (
size_t i = 0; i < m_substeps - 1; ++i)
228 Update(m_cellSol, m_wsp, time);
230 Vmath::Svtvp(m_nq, delta_t, m_wsp[0], 1, m_cellSol[0], 1, m_cellSol[0],
233 for (
size_t j = 0; j < m_concentrations.size(); ++j)
235 Vmath::Svtvp(m_nq, delta_t, m_wsp[m_concentrations[j]], 1,
236 m_cellSol[m_concentrations[j]], 1,
237 m_cellSol[m_concentrations[j]], 1);
240 for (
size_t j = 0; j < m_gates.size(); ++j)
242 Vmath::Sdiv(m_nq, -delta_t, m_gates_tau[j], 1, m_gates_tau[j], 1);
243 Vmath::Vexp(m_nq, m_gates_tau[j], 1, m_gates_tau[j], 1);
244 Vmath::Vsub(m_nq, m_cellSol[m_gates[j]], 1, m_wsp[m_gates[j]], 1,
245 m_cellSol[m_gates[j]], 1);
246 Vmath::Vvtvp(m_nq, m_cellSol[m_gates[j]], 1, m_gates_tau[j], 1,
247 m_wsp[m_gates[j]], 1, m_cellSol[m_gates[j]], 1);
252 Update(m_cellSol, m_wsp, time);
259 max(m_nodalTri->GetNcoeffs(), m_nodalTet->GetNcoeffs()));
261 for (
size_t k = 0; k < nvar; ++k)
263 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
265 int phys_offset = m_field->GetPhys_Offset(i);
266 int coef_offset = m_field->GetCoeff_Offset(i);
267 if (m_field->GetExp(0)->DetShapeType() ==
270 m_nodalTri->NodalToModal(m_wsp[k] + coef_offset, tmpCoeffs);
271 m_field->GetExp(0)->BwdTrans(tmpCoeffs, tmp = outarray[k] +
276 m_nodalTet->NodalToModal(m_wsp[k] + coef_offset, tmpCoeffs);
277 m_field->GetExp(0)->BwdTrans(tmpCoeffs, tmp = outarray[k] +
289 for (
size_t j = 0; j < m_concentrations.size(); ++j)
291 Vmath::Svtvp(m_nq, delta_t, m_wsp[m_concentrations[j]], 1,
292 m_cellSol[m_concentrations[j]], 1,
293 m_cellSol[m_concentrations[j]], 1);
297 for (
size_t j = 0; j < m_gates.size(); ++j)
299 Vmath::Sdiv(m_nq, -delta_t, m_gates_tau[j], 1, m_gates_tau[j], 1);
300 Vmath::Vexp(m_nq, m_gates_tau[j], 1, m_gates_tau[j], 1);
301 Vmath::Vsub(m_nq, m_cellSol[m_gates[j]], 1, m_wsp[m_gates[j]], 1,
302 m_cellSol[m_gates[j]], 1);
303 Vmath::Vvtvp(m_nq, m_cellSol[m_gates[j]], 1, m_gates_tau[j], 1,
304 m_wsp[m_gates[j]], 1, m_cellSol[m_gates[j]], 1);
312 ASSERTL0(idx < m_nvar,
"Index out of range for cell model.");
319 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
321 int coef_offset = m_field->GetCoeff_Offset(i);
324 m_nodalTri->NodalToModal(m_cellSol[idx] + coef_offset,
325 tmp = outarray + coef_offset);
329 m_nodalTet->NodalToModal(m_cellSol[idx] + coef_offset,
330 tmp = outarray + coef_offset);
336 m_field->FwdTransLocalElmt(m_cellSol[idx], outarray);
344 return m_cellSol[idx];
347 void CellModel::LoadCellModel()
349 const bool root = (m_session->GetComm()->GetRank() == 0);
350 const std::string fncName =
"CellModelInitialConditions";
351 const size_t nvar = m_cellSol[0].size();
361 cout <<
"Cell model initial conditions: " << endl;
365 std::set<std::string> filelist;
366 for (j = 1; j < nvar; ++j)
369 varName = GetCellVarName(j);
371 if (m_session->GetFunctionType(fncName, varName) ==
374 filelist.insert(m_session->GetFunctionFilename(fncName, varName));
379 typedef std::vector<LibUtilities::FieldDefinitionsSharedPtr> FDef;
380 typedef std::vector<std::vector<NekDouble>> FData;
381 std::map<std::string, FDef> FieldDef;
382 std::map<std::string, FData> FieldData;
385 for (
auto &setIt : filelist)
389 cout <<
" - Reading file: " << setIt << endl;
391 FieldDef[setIt] = FDef(0);
392 FieldData[setIt] = FData(0);
394 LibUtilities::FieldIO::CreateForFile(m_session, setIt);
395 fld->Import(setIt, FieldDef[setIt], FieldData[setIt], fieldMetaDataMap);
399 auto iter = fieldMetaDataMap.find(
"Time");
400 if (iter != fieldMetaDataMap.end())
402 m_lastTime = boost::lexical_cast<NekDouble>(iter->second);
408 for (j = 1; j < m_cellSol.size(); ++j)
411 varName = GetCellVarName(j);
414 if (m_session->GetFunctionType(fncName, varName) ==
417 const std::string file =
418 m_session->GetFunctionFilename(fncName, varName);
422 cout <<
" - Field " << varName <<
": from file " << file
427 for (
size_t i = 0; i < FieldDef[file].size(); ++i)
429 m_field->ExtractDataToCoeffs(
430 FieldDef[file][i], FieldData[file][i], varName, coeffs);
437 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
439 int coef_offset = m_field->GetCoeff_Offset(i);
440 if (m_field->GetExp(0)->DetShapeType() ==
443 m_nodalTri->ModalToNodal(coeffs + coef_offset,
449 m_nodalTet->ModalToNodal(coeffs + coef_offset,
457 m_field->BwdTrans(coeffs, m_cellSol[j]);
460 else if (m_session->GetFunctionType(fncName, varName) ==
464 m_session->GetFunction(fncName, varName);
468 cout <<
" - Field " << varName <<
": " << equ->GetExpression()
472 const size_t nphys = m_field->GetNpoints();
476 m_field->GetCoords(x0, x1, x2);
482 max(m_nodalTri->GetNcoeffs(), m_nodalTet->GetNcoeffs()));
484 equ->Evaluate(x0, x1, x2, phys);
485 for (
size_t i = 0; i < m_field->GetNumElmts(); ++i)
487 int phys_offset = m_field->GetPhys_Offset(i);
488 int coef_offset = m_field->GetCoeff_Offset(i);
489 if (m_field->GetExp(0)->DetShapeType() ==
492 m_field->GetExp(0)->FwdTrans(phys + phys_offset,
494 m_nodalTri->ModalToNodal(tmpCoeffs, tmp = m_cellSol[j] +
499 m_field->GetExp(0)->FwdTrans(phys + phys_offset,
501 m_nodalTet->ModalToNodal(tmpCoeffs, tmp = m_cellSol[j] +
508 equ->Evaluate(x0, x1, x2, m_cellSol[j]);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Describes the specification for a Basis.
Provides a generic Factory class.
Defines a specification for a set of points.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
@ eNodalTriEvenlySpaced
2D Evenly-spaced points on a Triangle
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
@ eNodalTetEvenlySpaced
3D Evenly-spaced points on a Tetrahedron
@ eFunctionTypeExpression
@ eModified_B
Principle Modified Functions .
@ eModified_C
Principle Modified Functions .
@ eModified_A
Principle Modified Functions .
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
CellModelFactory & GetCellModelFactory()
void Vexp(int n, const T *x, const int incx, T *y, const int incy)
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
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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.