Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Friends | List of all members
Nektar::SolverUtils::ForcingBody Class Reference

#include <ForcingBody.h>

Inheritance diagram for Nektar::SolverUtils::ForcingBody:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SolverUtils::ForcingBody:
Collaboration graph
[legend]

Static Public Member Functions

static SOLVER_UTILS_EXPORT ForcingSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::SolverUtils::Forcing
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtrLoad (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

virtual SOLVER_UTILS_EXPORT void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 
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)
 
- Protected Member Functions inherited from Nektar::SolverUtils::Forcing
SOLVER_UTILS_EXPORT Forcing (const LibUtilities::SessionReaderSharedPtr &)
 Constructor. More...
 
SOLVER_UTILS_EXPORT void EvaluateFunction (Array< OneD, MultiRegions::ExpListSharedPtr > pFields, LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
 
SOLVER_UTILS_EXPORT void EvaluateTimeFunction (LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
 

Private Member Functions

 ForcingBody (const LibUtilities::SessionReaderSharedPtr &pSession)
 
virtual ~ForcingBody (void)
 

Friends

class MemoryManager< ForcingBody >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::SolverUtils::Forcing
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...
 
- Protected Attributes inherited from Nektar::SolverUtils::Forcing
LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
Array< OneD, Array< OneD, NekDouble > > m_Forcing
 Evaluated forcing function. More...
 
int m_NumVariable
 Number of variables. More...
 

Detailed Description

Definition at line 52 of file ForcingBody.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::ForcingBody::ForcingBody ( const LibUtilities::SessionReaderSharedPtr pSession)
private

Definition at line 49 of file ForcingBody.cpp.

51  : Forcing(pSession)
52  {
53  }
SOLVER_UTILS_EXPORT Forcing(const LibUtilities::SessionReaderSharedPtr &)
Constructor.
Definition: Forcing.cpp:51
virtual Nektar::SolverUtils::ForcingBody::~ForcingBody ( void  )
inlineprivatevirtual

Definition at line 88 of file ForcingBody.h.

88 {};

Member Function Documentation

static SOLVER_UTILS_EXPORT ForcingSharedPtr Nektar::SolverUtils::ForcingBody::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
inlinestatic

Creates an instance of this class.

Definition at line 59 of file ForcingBody.h.

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

64  {
66  AllocateSharedPtr(pSession);
67  p->InitObject(pFields, pNumForcingFields, pForce);
68  return p;
69  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
SOLVER_UTILS_EXPORT typedef boost::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
Definition: Forcing.h:51
void Nektar::SolverUtils::ForcingBody::v_Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Forcing.

Definition at line 112 of file ForcingBody.cpp.

References Nektar::SolverUtils::Forcing::m_Forcing, Nektar::SolverUtils::Forcing::m_NumVariable, and Vmath::Vadd().

117  {
118  for (int i = 0; i < m_NumVariable; i++)
119  {
120  Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1,
121  m_Forcing[i], 1, outarray[i], 1);
122  }
123  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:97
int m_NumVariable
Number of variables.
Definition: Forcing.h:99
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.
Definition: Vmath.cpp:285
void Nektar::SolverUtils::ForcingBody::v_InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
protectedvirtual

Implements Nektar::SolverUtils::Forcing.

Definition at line 55 of file ForcingBody.cpp.

References ASSERTL0, Nektar::MultiRegions::e3DH1D, Nektar::SolverUtils::Forcing::EvaluateFunction(), Nektar::SolverUtils::Forcing::m_Forcing, Nektar::SolverUtils::Forcing::m_NumVariable, and Nektar::SolverUtils::Forcing::m_session.

59  {
60  m_NumVariable = pNumForcingFields;
61  int nq = pFields[0]->GetTotPoints();
62 
63  const TiXmlElement* funcNameElmt = pForce->FirstChildElement("BODYFORCE");
64  ASSERTL0(funcNameElmt, "Requires BODYFORCE tag specifying function "
65  "name which prescribes body force.");
66 
67  string funcName = funcNameElmt->GetText();
68  ASSERTL0(m_session->DefinesFunction(funcName),
69  "Function '" + funcName + "' not defined.");
70 
71  bool singleMode, halfMode;
72  m_session->MatchSolverInfo("ModeType", "SingleMode", singleMode, false);
73  m_session->MatchSolverInfo("ModeType", "HalfMode", halfMode, false);
74 
76  std::string s_FieldStr;
77  for (int i = 0; i < m_NumVariable; ++i)
78  {
79  m_Forcing[i] = Array<OneD, NekDouble> (nq, 0.0);
80  s_FieldStr = m_session->GetVariable(i);
81  ASSERTL0(m_session->DefinesFunction(funcName, s_FieldStr),
82  "Variable '" + s_FieldStr + "' not defined.");
83  EvaluateFunction(pFields, m_session, s_FieldStr,
84  m_Forcing[i], funcName);
85  }
86 
87  bool homogeneous = pFields[0]->GetExpType() == MultiRegions::e3DH1D;
88 
89  // If singleMode or halfMode, transform the forcing term to be in
90  // physical space in the plane, but Fourier space in the homogeneous
91  // direction
92  if (singleMode || halfMode || homogeneous)
93  {
94  // Temporary array
95  Array<OneD, NekDouble> forcingCoeff(pFields[0]->GetNcoeffs(), 0.0);
96 
97  bool w = pFields[0]->GetWaveSpace();
98  for (int i = 0; i < m_NumVariable; ++i)
99  {
100  // FwdTrans in SEM and Fourier
101  pFields[0]->SetWaveSpace(false);
102  pFields[0]->FwdTrans_IterPerExp(m_Forcing[i], forcingCoeff);
103  // BwdTrans in SEM only
104  pFields[0]->SetWaveSpace(true);
105  pFields[0]->BwdTrans(forcingCoeff, m_Forcing[i]);
106  }
107  pFields[0]->SetWaveSpace(w);
108  }
109 
110  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:97
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
SOLVER_UTILS_EXPORT void EvaluateFunction(Array< OneD, MultiRegions::ExpListSharedPtr > pFields, LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
Definition: Forcing.cpp:140
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:95
int m_NumVariable
Number of variables.
Definition: Forcing.h:99

Friends And Related Function Documentation

friend class MemoryManager< ForcingBody >
friend

Definition at line 56 of file ForcingBody.h.

Member Data Documentation

std::string Nektar::SolverUtils::ForcingBody::className
static
Initial value:
RegisterCreatorFunction("Body",
"Body Forcing")

Name of the class.

Definition at line 72 of file ForcingBody.h.