Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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...
 
SOLVER_UTILS_EXPORT const
Array< OneD, const Array< OneD,
NekDouble > > & 
GetForces ()
 
SOLVER_UTILS_EXPORT Array
< OneD, Array< OneD, NekDouble > > & 
UpdateForces ()
 
- 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 51 of file ForcingNoise.cpp.

53  : Forcing(pSession)
54  {
55  }
SOLVER_UTILS_EXPORT Forcing(const LibUtilities::SessionReaderSharedPtr &)
Constructor.
Definition: Forcing.cpp:53
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(), Nektar::SolverUtils::ForcingSharedPtr, and CellMLToNektar.cellml_metadata::p.

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

118  {
119  // Do not apply forcing if exceeded m_numSteps
120  if( m_numSteps && (m_index >= m_numSteps) )
121  {
122  return;
123  }
124 
125  // Update forcing (change seed to avoid getting same result)
127  {
128  for (int i = 0; i < m_NumVariable; ++i)
129  {
130  Vmath::FillWhiteNoise(outarray[i].num_elements(),
131  m_noise,m_Forcing[i],1);
132  }
133  }
134 
135  // Apply forcing
136  for (int i = 0; i < m_NumVariable; i++)
137  {
138  Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1,
139  m_Forcing[i], 1, outarray[i], 1);
140  }
141 
142  ++m_index;
143  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:102
int m_NumVariable
Number of variables.
Definition: Forcing.h:104
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:299
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 57 of file ForcingNoise.cpp.

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

61  {
62  m_NumVariable = pNumForcingFields;
63  int nq = pFields[0]->GetTotPoints();
64 
65  const TiXmlElement* noiseElmt = pForce->FirstChildElement("WHITENOISE");
66  ASSERTL0(noiseElmt, "Requires WHITENOISE tag specifying "
67  "magnitude of white noise force.");
68 
69  string noiseValue = noiseElmt->GetText();
70 
71  m_noise = boost::lexical_cast<NekDouble>(noiseValue);
72 
73  // Load optional parameters
74  const TiXmlElement* freqElmt = pForce->FirstChildElement("UPDATEFREQ");
75  if (freqElmt)
76  {
77  string freqValue = freqElmt->GetText();
78  m_updateFreq = boost::lexical_cast<int>(freqValue);
79  }
80  else
81  {
82  // Default is 0 (never update forcing)
83  m_updateFreq = 0;
84  }
85 
86  const TiXmlElement* stepsElmt = pForce->FirstChildElement("NSTEPS");
87  if (stepsElmt)
88  {
89  string stepsValue = stepsElmt->GetText();
90  m_numSteps = boost::lexical_cast<int>(stepsValue);
91  }
92  else
93  {
94  // Default is 0 (use noise in the entire simulation)
95  m_numSteps = 0;
96  }
97 
98  m_Forcing = Array<OneD, Array<OneD, NekDouble> > (m_NumVariable);
99 
100  // Fill forcing: use rank in seed to avoid repeated results
101  int seed = - m_session->GetComm()->GetRank();
102  m_Forcing[0] = Array<OneD, NekDouble> (nq, 0.0);
104  for (int i = 1; i < m_NumVariable; ++i)
105  {
106  m_Forcing[i] = Array<OneD, NekDouble> (nq, 0.0);
108  }
109 
110  m_index = 0;
111  }
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:102
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
double NekDouble
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:100
int m_NumVariable
Number of variables.
Definition: Forcing.h:104
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().