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::ForcingNoise Class Reference

#include <ForcingNoise.h>

Inheritance diagram for Nektar::SolverUtils::ForcingNoise:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SolverUtils::ForcingNoise:
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 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))
 
SOLVER_UTILS_EXPORT void EvaluateTimeFunction (const NekDouble pTime, const LibUtilities::EquationSharedPtr &pEqn, Array< OneD, NekDouble > &pArray)
 

Private Member Functions

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

Private Attributes

int m_index
 
int m_updateFreq
 
int m_numSteps
 
NekDouble m_noise
 

Friends

class MemoryManager< ForcingNoise >
 

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 51 of file ForcingNoise.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file ForcingNoise.cpp.

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

Definition at line 87 of file ForcingNoise.h.

87 {};

Member Function Documentation

static SOLVER_UTILS_EXPORT ForcingSharedPtr Nektar::SolverUtils::ForcingNoise::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 58 of file ForcingNoise.h.

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

63  {
65  AllocateSharedPtr(pSession);
66  p->InitObject(pFields, pNumForcingFields, pForce);
67  return p;
68  }
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::ForcingNoise::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 108 of file ForcingNoise.cpp.

References Vmath::FillWhiteNoise(), Nektar::SolverUtils::Forcing::m_Forcing, m_index, m_noise, m_numSteps, Nektar::SolverUtils::Forcing::m_NumVariable, m_updateFreq, and Vmath::Vadd().

113  {
114  // Do not apply forcing if exceeded m_numSteps
115  if( m_numSteps && (m_index >= m_numSteps) )
116  {
117  return;
118  }
119 
120  // Update forcing (change seed to avoid getting same result)
122  {
123  for (int i = 0; i < m_NumVariable; ++i)
124  {
125  Vmath::FillWhiteNoise(outarray[i].num_elements(),
126  m_noise,&m_Forcing[i][0],1,
127  -m_index*m_NumVariable-i);
128  }
129  }
130 
131  // Apply forcing
132  for (int i = 0; i < m_NumVariable; i++)
133  {
134  Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1,
135  m_Forcing[i], 1, outarray[i], 1);
136  }
137 
138  ++m_index;
139  }
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 FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
Definition: Vmath.cpp:138
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::ForcingNoise::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 ForcingNoise.cpp.

References ASSERTL0, Vmath::FillWhiteNoise(), Nektar::SolverUtils::Forcing::m_Forcing, m_index, m_noise, m_numSteps, Nektar::SolverUtils::Forcing::m_NumVariable, and m_updateFreq.

59  {
60  m_NumVariable = pNumForcingFields;
61  int nq = pFields[0]->GetTotPoints();
62 
63  const TiXmlElement* noiseElmt = pForce->FirstChildElement("WHITENOISE");
64  ASSERTL0(noiseElmt, "Requires WHITENOISE tag specifying "
65  "magnitude of white noise force.");
66 
67  string noiseValue = noiseElmt->GetText();
68 
69  m_noise = boost::lexical_cast<NekDouble>(noiseValue);
70 
71  // Load optional parameters
72  const TiXmlElement* freqElmt = pForce->FirstChildElement("UPDATEFREQ");
73  if (freqElmt)
74  {
75  string freqValue = freqElmt->GetText();
76  m_updateFreq = boost::lexical_cast<int>(freqValue);
77  }
78  else
79  {
80  // Default is 0 (never update forcing)
81  m_updateFreq = 0;
82  }
83 
84  const TiXmlElement* stepsElmt = pForce->FirstChildElement("NSTEPS");
85  if (stepsElmt)
86  {
87  string stepsValue = stepsElmt->GetText();
88  m_numSteps = boost::lexical_cast<int>(stepsValue);
89  }
90  else
91  {
92  // Default is 0 (use noise in the entire simulation)
93  m_numSteps = 0;
94  }
95 
97 
98  // Fill forcing: use -i as seed to avoid repeated results
99  for (int i = 0; i < m_NumVariable; ++i)
100  {
101  m_Forcing[i] = Array<OneD, NekDouble> (nq, 0.0);
102  Vmath::FillWhiteNoise(nq,m_noise,&m_Forcing[i][0],1,-i);
103  }
104 
105  m_index = 0;
106  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:97
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
double NekDouble
int m_NumVariable
Number of variables.
Definition: Forcing.h:99
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
Definition: Vmath.cpp:138

Friends And Related Function Documentation

friend class MemoryManager< ForcingNoise >
friend

Definition at line 55 of file ForcingNoise.h.

Member Data Documentation

std::string Nektar::SolverUtils::ForcingNoise::className
static
Initial value:
RegisterCreatorFunction("Noise",
"White Noise Forcing")

Name of the class.

Definition at line 71 of file ForcingNoise.h.

int Nektar::SolverUtils::ForcingNoise::m_index
private

Definition at line 87 of file ForcingNoise.h.

Referenced by v_Apply(), and v_InitObject().

NekDouble Nektar::SolverUtils::ForcingNoise::m_noise
private

Definition at line 92 of file ForcingNoise.h.

Referenced by v_Apply(), and v_InitObject().

int Nektar::SolverUtils::ForcingNoise::m_numSteps
private

Definition at line 91 of file ForcingNoise.h.

Referenced by v_Apply(), and v_InitObject().

int Nektar::SolverUtils::ForcingNoise::m_updateFreq
private

Definition at line 90 of file ForcingNoise.h.

Referenced by v_Apply(), and v_InitObject().