51 const std::weak_ptr<EquationSystem> &pEquation)
52 :
Forcing(pSession, pEquation), m_hasRefFlow(false), m_hasRefFlowTime(false)
58 const unsigned int &pNumForcingFields,
const TiXmlElement *pForce)
61 int npts = pFields[0]->GetTotPoints();
76 const TiXmlElement *funcNameElmt = pForce->FirstChildElement(
"REFFLOW");
79 string funcName = funcNameElmt->GetText();
81 "Function '" + funcName +
"' not defined.");
85 std::string s_FieldStr =
m_session->GetVariable(i);
87 "Variable '" + s_FieldStr +
"' not defined.");
95 funcNameElmt = pForce->FirstChildElement(
"REFFLOWTIME");
104 std::string s_FieldStr =
m_session->GetVariable(i);
106 "Variable '" + s_FieldStr +
"' not defined.");
115 const TiXmlElement *pForce)
117 const TiXmlElement *funcNameElmt = pForce->FirstChildElement(
"COEFF");
119 "Requires COEFF tag, specifying function "
120 "name which prescribes absorption layer coefficient.");
121 string funcName = funcNameElmt->GetText();
123 "Function '" + funcName +
"' not defined.");
125 int npts = pFields[0]->GetTotPoints();
133 funcNameElmt = pForce->FirstChildElement(
"BOUNDARYREGIONS");
138 "Unable to process list of BOUNDARYREGIONS in Absorption "
140 std::string(funcNameElmt->GetText()));
143 std::vector<unsigned int> localBRegions;
145 pFields[0]->GetGraph());
148 SpatialDomains::BoundaryRegionCollection::iterator it1;
150 for (it1 = regions.begin(); it1 != regions.end(); ++it1)
155 localBRegions.push_back(n);
166 std::vector<Array<OneD, const NekDouble>> points;
169 for (
int i = 0; i < 3; i++)
173 pFields[0]->GetCoords(x[0], x[1], x[2]);
174 for (
int i = 0; i < 3; i++)
176 points.push_back(x[i]);
183 std::vector<unsigned int>::iterator it;
184 std::vector<BPointPair> inPoints;
188 int bpts = pFields[0]->GetBndCondExpansions()[*it]->GetNpoints();
189 for (
int i = 0; i < 3; i++)
193 pFields[0]->GetBndCondExpansions()[*it]->GetCoords(b[0], b[1],
196 i < pFields[0]->GetBndCondExpansions()[*it]->GetNpoints(); ++i)
203 m_rtree->insert(inPoints.begin(), inPoints.end());
205 for (
int i = 0; i < npts; ++i)
207 std::vector<BPointPair> result;
208 BPoint sPoint(x[0][i], x[1][i], x[2][i]);
209 m_rtree->query(bgi::nearest(sPoint, 1), std::back_inserter(result));
210 r[i] = bg::distance(sPoint, result[0].first);
214 std::string s_FieldStr;
219 "Variable '" + s_FieldStr +
"' not defined.");
222 m_session->GetFunction(funcName, s_FieldStr);
223 ASSERTL0(ffunc->GetVlist() ==
"x y z t r",
224 "EVARS of " + funcName +
" must be 'r'");
233 std::string s_FieldStr =
m_session->GetVariable(i);
245 pFields[i]->HomogeneousFwdTrans(pFields[i]->GetTotPoints(),
276 Vmath::Vadd(ncoeff, tmp, 1, outarray[i], 1, outarray[i], 1);
286 std::string s_FieldStr;
299 std::string s_FieldStr =
m_session->GetVariable(i);
301 ->Evaluate(s_FieldStr,
m_Refflow[i], time);
#define ASSERTL0(condition, msg)
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.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
bg::model::point< NekDouble, 3, bg::cs::cartesian > BPoint
SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
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
ForcingAbsorption(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
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.
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
Array< OneD, Array< OneD, NekDouble > > m_Refflow
std::pair< BPoint, unsigned int > BPointPair
std::string m_funcNameTime
void CalcAbsorption(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pForce)
void CalculateForcing(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, const NekDouble &time)
static std::string className
Name of the class.
std::shared_ptr< BRTree > m_rtree
std::vector< unsigned int > m_bRegions
Array< OneD, Array< OneD, NekDouble > > m_Absorption
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 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.
const BoundaryRegionCollection & GetBoundaryRegions(void) const
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = 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.
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.