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

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

#include <ProcessL2Criterion.h>

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

Public Member Functions

 ProcessL2Criterion (FieldSharedPtr f)
 
virtual ~ProcessL2Criterion ()
 
virtual void Process (po::variables_map &vm)
 
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 Lambda 2 Criterion and adds it as an extra-field to the output file.

Definition at line 49 of file ProcessL2Criterion.h.

Constructor & Destructor Documentation

◆ ProcessL2Criterion()

Nektar::FieldUtils::ProcessL2Criterion::ProcessL2Criterion ( FieldSharedPtr  f)

Definition at line 55 of file ProcessL2Criterion.cpp.

◆ ~ProcessL2Criterion()

Nektar::FieldUtils::ProcessL2Criterion::~ProcessL2Criterion ( )
virtual

Definition at line 59 of file ProcessL2Criterion.cpp.

60 {
61 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 53 of file ProcessL2Criterion.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::ProcessL2Criterion::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessL2Criterion.h.

70  {
71  return "Calculating Lambda 2 Criterion";
72  }

◆ GetModuleName()

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

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessL2Criterion.h.

65  {
66  return "ProcessL2Criterion";
67  }

◆ GetModulePriority()

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

Implements Nektar::FieldUtils::Module.

Definition at line 74 of file ProcessL2Criterion.h.

References Nektar::FieldUtils::eModifyExp.

◆ Process()

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

Implements Nektar::FieldUtils::Module.

Definition at line 130 of file ProcessL2Criterion.cpp.

References ASSERTL0, Nektar::FieldUtils::Module::m_f, Nektar::FieldUtils::MatSymEVals(), and Vmath::Vcopy().

131 {
132  boost::ignore_unused(vm);
133 
134  auto nfields = m_f->m_variables.size();
135  m_f->m_variables.push_back("L2");
136 
137  // Skip in case of empty partition
138  if (m_f->m_exp[0]->GetNumElmts() == 0)
139  {
140  return;
141  }
142 
143  int i, s;
144  int expdim = m_f->m_graph->GetMeshDimension();
145  int spacedim = expdim + (m_f->m_numHomogeneousDir);
146 
147  ASSERTL0(
148  spacedim == 3,
149  "ProcessL2Criterion must be computed for a 3D (or quasi-3D) case.");
150 
151  int npoints = m_f->m_exp[0]->GetNpoints();
152 
153  Array<OneD, Array<OneD, NekDouble>> grad(spacedim * spacedim);
154 
155  // Will store the Lambdas
156  NekDouble a00, a11, a22, a01, a02, a12;
157  NekDouble t1, t2, t3, t4, t5, t6, t7, t8, t10, t11, t13, t14, t15;
158  NekDouble outfield1, outfield3;
159  Array<OneD, NekDouble> outfield2(npoints);
160 
161  int nstrips;
162  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
163 
164  for (i = 0; i < spacedim * spacedim; ++i)
165  {
166  grad[i] = Array<OneD, NekDouble>(npoints);
167  }
168 
170 
171  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
172  {
173  for (i = 0; i < spacedim; ++i)
174  {
175  m_f->m_exp[s * nfields + i]->PhysDeriv(
176  m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
177  grad[i * spacedim + 1], grad[i * spacedim + 2]);
178  }
179 
180  /*
181  * For each node calculate the S^2+W^2 tensor
182  * where S and W are the symmetric and the skew-symmetric
183  * parts of the velocity gradient tensor D=grad(u),
184  * S=0.5(D+transpose(D)) and W=0.5((D-transpose(D)))
185  */
186  for (int j = 0; j < npoints; ++j)
187  {
188  // diff(u,y) + diff(v,x);
189  t1 = grad[0 * spacedim + 1][j] + grad[1 * spacedim + 0][j];
190  // diff(u,z) + diff(w,x);
191  t2 = grad[0 * spacedim + 2][j] + grad[2 * spacedim + 0][j];
192  // diff(u,y) - diff(v,x);
193  t3 = grad[0 * spacedim + 1][j] - grad[1 * spacedim + 0][j];
194  // diff(u,z) - diff(w,x);
195  t4 = grad[0 * spacedim + 2][j] - grad[2 * spacedim + 0][j];
196 
197  t5 = t2 * t2;
198  t6 = t4 * t4;
199  t7 = t3 * t3;
200  t8 = t1 * t1;
201 
202  // diff(w,y) + diff(v,z);
203  t10 = grad[2 * spacedim + 1][j] + grad[1 * spacedim + 2][j];
204  // diff(w,y) - diff(v,z);
205  t11 = grad[2 * spacedim + 1][j] - grad[1 * spacedim + 2][j];
206 
207  t13 = 0.25 * (t10 * t2 + t11 * t4) +
208  0.5 * t1 *
209  (grad[0 * spacedim + 0][j] + grad[1 * spacedim + 1][j]);
210  t14 = 0.5 * t2 *
211  (grad[0 * spacedim + 0][j] + grad[2 * spacedim + 2][j]) +
212  0.25 * (t1 * t10 - t11 * t3);
213  t15 = t10 * t10;
214  t11 = t11 * t11;
215  t1 = 0.5 * t10 *
216  (grad[1 * spacedim + 1][j] + grad[2 * spacedim + 2][j]) -
217  0.25 * (-t1 * t2 + t3 * t4);
218 
219  a00 = 0.25 * (t5 - t6 - t7 + t8) +
220  grad[0 * spacedim + 0][j] * grad[0 * spacedim + 0][j];
221  a01 = t13;
222  a02 = t14;
223  a11 = 0.25 * (-t7 + t8 + t15 - t11) +
224  grad[1 * spacedim + 1][j] * grad[1 * spacedim + 1][j];
225  a12 = t1;
226  a22 = 0.25 * (t5 - t6 + t15 - t11) +
227  grad[2 * spacedim + 2][j] * grad[2 * spacedim + 2][j];
228 
229  // Compute the eigenvalues of a symmetric 3x3 matrix
230  MatSymEVals(a00, a11, a22, a01, a02, a12, outfield1, outfield2[j],
231  outfield3);
232  }
233 
234  Exp = m_f->AppendExpList(m_f->m_numHomogeneousDir);
235  Vmath::Vcopy(npoints, outfield2, 1, Exp->UpdatePhys(), 1);
236  Exp->FwdTrans_IterPerExp(outfield2, Exp->UpdateCoeffs());
237  auto it = m_f->m_exp.begin() + s * (nfields + 1) + nfields;
238  m_f->m_exp.insert(it, Exp);
239  }
240 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void MatSymEVals(NekDouble d1, NekDouble d2, NekDouble d3, NekDouble a, NekDouble b, NekDouble c, NekDouble &l1, NekDouble &l2, NekDouble &l3)
Calculates eigenvalues of a 3x3 Symmetric matrix.
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessL2Criterion::className
static
Initial value:
=
"Computes Lambda 2 Criterion.")

Definition at line 57 of file ProcessL2Criterion.h.