41#include <boost/format.hpp> 
   62    : m_session(session), m_field(field), m_name(functionName),
 
   66             "Function '" + 
m_name + 
"' does not exist.");
 
   80    std::vector<std::string> vFieldNames = 
m_session->GetVariables();
 
   82    for (
int i = 0; i < vFieldNames.size(); i++)
 
   84        Evaluate(vFieldNames[i], pArray[i], pTime, domain);
 
  101    ASSERTL1(pFieldNames.size() == pArray.size(),
 
  103                 "' variable list size mismatch with array storage.");
 
  105    for (
int i = 0; i < pFieldNames.size(); i++)
 
  107        Evaluate(pFieldNames[i], pArray[i], pTime, domain);
 
  121    std::vector<std::string> pFieldNames,
 
  123    const NekDouble &pTime, 
const int domain)
 
  125    ASSERTL0(pFieldNames.size() == pFields.size(),
 
  126             "Field list / name list size mismatch.");
 
  128    for (
int i = 0; i < pFieldNames.size(); i++)
 
  130        Evaluate(pFieldNames[i], pFields[i]->UpdatePhys(), pTime, domain);
 
  131        if (pFields[i]->GetWaveSpace())
 
  133            pFields[i]->HomogeneousFwdTrans(pFields[i]->GetTotPoints(),
 
  134                                            pFields[i]->GetPhys(),
 
  135                                            pFields[i]->UpdatePhys());
 
  137        pFields[i]->FwdTransLocalElmt(pFields[i]->GetPhys(),
 
  138                                      pFields[i]->UpdateCoeffs());
 
  153                               const NekDouble &pTime, 
const int domain)
 
  158    unsigned int nq = 
m_field->GetNpoints();
 
  160    std::pair<std::string, int> key(pFieldName, domain);
 
  168        if (pArray.size() < nq)
 
  184        std::string filename =
 
  187        if (boost::filesystem::path(filename).extension() == 
".pts" ||
 
  188            boost::filesystem::path(filename).extension() == 
".csv")
 
  199        ASSERTL0(
false, 
"unknown eFunctionType");
 
  227        retVal = ffunc->GetExpression();
 
  232        std::string filename =
 
  234        retVal = 
"from file " + filename;
 
  238        ASSERTL0(
false, 
"unknown eFunctionType");
 
  254                                  const NekDouble &pTime, 
const int domain)
 
  256    unsigned int nq = 
m_field->GetNpoints();
 
  257    if (pArray.size() < nq)
 
  268    m_field->GetCoords(x0, x1, x2);
 
  272    ffunc->Evaluate(x0, x1, x2, pTime, pArray);
 
  285                                  const NekDouble &pTime, 
const int domain)
 
  287    unsigned int nq = 
m_field->GetNpoints();
 
  288    if (pArray.size() < nq)
 
  293    std::string filename =
 
  295    std::string fileVar =
 
  298    if (fileVar.length() == 0)
 
  300        fileVar = pFieldName;
 
  311#if (defined _WIN32 && _MSC_VER < 1900) 
  314            unsigned int old_exponent_format;
 
  315            old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
 
  317            _set_output_format(old_exponent_format);
 
  325                                "\", variable \"" + fileVar + 
"\"")
 
  330    int numexp = 
m_field->GetExpSize();
 
  332    for (
int i = 0; i < numexp; ++i)
 
  334        ElementGIDs[i] = 
m_field->GetExp(i)->GetGeom()->GetGlobalID();
 
  337    std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
 
  338    std::vector<std::vector<NekDouble>> FieldData;
 
  341    fldIO->Import(filename, FieldDef, FieldData,
 
  347    for (
int i = 0; i < FieldDef.size(); ++i)
 
  351        for (
int j = 0; j < FieldDef[i]->m_fields.size(); ++j)
 
  353            if (FieldDef[i]->m_fields[j] == fileVar)
 
  361            m_field->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
 
  362                                         FieldDef[i]->m_fields[idx], vCoeffs);
 
  366            cout << 
"Field " + fileVar + 
" not found." << endl;
 
  370    bool wavespace = 
m_field->GetWaveSpace();
 
  372    m_field->BwdTrans(vCoeffs, pArray);
 
  373    m_field->SetWaveSpace(wavespace);
 
  386                                  const NekDouble &pTime, 
const int domain)
 
  388    unsigned int nq = 
m_field->GetNpoints();
 
  389    if (pArray.size() < nq)
 
  394    std::string filename =
 
  396    std::string fileVar =
 
  399    if (fileVar.length() == 0)
 
  401        fileVar = pFieldName;
 
  412#if (defined _WIN32 && _MSC_VER < 1900) 
  415            unsigned int old_exponent_format;
 
  416            old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
 
  418            _set_output_format(old_exponent_format);
 
  426                                "\", variable \"" + fileVar + 
"\"")
 
  434    std::string funcFilename =
 
  438    if (boost::filesystem::path(filename).extension() == 
".pts")
 
  441        ptsIO.
Import(filename, inPts);
 
  443    else if (boost::filesystem::path(filename).extension() == 
".csv")
 
  446        csvIO.
Import(filename, inPts);
 
  450        ASSERTL1(
false, 
"Unsupported file type");
 
  454                                            inPts->GetNFields());
 
  455    for (
int i = 0; i < inPts->GetDim() + inPts->GetNFields(); ++i)
 
  459    if (inPts->GetDim() == 1)
 
  463    else if (inPts->GetDim() == 2)
 
  465        m_field->GetCoords(pts[0], pts[1]);
 
  467    else if (inPts->GetDim() == 3)
 
  469        m_field->GetCoords(pts[0], pts[1], pts[2]);
 
  472        inPts->GetDim(), inPts->GetFieldNames(), pts);
 
  483            std::vector<MultiRegions::ExpListSharedPtr>>(
 
  485        if (
m_session->GetComm()->GetRank() == 0)
 
  491        if (
m_session->GetComm()->GetRank() == 0)
 
  494            if (
m_session->DefinesCmdLineArgument(
"verbose"))
 
  510    vector<string> fieldNames = outPts->GetFieldNames();
 
  511    for (fieldInd = 0; fieldInd < fieldNames.size(); ++fieldInd)
 
  513        if (outPts->GetFieldName(fieldInd) == fileVar)
 
  518    ASSERTL0(fieldInd != fieldNames.size(), 
"field not found");
 
  520    pArray = outPts->GetPts(fieldInd + outPts->GetDim());
 
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
FIELD_UTILS_EXPORT void Interpolate(const T expInField, T &expOutField, NekDouble def_value=0.0)
Interpolate from an expansion to an expansion.
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
void PrintStatistics()
Returns if the weights have already been computed.
void SetProgressCallback(FuncPointerT func, ObjectPointerT obj)
sets a callback funtion which gets called every time the interpolation progresses
void CalcWeights(const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField, bool reuseTree=false)
Compute interpolation weights without doing any interpolation.
void Import(const std::string &inFile, PtsFieldSharedPtr &ptsField, FieldMetaDataMap &fieldmetadatamap=NullFieldMetaDataMap, DomainRangeShPtr &Range=NullDomainRangeShPtr)
Import a pts field from file.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::map< std::string, FieldUtils::Interpolator< std::vector< MultiRegions::ExpListSharedPtr > > > m_interpolators
Interpolator for pts file input for a variable & domain combination.
MultiRegions::ExpListSharedPtr m_field
The expansion we want to evaluate this function for.
bool m_toCache
Store resulting arrays (and interpolators)
std::map< std::pair< std::string, int >, Array< OneD, NekDouble > > m_arrays
Cached result arrays.
SOLVER_UTILS_EXPORT void EvaluateFld(std::string pFieldName, Array< OneD, NekDouble > &pArray, const NekDouble &pTime=0.0, const int domain=0)
SOLVER_UTILS_EXPORT void Evaluate(Array< OneD, Array< OneD, NekDouble > > &pArray, const NekDouble pTime=0.0, const int domain=0)
Evaluates a function defined in the xml session file at each quadrature point.
SOLVER_UTILS_EXPORT void EvaluatePts(std::string pFieldName, Array< OneD, NekDouble > &pArray, const NekDouble &pTime=0.0, const int domain=0)
Evaluates a function from pts file.
SOLVER_UTILS_EXPORT SessionFunction(const LibUtilities::SessionReaderSharedPtr &session, const MultiRegions::ExpListSharedPtr &field, std::string functionName, bool toCache=false)
Representation of a FUNCTION defined in the session xml file.
SOLVER_UTILS_EXPORT void PrintProgressbar(const int position, const int goal) const
std::map< std::pair< std::string, int >, NekDouble > m_lastCached
Last time the cache for this variable & domain combo was updated.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT std::string Describe(std::string pFieldName, const int domain=0)
Provide a description of a function for a given field name.
SOLVER_UTILS_EXPORT void EvaluateExp(std::string pFieldName, Array< OneD, NekDouble > &pArray, const NekDouble &pTime=0.0, const int domain=0)
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
static FieldMetaDataMap NullFieldMetaDataMap
std::shared_ptr< PtsField > PtsFieldSharedPtr
@ eFunctionTypeExpression
@ eFunctionTypeTransientFile
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekZeroTol
The above copyright notice and this permission notice shall be included.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)