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

References Apply(), GetForces(), InitObject(), Load(), SOLVER_UTILS_EXPORT, and UpdateForces().

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  }
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:103
const std::weak_ptr< EquationSystem > m_equ
Weak pointer to equation system using this forcing.
Definition: Forcing.h:105

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.

References v_Apply().

Referenced by ~Forcing().

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

◆ EvaluateTimeFunction() [1/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 131 of file Forcing.cpp.

References ASSERTL0.

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

137  {
138  ASSERTL0(pSession->DefinesFunction(pFunctionName),
139  "Function '" + pFunctionName + "' does not exist.");
140 
142  pSession->GetFunction(pFunctionName, pFieldName);
143 
144  EvaluateTimeFunction(pTime,ffunc,pArray);
145  }
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:131
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131

◆ EvaluateTimeFunction() [2/2]

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

Definition at line 148 of file Forcing.cpp.

152  {
153  // dummy array of zero pts.
154  Array<OneD, NekDouble> x0(pArray.num_elements(),0.0);
155 
156  pEqn->Evaluate(x0, x0, x0, pTime, pArray);
157  }

◆ GetForces()

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

Definition at line 126 of file Forcing.cpp.

References m_Forcing.

Referenced by ~Forcing().

127  {
128  return m_Forcing;
129  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:107

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

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

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

164  {
165  if (pCache)
166  {
167  if ((m_sessionFunctions.find(pName) == m_sessionFunctions.end())
168  || (m_sessionFunctions[pName]->GetSession() != pSession)
169  || (m_sessionFunctions[pName]->GetExpansion() != pFields[0])
170  )
171  {
172  m_sessionFunctions[pName] =
174  pSession, pFields[0], pName, pCache);
175  }
176 
177  return m_sessionFunctions[pName];
178  }
179  else
180  {
181  return SessionFunctionSharedPtr(new SessionFunction(pSession, pFields[0], pName, pCache));
182  }
183  }
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
Definition: Forcing.h:111
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr

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

References v_InitObject().

Referenced by ~Forcing().

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

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

References Nektar::SolverUtils::GetForcingFactory().

Referenced by Nektar::UnsteadyReactionDiffusion::v_InitObject(), Nektar::Dummy::v_InitObject(), Nektar::AcousticSystem::v_InitObject(), Nektar::CompressibleFlowSystem::v_InitObject(), Nektar::UnsteadyViscousBurgers::v_InitObject(), Nektar::IncNavierStokes::v_InitObject(), and ~Forcing().

90  {
91  vector<ForcingSharedPtr> vForceList;
92 
93  if (!pSession->DefinesElement("Nektar/Forcing"))
94  {
95  return vForceList;
96  }
97 
98  TiXmlElement* vForcing = pSession->GetElement("Nektar/Forcing");
99  if (vForcing)
100  {
101  unsigned int vNumForcingFields = pNumForcingFields;
102  if (!pNumForcingFields)
103  {
104  vNumForcingFields = pFields.num_elements();
105  }
106 
107  TiXmlElement* vForce = vForcing->FirstChildElement("FORCE");
108  while (vForce)
109  {
110  string vType = vForce->Attribute("TYPE");
111 
112  vForceList.push_back(GetForcingFactory().CreateInstance(
113  vType, pSession, pEquation, pFields,
114  vNumForcingFields, vForce));
115  vForce = vForce->NextSiblingElement("FORCE");
116  }
117  }
118  return vForceList;
119  }
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:44

◆ UpdateForces()

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

Definition at line 121 of file Forcing.cpp.

References m_Forcing.

Referenced by ~Forcing().

122  {
123  return m_Forcing;
124  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:107

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

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 105 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 111 of file Forcing.h.

Referenced by GetFunction().