Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SolverUtils::FilterModalEnergy:
Collaboration graph
[legend]

Public Member Functions

SOLVER_UTILS_EXPORT FilterModalEnergy (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
 
virtual SOLVER_UTILS_EXPORT ~FilterModalEnergy ()
 
- Public Member Functions inherited from Nektar::SolverUtils::Filter
SOLVER_UTILS_EXPORT Filter (const LibUtilities::SessionReaderSharedPtr &pSession)
 
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 ParamMap &pParams)
 

Static Public Attributes

static std::string className
 

Protected Member Functions

virtual void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual bool v_IsTimeDependent ()
 
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, SpatialDomains::MeshGraphSharedPtr pGraph)
 

Private Attributes

enum MultiRegions::ProjectionType m_projectionType
 
Array< OneD,
MultiRegions::ExpListSharedPtr
m_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
 

Detailed Description

Definition at line 57 of file FilterModalEnergy.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::FilterModalEnergy::FilterModalEnergy ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)

Constructor.

Definition at line 53 of file FilterModalEnergy.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, 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.

55  :
56  Filter(pSession)
57 {
58  ParamMap::const_iterator it;
59 
60  // OutputFile
61  it = pParams.find("OutputFile");
62  if (it == pParams.end())
63  {
64  m_outputFile = m_session->GetSessionName();
65  }
66  else
67  {
68  ASSERTL0(it->second.length() > 0, "Missing parameter 'OutputFile'.");
69  m_outputFile = it->second;
70  }
71  if (!(m_outputFile.length() >= 4
72  && m_outputFile.substr(m_outputFile.length() - 4) == ".mdl"))
73  {
74  m_outputFile += ".mdl";
75  }
76 
77  // OutputFrequency
78  it = pParams.find("OutputFrequency");
79  if (it == pParams.end())
80  {
82  }
83  else
84  {
85  LibUtilities::Equation equ(m_session, it->second);
86  m_outputFrequency = floor(equ.Evaluate());
87  }
88 
89 
90  m_session->MatchSolverInfo("Homogeneous", "1D", m_isHomogeneous1D, false);
91  m_session->MatchSolverInfo("Homogeneous", "2D", m_isHomogeneous2D, false);
92  m_session->MatchSolverInfo("CalculatePerturbationEnergy", "True",
93  m_PertEnergy, false);
94  m_session->LoadParameter ("NumQuadPointsError", m_NumQuadPointsError, 0);
95  m_EqTypeStr = m_session->GetSolverInfo("EQTYPE");
96 
97  // OutputPlane
99  {
100  m_session->LoadParameter("LZ", m_LhomZ);
101 
102  it = pParams.find("OutputPlane");
103  if (it == pParams.end())
104  {
105  m_outputPlane = 0;
106  }
107  else
108  {
109  LibUtilities::Equation equ(m_session, it->second);
110  m_outputPlane = floor(equ.Evaluate());
111  }
112  }
113 
115  AllocateSharedPtr(pSession->GetComm());
116 
117 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
LibUtilities::FieldIOSharedPtr m_fld
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Filter.cpp:52
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
Nektar::SolverUtils::FilterModalEnergy::~FilterModalEnergy ( )
virtual

Destructor.

Definition at line 122 of file FilterModalEnergy.cpp.

123 {
124 
125 }

Member Function Documentation

static FilterSharedPtr Nektar::SolverUtils::FilterModalEnergy::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)
inlinestatic

Definition at line 63 of file FilterModalEnergy.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

66  {
68  AllocateSharedPtr(pSession, pParams);
69  //p->InitObject();
70  return p;
71  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:50
void Nektar::SolverUtils::FilterModalEnergy::ImportFldBase ( std::string  pInfile,
SpatialDomains::MeshGraphSharedPtr  pGraph 
)
protected

Import the base flow fld file.

Definition at line 635 of file FilterModalEnergy.cpp.

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

Referenced by v_Update().

638 {
639  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
640  std::vector<std::vector<NekDouble> > FieldData;
641 
642  // Get Homogeneous
643  m_fld->Import(pInfile,FieldDef,FieldData);
644 
645  int nvar = m_session->GetVariables().size();
646  if(m_session->DefinesSolverInfo("HOMOGENEOUS"))
647  {
648  std::string HomoStr = m_session->GetSolverInfo("HOMOGENEOUS");
649  }
650  // Copy FieldData into m_fields
651  for (int j = 0; j < nvar; ++j)
652  {
653  for (int i = 0; i < FieldDef.size(); ++i)
654  {
655  bool flag =
656  FieldDef[i]->m_fields[j] == m_session->GetVariable(j);
657 
658  ASSERTL0(flag, (std::string("Order of ") + pInfile
659  + std::string(" data and that defined in "
660  "m_boundaryconditions differs")).c_str());
661 
662  m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
663  FieldDef[i]->m_fields[j],
664  m_base[j]->UpdateCoeffs());
665  }
666  }
667 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
Array< OneD, MultiRegions::ExpListSharedPtr > m_base
LibUtilities::FieldIOSharedPtr m_fld
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
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 359 of file FilterModalEnergy.cpp.

References m_NumQuadPointsError.

Referenced by v_Update().

363 {
364  NekDouble L2error = -1.0;
365  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
366 
367  if (m_NumQuadPointsError == 0)
368  {
369  if (pFields[field]->GetPhysState() == false)
370  {
371  pFields[field]->BwdTrans(pFields[field]->GetCoeffs(),
372  pFields[field]->UpdatePhys());
373  }
374  }
375 
376  L2error = pFields[field]->L2(pFields[field]->GetPhys());
377  return L2error;
378 }
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
double NekDouble
void Nektar::SolverUtils::FilterModalEnergy::SetUpBaseFields ( SpatialDomains::MeshGraphSharedPtr graphShrPtr)
protected

Setup the base fields in case of stability analyses.

Definition at line 383 of file FilterModalEnergy.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::MultiRegions::eDiscontinuous, 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, and m_useFFT.

Referenced by v_Update().

385 {
386  int i;
387  int m_expdim = graphShrPtr->GetMeshDimension();
388 
389  //definition of the projection tipe:
390  if(m_session->DefinesSolverInfo("PROJECTION"))
391  {
392  std::string ProjectStr = m_session->GetSolverInfo("PROJECTION");
393 
394  if ((ProjectStr == "Continuous") ||
395  (ProjectStr == "Galerkin") ||
396  (ProjectStr == "CONTINUOUS") ||
397  (ProjectStr == "GALERKIN"))
398  {
400  }
401  else if ((ProjectStr == "MixedCGDG") ||
402  (ProjectStr == "Mixed_CG_Discontinuous"))
403  {
405  }
406  else if(ProjectStr == "DisContinuous")
407  {
409  }
410  else
411  {
412  ASSERTL0(false, "PROJECTION value not recognised");
413  }
414  }
415  else
416  {
417  cerr << "Projection type not specified in SOLVERINFO,"
418  "defaulting to continuous Galerkin" << endl;
420  }
421 
422  if (m_session->DefinesSolverInfo("ModeType"))
423  {
424  m_session->MatchSolverInfo("ModeType", "SingleMode",
425  m_SingleMode, false);
426  m_session->MatchSolverInfo("ModeType", "HalfMode",
427  m_HalfMode, false);
428  m_session->MatchSolverInfo("ModeType", "MultipleModes",
429  m_MultipleModes, false);
430  }
431 
432  m_session->MatchSolverInfo("USEFFT","FFTW", m_useFFT, false);
433  m_session->MatchSolverInfo("DEALIASING", "True",
434  m_homogen_dealiasing, false);
435 
436  if (m_homogen_dealiasing == false)
437  {
438  m_session->MatchSolverInfo("DEALIASING", "On",
439  m_homogen_dealiasing, false);
440  }
441 
442  // Stability Analysis flags
443  if (m_session->DefinesSolverInfo("ModeType"))
444  {
445  if (m_SingleMode)
446  {
447  m_npointsZ = 2;
448  }
449  else if (m_HalfMode)
450  {
451  m_npointsZ = 1;
452  }
453  else if (m_MultipleModes)
454  {
455  m_npointsZ = m_session->GetParameter("HomModesZ");
456  }
457  else
458  {
459  ASSERTL0(false, "SolverInfo ModeType not valid");
460  }
461  }
462  else
463  {
464  m_npointsZ = m_session->GetParameter("HomModesZ");
465  }
466 
469  {
470  switch (m_expdim)
471  {
472  case 1:
473  {
474  for(i = 0; i < m_base.num_elements(); i++)
475  {
477  ::AllocateSharedPtr(m_session, graphShrPtr,
478  m_session->GetVariable(0));
479  }
480  }
481  break;
482  case 2:
483  {
484  if (m_isHomogeneous1D)
485  {
486  if (m_SingleMode)
487  {
488  const LibUtilities::PointsKey PkeyZ(
489  m_npointsZ,
491  const LibUtilities::BasisKey BkeyZ(
493  m_npointsZ, PkeyZ);
494 
495  for (i = 0 ; i < m_base.num_elements(); i++)
496  {
497  m_base[i] = MemoryManager<MultiRegions::
498  ContField3DHomogeneous1D>::
499  AllocateSharedPtr(
500  m_session, BkeyZ, m_LhomZ,
502  graphShrPtr,
503  m_session->GetVariable(i));
504 
505  m_base[i]->SetWaveSpace(true);
506  }
507  }
508  else if (m_HalfMode)
509  {
510  //1 plane field (half mode expansion)
511  const LibUtilities::PointsKey PkeyZ(
512  m_npointsZ,
514  const LibUtilities::BasisKey BkeyZ(
516  m_npointsZ,PkeyZ);
517 
518  for (i = 0 ; i < m_base.num_elements(); i++)
519  {
520  m_base[i] = MemoryManager<MultiRegions::
521  ContField3DHomogeneous1D>::
522  AllocateSharedPtr(
523  m_session, BkeyZ, m_LhomZ,
525  graphShrPtr,
526  m_session->GetVariable(i));
527 
528  m_base[i]->SetWaveSpace(true);
529  }
530  }
531  else
532  {
533  const LibUtilities::PointsKey PkeyZ(
534  m_npointsZ,
536  const LibUtilities::BasisKey BkeyZ(
538 
539  for (i = 0 ; i < m_base.num_elements(); i++)
540  {
541  m_base[i] = MemoryManager<MultiRegions::
542  ContField3DHomogeneous1D>::
543  AllocateSharedPtr(
544  m_session, BkeyZ, m_LhomZ,
546  graphShrPtr,
547  m_session->GetVariable(i));
548 
549  m_base[i]->SetWaveSpace(false);
550  }
551  }
552  }
553  else
554  {
555  i = 0;
559  m_session,graphShrPtr,
560  m_session->GetVariable(i));
561 
562  m_base[0] = firstbase;
563 
564  for (i = 1 ; i < m_base.num_elements(); i++)
565  {
566  m_base[i] = MemoryManager<MultiRegions::
567  ContField2D>::AllocateSharedPtr(
568  *firstbase, graphShrPtr,
569  m_session->GetVariable(i));
570  }
571  }
572  }
573  break;
574  case 3:
575  {
578  AllocateSharedPtr(m_session, graphShrPtr,
579  m_session->GetVariable(0));
580  m_base[0] = firstbase;
581  for (i = 1 ; i < m_base.num_elements(); i++)
582  {
583  m_base[i] = MemoryManager<MultiRegions::
584  ContField3D>::AllocateSharedPtr(
585  *firstbase, graphShrPtr,
586  m_session->GetVariable(0));
587  }
588  }
589  break;
590  default:
591  ASSERTL0(false, "Expansion dimension not recognised");
592  break;
593  }
594  }
595  else
596  {
597  switch (m_expdim)
598  {
599  case 1:
600  {
601  // need to use zero for variable as may be more base
602  // flows than variables
603  for (i = 0 ; i < m_base.num_elements(); i++)
604  {
605  m_base[i] = MemoryManager<MultiRegions::
606  DisContField1D>::AllocateSharedPtr(
607  m_session, graphShrPtr,
608  m_session->GetVariable(0));
609  }
610  break;
611  }
612  case 2:
613  {
614  for (i = 0 ; i < m_base.num_elements(); i++)
615  {
616  m_base[i] = MemoryManager<MultiRegions::
617  DisContField2D>::AllocateSharedPtr(
618  m_session, graphShrPtr,
619  m_session->GetVariable(0));
620  }
621  break;
622  }
623  case 3:
624  ASSERTL0(false, "3D not set up");
625  default:
626  ASSERTL0(false, "Expansion dimension not recognised");
627  break;
628  }
629  }
630 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
enum MultiRegions::ProjectionType m_projectionType
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< ContField2D > ContField2DSharedPtr
Definition: ContField2D.h:293
Array< OneD, MultiRegions::ExpListSharedPtr > m_base
Fourier Expansion .
Definition: BasisType.h:52
1D Evenly-spaced points using Fourier Fit
Definition: PointsType.h:64
Fourier Modified expansions with just the real part of the first mode .
Definition: BasisType.h:59
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
1D Non Evenly-spaced points for Single Mode analysis
Definition: PointsType.h:65
boost::shared_ptr< ContField3D > ContField3DSharedPtr
Definition: ContField3D.h:191
void Nektar::SolverUtils::FilterModalEnergy::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Close the output stream.

Implements Nektar::SolverUtils::Filter.

Definition at line 345 of file FilterModalEnergy.cpp.

References m_outputStream.

348 {
349  if (pFields[0]->GetComm()->GetRank() == 0)
350  {
351  m_outputStream.close();
352  }
353 }
void Nektar::SolverUtils::FilterModalEnergy::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Initialize the parallel communication and the output stream.

Implements Nektar::SolverUtils::Filter.

Definition at line 130 of file FilterModalEnergy.cpp.

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

133 {
134  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
135 
136  if (vComm->GetRank() == 0)
137  {
138  // Open output stream
139  bool adaptive;
140  m_session->MatchSolverInfo("Driver", "Adaptive",
141  adaptive, false);
142  if (adaptive)
143  {
144  m_outputStream.open(m_outputFile.c_str(), ofstream::app);
145  }
146  else
147  {
148  m_outputStream.open(m_outputFile.c_str());
149  }
151  {
152  m_outputStream << "# Time, Fourier Mode, Energy ";
153  m_outputStream << endl;
154  }
155  else
156  {
157  m_outputStream << "# Time, Energy ";
158  m_outputStream << endl;
159  }
160 
161  }
162 
163  m_index = 0;
164  v_Update(pFields, time);
165 }
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
bool Nektar::SolverUtils::FilterModalEnergy::v_IsTimeDependent ( )
protectedvirtual

Flag for time-dependent flows.

Implements Nektar::SolverUtils::Filter.

Definition at line 672 of file FilterModalEnergy.cpp.

673 {
674  return true;
675 }
void Nektar::SolverUtils::FilterModalEnergy::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Update the modal energy every m_outputFrequency.

Implements Nektar::SolverUtils::Filter.

Definition at line 171 of file FilterModalEnergy.cpp.

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().

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

Friends And Related Function Documentation

friend class MemoryManager< FilterModalEnergy >
friend

Definition at line 60 of file FilterModalEnergy.h.

Member Data Documentation

std::string Nektar::SolverUtils::FilterModalEnergy::className
static
Initial value:
RegisterCreatorFunction("ModalEnergy", FilterModalEnergy::create)

Definition at line 74 of file FilterModalEnergy.h.

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

Definition at line 104 of file FilterModalEnergy.h.

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

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

Definition at line 111 of file FilterModalEnergy.h.

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

Definition at line 108 of file FilterModalEnergy.h.

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

Definition at line 126 of file FilterModalEnergy.h.

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

Definition at line 123 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

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

Definition at line 105 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and ImportFldBase().

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

Definition at line 130 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

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

Definition at line 134 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

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

Definition at line 125 of file FilterModalEnergy.h.

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

Definition at line 112 of file FilterModalEnergy.h.

Referenced by v_Initialise(), and v_Update().

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

Definition at line 117 of file FilterModalEnergy.h.

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

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

Definition at line 118 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

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

Definition at line 133 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and SetUpBaseFields().

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

Definition at line 131 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

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

Definition at line 127 of file FilterModalEnergy.h.

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

Definition at line 120 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields(), and v_Update().

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

Definition at line 121 of file FilterModalEnergy.h.

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

Definition at line 128 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and L2Error().

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

Definition at line 122 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Initialise().

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

Definition at line 113 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

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

Definition at line 116 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy().

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

Definition at line 124 of file FilterModalEnergy.h.

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

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

Definition at line 119 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

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

Definition at line 103 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

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

Definition at line 129 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

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

Definition at line 132 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().