Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
Nektar::SolverUtils::FilterModalEnergy Class Reference

#include <FilterModalEnergy.h>

Inheritance diagram for Nektar::SolverUtils::FilterModalEnergy:
[legend]

Public Member Functions

SOLVER_UTILS_EXPORT FilterModalEnergy (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
 
SOLVER_UTILS_EXPORT ~FilterModalEnergy () 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)
 

Static Public Attributes

static std::string className
 

Protected Member Functions

void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
 
void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
 
void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
 
bool v_IsTimeDependent () override
 
NekDouble L2Error (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, unsigned int field, const NekDouble &time)
 
void SetUpBaseFields (SpatialDomains::MeshGraphSharedPtr &mesh)
 
void ImportFldBase (std::string pInfile)
 
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

enum MultiRegions::ProjectionType m_projectionType
 
Array< OneD, MultiRegions::ExpListSharedPtrm_base
 
LibUtilities::FieldIOSharedPtr m_fld
 
std::vector< unsigned int > m_boundaryRegionsIdList
 
std::vector< bool > m_boundaryRegionIsInList
 
unsigned int m_index
 
unsigned int m_outputFrequency
 
unsigned int m_outputPlane
 
bool m_isHomogeneous1D
 
bool m_isHomogeneous2D
 
bool m_PertEnergy
 
int m_npointsZ
 
int m_nproc
 
std::string m_outputFile
 
std::string m_EqTypeStr
 
std::ofstream m_outputStream
 
LibUtilities::BasisSharedPtr m_homogeneousBasis
 
std::string m_BoundaryString
 
int m_nplanes
 
int m_NumQuadPointsError
 
bool m_SingleMode
 
bool m_HalfMode
 
bool m_MultipleModes
 
bool m_useFFT
 
NekDouble m_LhomZ
 
bool m_homogen_dealiasing
 

Friends

class MemoryManager< FilterModalEnergy >
 

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 49 of file FilterModalEnergy.h.

Constructor & Destructor Documentation

◆ FilterModalEnergy()

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

Constructor.

Definition at line 51 of file FilterModalEnergy.cpp.

54 : Filter(pSession, pEquation)
55{
56 // OutputFile
57 auto it = pParams.find("OutputFile");
58 if (it == pParams.end())
59 {
60 m_outputFile = m_session->GetSessionName();
61 }
62 else
63 {
64 ASSERTL0(it->second.length() > 0, "Missing parameter 'OutputFile'.");
65 m_outputFile = it->second;
66 }
67 if (!(m_outputFile.length() >= 4 &&
68 m_outputFile.substr(m_outputFile.length() - 4) == ".mdl"))
69 {
70 m_outputFile += ".mdl";
71 }
72
73 // OutputFrequency
74 it = pParams.find("OutputFrequency");
75 if (it == pParams.end())
76 {
78 }
79 else
80 {
81 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
82 m_outputFrequency = round(equ.Evaluate());
83 }
84
85 m_session->MatchSolverInfo("Homogeneous", "1D", m_isHomogeneous1D, false);
86 m_session->MatchSolverInfo("Homogeneous", "2D", m_isHomogeneous2D, false);
87 m_session->MatchSolverInfo("CalculatePerturbationEnergy", "True",
88 m_PertEnergy, false);
89 m_session->LoadParameter("NumQuadPointsError", m_NumQuadPointsError, 0);
90 m_EqTypeStr = m_session->GetSolverInfo("EQTYPE");
91
92 // OutputPlane
94 {
95 m_session->LoadParameter("LZ", m_LhomZ);
96
97 it = pParams.find("OutputPlane");
98 if (it == pParams.end())
99 {
100 m_outputPlane = 0;
101 }
102 else
103 {
104 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
105 m_outputPlane = round(equ.Evaluate());
106 }
107 }
108
110}
#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
LibUtilities::FieldIOSharedPtr m_fld

References ASSERTL0, Nektar::LibUtilities::FieldIO::CreateDefault(), Nektar::LibUtilities::Equation::Evaluate(), m_EqTypeStr, m_fld, m_isHomogeneous1D, m_isHomogeneous2D, m_LhomZ, m_NumQuadPointsError, m_outputFile, m_outputFrequency, m_outputPlane, m_PertEnergy, and Nektar::SolverUtils::Filter::m_session.

◆ ~FilterModalEnergy()

Nektar::SolverUtils::FilterModalEnergy::~FilterModalEnergy ( )
override

Destructor.

Definition at line 115 of file FilterModalEnergy.cpp.

116{
117}

Member Function Documentation

◆ create()

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

Definition at line 55 of file FilterModalEnergy.h.

58 {
60 pSession, pEquation, pParams);
61 return p;
62 }
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.

◆ ImportFldBase()

void Nektar::SolverUtils::FilterModalEnergy::ImportFldBase ( std::string  pInfile)
protected

Import the base flow fld file.

Definition at line 596 of file FilterModalEnergy.cpp.

597{
598 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
599 std::vector<std::vector<NekDouble>> FieldData;
600
601 // Get Homogeneous
602 m_fld->Import(pInfile, FieldDef, FieldData);
603
604 int nvar = m_session->GetVariables().size();
605 if (m_session->DefinesSolverInfo("HOMOGENEOUS"))
606 {
607 std::string HomoStr = m_session->GetSolverInfo("HOMOGENEOUS");
608 }
609 // Copy FieldData into m_fields
610 for (int j = 0; j < nvar; ++j)
611 {
612 for (int i = 0; i < FieldDef.size(); ++i)
613 {
614 bool flag = FieldDef[i]->m_fields[j] == m_session->GetVariable(j);
615
616 ASSERTL0(flag, (std::string("Order of ") + pInfile +
617 std::string(" data and that defined in "
618 "m_boundaryconditions differs"))
619 .c_str());
620
621 m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
622 FieldDef[i]->m_fields[j],
623 m_base[j]->UpdateCoeffs());
624 }
625 }
626}
Array< OneD, MultiRegions::ExpListSharedPtr > m_base

References ASSERTL0, m_base, m_fld, and Nektar::SolverUtils::Filter::m_session.

Referenced by v_Update().

◆ L2Error()

NekDouble Nektar::SolverUtils::FilterModalEnergy::L2Error ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
unsigned int  field,
const NekDouble time 
)
protected

Calculate the L2 norm of a given field for calculating the modal energy.

Definition at line 339 of file FilterModalEnergy.cpp.

342{
343 NekDouble L2error = -1.0;
344 LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
345
346 if (m_NumQuadPointsError == 0)
347 {
348 if (pFields[field]->GetPhysState() == false)
349 {
350 pFields[field]->BwdTrans(pFields[field]->GetCoeffs(),
351 pFields[field]->UpdatePhys());
352 }
353 }
354
355 L2error = pFields[field]->L2(pFields[field]->GetPhys());
356 return L2error;
357}
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
double NekDouble

References m_NumQuadPointsError.

Referenced by v_Update().

◆ SetUpBaseFields()

void Nektar::SolverUtils::FilterModalEnergy::SetUpBaseFields ( SpatialDomains::MeshGraphSharedPtr graphShrPtr)
protected

Setup the base fields in case of stability analyses.

Definition at line 362 of file FilterModalEnergy.cpp.

364{
365 int i;
366 int m_expdim = graphShrPtr->GetMeshDimension();
367
368 // definition of the projection tipe:
369 if (m_session->DefinesSolverInfo("PROJECTION"))
370 {
371 std::string ProjectStr = m_session->GetSolverInfo("PROJECTION");
372
373 if ((ProjectStr == "Continuous") || (ProjectStr == "Galerkin") ||
374 (ProjectStr == "CONTINUOUS") || (ProjectStr == "GALERKIN"))
375 {
377 }
378 else if ((ProjectStr == "MixedCGDG") ||
379 (ProjectStr == "Mixed_CG_Discontinuous"))
380 {
382 }
383 else if (ProjectStr == "DisContinuous")
384 {
386 }
387 else
388 {
389 ASSERTL0(false, "PROJECTION value not recognised");
390 }
391 }
392 else
393 {
394 cerr << "Projection type not specified in SOLVERINFO,"
395 "defaulting to continuous Galerkin"
396 << endl;
398 }
399
400 if (m_session->DefinesSolverInfo("ModeType"))
401 {
402 m_session->MatchSolverInfo("ModeType", "SingleMode", m_SingleMode,
403 false);
404 m_session->MatchSolverInfo("ModeType", "HalfMode", m_HalfMode, false);
405 m_session->MatchSolverInfo("ModeType", "MultipleModes", m_MultipleModes,
406 false);
407 }
408
409 m_session->MatchSolverInfo("USEFFT", "FFTW", m_useFFT, false);
410 m_session->MatchSolverInfo("DEALIASING", "True", m_homogen_dealiasing,
411 false);
412
413 // Stability Analysis flags
414 if (m_session->DefinesSolverInfo("ModeType"))
415 {
416 if (m_SingleMode)
417 {
418 m_npointsZ = 2;
419 }
420 else if (m_HalfMode)
421 {
422 m_npointsZ = 1;
423 }
424 else if (m_MultipleModes)
425 {
426 m_npointsZ = m_session->GetParameter("HomModesZ");
427 }
428 else
429 {
430 ASSERTL0(false, "SolverInfo ModeType not valid");
431 }
432 }
433 else
434 {
435 m_npointsZ = m_session->GetParameter("HomModesZ");
436 }
437
440 {
441 switch (m_expdim)
442 {
443 case 1:
444 {
445 for (i = 0; i < m_base.size(); i++)
446 {
448 AllocateSharedPtr(m_session, graphShrPtr,
449 m_session->GetVariable(0));
450 }
451 }
452 break;
453 case 2:
454 {
456 {
457 if (m_SingleMode)
458 {
459 const LibUtilities::PointsKey PkeyZ(
461 const LibUtilities::BasisKey BkeyZ(
463
464 for (i = 0; i < m_base.size(); i++)
465 {
466 m_base[i] = MemoryManager<
467 MultiRegions::ContField3DHomogeneous1D>::
468 AllocateSharedPtr(
469 m_session, BkeyZ, m_LhomZ, m_useFFT,
470 m_homogen_dealiasing, graphShrPtr,
471 m_session->GetVariable(i));
472
473 m_base[i]->SetWaveSpace(true);
474 }
475 }
476 else if (m_HalfMode)
477 {
478 // 1 plane field (half mode expansion)
479 const LibUtilities::PointsKey PkeyZ(
481 const LibUtilities::BasisKey BkeyZ(
483 PkeyZ);
484
485 for (i = 0; i < m_base.size(); i++)
486 {
487 m_base[i] = MemoryManager<
488 MultiRegions::ContField3DHomogeneous1D>::
489 AllocateSharedPtr(
490 m_session, BkeyZ, m_LhomZ, m_useFFT,
491 m_homogen_dealiasing, graphShrPtr,
492 m_session->GetVariable(i));
493
494 m_base[i]->SetWaveSpace(true);
495 }
496 }
497 else
498 {
499 const LibUtilities::PointsKey PkeyZ(
501 const LibUtilities::BasisKey BkeyZ(
503
504 for (i = 0; i < m_base.size(); i++)
505 {
506 m_base[i] = MemoryManager<
507 MultiRegions::ContField3DHomogeneous1D>::
508 AllocateSharedPtr(
509 m_session, BkeyZ, m_LhomZ, m_useFFT,
510 m_homogen_dealiasing, graphShrPtr,
511 m_session->GetVariable(i));
512
513 m_base[i]->SetWaveSpace(false);
514 }
515 }
516 }
517 else
518 {
519 i = 0;
522 AllocateSharedPtr(m_session, graphShrPtr,
523 m_session->GetVariable(i));
524
525 m_base[0] = firstbase;
526
527 for (i = 1; i < m_base.size(); i++)
528 {
530 AllocateSharedPtr(*firstbase, graphShrPtr,
531 m_session->GetVariable(i));
532 }
533 }
534 }
535 break;
536 case 3:
537 {
540 m_session, graphShrPtr, m_session->GetVariable(0));
541 m_base[0] = firstbase;
542 for (i = 1; i < m_base.size(); i++)
543 {
545 AllocateSharedPtr(*firstbase, graphShrPtr,
546 m_session->GetVariable(0));
547 }
548 }
549 break;
550 default:
552 "Expansion dimension not recognised");
553 break;
554 }
555 }
556 else
557 {
558 switch (m_expdim)
559 {
560 case 1:
561 {
562 // need to use zero for variable as may be more base
563 // flows than variables
564 for (i = 0; i < m_base.size(); i++)
565 {
567 AllocateSharedPtr(m_session, graphShrPtr,
568 m_session->GetVariable(0));
569 }
570 break;
571 }
572 case 2:
573 {
574 for (i = 0; i < m_base.size(); i++)
575 {
577 AllocateSharedPtr(m_session, graphShrPtr,
578 m_session->GetVariable(0));
579 }
580 break;
581 }
582 case 3:
583 NEKERROR(ErrorUtil::efatal, "3D not set up");
584 break;
585 default:
587 "Expansion dimension not recognised");
588 break;
589 }
590 }
591}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
enum MultiRegions::ProjectionType m_projectionType
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
Definition: PointsType.h:74
@ eFourierSingleModeSpaced
1D Non Evenly-spaced points for Single Mode analysis
Definition: PointsType.h:75
@ eFourierHalfModeRe
Fourier Modified expansions with just the real part of the first mode .
Definition: BasisType.h:66
@ eFourier
Fourier Expansion .
Definition: BasisType.h:55
std::shared_ptr< ContField > ContFieldSharedPtr
Definition: ContField.h:268

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::MultiRegions::eDiscontinuous, Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eFourier, Nektar::LibUtilities::eFourierEvenlySpaced, Nektar::LibUtilities::eFourierHalfModeRe, Nektar::LibUtilities::eFourierSingleModeSpaced, Nektar::MultiRegions::eGalerkin, Nektar::MultiRegions::eMixed_CG_Discontinuous, m_base, m_HalfMode, m_homogen_dealiasing, m_isHomogeneous1D, m_LhomZ, m_MultipleModes, m_npointsZ, m_projectionType, Nektar::SolverUtils::Filter::m_session, m_SingleMode, m_useFFT, and NEKERROR.

Referenced by v_Update().

◆ v_Finalise()

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

Close the output stream.

Implements Nektar::SolverUtils::Filter.

Definition at line 325 of file FilterModalEnergy.cpp.

328{
329 if (pFields[0]->GetComm()->GetRank() == 0)
330 {
331 m_outputStream.close();
332 }
333}

References m_outputStream.

◆ v_Initialise()

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

Initialize the parallel communication and the output stream.

Implements Nektar::SolverUtils::Filter.

Definition at line 122 of file FilterModalEnergy.cpp.

125{
126 LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
127
128 if (vComm->GetRank() == 0)
129 {
130 // Open output stream
131 bool adaptive;
132 m_session->MatchSolverInfo("Driver", "Adaptive", adaptive, false);
133 if (adaptive)
134 {
135 m_outputStream.open(m_outputFile.c_str(), ofstream::app);
136 }
137 else
138 {
139 m_outputStream.open(m_outputFile.c_str());
140 }
142 {
143 m_outputStream << "# Time, Fourier Mode, Energy ";
144 m_outputStream << endl;
145 }
146 else
147 {
148 m_outputStream << "# Time, Energy ";
149 m_outputStream << endl;
150 }
151 }
152
153 m_index = 0;
154 v_Update(pFields, time);
155}
void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override

References m_index, m_isHomogeneous1D, m_outputFile, m_outputStream, Nektar::SolverUtils::Filter::m_session, and v_Update().

◆ v_IsTimeDependent()

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

Flag for time-dependent flows.

Implements Nektar::SolverUtils::Filter.

Definition at line 631 of file FilterModalEnergy.cpp.

632{
633 return true;
634}

◆ v_Update()

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

Update the modal energy every m_outputFrequency.

Implements Nektar::SolverUtils::Filter.

Definition at line 160 of file FilterModalEnergy.cpp.

163{
164 // Only output every m_outputFrequency
165 if ((m_index++) % m_outputFrequency)
166 {
167 return;
168 }
169
170 LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
171
172 // Homogeneous 1D implementation
174 {
175 int colrank = vComm->GetColumnComm()->GetRank();
176 int nproc = vComm->GetColumnComm()->GetSize();
177 m_npointsZ = (m_session->GetParameter("HomModesZ"));
178 int locsize = m_npointsZ / nproc / 2;
179
180 Array<OneD, NekDouble> energy(locsize, 0.0);
181 Array<OneD, NekDouble> energy_tmp(locsize, 0.0);
182 Array<OneD, NekDouble> tmp;
183
184 // Calculate the energy of the perturbation for stability
185 // analysis
186 if (m_PertEnergy)
187 {
188 // Compressible Flow Solver
189 if (m_EqTypeStr == "EulerCFE" || m_EqTypeStr == "EulerADCFE" ||
190 m_EqTypeStr == "NavierStokesCFE")
191 {
192 ASSERTL0(false, "Stability analysis module not "
193 "implemented for the Compressible Flow "
194 "Solver. Please remove the function BaseFlow "
195 "from your .xml file");
196 }
197 // Incompressible Navier-Stokes Solver
198 else
199 {
202 SetUpBaseFields(graphShrPtr);
203 string file = m_session->GetFunctionFilename("BaseFlow", 0);
204 ImportFldBase(file);
205
206 for (int i = 0; i < pFields.size() - 1; ++i)
207 {
208 Vmath::Vsub(pFields[i]->GetNcoeffs(),
209 pFields[i]->GetCoeffs(), 1,
210 m_base[i]->GetCoeffs(), 1,
211 pFields[i]->UpdateCoeffs(), 1);
212
213 energy_tmp = pFields[i]->HomogeneousEnergy();
214 Vmath::Vadd(locsize, energy_tmp, 1, energy, 1, energy, 1);
215
216 Vmath::Vadd(pFields[i]->GetNcoeffs(),
217 pFields[i]->GetCoeffs(), 1,
218 m_base[i]->GetCoeffs(), 1,
219 pFields[i]->UpdateCoeffs(), 1);
220 }
221 }
222 }
223 // Calculate the modal energy for general simulation
224 else
225 {
226 // Compressible Flow Solver
227 if (m_EqTypeStr == "EulerCFE" || m_EqTypeStr == "EulerADCFE" ||
228 m_EqTypeStr == "NavierStokesCFE")
229 {
230 // Extracting kinetic energy
231 for (int i = 1; i < pFields.size() - 1; ++i)
232 {
233 energy_tmp = pFields[i]->HomogeneousEnergy();
234 Vmath::Vadd(locsize, energy_tmp, 1, energy, 1, energy, 1);
235 }
236 }
237 // Incompressible Navier-Stokes Solver
238 else
239 {
240 // Extracting kinetic energy
241 for (int i = 0; i < pFields.size() - 1; ++i)
242 {
243 energy_tmp = pFields[i]->HomogeneousEnergy();
244 Vmath::Vadd(locsize, energy_tmp, 1, energy, 1, energy, 1);
245 }
246 }
247 }
248
249 // Send to root process
250 if (colrank == 0)
251 {
252 int j, m = 0;
253
254 for (j = 0; j < energy.size(); ++j, ++m)
255 {
256 m_outputStream << setw(10) << time << setw(5) << m << setw(18)
257 << energy[j] << endl;
258 }
259
260 for (int i = 1; i < nproc; ++i)
261 {
262 vComm->GetColumnComm()->Recv(i, energy);
263
264 for (j = 0; j < energy.size(); ++j, ++m)
265 {
266 m_outputStream << setw(10) << time << setw(5) << m
267 << setw(18) << energy[j] << endl;
268 }
269 }
270 }
271 else
272 {
273 vComm->GetColumnComm()->Send(0, energy);
274 }
275 }
276 // Homogeneous 2D implementation
277 else if (m_isHomogeneous2D)
278 {
279 ASSERTL0(false, "3D Homogeneous 2D energy "
280 "dumping not implemented yet");
281 }
282 // General implementation
283 else
284 {
285 // Compressible Flow Solver
286 if (m_EqTypeStr == "EulerCFE" || m_EqTypeStr == "EulerADCFE" ||
287 m_EqTypeStr == "NavierStokesCFE")
288 {
289 // Total energy
290 NekDouble energy = 0.0;
291 for (int i = 1; i < pFields.size() - 1; ++i)
292 {
293 pFields[i]->SetPhysState(true);
294 NekDouble norm = L2Error(pFields, i, time);
295 energy += norm * norm;
296 }
297
298 m_outputStream << setprecision(6) << time;
299 m_outputStream.width(25);
300 m_outputStream << setprecision(8) << 0.5 * energy;
301 m_outputStream << endl;
302 }
303 // Incompressible Navier-Stokes Solver
304 else
305 {
306 // Kinetic energy
307 NekDouble energy = 0.0;
308 for (int i = 0; i < pFields.size() - 1; ++i)
309 {
310 pFields[i]->SetPhysState(true);
311 NekDouble norm = L2Error(pFields, i, time);
312 energy += norm * norm;
313 }
314 m_outputStream << setprecision(6) << time;
315 m_outputStream.width(25);
316 m_outputStream << setprecision(8) << 0.5 * energy;
317 m_outputStream << endl;
318 }
319 }
320}
NekDouble L2Error(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, unsigned int field, const NekDouble &time)
void SetUpBaseFields(SpatialDomains::MeshGraphSharedPtr &mesh)
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
Definition: MeshGraph.cpp:115
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.hpp:180
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.
Definition: Vmath.hpp:220

References ASSERTL0, ImportFldBase(), L2Error(), m_base, m_EqTypeStr, m_index, m_isHomogeneous1D, m_isHomogeneous2D, m_npointsZ, m_outputFrequency, m_outputStream, m_PertEnergy, Nektar::SolverUtils::Filter::m_session, Nektar::SpatialDomains::MeshGraph::Read(), SetUpBaseFields(), Vmath::Vadd(), and Vmath::Vsub().

Referenced by v_Initialise().

Friends And Related Function Documentation

◆ MemoryManager< FilterModalEnergy >

friend class MemoryManager< FilterModalEnergy >
friend

Definition at line 1 of file FilterModalEnergy.h.

Member Data Documentation

◆ className

std::string Nektar::SolverUtils::FilterModalEnergy::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)
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:39

Definition at line 65 of file FilterModalEnergy.h.

◆ m_base

Array<OneD, MultiRegions::ExpListSharedPtr> Nektar::SolverUtils::FilterModalEnergy::m_base
private

Definition at line 92 of file FilterModalEnergy.h.

Referenced by ImportFldBase(), SetUpBaseFields(), and v_Update().

◆ m_boundaryRegionIsInList

std::vector<bool> Nektar::SolverUtils::FilterModalEnergy::m_boundaryRegionIsInList
private

Definition at line 99 of file FilterModalEnergy.h.

◆ m_boundaryRegionsIdList

std::vector<unsigned int> Nektar::SolverUtils::FilterModalEnergy::m_boundaryRegionsIdList
private

Definition at line 96 of file FilterModalEnergy.h.

◆ m_BoundaryString

std::string Nektar::SolverUtils::FilterModalEnergy::m_BoundaryString
private

Definition at line 114 of file FilterModalEnergy.h.

◆ m_EqTypeStr

std::string Nektar::SolverUtils::FilterModalEnergy::m_EqTypeStr
private

Definition at line 111 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

◆ m_fld

LibUtilities::FieldIOSharedPtr Nektar::SolverUtils::FilterModalEnergy::m_fld
private

Definition at line 93 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and ImportFldBase().

◆ m_HalfMode

bool Nektar::SolverUtils::FilterModalEnergy::m_HalfMode
private

Definition at line 118 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

◆ m_homogen_dealiasing

bool Nektar::SolverUtils::FilterModalEnergy::m_homogen_dealiasing
private

Definition at line 122 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

◆ m_homogeneousBasis

LibUtilities::BasisSharedPtr Nektar::SolverUtils::FilterModalEnergy::m_homogeneousBasis
private

Definition at line 113 of file FilterModalEnergy.h.

◆ m_index

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_index
private

Definition at line 100 of file FilterModalEnergy.h.

Referenced by v_Initialise(), and v_Update().

◆ m_isHomogeneous1D

bool Nektar::SolverUtils::FilterModalEnergy::m_isHomogeneous1D
private

Definition at line 105 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), SetUpBaseFields(), v_Initialise(), and v_Update().

◆ m_isHomogeneous2D

bool Nektar::SolverUtils::FilterModalEnergy::m_isHomogeneous2D
private

Definition at line 106 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

◆ m_LhomZ

NekDouble Nektar::SolverUtils::FilterModalEnergy::m_LhomZ
private

Definition at line 121 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and SetUpBaseFields().

◆ m_MultipleModes

bool Nektar::SolverUtils::FilterModalEnergy::m_MultipleModes
private

Definition at line 119 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

◆ m_nplanes

int Nektar::SolverUtils::FilterModalEnergy::m_nplanes
private

Definition at line 115 of file FilterModalEnergy.h.

◆ m_npointsZ

int Nektar::SolverUtils::FilterModalEnergy::m_npointsZ
private

Definition at line 108 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields(), and v_Update().

◆ m_nproc

int Nektar::SolverUtils::FilterModalEnergy::m_nproc
private

Definition at line 109 of file FilterModalEnergy.h.

◆ m_NumQuadPointsError

int Nektar::SolverUtils::FilterModalEnergy::m_NumQuadPointsError
private

Definition at line 116 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and L2Error().

◆ m_outputFile

std::string Nektar::SolverUtils::FilterModalEnergy::m_outputFile
private

Definition at line 110 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Initialise().

◆ m_outputFrequency

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_outputFrequency
private

Definition at line 101 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

◆ m_outputPlane

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_outputPlane
private

Definition at line 104 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy().

◆ m_outputStream

std::ofstream Nektar::SolverUtils::FilterModalEnergy::m_outputStream
private

Definition at line 112 of file FilterModalEnergy.h.

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

◆ m_PertEnergy

bool Nektar::SolverUtils::FilterModalEnergy::m_PertEnergy
private

Definition at line 107 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

◆ m_projectionType

enum MultiRegions::ProjectionType Nektar::SolverUtils::FilterModalEnergy::m_projectionType
private

Definition at line 91 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

◆ m_SingleMode

bool Nektar::SolverUtils::FilterModalEnergy::m_SingleMode
private

Definition at line 117 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

◆ m_useFFT

bool Nektar::SolverUtils::FilterModalEnergy::m_useFFT
private

Definition at line 120 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().