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

Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

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

Detailed Description

Definition at line 43 of file FilterThresholdMin.h.

Constructor & Destructor Documentation

◆ FilterThresholdMin()

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

Definition at line 49 of file FilterThresholdMin.cpp.

52 : Filter(pSession, pEquation)
53{
54 // ThresholdValue
55 auto it = pParams.find("ThresholdValue");
56 ASSERTL0(it != pParams.end(), "Missing parameter 'ThresholdValue'.");
57 LibUtilities::Equation equ1(m_session->GetInterpreter(), 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->GetInterpreter(), 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->GetInterpreter(), 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");
86 if (it != pParams.end())
87 {
88 std::string var = it->second.c_str();
89 std::vector<string> varlist = pSession->GetVariables();
90 auto x = std::find(varlist.begin(), varlist.end(), var);
91 ASSERTL0(x != varlist.end(),
92 "Specified variable " + var +
93 " in ThresholdMin filter is not available.");
94 m_thresholdVar = x - varlist.begin();
95 }
96
98}
#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
NekDouble m_thresholdValue
Value of threshold.
LibUtilities::FieldIOSharedPtr m_fld
FieldIO object for writing data.
NekDouble m_initialValue
Initial value of storage.
std::string m_outputFile
File into which to write output data.
int m_thresholdVar
Variable on which to detect threshold.
NekDouble m_startTime
Time at which to start recording.
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.

◆ ~FilterThresholdMin()

Nektar::SolverUtils::FilterThresholdMin::~FilterThresholdMin ( )
override

Definition at line 103 of file FilterThresholdMin.cpp.

104{
105}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 49 of file FilterThresholdMin.h.

52 {
55 pSession, pEquation, pParams);
56 return p;
57 }
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::FilterThresholdMin::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 147 of file FilterThresholdMin.cpp.

150{
151 std::stringstream vOutputFilename;
152 vOutputFilename << m_outputFile << ".fld";
153
154 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
155 pFields[0]->GetFieldDefinitions();
156 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
157
158 Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
159 pFields[0]->FwdTransLocalElmt(m_threshold, vCoeffs);
160
161 // copy Data into FieldData and set variable
162 for (int i = 0; i < FieldDef.size(); ++i)
163 {
164 // Could do a search here to find correct variable
165 FieldDef[i]->m_fields.push_back("m");
166 pFields[0]->AppendFieldData(FieldDef[i], FieldData[i], vCoeffs);
167 }
168
169 m_fld->Write(vOutputFilename.str(), FieldDef, FieldData);
170}
Array< OneD, NekDouble > m_threshold
Storage for recording when each point in domain drops below threshold.

References m_fld, m_outputFile, and m_threshold.

◆ v_Initialise()

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

Initialises the filter.

Implements Nektar::SolverUtils::Filter.

Definition at line 110 of file FilterThresholdMin.cpp.

113{
114 m_threshold = Array<OneD, NekDouble>(pFields[m_thresholdVar]->GetNpoints(),
116}

References m_initialValue, m_threshold, and m_thresholdVar.

◆ v_IsTimeDependent()

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

Indicate that this filter is time dependent.

Implements Nektar::SolverUtils::Filter.

Definition at line 175 of file FilterThresholdMin.cpp.

176{
177 return true;
178}

◆ v_Update()

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

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

Implements Nektar::SolverUtils::Filter.

Definition at line 121 of file FilterThresholdMin.cpp.

124{
125 if (time < m_startTime)
126 {
127 return;
128 }
129
130 int i;
131 NekDouble timestep =
132 pFields[m_thresholdVar]->GetSession()->GetParameter("TimeStep");
133
134 for (i = 0; i < pFields[m_thresholdVar]->GetNpoints(); ++i)
135 {
136 if (m_threshold[i] < timestep &&
137 pFields[m_thresholdVar]->GetPhys()[i] > m_thresholdValue)
138 {
139 m_threshold[i] = time;
140 }
141 }
142}
double NekDouble

References m_startTime, m_threshold, m_thresholdValue, and m_thresholdVar.

Friends And Related Function Documentation

◆ MemoryManager< FilterThresholdMin >

friend class MemoryManager< FilterThresholdMin >
friend

Definition at line 1 of file FilterThresholdMin.h.

Member Data Documentation

◆ className

std::string Nektar::SolverUtils::FilterThresholdMin::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 ParamMap &pParams)
Creates an instance of this class.
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:39

Name of the class.

Definition at line 60 of file FilterThresholdMin.h.

◆ m_fld

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

FieldIO object for writing data.

Definition at line 98 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Finalise().

◆ m_initialValue

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

Initial value of storage.

Definition at line 94 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Initialise().

◆ m_outputFile

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

File into which to write output data.

Definition at line 96 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Finalise().

◆ m_startTime

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

Time at which to start recording.

Definition at line 88 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Update().

◆ m_threshold

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

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

Definition at line 86 of file FilterThresholdMin.h.

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

◆ m_thresholdValue

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

Value of threshold.

Definition at line 90 of file FilterThresholdMin.h.

Referenced by FilterThresholdMin(), and v_Update().

◆ m_thresholdVar

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

Variable on which to detect threshold.

Definition at line 92 of file FilterThresholdMin.h.

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