Nektar++
Filter.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Filter.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Base class for filters.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_SOLVERUTILS_FILTER_FILTER_H
36#define NEKTAR_SOLVERUTILS_FILTER_FILTER_H
37
43
45
46namespace Nektar::SolverUtils
47{
48class Filter;
49class EquationSystem;
50
51/// A shared pointer to a Driver object
52typedef std::shared_ptr<Filter> FilterSharedPtr;
53
54/// Datatype of the NekFactory used to instantiate classes derived from
55/// the Driver class.
56typedef LibUtilities::NekFactory<std::string, Filter,
58 const std::shared_ptr<EquationSystem> &,
59 const std::map<std::string, std::string> &>
62
63class Filter
64{
65public:
66 typedef std::map<std::string, std::string> ParamMap;
69 const std::shared_ptr<EquationSystem> &pEquation);
71
74 const NekDouble &time);
75 SOLVER_UTILS_EXPORT inline void Update(
77 const NekDouble &time);
78 SOLVER_UTILS_EXPORT inline void Finalise(
80 const NekDouble &time);
82 SOLVER_UTILS_EXPORT inline std::string SetupOutput(const std::string ext,
83 const ParamMap &pParams);
84 SOLVER_UTILS_EXPORT inline std::string SetupOutput(
85 const std::string ext, const std::string inname);
86
88 {
90 }
91
92protected:
94 const std::weak_ptr<EquationSystem> m_equ;
96
97 virtual void v_Initialise(
99 const NekDouble &time) = 0;
100 virtual void v_Update(
102 const NekDouble &time) = 0;
103 virtual void v_Finalise(
105 const NekDouble &time) = 0;
106 virtual bool v_IsTimeDependent() = 0;
107 SOLVER_UTILS_EXPORT virtual std::string v_SetupOutput(
108 const std::string ext, const ParamMap &pParams);
109 SOLVER_UTILS_EXPORT virtual std::string v_SetupOutput(
110 const std::string ext, const std::string inname);
111};
112
115 const NekDouble &time)
116{
117 v_Initialise(pFields, time);
118}
119
120inline void Filter::Update(
122 const NekDouble &time)
123{
124 v_Update(pFields, time);
125}
126
129 const NekDouble &time)
130{
131 v_Finalise(pFields, time);
132}
133
135{
136 return v_IsTimeDependent();
137}
138
139inline std::string Filter::SetupOutput(const std::string ext,
140 const ParamMap &pParams)
141{
142 return v_SetupOutput(ext, pParams);
143}
144inline std::string Filter::SetupOutput(const std::string ext,
145 const std::string inname)
146{
147 return v_SetupOutput(ext, inname);
148}
149} // namespace Nektar::SolverUtils
150#endif /* NEKTAR_SOLVERUTILS_FILTER_FILTER_H */
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
SOLVER_UTILS_EXPORT std::string SetupOutput(const std::string ext, const ParamMap &pParams)
Definition: Filter.h:139
virtual void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)=0
SOLVER_UTILS_EXPORT void Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
Definition: Filter.h:127
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:93
const std::weak_ptr< EquationSystem > m_equ
Definition: Filter.h:94
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)=0
SOLVER_UTILS_EXPORT void SetUpdateOnInitialise(bool flag)
Definition: Filter.h:87
SOLVER_UTILS_EXPORT void Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
Definition: Filter.h:113
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation)
SOLVER_UTILS_EXPORT bool IsTimeDependent()
Definition: Filter.h:134
virtual bool v_IsTimeDependent()=0
virtual SOLVER_UTILS_EXPORT ~Filter()
std::map< std::string, std::string > ParamMap
Definition: Filter.h:66
virtual SOLVER_UTILS_EXPORT std::string v_SetupOutput(const std::string ext, const ParamMap &pParams)
virtual void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)=0
SOLVER_UTILS_EXPORT void Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
Definition: Filter.h:120
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:52
FilterFactory & GetFilterFactory()
LibUtilities::NekFactory< std::string, Filter, const LibUtilities::SessionReaderSharedPtr &, const std::shared_ptr< EquationSystem > &, const std::map< std::string, std::string > & > FilterFactory
Datatype of the NekFactory used to instantiate classes derived from the Driver class.
Definition: Filter.h:60
double NekDouble