Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::ProcessQCriterion Class Reference

This processing module calculates the Q Criterion and adds it as an extra-field to the output file. More...

#include <ProcessQCriterion.h>

Inheritance diagram for Nektar::FieldUtils::ProcessQCriterion:
[legend]

Public Member Functions

 ProcessQCriterion (FieldSharedPtr f)
 
virtual ~ProcessQCriterion ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

This processing module calculates the Q Criterion and adds it as an extra-field to the output file.

Definition at line 49 of file ProcessQCriterion.h.

Constructor & Destructor Documentation

◆ ProcessQCriterion()

Nektar::FieldUtils::ProcessQCriterion::ProcessQCriterion ( FieldSharedPtr  f)

Definition at line 56 of file ProcessQCriterion.cpp.

◆ ~ProcessQCriterion()

Nektar::FieldUtils::ProcessQCriterion::~ProcessQCriterion ( )
virtual

Definition at line 60 of file ProcessQCriterion.cpp.

61 {
62 }

Member Function Documentation

◆ create()

static std::shared_ptr<Module> Nektar::FieldUtils::ProcessQCriterion::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 53 of file ProcessQCriterion.h.

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

54  {
56  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessQCriterion::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessQCriterion.h.

71  {
72  return "Calculating Q Criterion";
73  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessQCriterion::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessQCriterion.h.

66  {
67  return "ProcessQCriterion";
68  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessQCriterion::GetModulePriority ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessQCriterion.h.

References Nektar::FieldUtils::eModifyExp.

◆ Process()

void Nektar::FieldUtils::ProcessQCriterion::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessQCriterion.cpp.

References ASSERTL0, Nektar::FieldUtils::Module::m_f, Vmath::Smul(), Vmath::Vadd(), Vmath::Vcopy(), Vmath::Vmul(), and Vmath::Vsub().

65 {
66  boost::ignore_unused(vm);
67 
68  int nfields = m_f->m_variables.size();
69  m_f->m_variables.push_back("Q");
70  // Skip in case of empty partition
71  if (m_f->m_exp[0]->GetNumElmts() == 0)
72  {
73  return;
74  }
75 
76  int i, s;
77  int expdim = m_f->m_graph->GetMeshDimension();
78  int spacedim = expdim + (m_f->m_numHomogeneousDir);
79 
80  ASSERTL0(spacedim == 3,
81  "ProcessQCriterion must be computed for a 3D (or quasi-3D) case.");
82 
83  int npoints = m_f->m_exp[0]->GetNpoints();
84 
85  Array<OneD, Array<OneD, NekDouble> > grad(spacedim * spacedim);
86 
87  Array<OneD, NekDouble> omega(npoints);
88  Array<OneD, NekDouble> S(npoints);
89 
90  // Will store the Q-Criterion
91  Array<OneD, NekDouble> outfield (npoints);
92  Array<OneD, NekDouble> outfield1(npoints);
93  Array<OneD, NekDouble> outfield2(npoints);
94  Array<OneD, NekDouble> outfield3(npoints);
95 
96  int nstrips;
97 
98  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
99 
100  for (i = 0; i < spacedim * spacedim; ++i)
101  {
102  grad[i] = Array<OneD, NekDouble>(npoints);
103  }
104 
106 
107  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
108  {
109  for (i = 0; i < spacedim; ++i)
110  {
111  m_f->m_exp[s * nfields + i]->PhysDeriv(
112  m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
113  grad[i * spacedim + 1], grad[i * spacedim + 2]);
114  }
115 
116  // W_x = Wy - Vz
117  Vmath::Vsub(npoints, grad[2 * spacedim + 1], 1,
118  grad[1 * spacedim + 2], 1,
119  outfield1, 1);
120  // W_x^2
121  Vmath::Vmul(npoints, outfield1, 1, outfield1, 1, outfield1, 1);
122 
123  // W_y = Uz - Wx
124  Vmath::Vsub(npoints, grad[0 * spacedim + 2], 1,
125  grad[2 * spacedim + 0], 1,
126  outfield2, 1);
127  // W_y^2
128  Vmath::Vmul(npoints, outfield2, 1, outfield2, 1, outfield2, 1);
129 
130  // W_z = Vx - Uy
131  Vmath::Vsub(npoints, grad[1 * spacedim + 0], 1,
132  grad[0 * spacedim + 1], 1,
133  outfield3, 1);
134  // W_z^2
135  Vmath::Vmul(npoints, outfield3, 1, outfield3, 1, outfield3, 1);
136 
137  // Omega = 0.5*(W_x^2 + W_y^2 + W_z^2)
138  NekDouble fac = 0.5;
139  Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, omega, 1);
140  Vmath::Vadd(npoints, omega, 1, outfield3, 1, omega, 1);
141  Vmath::Smul(npoints, fac, omega, 1, omega, 1);
142 
143  // Ux^2
144  Vmath::Vmul(npoints, grad[0 * spacedim + 0], 1,
145  grad[0 * spacedim + 0], 1,
146  outfield1, 1);
147  // Vy^2
148  Vmath::Vmul(npoints, grad[1 * spacedim + 1], 1,
149  grad[1 * spacedim + 1], 1,
150  outfield2, 1);
151  // Wz^2
152  Vmath::Vmul(npoints, grad[2 * spacedim + 2], 1,
153  grad[2 * spacedim + 2], 1,
154  outfield3, 1);
155 
156  //
157  Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, S, 1);
158  Vmath::Vadd(npoints, S, 1, outfield3, 1, S, 1);
159 
160  // Wy + Vz
161  Vmath::Vadd(npoints, grad[2 * spacedim + 1], 1,
162  grad[1 * spacedim + 2], 1,
163  outfield1, 1);
164  Vmath::Vmul(npoints, outfield1, 1, outfield1, 1, outfield1, 1);
165 
166  // Uz + Wx
167  Vmath::Vadd(npoints, grad[0 * spacedim + 2], 1,
168  grad[2 * spacedim + 0], 1,
169  outfield2, 1);
170  Vmath::Vmul(npoints, outfield2, 1, outfield2, 1, outfield2, 1);
171 
172  // Vx + Uy
173  Vmath::Vadd(npoints, grad[1 * spacedim + 0], 1,
174  grad[0 * spacedim + 1], 1,
175  outfield3, 1);
176  Vmath::Vmul(npoints, outfield3, 1, outfield3, 1, outfield3, 1);
177 
178  Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, outfield2, 1);
179  Vmath::Vadd(npoints, outfield2, 1, outfield3, 1, outfield3, 1);
180 
181  Vmath::Smul(npoints, fac, outfield3, 1, outfield3, 1);
182 
183  Vmath::Vadd(npoints, outfield3, 1, S, 1, S, 1);
184  Vmath::Vsub(npoints, omega, 1, S, 1, outfield, 1);
185 
186  Vmath::Smul(npoints, fac, outfield, 1, outfield, 1);
187 
188  Exp = m_f->AppendExpList(m_f->m_numHomogeneousDir);
189  Vmath::Vcopy(npoints, outfield, 1, Exp->UpdatePhys(), 1);
190  Exp->FwdTrans_IterPerExp(outfield, Exp->UpdateCoeffs());
191 
192  auto it = m_f->m_exp.begin() + s * (nfields + 1) + nfields;
193  m_f->m_exp.insert(it, Exp);
194  }
195 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
double NekDouble
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:346
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
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:302
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.
Definition: Vmath.cpp:186
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessQCriterion::className
static
Initial value:

Definition at line 57 of file ProcessQCriterion.h.