49 const std::shared_ptr<EquationSystem> &pEquation,
51 :
Filter(pSession, pEquation), m_index(-1), m_homogeneous(false), m_planes()
56 auto it = pParams.find(
"OutputFile");
57 if (it == pParams.end())
63 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
68 m_comm = pSession->GetComm();
69 if (
m_comm->GetRank() == 0)
73 m_outFile.setf(ios::scientific, ios::floatfield);
75 <<
"Enstrophy" << endl
76 <<
"# ---------------------------------------------"
77 <<
"--------------" << endl;
82 it = pParams.find(
"OutputFrequency");
83 ASSERTL0(it != pParams.end(),
"Missing parameter 'OutputFrequency'.");
100 "1D expansion not supported for energy filter");
103 "2D expansion not supported for energy filter");
106 "Homogeneous 2D expansion not supported for energy filter");
117 areaField = pFields[0]->GetPlane(0);
121 areaField = pFields[0];
125 m_area = areaField->Integral(inarray);
140 int i, nPoints = pFields[0]->GetNpoints();
150 auto equ =
m_equ.lock();
151 ASSERTL0(equ,
"Weak pointer expired");
153 auto fluidEqu = std::dynamic_pointer_cast<FluidInterface>(equ);
154 ASSERTL0(fluidEqu,
"Energy filter is incompatible with this solver.");
158 for (i = 0; i < pFields.size(); ++i)
160 physfields[i] = pFields[i]->GetPhys();
168 for (i = 0; i < 3; ++i)
172 fluidEqu->GetVelocity(physfields, u);
174 for (i = 0; i < 3; ++i)
178 pFields[i]->HomogeneousBwdTrans(nPoints, u[i], u[i]);
181 Vmath::Vvtvp(nPoints, u[i], 1, u[i], 1, tmp, 1, tmp, 1);
184 if (!fluidEqu->HasConstantDensity())
187 fluidEqu->GetDensity(physfields, density);
194 pFields[0]->HomogeneousFwdTrans(nPoints, tmp, tmp2);
199 Ek = pFields[0]->Integral(tmp);
204 if (
m_comm->GetRank() == 0)
206 m_outFile << setw(17) << setprecision(8) << time << setw(22)
207 << setprecision(11) << Ek;
210 bool waveSpace[3] = {pFields[0]->GetWaveSpace(), pFields[1]->GetWaveSpace(),
211 pFields[2]->GetWaveSpace()};
215 for (i = 0; i < 3; ++i)
217 pFields[i]->SetWaveSpace(
false);
224 for (i = 0; i < 3; ++i)
226 int f1 = (i + 2) % 3, c2 = f1;
227 int c1 = (i + 1) % 3, f2 = c1;
228 pFields[f1]->PhysDeriv(c1, u[f1], tmp2);
229 pFields[f2]->PhysDeriv(c2, u[f2], tmp3);
231 Vmath::Vvtvp(nPoints, tmp2, 1, tmp2, 1, tmp, 1, tmp, 1);
234 if (!fluidEqu->HasConstantDensity())
241 for (i = 0; i < 3; ++i)
243 pFields[i]->SetWaveSpace(waveSpace[i]);
245 pFields[0]->HomogeneousFwdTrans(nPoints, tmp, tmp);
250 Ek = pFields[0]->Integral(tmp);
255 if (
m_comm->GetRank() == 0)
257 m_outFile << setw(22) << setprecision(11) << Ek << endl;
#define ASSERTL0(condition, msg)
NekDouble Evaluate() const
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
SOLVER_UTILS_EXPORT void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
SOLVER_UTILS_EXPORT void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
static std::string className
Name of the class.
SOLVER_UTILS_EXPORT void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pField, const NekDouble &time) override
LibUtilities::CommSharedPtr m_comm
SOLVER_UTILS_EXPORT FilterEnergy(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
Array< OneD, unsigned int > m_planes
NekDouble m_homogeneousLength
SOLVER_UTILS_EXPORT ~FilterEnergy() override
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< SolverUtils::EquationSystem > &pEquation, const ParamMap &pParams)
Creates an instance of this class.
unsigned int m_outputFrequency
SOLVER_UTILS_EXPORT bool v_IsTimeDependent() override
LibUtilities::SessionReaderSharedPtr m_session
const std::weak_ptr< EquationSystem > m_equ
std::map< std::string, std::string > ParamMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
FilterFactory & GetFilterFactory()
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Zero(int n, T *x, const int incx)
Zero vector.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.