Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
Nektar::SolverUtils::FilterThresholdMax Class Reference

#include <FilterThresholdMax.h>

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

Public Member Functions

SOLVER_UTILS_EXPORT FilterThresholdMax (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
 
virtual SOLVER_UTILS_EXPORT ~FilterThresholdMax ()
 
- Public Member Functions inherited from Nektar::SolverUtils::Filter
SOLVER_UTILS_EXPORT Filter (const LibUtilities::SessionReaderSharedPtr &pSession)
 
virtual SOLVER_UTILS_EXPORT ~Filter ()
 
SOLVER_UTILS_EXPORT void Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT void Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT void Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT bool IsTimeDependent ()
 

Static Public Member Functions

static FilterSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
 Creates an instance of this class. More...
 

Static Public Attributes

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

Protected Member Functions

virtual void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 Initialises the filter. More...
 
virtual void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 For each point in domain test if solution is above threshold. More...
 
virtual void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 Finalise the filter and write out data. More...
 
virtual bool v_IsTimeDependent ()
 Indicate that this filter is time dependent. More...
 

Private Attributes

Array< OneD, NekDoublem_threshold
 Storage for recording when each point in domain rises above threshold. More...
 
NekDouble m_startTime
 Time at which to start recording. More...
 
NekDouble m_thresholdValue
 Value of threshold. More...
 
int m_thresholdVar
 Variable on which to detect threshold. More...
 
NekDouble m_initialValue
 Initial value of storage. More...
 
std::string m_outputFile
 File into which to write output data. More...
 
LibUtilities::FieldIOSharedPtr m_fld
 FieldIO object for writing data. More...
 

Friends

class MemoryManager< FilterThresholdMax >
 

Additional Inherited Members

- Public Types inherited from Nektar::SolverUtils::Filter
typedef std::map< std::string,
std::string > 
ParamMap
 
- Protected Attributes inherited from Nektar::SolverUtils::Filter
LibUtilities::SessionReaderSharedPtr m_session
 

Detailed Description

Definition at line 46 of file FilterThresholdMax.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::FilterThresholdMax::FilterThresholdMax ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)

Definition at line 47 of file FilterThresholdMax.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::Equation::Evaluate(), Nektar::StdRegions::find(), m_fld, m_initialValue, m_outputFile, Nektar::SolverUtils::Filter::m_session, m_startTime, m_thresholdValue, and m_thresholdVar.

49  :
50  Filter(pSession)
51 {
52  ParamMap::const_iterator it;
53 
54  // ThresholdValue
55  it = pParams.find("ThresholdValue");
56  ASSERTL0(it != pParams.end(), "Missing parameter 'ThresholdValue'.");
57  LibUtilities::Equation equ1(m_session, it->second);
58  m_thresholdValue = equ1.Evaluate();
59 
60  // InitialValue
61  it = pParams.find("InitialValue");
62  ASSERTL0(it != pParams.end(), "Missing parameter 'InitialValue'.");
63  LibUtilities::Equation equ2(m_session, it->second);
64  m_initialValue = equ2.Evaluate();
65 
66  // StartTime
67  it = pParams.find("StartTime");
68  m_startTime = 0.0;
69  if (it != pParams.end())
70  {
71  LibUtilities::Equation equ(m_session, it->second);
72  m_startTime = equ.Evaluate();
73  }
74 
75  // OutputFile
76  it = pParams.find("OutputFile");
77  m_outputFile = pSession->GetSessionName() + "_max.fld";
78  if (it != pParams.end())
79  {
80  m_outputFile = it->second;
81  }
82 
83  // ThresholdVar
84  it = pParams.find("ThresholdVar");
85  m_thresholdVar = 0;
86  if (it != pParams.end())
87  {
88  std::string var = it->second.c_str();
89  std::vector<string> varlist = pSession->GetVariables();
90  std::vector<string>::const_iterator x;
91  ASSERTL0((x=std::find(varlist.begin(), varlist.end(), var))
92  != varlist.end(),
93  "Specified variable " + var +
94  " in ThresholdMax filter is not available.");
95  m_thresholdVar = x - varlist.begin();
96  }
97 
99  ::AllocateSharedPtr(pSession->GetComm());
100 
101 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
LibUtilities::FieldIOSharedPtr m_fld
FieldIO object for writing data.
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_initialValue
Initial value of storage.
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Filter.cpp:52
NekDouble m_thresholdValue
Value of threshold.
NekDouble m_startTime
Time at which to start recording.
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
std::string m_outputFile
File into which to write output data.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:315
Nektar::SolverUtils::FilterThresholdMax::~FilterThresholdMax ( )
virtual

Definition at line 103 of file FilterThresholdMax.cpp.

104 {
105 
106 }

Member Function Documentation

static FilterSharedPtr Nektar::SolverUtils::FilterThresholdMax::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::map< std::string, std::string > &  pParams 
)
inlinestatic

Creates an instance of this class.

Definition at line 52 of file FilterThresholdMax.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

54  {
56  //p->InitObject();
57  return p;
58  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:50
void Nektar::SolverUtils::FilterThresholdMax::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Finalise the filter and write out data.

Implements Nektar::SolverUtils::Filter.

Definition at line 138 of file FilterThresholdMax.cpp.

References m_fld, m_outputFile, m_threshold, and m_thresholdVar.

141 {
142  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
143  = pFields[m_thresholdVar]->GetFieldDefinitions();
144  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
145 
146  Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
147  pFields[m_thresholdVar]->FwdTrans_IterPerExp(m_threshold, vCoeffs);
148 
149  // copy Data into FieldData and set variable
150  for(int i = 0; i < FieldDef.size(); ++i)
151  {
152  // Could do a search here to find correct variable
153  FieldDef[i]->m_fields.push_back("m");
154  pFields[m_thresholdVar]->AppendFieldData(FieldDef[i], FieldData[i], vCoeffs);
155  }
156 
157  m_fld->Write(m_outputFile,FieldDef,FieldData);
158 
159 }
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain rises above threshold.
LibUtilities::FieldIOSharedPtr m_fld
FieldIO object for writing data.
int m_thresholdVar
Variable on which to detect threshold.
std::string m_outputFile
File into which to write output data.
void Nektar::SolverUtils::FilterThresholdMax::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Initialises the filter.

Implements Nektar::SolverUtils::Filter.

Definition at line 108 of file FilterThresholdMax.cpp.

References m_initialValue, m_threshold, and m_thresholdVar.

111 {
113  pFields[m_thresholdVar]->GetNpoints(), m_initialValue);
114 }
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain rises above threshold.
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_initialValue
Initial value of storage.
bool Nektar::SolverUtils::FilterThresholdMax::v_IsTimeDependent ( )
protectedvirtual

Indicate that this filter is time dependent.

Implements Nektar::SolverUtils::Filter.

Definition at line 161 of file FilterThresholdMax.cpp.

162 {
163  return true;
164 }
void Nektar::SolverUtils::FilterThresholdMax::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

For each point in domain test if solution is above threshold.

Implements Nektar::SolverUtils::Filter.

Definition at line 116 of file FilterThresholdMax.cpp.

References m_startTime, m_threshold, m_thresholdValue, and m_thresholdVar.

119 {
120  if (time < m_startTime)
121  {
122  return;
123  }
124 
125  int i;
126  NekDouble timestep = pFields[m_thresholdVar]->GetSession()->GetParameter("TimeStep");
127 
128  for (i = 0; i < pFields[m_thresholdVar]->GetNpoints(); ++i)
129  {
130  if (m_threshold[i] < timestep &&
131  pFields[m_thresholdVar]->GetPhys()[i] > m_thresholdValue)
132  {
133  m_threshold[i] = time;
134  }
135  }
136 }
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain rises above threshold.
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_thresholdValue
Value of threshold.
NekDouble m_startTime
Time at which to start recording.
double NekDouble

Friends And Related Function Documentation

friend class MemoryManager< FilterThresholdMax >
friend

Definition at line 49 of file FilterThresholdMax.h.

Member Data Documentation

std::string Nektar::SolverUtils::FilterThresholdMax::className
static
Initial value:

Name of the class.

Definition at line 61 of file FilterThresholdMax.h.

LibUtilities::FieldIOSharedPtr Nektar::SolverUtils::FilterThresholdMax::m_fld
private

FieldIO object for writing data.

Definition at line 98 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

NekDouble Nektar::SolverUtils::FilterThresholdMax::m_initialValue
private

Initial value of storage.

Definition at line 94 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Initialise().

std::string Nektar::SolverUtils::FilterThresholdMax::m_outputFile
private

File into which to write output data.

Definition at line 96 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

NekDouble Nektar::SolverUtils::FilterThresholdMax::m_startTime
private

Time at which to start recording.

Definition at line 88 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

Array<OneD, NekDouble> Nektar::SolverUtils::FilterThresholdMax::m_threshold
private

Storage for recording when each point in domain rises above threshold.

Definition at line 86 of file FilterThresholdMax.h.

Referenced by v_Finalise(), v_Initialise(), and v_Update().

NekDouble Nektar::SolverUtils::FilterThresholdMax::m_thresholdValue
private

Value of threshold.

Definition at line 90 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

int Nektar::SolverUtils::FilterThresholdMax::m_thresholdVar
private

Variable on which to detect threshold.

Definition at line 92 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), v_Finalise(), v_Initialise(), and v_Update().