Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | 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< ForcingSharedPtr
Load (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
 

Static Public Attributes

static std::string classNameBody
 Name of the class. More...
 
static std::string classNameField
 

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))
 
SOLVER_UTILS_EXPORT void EvaluateTimeFunction (const NekDouble pTime, const LibUtilities::EquationSharedPtr &pEqn, Array< OneD, NekDouble > &pArray)
 

Private Member Functions

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

Private Attributes

bool m_hasTimeFcnScaling
 
LibUtilities::EquationSharedPtr m_timeFcnEqn
 

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 53 of file ForcingBody.cpp.

55  : Forcing(pSession),
56  m_hasTimeFcnScaling(false)
57  {
58  }
SOLVER_UTILS_EXPORT Forcing(const LibUtilities::SessionReaderSharedPtr &)
Constructor.
Definition: Forcing.cpp:51
virtual Nektar::SolverUtils::ForcingBody::~ForcingBody ( void  )
inlineprivatevirtual

Definition at line 89 of file ForcingBody.h.

89 {};

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 135 of file ForcingBody.cpp.

References Nektar::SolverUtils::Forcing::EvaluateTimeFunction(), Nektar::SolverUtils::Forcing::m_Forcing, m_hasTimeFcnScaling, Nektar::SolverUtils::Forcing::m_NumVariable, m_timeFcnEqn, Vmath::Svtvp(), and Vmath::Vadd().

140  {
141 
143  {
144  Array<OneD, NekDouble> TimeFcn(1);
145 
146  for (int i = 0; i < m_NumVariable; i++)
147  {
148  EvaluateTimeFunction(time, m_timeFcnEqn, TimeFcn);
149 
150  Vmath::Svtvp(outarray[i].num_elements(), TimeFcn[0],
151  m_Forcing[i], 1,
152  outarray[i], 1,
153  outarray[i], 1);
154  }
155  }
156  else
157  {
158  for (int i = 0; i < m_NumVariable; i++)
159  {
160  Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1,
161  m_Forcing[i], 1, outarray[i], 1);
162  }
163  }
164  }
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:119
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:97
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:471
int m_NumVariable
Number of variables.
Definition: Forcing.h:99
LibUtilities::EquationSharedPtr m_timeFcnEqn
Definition: ForcingBody.h:92
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 60 of file ForcingBody.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::MultiRegions::e3DH1D, Nektar::SolverUtils::Forcing::EvaluateFunction(), Nektar::SolverUtils::Forcing::m_Forcing, m_hasTimeFcnScaling, Nektar::SolverUtils::Forcing::m_NumVariable, Nektar::SolverUtils::Forcing::m_session, and m_timeFcnEqn.

64  {
65  m_NumVariable = pNumForcingFields;
66  int nq = pFields[0]->GetTotPoints();
67 
68  const TiXmlElement* funcNameElmt = pForce->FirstChildElement("BODYFORCE");
69  if(!funcNameElmt)
70  {
71  funcNameElmt = pForce->FirstChildElement("FIELDFORCE");
72 
73  ASSERTL0(funcNameElmt, "Requires BODYFORCE or FIELDFORCE tag "
74  "specifying function name which prescribes body force.");
75  }
76 
77  string funcName = funcNameElmt->GetText();
78  ASSERTL0(m_session->DefinesFunction(funcName),
79  "Function '" + funcName + "' not defined.");
80 
81  // Time function is optional
82  funcNameElmt = pForce->FirstChildElement("BODYFORCETIMEFCN");
83  if(!funcNameElmt)
84  {
85  funcNameElmt = pForce->FirstChildElement("FIELDFORCETIMEFCN");
86  }
87 
88  // Load time function if specified
89  if(funcNameElmt)
90  {
91  std::string funcNameTime = funcNameElmt->GetText();
92 
93  ASSERTL0(!funcNameTime.empty(),
94  "Expression must be given in BODYFORCETIMEFCN or "
95  "FIELDFORCETIMEFCN.");
96 
97  m_session->SubstituteExpressions(funcNameTime);
99  ::AllocateSharedPtr(m_session,funcNameTime);
100 
101  m_hasTimeFcnScaling = true;
102  }
103 
105 
106  std::string s_FieldStr;
107 
108  for (int i = 0; i < m_NumVariable; ++i)
109  {
110  m_Forcing[i] = Array<OneD, NekDouble> (nq, 0.0);
111  s_FieldStr = m_session->GetVariable(i);
112  ASSERTL0(m_session->DefinesFunction(funcName, s_FieldStr),
113  "Variable '" + s_FieldStr + "' not defined.");
114  EvaluateFunction(pFields, m_session, s_FieldStr,
115  m_Forcing[i], funcName);
116  }
117 
118  bool singleMode, halfMode;
119  m_session->MatchSolverInfo("ModeType","SingleMode",singleMode,false);
120  m_session->MatchSolverInfo("ModeType","HalfMode", halfMode, false);
121  bool homogeneous = pFields[0]->GetExpType() == MultiRegions::e3DH1D;
122 
123  // If singleMode or halfMode, transform the forcing term to be in
124  // physical space in the plane, but Fourier space in the homogeneous
125  // direction
126  if (singleMode || halfMode || homogeneous)
127  {
128  for (int i = 0; i < m_NumVariable; ++i)
129  {
130  pFields[0]->HomogeneousFwdTrans(m_Forcing[i],m_Forcing[i]);
131  }
132  }
133  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:97
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
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:149
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:95
int m_NumVariable
Number of variables.
Definition: Forcing.h:99
LibUtilities::EquationSharedPtr m_timeFcnEqn
Definition: ForcingBody.h:92

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::classNameBody
static
Initial value:
RegisterCreatorFunction("Body",
"Body Forcing")

Name of the class.

Definition at line 72 of file ForcingBody.h.

std::string Nektar::SolverUtils::ForcingBody::classNameField
static
Initial value:
RegisterCreatorFunction("Field",
"Field Forcing")

Definition at line 73 of file ForcingBody.h.

bool Nektar::SolverUtils::ForcingBody::m_hasTimeFcnScaling
private

Definition at line 89 of file ForcingBody.h.

Referenced by v_Apply(), and v_InitObject().

LibUtilities::EquationSharedPtr Nektar::SolverUtils::ForcingBody::m_timeFcnEqn
private

Definition at line 92 of file ForcingBody.h.

Referenced by v_Apply(), and v_InitObject().