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

#include <FilterThresholdMin.h>

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

Public Member Functions

SOLVER_UTILS_EXPORT FilterThresholdMin (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
 
virtual SOLVER_UTILS_EXPORT ~FilterThresholdMin ()
 
- 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 ParamMap &pParams)
 Creates an instance of this class. More...
 

Static Public Attributes

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

Protected Member Functions

virtual SOLVER_UTILS_EXPORT void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 Initialises the filter. More...
 
virtual SOLVER_UTILS_EXPORT void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 For each point in domain test if solution is below threshold. More...
 
virtual SOLVER_UTILS_EXPORT void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 Finalise the filter and write out data. More...
 
virtual SOLVER_UTILS_EXPORT 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 drops below 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< FilterThresholdMin >
 

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 FilterThresholdMin.h.

Constructor & Destructor Documentation

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

Definition at line 51 of file FilterThresholdMin.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.

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

Definition at line 110 of file FilterThresholdMin.cpp.

111 {
112 
113 }

Member Function Documentation

static FilterSharedPtr Nektar::SolverUtils::FilterThresholdMin::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)
inlinestatic

Creates an instance of this class.

Definition at line 52 of file FilterThresholdMin.h.

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

55  {
56  FilterSharedPtr p =
58  pSession, pParams);
59  return p;
60  }
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::FilterThresholdMin::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 157 of file FilterThresholdMin.cpp.

References m_fld, m_outputFile, and m_threshold.

160 {
161  std::stringstream vOutputFilename;
162  vOutputFilename << m_outputFile << ".fld";
163 
164  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
165  = pFields[0]->GetFieldDefinitions();
166  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
167 
168  Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
169  pFields[0]->FwdTrans_IterPerExp(m_threshold, vCoeffs);
170 
171  // copy Data into FieldData and set variable
172  for(int i = 0; i < FieldDef.size(); ++i)
173  {
174  // Could do a search here to find correct variable
175  FieldDef[i]->m_fields.push_back("m");
176  pFields[0]->AppendFieldData(FieldDef[i], FieldData[i], vCoeffs);
177  }
178 
179  m_fld->Write(vOutputFilename.str(),FieldDef,FieldData);
180 }
std::string m_outputFile
File into which to write output data.
LibUtilities::FieldIOSharedPtr m_fld
FieldIO object for writing data.
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain drops below threshold.
void Nektar::SolverUtils::FilterThresholdMin::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Initialises the filter.

Implements Nektar::SolverUtils::Filter.

Definition at line 119 of file FilterThresholdMin.cpp.

References m_initialValue, m_threshold, and m_thresholdVar.

122 {
124  pFields[m_thresholdVar]->GetNpoints(), m_initialValue);
125 }
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_initialValue
Initial value of storage.
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain drops below threshold.
bool Nektar::SolverUtils::FilterThresholdMin::v_IsTimeDependent ( )
protectedvirtual

Indicate that this filter is time dependent.

Implements Nektar::SolverUtils::Filter.

Definition at line 186 of file FilterThresholdMin.cpp.

187 {
188  return true;
189 }
void Nektar::SolverUtils::FilterThresholdMin::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

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

Implements Nektar::SolverUtils::Filter.

Definition at line 131 of file FilterThresholdMin.cpp.

References m_startTime, m_threshold, m_thresholdValue, and m_thresholdVar.

134 {
135  if (time < m_startTime)
136  {
137  return;
138  }
139 
140  int i;
141  NekDouble timestep = pFields[m_thresholdVar]->GetSession()->GetParameter("TimeStep");
142 
143  for (i = 0; i < pFields[m_thresholdVar]->GetNpoints(); ++i)
144  {
145  if (m_threshold[i] < timestep &&
146  pFields[m_thresholdVar]->GetPhys()[i] > m_thresholdValue)
147  {
148  m_threshold[i] = time;
149  }
150  }
151 }
NekDouble m_startTime
Time at which to start recording.
NekDouble m_thresholdValue
Value of threshold.
int m_thresholdVar
Variable on which to detect threshold.
double NekDouble
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain drops below threshold.

Friends And Related Function Documentation

friend class MemoryManager< FilterThresholdMin >
friend

Definition at line 49 of file FilterThresholdMin.h.

Member Data Documentation

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

Name of the class.

Definition at line 63 of file FilterThresholdMin.h.

LibUtilities::FieldIOSharedPtr Nektar::SolverUtils::FilterThresholdMin::m_fld
private

FieldIO object for writing data.

Definition at line 100 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Finalise().

NekDouble Nektar::SolverUtils::FilterThresholdMin::m_initialValue
private

Initial value of storage.

Definition at line 96 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Initialise().

std::string Nektar::SolverUtils::FilterThresholdMin::m_outputFile
private

File into which to write output data.

Definition at line 98 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Finalise().

NekDouble Nektar::SolverUtils::FilterThresholdMin::m_startTime
private

Time at which to start recording.

Definition at line 90 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Update().

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

Storage for recording when each point in domain drops below threshold.

Definition at line 88 of file FilterThresholdMin.h.

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

NekDouble Nektar::SolverUtils::FilterThresholdMin::m_thresholdValue
private

Value of threshold.

Definition at line 92 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Update().

int Nektar::SolverUtils::FilterThresholdMin::m_thresholdVar
private

Variable on which to detect threshold.

Definition at line 94 of file FilterThresholdMin.h.

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