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:
[legend]

Public Member Functions

SOLVER_UTILS_EXPORT FilterThresholdMax (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
 
SOLVER_UTILS_EXPORT ~FilterThresholdMax () override
 
- Public Member Functions inherited from Nektar::SolverUtils::Filter
SOLVER_UTILS_EXPORT Filter (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
 
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::weak_ptr< EquationSystem > &pEquation, 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

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

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
 
const std::weak_ptr< EquationSystemm_equ
 

Detailed Description

Definition at line 43 of file FilterThresholdMax.h.

Constructor & Destructor Documentation

◆ FilterThresholdMax()

Nektar::SolverUtils::FilterThresholdMax::FilterThresholdMax ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< EquationSystem > &  pEquation,
const ParamMap pParams 
)

Definition at line 46 of file FilterThresholdMax.cpp.

49 : Filter(pSession, pEquation)
50{
51 // ThresholdValue
52 auto it = pParams.find("ThresholdValue");
53 ASSERTL0(it != pParams.end(), "Missing parameter 'ThresholdValue'.");
54 LibUtilities::Equation equ1(m_session->GetInterpreter(), it->second);
55 m_thresholdValue = equ1.Evaluate();
56
57 // InitialValue
58 it = pParams.find("InitialValue");
59 ASSERTL0(it != pParams.end(), "Missing parameter 'InitialValue'.");
60 LibUtilities::Equation equ2(m_session->GetInterpreter(), it->second);
61 m_initialValue = equ2.Evaluate();
62
63 // StartTime
64 it = pParams.find("StartTime");
65 m_startTime = 0.0;
66 if (it != pParams.end())
67 {
68 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
69 m_startTime = equ.Evaluate();
70 }
71
72 // OutputFile
73 it = pParams.find("OutputFile");
74 m_outputFile = pSession->GetSessionName() + "_max.fld";
75 if (it != pParams.end())
76 {
77 m_outputFile = it->second;
78 }
79
80 // ThresholdVar
81 it = pParams.find("ThresholdVar");
83 if (it != pParams.end())
84 {
85 std::string var = it->second.c_str();
86 std::vector<string> varlist = pSession->GetVariables();
87 auto x = std::find(varlist.begin(), varlist.end(), var);
88 ASSERTL0(x != varlist.end(),
89 "Specified variable " + var +
90 " in ThresholdMax filter is not available.");
91 m_thresholdVar = x - varlist.begin();
92 }
93
95}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
Definition: FieldIO.cpp:195
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:83
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
Definition: Filter.cpp:45
LibUtilities::FieldIOSharedPtr m_fld
FieldIO object for writing data.
NekDouble m_startTime
Time at which to start recording.
std::string m_outputFile
File into which to write output data.
NekDouble m_initialValue
Initial value of storage.
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_thresholdValue
Value of threshold.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:447

References ASSERTL0, Nektar::LibUtilities::FieldIO::CreateDefault(), 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.

◆ ~FilterThresholdMax()

Nektar::SolverUtils::FilterThresholdMax::~FilterThresholdMax ( )
override

Definition at line 97 of file FilterThresholdMax.cpp.

98{
99}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 49 of file FilterThresholdMax.h.

53 {
56 pSession, pEquation, pParams);
57 return p;
58 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:51

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ v_Finalise()

void Nektar::SolverUtils::FilterThresholdMax::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

Finalise the filter and write out data.

Implements Nektar::SolverUtils::Filter.

Definition at line 132 of file FilterThresholdMax.cpp.

135{
136 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
137 pFields[m_thresholdVar]->GetFieldDefinitions();
138 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
139
140 Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
141 pFields[m_thresholdVar]->FwdTransLocalElmt(m_threshold, vCoeffs);
142
143 // copy Data into FieldData and set variable
144 for (int i = 0; i < FieldDef.size(); ++i)
145 {
146 // Could do a search here to find correct variable
147 FieldDef[i]->m_fields.push_back("m");
148 pFields[m_thresholdVar]->AppendFieldData(FieldDef[i], FieldData[i],
149 vCoeffs);
150 }
151
152 m_fld->Write(m_outputFile, FieldDef, FieldData);
153}
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain rises above threshold.

References m_fld, m_outputFile, m_threshold, and m_thresholdVar.

◆ v_Initialise()

void Nektar::SolverUtils::FilterThresholdMax::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

Initialises the filter.

Implements Nektar::SolverUtils::Filter.

Definition at line 101 of file FilterThresholdMax.cpp.

104{
105 m_threshold = Array<OneD, NekDouble>(pFields[m_thresholdVar]->GetNpoints(),
107}

References m_initialValue, m_threshold, and m_thresholdVar.

◆ v_IsTimeDependent()

bool Nektar::SolverUtils::FilterThresholdMax::v_IsTimeDependent ( )
overrideprotectedvirtual

Indicate that this filter is time dependent.

Implements Nektar::SolverUtils::Filter.

Definition at line 155 of file FilterThresholdMax.cpp.

156{
157 return true;
158}

◆ v_Update()

void Nektar::SolverUtils::FilterThresholdMax::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

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

Implements Nektar::SolverUtils::Filter.

Definition at line 109 of file FilterThresholdMax.cpp.

112{
113 if (time < m_startTime)
114 {
115 return;
116 }
117
118 int i;
119 NekDouble timestep =
120 pFields[m_thresholdVar]->GetSession()->GetParameter("TimeStep");
121
122 for (i = 0; i < pFields[m_thresholdVar]->GetNpoints(); ++i)
123 {
124 if (m_threshold[i] < timestep &&
125 pFields[m_thresholdVar]->GetPhys()[i] > m_thresholdValue)
126 {
127 m_threshold[i] = time;
128 }
129 }
130}
double NekDouble

References m_startTime, m_threshold, m_thresholdValue, and m_thresholdVar.

Friends And Related Function Documentation

◆ MemoryManager< FilterThresholdMax >

friend class MemoryManager< FilterThresholdMax >
friend

Definition at line 1 of file FilterThresholdMax.h.

Member Data Documentation

◆ className

std::string Nektar::SolverUtils::FilterThresholdMax::className
static
Initial value:
=
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
static FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const std::map< std::string, std::string > &pParams)
Creates an instance of this class.
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:39

Name of the class.

Definition at line 61 of file FilterThresholdMax.h.

◆ m_fld

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

FieldIO object for writing data.

Definition at line 99 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

◆ m_initialValue

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

Initial value of storage.

Definition at line 95 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Initialise().

◆ m_outputFile

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

File into which to write output data.

Definition at line 97 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Finalise().

◆ m_startTime

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

Time at which to start recording.

Definition at line 89 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

◆ m_threshold

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

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

Definition at line 87 of file FilterThresholdMax.h.

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

◆ m_thresholdValue

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

Value of threshold.

Definition at line 91 of file FilterThresholdMax.h.

Referenced by FilterThresholdMax(), and v_Update().

◆ m_thresholdVar

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

Variable on which to detect threshold.

Definition at line 93 of file FilterThresholdMax.h.

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