35#include <boost/core/ignore_unused.hpp>
58 const std::weak_ptr<EquationSystem> &pEquation,
const ParamMap &pParams)
59 :
Filter(pSession, pEquation), m_index(0)
61 ASSERTL0(pSession->GetComm()->GetSize() == 1,
62 "The 1D energy filter currently only works in serial.");
67 auto it = pParams.find(
"OutputFile");
68 if (it == pParams.end())
74 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
78 m_out.open(outName.c_str());
81 it = pParams.find(
"OutputFrequency");
82 if (it == pParams.end())
107 boost::ignore_unused(time);
108 ASSERTL0(pFields[0]->GetExp(0)->GetNumBases() == 1,
109 "The Energy 1D filter is only valid in 1D.");
126 int nElmt = pFields[0]->GetExpSize();
129 m_out <<
"##" << endl;
130 m_out <<
"## Time = " << time << endl;
131 m_out <<
"##" << endl;
133 for (
int i = 0; i < nElmt; ++i)
137 int nModes = exp->GetBasis(0)->GetNumModes();
142 exp->GetBasis(0)->GetPointsKey());
146 exp->GetBasis(0)->GetNumModes(),
147 exp->GetBasis(0)->GetPointsKey());
151 pFields[0]->GetCoeffs() + pFields[0]->GetCoeff_Offset(i);
160 m_out <<
"# Element " << i <<
" (ID " << exp->GetGeom()->GetGlobalID()
162 for (
int j = 0; j < nModes; ++j)
164 m_out << coeffsOrth[j] << endl;
174 boost::ignore_unused(pFields, time);
#define ASSERTL0(condition, msg)
Describes the specification for a Basis.
NekDouble Evaluate() const
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
virtual void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
Initialize filter.
static std::string className
Name of the class.
virtual bool v_IsTimeDependent() override
SOLVER_UTILS_EXPORT FilterEnergy1D(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
Set up filter with output file and frequency parameters.
unsigned int m_outputFrequency
Output frequency.
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
Update filter output with the current timestep's orthogonal coefficients.
unsigned int m_index
Current index counter.
SOLVER_UTILS_EXPORT ~FilterEnergy1D()
Destructor.
virtual void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
std::ofstream m_out
Output file.
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.
LibUtilities::SessionReaderSharedPtr m_session
std::map< std::string, std::string > ParamMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void InterpCoeff1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
@ eOrtho_A
Principle Orthogonal Functions .
std::shared_ptr< Expansion > ExpansionSharedPtr
FilterFactory & GetFilterFactory()
The above copyright notice and this permission notice shall be included.