34#include <boost/algorithm/string.hpp>
52 const std::weak_ptr<EquationSystem> &pEquation)
53 :
Forcing(pSession, pEquation), m_hasTimeFcnScaling(false)
59 const unsigned int &pNumForcingFields,
const TiXmlElement *pForce)
63 const TiXmlElement *funcNameElmt = pForce->FirstChildElement(
"BODYFORCE");
66 funcNameElmt = pForce->FirstChildElement(
"FIELDFORCE");
69 "Requires BODYFORCE or FIELDFORCE tag "
70 "specifying function name which prescribes body force.");
81 funcNameElmt = pForce->FirstChildElement(
"BODYFORCETIMEFCN");
84 funcNameElmt = pForce->FirstChildElement(
"FIELDFORCETIMEFCN");
90 std::string funcNameTime = funcNameElmt->GetText();
93 "Expression must be given in BODYFORCETIMEFCN or "
94 "FIELDFORCETIMEFCN.");
97 m_session->GetInterpreter(), funcNameTime);
105 tmp[i] = pFields[i]->GetPhys();
108 std::map<std::string, int> varIndex;
120 string varStr =
m_session->GetVariable(it.first);
126 string vlist = eqn->GetVlist();
127 if (!boost::iequals(vlist,
"x y z t"))
131 std::vector<std::string> vars;
132 boost::split(vars, vlist, boost::is_any_of(
", "));
133 for (
size_t j = 4; j < vars.size(); ++j)
135 if (vars[j].size() != 0 &&
136 varIndex.find(vars[j]) == varIndex.end())
139 "Variable '" + vars[j] +
140 "' cannot be used as equation variable in "
144 if (vars[j].size() &&
145 varIndex.find(vars[j]) != varIndex.end())
147 it.second.push_back(varIndex[vars[j]]);
161 Update(pFields, tmp, 0.0);
168 std::vector<Array<OneD, const NekDouble>> fielddata;
169 int nq = pFields[0]->GetNpoints();
173 pFields[0]->GetCoords(xc, yc, zc);
174 fielddata.push_back(xc);
175 fielddata.push_back(yc);
176 fielddata.push_back(zc);
177 fielddata.push_back(t);
183 if (it.second.size() > 0)
187 for (
int j : it.second)
192 pFields[i]->HomogeneousBwdTrans(nq, inarray[j], tmp);
193 fielddata.push_back(tmp);
197 fielddata.push_back(inarray[j]);
213 pFields[i]->HomogeneousFwdTrans(pFields[i]->GetTotPoints(),
233 outarray[i], 1, outarray[i], 1);
238 Update(fields, inarray, time);
266 Vmath::Svtvp(ncoeff, TimeFcn[0], tmp, 1, outarray[i], 1,
272 Update(fields, inarray, time);
278 Vmath::Vadd(ncoeff, outarray[i], 1, tmp, 1, outarray[i], 1);
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
static std::string classNameBody
Name of the class.
SOLVER_UTILS_EXPORT void v_ApplyCoeff(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
void Update(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &inarray, const NekDouble &time)
LibUtilities::EquationSharedPtr m_timeFcnEqn
SOLVER_UTILS_EXPORT void v_Apply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
static SOLVER_UTILS_EXPORT ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
static std::string classNameField
ForcingBody(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
std::map< int, std::vector< int > > m_eqnEvars
Defines a forcing term to be explicitly applied.
int m_NumVariable
Number of variables.
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
SOLVER_UTILS_EXPORT void EvaluateTimeFunction(LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, std::string pName, bool pCache=false)
Get a SessionFunction by name.
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
@ eFunctionTypeExpression
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
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 Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.