54 const std::shared_ptr<EquationSystem> &pEquation,
const ParamMap &pParams)
55 :
Filter(pSession, pEquation), m_index(0)
57 ASSERTL0(pSession->GetComm()->GetSize() == 1,
58 "The 1D energy filter currently only works in serial.");
63 auto it = pParams.find(
"OutputFile");
64 if (it == pParams.end())
70 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
74 m_out.open(outName.c_str());
77 it = pParams.find(
"OutputFrequency");
78 if (it == pParams.end())
103 ASSERTL0(pFields[0]->GetExp(0)->GetNumBases() == 1,
104 "The Energy 1D filter is only valid in 1D.");
121 int nElmt = pFields[0]->GetExpSize();
124 m_out <<
"##" << endl;
125 m_out <<
"## Time = " << time << endl;
126 m_out <<
"##" << endl;
128 for (
int i = 0; i < nElmt; ++i)
132 int nModes = exp->GetBasis(0)->GetNumModes();
137 exp->GetBasis(0)->GetPointsKey());
141 exp->GetBasis(0)->GetNumModes(),
142 exp->GetBasis(0)->GetPointsKey());
146 pFields[0]->GetCoeffs() + pFields[0]->GetCoeff_Offset(i);
155 m_out <<
"# Element " << i <<
" (ID " << exp->GetGeom()->GetGlobalID()
157 for (
int j = 0; j < nModes; ++j)
159 m_out << coeffsOrth[j] << endl;
#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.
void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
Initialize filter.
static std::string className
Name of the class.
SOLVER_UTILS_EXPORT ~FilterEnergy1D() override
Destructor.
bool v_IsTimeDependent() override
unsigned int m_outputFrequency
Output frequency.
SOLVER_UTILS_EXPORT FilterEnergy1D(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
Set up filter with output file and frequency parameters.
void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
Update filter output with the current timestep's orthogonal coefficients.
static FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const std::map< std::string, std::string > &pParams)
Creates an instance of this class.
unsigned int m_index
Current index counter.
void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
std::ofstream m_out
Output file.
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()