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.

75 {}

◆ 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.

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

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 72 of file Forcing.cpp.

77  {
78  v_Apply(fields, inarray, outarray, time);
79  }
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 116 of file Forcing.cpp.

121  {
122  v_ApplyCoeff(fields, inarray, outarray, time);
123  }
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:228

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 191 of file Forcing.cpp.

195  {
196  // dummy array of zero pts.
197  Array<OneD, NekDouble> x0(pArray.size(),0.0);
198 
199  pEqn->Evaluate(x0, x0, x0, pTime, pArray);
200  }

◆ 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 174 of file Forcing.cpp.

180  {
181  ASSERTL0(pSession->DefinesFunction(pFunctionName),
182  "Function '" + pFunctionName + "' does not exist.");
183 
185  pSession->GetFunction(pFunctionName, pFieldName);
186 
187  EvaluateTimeFunction(pTime,ffunc,pArray);
188  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
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:174
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131

References ASSERTL0.

Referenced by 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 169 of file Forcing.cpp.

170  {
171  return m_Forcing;
172  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:122

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 202 of file Forcing.cpp.

207  {
208  if (pCache)
209  {
210  if ((m_sessionFunctions.find(pName) == m_sessionFunctions.end())
211  || (m_sessionFunctions[pName]->GetSession() != pSession)
212  || (m_sessionFunctions[pName]->GetExpansion() != pFields[0])
213  )
214  {
215  m_sessionFunctions[pName] =
217  pSession, pFields[0], pName, pCache);
218  }
219 
220  return m_sessionFunctions[pName];
221  }
222  else
223  {
224  return SessionFunctionSharedPtr(new SessionFunction(pSession, pFields[0], pName, pCache));
225  }
226  }
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(), Nektar::SolverUtils::ForcingMovingReferenceFrame::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 58 of file Forcing.cpp.

62  {
63  v_InitObject(pFields, pNumForcingFields, pForce);
64  }
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 128 of file Forcing.cpp.

133  {
134  vector<ForcingSharedPtr> vForceList;
135 
136  if (!pSession->DefinesElement("Nektar/Forcing"))
137  {
138  return vForceList;
139  }
140 
141  TiXmlElement* vForcing = pSession->GetElement("Nektar/Forcing");
142  if (vForcing)
143  {
144  unsigned int vNumForcingFields = pNumForcingFields;
145  if (!pNumForcingFields)
146  {
147  vNumForcingFields = pFields.size();
148  }
149 
150  TiXmlElement* vForce = vForcing->FirstChildElement("FORCE");
151  while (vForce)
152  {
153  string vType = vForce->Attribute("TYPE");
154 
155  vForceList.push_back(GetForcingFactory().CreateInstance(
156  vType, pSession, pEquation, pFields,
157  vNumForcingFields, vForce));
158  vForce = vForce->NextSiblingElement("FORCE");
159  }
160  }
161  return vForceList;
162  }
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:44

References Nektar::SolverUtils::GetForcingFactory().

Referenced by Nektar::AcousticSystem::v_InitObject(), Nektar::UnsteadyReactionDiffusion::v_InitObject(), Nektar::UnsteadyViscousBurgers::v_InitObject(), Nektar::CompressibleFlowSystem::v_InitObject(), Nektar::Dummy::v_InitObject(), and Nektar::IncNavierStokes::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 81 of file Forcing.cpp.

86  {
87  v_PreApply(fields, inarray, outarray, time);
88  }
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:90

References v_PreApply().

◆ UpdateForces()

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

Definition at line 164 of file Forcing.cpp.

165  {
166  return m_Forcing;
167  }

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::ForcingBody, and Nektar::SolverUtils::ForcingAbsorption.

Definition at line 228 of file Forcing.cpp.

233  {
234  boost::ignore_unused(fields, inarray, outarray, time);
235  ASSERTL0(false, "v_ApplyCoeff not defined");
236  }

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 90 of file Forcing.cpp.

95  {
96  boost::ignore_unused(fields, time);
97  if (&inarray != &outarray)
98  {
99  int nvar = std::min(inarray.size(), outarray.size());
100  for (int i=0; i < nvar; ++i)
101  {
102  if (&inarray[i] != &outarray[i])
103  {
104  int np = std::min(inarray[i].size(), outarray[i].size());
105  Vmath::Vcopy(np, inarray[i], 1, outarray[i], 1);
106  }
107  }
108  }
109  }
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199

References Vmath::Vcopy().

Referenced by PreApply().

Member Data Documentation

◆ m_equ

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

Weak pointer to equation system using this forcing.

Definition at line 120 of file Forcing.h.

Referenced by Nektar::ForcingMovingBody::InitialiseFilter().

◆ 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().