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:161
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 626 of file FilterModalEnergy.cpp.

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

Referenced by v_Update().

629 {
630  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
631  std::vector<std::vector<NekDouble> > FieldData;
632 
633  // Get Homogeneous
634  m_fld->Import(pInfile,FieldDef,FieldData);
635 
636  int nvar = m_session->GetVariables().size();
637  if(m_session->DefinesSolverInfo("HOMOGENEOUS"))
638  {
639  std::string HomoStr = m_session->GetSolverInfo("HOMOGENEOUS");
640  }
641  // Copy FieldData into m_fields
642  for (int j = 0; j < nvar; ++j)
643  {
644  for (int i = 0; i < FieldDef.size(); ++i)
645  {
646  bool flag =
647  FieldDef[i]->m_fields[j] == m_session->GetVariable(j);
648 
649  ASSERTL0(flag, (std::string("Order of ") + pInfile
650  + std::string(" data and that defined in "
651  "m_boundaryconditions differs")).c_str());
652 
653  m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
654  FieldDef[i]->m_fields[j],
655  m_base[j]->UpdateCoeffs());
656  }
657  }
658 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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 350 of file FilterModalEnergy.cpp.

References m_NumQuadPointsError.

Referenced by v_Update().

354 {
355  NekDouble L2error = -1.0;
356  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
357 
358  if (m_NumQuadPointsError == 0)
359  {
360  if (pFields[field]->GetPhysState() == false)
361  {
362  pFields[field]->BwdTrans(pFields[field]->GetCoeffs(),
363  pFields[field]->UpdatePhys());
364  }
365  }
366 
367  L2error = pFields[field]->L2(pFields[field]->GetPhys());
368  return L2error;
369 }
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 374 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().

376 {
377  int i;
378  int m_expdim = graphShrPtr->GetMeshDimension();
379 
380  //definition of the projection tipe:
381  if(m_session->DefinesSolverInfo("PROJECTION"))
382  {
383  std::string ProjectStr = m_session->GetSolverInfo("PROJECTION");
384 
385  if ((ProjectStr == "Continuous") ||
386  (ProjectStr == "Galerkin") ||
387  (ProjectStr == "CONTINUOUS") ||
388  (ProjectStr == "GALERKIN"))
389  {
391  }
392  else if ((ProjectStr == "MixedCGDG") ||
393  (ProjectStr == "Mixed_CG_Discontinuous"))
394  {
396  }
397  else if(ProjectStr == "DisContinuous")
398  {
400  }
401  else
402  {
403  ASSERTL0(false, "PROJECTION value not recognised");
404  }
405  }
406  else
407  {
408  cerr << "Projection type not specified in SOLVERINFO,"
409  "defaulting to continuous Galerkin" << endl;
411  }
412 
413  if (m_session->DefinesSolverInfo("ModeType"))
414  {
415  m_session->MatchSolverInfo("ModeType", "SingleMode",
416  m_SingleMode, false);
417  m_session->MatchSolverInfo("ModeType", "HalfMode",
418  m_HalfMode, false);
419  m_session->MatchSolverInfo("ModeType", "MultipleModes",
420  m_MultipleModes, false);
421  }
422 
423  m_session->MatchSolverInfo("USEFFT","FFTW", m_useFFT, false);
424  m_session->MatchSolverInfo("DEALIASING", "True",
425  m_homogen_dealiasing, false);
426 
427  if (m_homogen_dealiasing == false)
428  {
429  m_session->MatchSolverInfo("DEALIASING", "On",
430  m_homogen_dealiasing, false);
431  }
432 
433  // Stability Analysis flags
434  if (m_session->DefinesSolverInfo("ModeType"))
435  {
436  if (m_SingleMode)
437  {
438  m_npointsZ = 2;
439  }
440  else if (m_HalfMode)
441  {
442  m_npointsZ = 1;
443  }
444  else if (m_MultipleModes)
445  {
446  m_npointsZ = m_session->GetParameter("HomModesZ");
447  }
448  else
449  {
450  ASSERTL0(false, "SolverInfo ModeType not valid");
451  }
452  }
453  else
454  {
455  m_npointsZ = m_session->GetParameter("HomModesZ");
456  }
457 
460  {
461  switch (m_expdim)
462  {
463  case 1:
464  {
465  for(i = 0; i < m_base.num_elements(); i++)
466  {
468  ::AllocateSharedPtr(m_session, graphShrPtr,
469  m_session->GetVariable(0));
470  }
471  }
472  break;
473  case 2:
474  {
475  if (m_isHomogeneous1D)
476  {
477  if (m_SingleMode)
478  {
479  const LibUtilities::PointsKey PkeyZ(
480  m_npointsZ,
482  const LibUtilities::BasisKey BkeyZ(
484  m_npointsZ, PkeyZ);
485 
486  for (i = 0 ; i < m_base.num_elements(); i++)
487  {
488  m_base[i] = MemoryManager<MultiRegions::
489  ContField3DHomogeneous1D>::
490  AllocateSharedPtr(
491  m_session, BkeyZ, m_LhomZ,
493  graphShrPtr,
494  m_session->GetVariable(i));
495 
496  m_base[i]->SetWaveSpace(true);
497  }
498  }
499  else if (m_HalfMode)
500  {
501  //1 plane field (half mode expansion)
502  const LibUtilities::PointsKey PkeyZ(
503  m_npointsZ,
505  const LibUtilities::BasisKey BkeyZ(
507  m_npointsZ,PkeyZ);
508 
509  for (i = 0 ; i < m_base.num_elements(); i++)
510  {
511  m_base[i] = MemoryManager<MultiRegions::
512  ContField3DHomogeneous1D>::
513  AllocateSharedPtr(
514  m_session, BkeyZ, m_LhomZ,
516  graphShrPtr,
517  m_session->GetVariable(i));
518 
519  m_base[i]->SetWaveSpace(true);
520  }
521  }
522  else
523  {
524  const LibUtilities::PointsKey PkeyZ(
525  m_npointsZ,
527  const LibUtilities::BasisKey BkeyZ(
529 
530  for (i = 0 ; i < m_base.num_elements(); i++)
531  {
532  m_base[i] = MemoryManager<MultiRegions::
533  ContField3DHomogeneous1D>::
534  AllocateSharedPtr(
535  m_session, BkeyZ, m_LhomZ,
537  graphShrPtr,
538  m_session->GetVariable(i));
539 
540  m_base[i]->SetWaveSpace(false);
541  }
542  }
543  }
544  else
545  {
546  i = 0;
550  m_session,graphShrPtr,
551  m_session->GetVariable(i));
552 
553  m_base[0] = firstbase;
554 
555  for (i = 1 ; i < m_base.num_elements(); i++)
556  {
557  m_base[i] = MemoryManager<MultiRegions::
558  ContField2D>::AllocateSharedPtr(
559  *firstbase, graphShrPtr,
560  m_session->GetVariable(i));
561  }
562  }
563  }
564  break;
565  case 3:
566  {
569  AllocateSharedPtr(m_session, graphShrPtr,
570  m_session->GetVariable(0));
571  m_base[0] = firstbase;
572  for (i = 1 ; i < m_base.num_elements(); i++)
573  {
574  m_base[i] = MemoryManager<MultiRegions::
575  ContField3D>::AllocateSharedPtr(
576  *firstbase, graphShrPtr,
577  m_session->GetVariable(0));
578  }
579  }
580  break;
581  default:
582  ASSERTL0(false, "Expansion dimension not recognised");
583  break;
584  }
585  }
586  else
587  {
588  switch (m_expdim)
589  {
590  case 1:
591  {
592  // need to use zero for variable as may be more base
593  // flows than variables
594  for (i = 0 ; i < m_base.num_elements(); i++)
595  {
596  m_base[i] = MemoryManager<MultiRegions::
597  DisContField1D>::AllocateSharedPtr(
598  m_session, graphShrPtr,
599  m_session->GetVariable(0));
600  }
601  break;
602  }
603  case 2:
604  {
605  for (i = 0 ; i < m_base.num_elements(); i++)
606  {
607  m_base[i] = MemoryManager<MultiRegions::
608  DisContField2D>::AllocateSharedPtr(
609  m_session, graphShrPtr,
610  m_session->GetVariable(0));
611  }
612  break;
613  }
614  case 3:
615  ASSERTL0(false, "3D not set up");
616  default:
617  ASSERTL0(false, "Expansion dimension not recognised");
618  break;
619  }
620  }
621 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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 336 of file FilterModalEnergy.cpp.

References m_outputStream.

339 {
340  if (pFields[0]->GetComm()->GetRank() == 0)
341  {
342  m_outputStream.close();
343  }
344 }
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, and v_Update().

133 {
134  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
135 
136  if (vComm->GetRank() == 0)
137  {
138  // Open output stream
140  {
141  m_outputStream.open(m_outputFile.c_str());
142  m_outputStream << "# Time, Fourier Mode, Energy ";
143  m_outputStream << endl;
144  }
145  else
146  {
147  m_outputStream.open(m_outputFile.c_str());
148  m_outputStream << "# Time, Energy ";
149  m_outputStream << endl;
150  }
151 
152  }
153 
154  m_index = 0;
155  v_Update(pFields, time);
156 }
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
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 663 of file FilterModalEnergy.cpp.

664 {
665  return true;
666 }
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 162 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().

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