本文整理汇总了C++中libutilities::SessionReaderSharedPtr::DefinesFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ SessionReaderSharedPtr::DefinesFunction方法的具体用法?C++ SessionReaderSharedPtr::DefinesFunction怎么用?C++ SessionReaderSharedPtr::DefinesFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libutilities::SessionReaderSharedPtr
的用法示例。
在下文中一共展示了SessionReaderSharedPtr::DefinesFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvaluateFunction
void Forcing::EvaluateFunction(
Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
LibUtilities::SessionReaderSharedPtr pSession,
std::string pFieldName,
Array<OneD, NekDouble>& pArray,
const std::string& pFunctionName,
NekDouble pTime)
{
ASSERTL0(pSession->DefinesFunction(pFunctionName),
"Function '" + pFunctionName + "' does not exist.");
unsigned int nq = pFields[0]->GetNpoints();
if (pArray.num_elements() != nq)
{
pArray = Array<OneD, NekDouble> (nq);
}
LibUtilities::FunctionType vType;
vType = pSession->GetFunctionType(pFunctionName, pFieldName);
if (vType == LibUtilities::eFunctionTypeExpression)
{
Array<OneD, NekDouble> x0(nq);
Array<OneD, NekDouble> x1(nq);
Array<OneD, NekDouble> x2(nq);
pFields[0]->GetCoords(x0, x1, x2);
LibUtilities::EquationSharedPtr ffunc =
pSession->GetFunction(pFunctionName, pFieldName);
ffunc->Evaluate(x0, x1, x2, pTime, pArray);
}
else if (vType == LibUtilities::eFunctionTypeFile)
{
std::string filename = pSession->GetFunctionFilename(
pFunctionName,
pFieldName);
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
Vmath::Zero(vCoeffs.num_elements(), vCoeffs, 1);
LibUtilities::FieldIOSharedPtr fld =
MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(m_session->GetComm());
fld->Import(filename, FieldDef, FieldData);
int idx = -1;
for (int i = 0; i < FieldDef.size(); ++i)
{
for (int j = 0; j < FieldDef[i]->m_fields.size(); ++j)
{
if (FieldDef[i]->m_fields[j] == pFieldName)
{
idx = j;
}
}
if (idx >= 0)
{
pFields[0]->ExtractDataToCoeffs(
FieldDef[i],
FieldData[i],
FieldDef[i]->m_fields[idx],
vCoeffs);
}
else
{
cout << "Field " + pFieldName + " not found." << endl;
}
}
pFields[0]->BwdTrans_IterPerExp(vCoeffs, pArray);
}
}