Nektar++
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::SolverUtils::Forcing Class Referenceabstract

Defines a forcing term to be explicitly applied. More...

#include <Forcing.h>

Inheritance diagram for Nektar::SolverUtils::Forcing:
[legend]

Public Member Functions

virtual SOLVER_UTILS_EXPORT ~Forcing ()
 
SOLVER_UTILS_EXPORT void InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 Initialise the forcing object. More...
 
SOLVER_UTILS_EXPORT void Apply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
 Apply the forcing. More...
 
SOLVER_UTILS_EXPORT void PreApply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
 Change the advection velocity before applying the forcing. For example, subtracting the frame velocity from the advection velocity in the MovingRefercenceFrame. More...
 
SOLVER_UTILS_EXPORT void ApplyCoeff (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
 Apply the forcing. More...
 
SOLVER_UTILS_EXPORT const Array< OneD, const Array< OneD, NekDouble > > & GetForces ()
 
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > & UpdateForces ()
 

Static Public Member Functions

static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtrLoad (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
 

Protected Member Functions

SOLVER_UTILS_EXPORT Forcing (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
 Constructor. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)=0
 
virtual 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)=0
 
virtual SOLVER_UTILS_EXPORT void v_PreApply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
 
virtual 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)
 
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. More...
 
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 void EvaluateTimeFunction (const NekDouble pTime, const LibUtilities::EquationSharedPtr &pEqn, Array< OneD, NekDouble > &pArray)
 

Protected Attributes

LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
const std::weak_ptr< EquationSystemm_equ
 Weak pointer to equation system using this forcing. More...
 
Array< OneD, Array< OneD, NekDouble > > m_Forcing
 Evaluated forcing function. More...
 
int m_NumVariable
 Number of variables. More...
 
std::map< std::string, SolverUtils::SessionFunctionSharedPtrm_sessionFunctions
 Map of known SessionFunctions. More...
 

Detailed Description

Defines a forcing term to be explicitly applied.

Definition at line 72 of file Forcing.h.

Constructor & Destructor Documentation

◆ ~Forcing()

virtual SOLVER_UTILS_EXPORT Nektar::SolverUtils::Forcing::~Forcing ( )
inlinevirtual

Definition at line 75 of file Forcing.h.

76 {
77 }

◆ Forcing()

Nektar::SolverUtils::Forcing::Forcing ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< EquationSystem > &  pEquation 
)
protected

Constructor.

Definition at line 50 of file Forcing.cpp.

52 : m_session(pSession), m_equ(pEquation)
53{
54}
const std::weak_ptr< EquationSystem > m_equ
Weak pointer to equation system using this forcing.
Definition: Forcing.h:119
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:117

Member Function Documentation

◆ Apply()

void Nektar::SolverUtils::Forcing::Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)

Apply the forcing.

Parameters
fieldsExpansion lists corresponding to input arrays
inarrayu^n from previous timestep
outarrayoutput array to append forcing to

Definition at line 68 of file Forcing.cpp.

72{
73 v_Apply(fields, inarray, outarray, time);
74}
virtual 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)=0

References v_Apply().

◆ ApplyCoeff()

void Nektar::SolverUtils::Forcing::ApplyCoeff ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)

Apply the forcing.

Parameters
fieldsExpansion lists corresponding to input arrays
inarrayu^n from previous timestep
outarrayoutput array to append forcing to

Definition at line 109 of file Forcing.cpp.

113{
114 v_ApplyCoeff(fields, inarray, outarray, time);
115}
virtual 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)
Definition: Forcing.cpp:219

References v_ApplyCoeff().

◆ EvaluateTimeFunction() [1/2]

void Nektar::SolverUtils::Forcing::EvaluateTimeFunction ( const NekDouble  pTime,
const LibUtilities::EquationSharedPtr pEqn,
Array< OneD, NekDouble > &  pArray 
)
protected

Definition at line 184 of file Forcing.cpp.

187{
188 // dummy array of zero pts.
189 Array<OneD, NekDouble> x0(pArray.size(), 0.0);
190
191 pEqn->Evaluate(x0, x0, x0, pTime, pArray);
192}

◆ EvaluateTimeFunction() [2/2]

void Nektar::SolverUtils::Forcing::EvaluateTimeFunction ( LibUtilities::SessionReaderSharedPtr  pSession,
std::string  pFieldName,
Array< OneD, NekDouble > &  pArray,
const std::string &  pFunctionName,
NekDouble  pTime = NekDouble(0) 
)
protected

Definition at line 170 of file Forcing.cpp.

174{
175 ASSERTL0(pSession->DefinesFunction(pFunctionName),
176 "Function '" + pFunctionName + "' does not exist.");
177
179 pSession->GetFunction(pFunctionName, pFieldName);
180
181 EvaluateTimeFunction(pTime, ffunc, pArray);
182}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
SOLVER_UTILS_EXPORT void EvaluateTimeFunction(LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
Definition: Forcing.cpp:170
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:129

References ASSERTL0, and EvaluateTimeFunction().

Referenced by EvaluateTimeFunction(), Nektar::SolverUtils::ForcingBody::v_Apply(), and Nektar::SolverUtils::ForcingBody::v_ApplyCoeff().

◆ GetForces()

const Nektar::Array< OneD, const Array< OneD, NekDouble > > & Nektar::SolverUtils::Forcing::GetForces ( )

Definition at line 165 of file Forcing.cpp.

166{
167 return m_Forcing;
168}
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:121

References m_Forcing.

◆ GetFunction()

SessionFunctionSharedPtr Nektar::SolverUtils::Forcing::GetFunction ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const LibUtilities::SessionReaderSharedPtr pSession,
std::string  pName,
bool  pCache = false 
)
protected

Get a SessionFunction by name.

Definition at line 194 of file Forcing.cpp.

198{
199 if (pCache)
200 {
201 if ((m_sessionFunctions.find(pName) == m_sessionFunctions.end()) ||
202 (m_sessionFunctions[pName]->GetSession() != pSession) ||
203 (m_sessionFunctions[pName]->GetExpansion() != pFields[0]))
204 {
205 m_sessionFunctions[pName] =
207 pSession, pFields[0], pName, pCache);
208 }
209
210 return m_sessionFunctions[pName];
211 }
212 else
213 {
215 new SessionFunction(pSession, pFields[0], pName, pCache));
216 }
217}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
Definition: Forcing.h:126
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and m_sessionFunctions.

Referenced by Nektar::SolverUtils::ForcingAbsorption::CalcAbsorption(), Nektar::SolverUtils::ForcingAbsorption::CalculateForcing(), Nektar::SolverUtils::ForcingBody::Update(), Nektar::ForcingMovingBody::v_Apply(), Nektar::SolverUtils::ForcingAbsorption::v_InitObject(), and Nektar::ForcingQuasi1D::v_InitObject().

◆ InitObject()

void Nektar::SolverUtils::Forcing::InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)

Initialise the forcing object.

Definition at line 56 of file Forcing.cpp.

59{
60 v_InitObject(pFields, pNumForcingFields, pForce);
61}
virtual SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)=0

References v_InitObject().

◆ Load()

vector< ForcingSharedPtr > Nektar::SolverUtils::Forcing::Load ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< EquationSystem > &  pEquation,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields = 0 
)
static

Definition at line 120 of file Forcing.cpp.

125{
126 vector<ForcingSharedPtr> vForceList;
127
128 if (!pSession->DefinesElement("Nektar/Forcing"))
129 {
130 return vForceList;
131 }
132
133 TiXmlElement *vForcing = pSession->GetElement("Nektar/Forcing");
134 if (vForcing)
135 {
136 unsigned int vNumForcingFields = pNumForcingFields;
137 if (!pNumForcingFields)
138 {
139 vNumForcingFields = pFields.size();
140 }
141
142 TiXmlElement *vForce = vForcing->FirstChildElement("FORCE");
143 while (vForce)
144 {
145 string vType = vForce->Attribute("TYPE");
146
147 TiXmlElement *vForceParam = vForce;
149 vForceParam, pSession->GetTimeLevel(), false);
150 vForceList.push_back(GetForcingFactory().CreateInstance(
151 vType, pSession, pEquation, pFields, vNumForcingFields,
152 vForceParam));
153
154 vForce = vForce->NextSiblingElement("FORCE");
155 }
156 }
157 return vForceList;
158}
static void GetXMLElementTimeLevel(TiXmlElement *&element, const size_t timeLevel, const bool disableCheck=true)
Get XML elment time level (Parallel-in-Time)
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:44

References Nektar::SolverUtils::GetForcingFactory(), and Nektar::LibUtilities::SessionReader::GetXMLElementTimeLevel().

Referenced by Nektar::IncNavierStokes::v_InitObject(), Nektar::AcousticSystem::v_InitObject(), Nektar::UnsteadyAdvection::v_InitObject(), Nektar::UnsteadyAdvectionDiffusion::v_InitObject(), Nektar::UnsteadyInviscidBurger::v_InitObject(), Nektar::UnsteadyReactionDiffusion::v_InitObject(), Nektar::UnsteadyViscousBurgers::v_InitObject(), Nektar::CompressibleFlowSystem::v_InitObject(), and Nektar::Dummy::v_InitObject().

◆ PreApply()

void Nektar::SolverUtils::Forcing::PreApply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)

Change the advection velocity before applying the forcing. For example, subtracting the frame velocity from the advection velocity in the MovingRefercenceFrame.

Definition at line 76 of file Forcing.cpp.

80{
81 v_PreApply(fields, inarray, outarray, time);
82}
virtual SOLVER_UTILS_EXPORT void v_PreApply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Definition: Forcing.cpp:84

References v_PreApply().

◆ UpdateForces()

Nektar::Array< OneD, Array< OneD, NekDouble > > & Nektar::SolverUtils::Forcing::UpdateForces ( )

Definition at line 160 of file Forcing.cpp.

161{
162 return m_Forcing;
163}

References m_Forcing.

◆ v_Apply()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Forcing::v_Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)
protectedpure virtual

◆ v_ApplyCoeff()

void Nektar::SolverUtils::Forcing::v_ApplyCoeff ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)
protectedvirtual

Reimplemented in Nektar::SolverUtils::ForcingAbsorption, and Nektar::SolverUtils::ForcingBody.

Definition at line 219 of file Forcing.cpp.

223{
224 boost::ignore_unused(fields, inarray, outarray, time);
225 ASSERTL0(false, "v_ApplyCoeff not defined");
226}

References ASSERTL0.

Referenced by ApplyCoeff().

◆ v_InitObject()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Forcing::v_InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
protectedpure virtual

◆ v_PreApply()

void Nektar::SolverUtils::Forcing::v_PreApply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)
protectedvirtual

Reimplemented in Nektar::SolverUtils::ForcingMovingReferenceFrame.

Definition at line 84 of file Forcing.cpp.

88{
89 boost::ignore_unused(fields, time);
90 if (&inarray != &outarray)
91 {
92 int nvar = std::min(inarray.size(), outarray.size());
93 for (int i = 0; i < nvar; ++i)
94 {
95 if (&inarray[i] != &outarray[i])
96 {
97 int np = std::min(inarray[i].size(), outarray[i].size());
98 Vmath::Vcopy(np, inarray[i], 1, outarray[i], 1);
99 }
100 }
101 }
102}
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191

References Vmath::Vcopy().

Referenced by PreApply().

Member Data Documentation

◆ m_equ

const std::weak_ptr<EquationSystem> Nektar::SolverUtils::Forcing::m_equ
protected

◆ m_Forcing

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::Forcing::m_Forcing
protected

◆ m_NumVariable

int Nektar::SolverUtils::Forcing::m_NumVariable
protected

◆ m_session

LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Forcing::m_session
protected

◆ m_sessionFunctions

std::map<std::string, SolverUtils::SessionFunctionSharedPtr> Nektar::SolverUtils::Forcing::m_sessionFunctions
protected

Map of known SessionFunctions.

Definition at line 126 of file Forcing.h.

Referenced by GetFunction().