Nektar++
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 std::map< std::string, std::string > &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 = GetFilterFactory().RegisterCreatorFunction("ThresholdMax", FilterThresholdMax::create)
 Name of the class. More...
 

Protected Member Functions

virtual void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual bool v_IsTimeDependent ()
 

Private Attributes

Array< OneD, NekDoublem_threshold
 
NekDouble m_startTime
 
NekDouble m_thresholdValue
 
int m_thresholdVar
 
NekDouble m_initialValue
 
std::string m_outputFile
 
LibUtilities::FieldIOSharedPtr m_fld
 

Friends

class MemoryManager< FilterThresholdMax >
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::SolverUtils::Filter
LibUtilities::SessionReaderSharedPtr m_session
 

Detailed Description

Definition at line 45 of file FilterThresholdMax.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file FilterThresholdMax.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::StdRegions::find(), m_fld, m_initialValue, m_outputFile, m_startTime, m_thresholdValue, and m_thresholdVar.

46  :
47  Filter(pSession)
48  {
49  ASSERTL0(pParams.find("ThresholdValue") != pParams.end(),
50  "Missing parameter 'ThresholdValue'.");
51  m_thresholdValue = atof(pParams.find("ThresholdValue")->second.c_str());
52  ASSERTL0(pParams.find("InitialValue") != pParams.end(),
53  "Missing parameter 'InitialValue'.");
54  m_initialValue = atof(pParams.find("InitialValue")->second.c_str());
55 
56  if (pParams.find("StartTime") != pParams.end())
57  {
58  m_startTime = atof(pParams.find("StartTime")->second.c_str());
59  }
60 
61  m_outputFile = pSession->GetSessionName() + "_max.fld";
62  if (pParams.find("OutputFile") != pParams.end())
63  {
64  m_outputFile = pParams.find("OutputFile")->second;
65  }
66 
67  m_thresholdVar = 0;
68  if (pParams.find("ThresholdVar") != pParams.end())
69  {
70  std::string var = pParams.find("ThresholdVar")->second.c_str();
71  std::vector<string> varlist = pSession->GetVariables();
72  std::vector<string>::const_iterator x;
73  ASSERTL0((x=std::find(varlist.begin(), varlist.end(), var)) != varlist.end(),
74  "Specified variable " + var +
75  " in ThresholdMax filter is not available.");
76  m_thresholdVar = x - varlist.begin();
77  }
78 
80 
81  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:135
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Filter.cpp:52
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
LibUtilities::FieldIOSharedPtr m_fld
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:312
Nektar::SolverUtils::FilterThresholdMax::~FilterThresholdMax ( )
virtual

Definition at line 83 of file FilterThresholdMax.cpp.

84  {
85 
86  }

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

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

53  {
55  //p->InitObject();
56  return p;
57  }
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

Implements Nektar::SolverUtils::Filter.

Definition at line 112 of file FilterThresholdMax.cpp.

References m_fld, m_outputFile, m_threshold, and m_thresholdVar.

113  {
114  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
115  = pFields[m_thresholdVar]->GetFieldDefinitions();
116  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
117 
118  Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
119  pFields[m_thresholdVar]->FwdTrans_IterPerExp(m_threshold, vCoeffs);
120 
121  // copy Data into FieldData and set variable
122  for(int i = 0; i < FieldDef.size(); ++i)
123  {
124  // Could do a search here to find correct variable
125  FieldDef[i]->m_fields.push_back("m");
126  pFields[m_thresholdVar]->AppendFieldData(FieldDef[i], FieldData[i], vCoeffs);
127  }
128 
129  m_fld->Write(m_outputFile,FieldDef,FieldData);
130 
131  }
LibUtilities::FieldIOSharedPtr m_fld
void Nektar::SolverUtils::FilterThresholdMax::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual
bool Nektar::SolverUtils::FilterThresholdMax::v_IsTimeDependent ( )
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 133 of file FilterThresholdMax.cpp.

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

Implements Nektar::SolverUtils::Filter.

Definition at line 93 of file FilterThresholdMax.cpp.

References m_startTime, m_threshold, m_thresholdValue, and m_thresholdVar.

94  {
95  if (time < m_startTime)
96  {
97  return;
98  }
99 
100  int i;
101  NekDouble timestep = pFields[m_thresholdVar]->GetSession()->GetParameter("TimeStep");
102 
103  for (i = 0; i < pFields[m_thresholdVar]->GetNpoints(); ++i)
104  {
105  if (m_threshold[i] < timestep && pFields[m_thresholdVar]->GetPhys()[i] > m_thresholdValue)
106  {
107  m_threshold[i] = time;
108  }
109  }
110  }
double NekDouble

Friends And Related Function Documentation

friend class MemoryManager< FilterThresholdMax >
friend

Definition at line 48 of file FilterThresholdMax.h.

Member Data Documentation

std::string Nektar::SolverUtils::FilterThresholdMax::className = GetFilterFactory().RegisterCreatorFunction("ThresholdMax", FilterThresholdMax::create)
static

Name of the class.

Definition at line 60 of file FilterThresholdMax.h.

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

Definition at line 80 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

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

Definition at line 78 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Initialise().

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

Definition at line 79 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

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

Definition at line 75 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

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

Definition at line 74 of file FilterThresholdMax.h.

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

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

Definition at line 76 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

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

Definition at line 77 of file FilterThresholdMax.h.

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