Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::ProcessQCriterion:
Collaboration graph
[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 ()
 
- 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 (string key, 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 bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::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...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

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

Definition at line 50 of file ProcessQCriterion.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file ProcessQCriterion.cpp.

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

Definition at line 60 of file ProcessQCriterion.cpp.

61 {
62 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessQCriterion.h.

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

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::ProcessQCriterion::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessQCriterion.h.

67  {
68  return "ProcessQCriterion";
69  }
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 Nektar::iterator, Nektar::FieldUtils::Module::m_f, Vmath::Smul(), Vmath::Vadd(), Vmath::Vmul(), Vmath::Vsub(), and Vmath::Zero().

65 {
66  if (m_f->m_verbose)
67  {
68  if (m_f->m_comm->TreatAsRankZero())
69  {
70  cout << "ProcessQCriterion: Calculating Q Criterion..." << endl;
71  }
72  }
73 
74  int i, j, s;
75  int expdim = m_f->m_graph->GetMeshDimension();
76  int spacedim = expdim;
77  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
78  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
79  {
80  spacedim = 3;
81  }
82  int nfields = m_f->m_fielddef[0]->m_fields.size();
83  if (spacedim == 1 || spacedim == 2)
84  {
85  cerr << "\n Error: ProcessQCriterion must be computed for a 3D"
86  " (or quasi-3D) case. \n"
87  << endl;
88  }
89 
90  // For calculating Q-Criterion only 1 field must be added
91  int addfields = 1;
92 
93  int npoints = m_f->m_exp[0]->GetNpoints();
94 
95  Array<OneD, Array<OneD, NekDouble> > grad(nfields * nfields);
96 
97  Array<OneD, Array<OneD, NekDouble> > omega(nfields * nfields);
98  Array<OneD, Array<OneD, NekDouble> > S(nfields * nfields);
99 
100  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
101  Array<OneD, Array<OneD, NekDouble> > outfield1(addfields);
102  Array<OneD, Array<OneD, NekDouble> > outfield2(addfields);
103  Array<OneD, Array<OneD, NekDouble> > outfield3(addfields);
104 
105  int nstrips;
106 
107  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
108 
109  m_f->m_exp.resize(nfields * nstrips);
110 
111  for (i = 0; i < nfields * nfields; ++i)
112  {
113  grad[i] = Array<OneD, NekDouble>(npoints);
114  }
115 
116  for (i = 0; i < addfields; ++i)
117  {
118  // Will store the Q-Criterion
119  outfield[i] = Array<OneD, NekDouble>(npoints);
120  outfield1[i] = Array<OneD, NekDouble>(npoints);
121  outfield2[i] = Array<OneD, NekDouble>(npoints);
122  outfield3[i] = Array<OneD, NekDouble>(npoints);
123 
124  omega[i] = Array<OneD, NekDouble>(npoints);
125  S[i] = Array<OneD, NekDouble>(npoints);
126  }
127 
128  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips * addfields);
129 
130  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
131  {
132  for (i = 0; i < nfields; ++i)
133  {
134  m_f->m_exp[s * nfields + i]->PhysDeriv(
135  m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * nfields],
136  grad[i * nfields + 1], grad[i * nfields + 2]);
137  }
138 
139  // W_x = Wy - Vz
140  Vmath::Vsub(npoints, grad[2 * nfields + 1], 1, grad[1 * nfields + 2], 1,
141  outfield1[0], 1);
142  // W_x^2
143  Vmath::Vmul(npoints, outfield1[0], 1, outfield1[0], 1, outfield1[0], 1);
144 
145  // W_y = Uz - Wx
146  Vmath::Vsub(npoints, grad[0 * nfields + 2], 1, grad[2 * nfields + 0], 1,
147  outfield2[0], 1);
148  // W_y^2
149  Vmath::Vmul(npoints, outfield2[0], 1, outfield2[0], 1, outfield2[0], 1);
150 
151  // W_z = Vx - Uy
152  Vmath::Vsub(npoints, grad[1 * nfields + 0], 1, grad[0 * nfields + 1], 1,
153  outfield3[0], 1);
154  // W_z^2
155  Vmath::Vmul(npoints, outfield3[0], 1, outfield3[0], 1, outfield3[0], 1);
156 
157  // add fields omega = 0.5*(W_x^2 + W_y^2 + W_z^2)
158 
159  NekDouble fac = 0.5;
160  Vmath::Vadd(npoints, &outfield1[0][0], 1, &outfield2[0][0], 1,
161  &omega[0][0], 1);
162  Vmath::Vadd(npoints, &omega[0][0], 1, &outfield3[0][0], 1, &omega[0][0],
163  1);
164 
165  for (int k = 0; k < addfields; ++k)
166  {
167  Vmath::Smul(npoints, fac, &omega[k][0], 1, &omega[k][0], 1);
168  }
169 
170  Vmath::Zero(npoints, &outfield1[0][0], 1);
171  Vmath::Zero(npoints, &outfield2[0][0], 1);
172  Vmath::Zero(npoints, &outfield3[0][0], 1);
173 
174  Vmath::Vmul(npoints, grad[0 * nfields + 0], 1, grad[0 * nfields + 0], 1,
175  outfield1[0], 1);
176  Vmath::Vmul(npoints, grad[1 * nfields + 1], 1, grad[1 * nfields + 1], 1,
177  outfield2[0], 1);
178  Vmath::Vmul(npoints, grad[2 * nfields + 2], 1, grad[2 * nfields + 2], 1,
179  outfield3[0], 1);
180 
181  Vmath::Vadd(npoints, &outfield1[0][0], 1, &outfield2[0][0], 1, &S[0][0],
182  1);
183  Vmath::Vadd(npoints, &S[0][0], 1, &outfield3[0][0], 1, &S[0][0], 1);
184 
185  // W_y + V_z
186  Vmath::Vadd(npoints, grad[2 * nfields + 1], 1, grad[1 * nfields + 2], 1,
187  outfield1[0], 1);
188  Vmath::Vmul(npoints, &outfield1[0][0], 1, &outfield1[0][0], 1,
189  &outfield1[0][0], 1);
190 
191  // U_z + W_x
192  Vmath::Vadd(npoints, grad[0 * nfields + 2], 1, grad[2 * nfields + 0], 1,
193  outfield2[0], 1);
194  Vmath::Vmul(npoints, &outfield2[0][0], 1, &outfield2[0][0], 1,
195  &outfield2[0][0], 1);
196 
197  // V_x + U_y
198  Vmath::Vadd(npoints, grad[1 * nfields + 0], 1, grad[0 * nfields + 1], 1,
199  outfield3[0], 1);
200  Vmath::Vmul(npoints, &outfield3[0][0], 1, &outfield3[0][0], 1,
201  &outfield3[0][0], 1);
202 
203  Vmath::Vadd(npoints, &outfield1[0][0], 1, &outfield2[0][0], 1,
204  &outfield2[0][0], 1);
205  Vmath::Vadd(npoints, &outfield2[0][0], 1, &outfield3[0][0], 1,
206  &outfield3[0][0], 1);
207 
208  for (int k = 0; k < addfields; ++k)
209  {
210  Vmath::Smul(npoints, fac, &outfield3[k][0], 1, &outfield3[k][0], 1);
211  }
212 
213  Vmath::Vadd(npoints, &outfield3[0][0], 1, &S[0][0], 1, &S[0][0], 1);
214  Vmath::Vsub(npoints, omega[0], 1, S[0], 1, outfield[0], 1);
215 
216  for (int k = 0; k < addfields; ++k)
217  {
218  Vmath::Smul(npoints, fac, &outfield[k][0], 1, &outfield[k][0], 1);
219  }
220 
221  for (i = 0; i < addfields; ++i)
222  {
223  int n = s * addfields + i;
224  Exp[n] =
225  m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
226  Exp[n]->UpdatePhys() = outfield[i];
227  Exp[n]->FwdTrans(outfield[i], Exp[n]->UpdateCoeffs());
228  }
229  }
230 
232 
233  for (s = 0; s < nstrips; ++s)
234  {
235  for (i = 0; i < addfields; ++i)
236  {
237  it = m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
238  m_f->m_exp.insert(it, Exp[s * addfields + i]);
239  }
240  }
241 
242  vector<string> outname;
243  outname.push_back("Q");
244 
245  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
246  m_f->m_exp[0]->GetFieldDefinitions();
247  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
248 
249  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
250  {
251  for (j = 0; j < nfields + addfields; ++j)
252  {
253  for (i = 0; i < FieldDef.size() / nstrips; ++i)
254  {
255  int n = s * FieldDef.size() / nstrips + i;
256 
257  if (j >= nfields)
258  {
259  FieldDef[n]->m_fields.push_back(outname[j - nfields]);
260  }
261  else
262  {
263  FieldDef[n]->m_fields.push_back(
264  m_f->m_fielddef[0]->m_fields[j]);
265  }
266  m_f->m_exp[s * (nfields + addfields) + j]->AppendFieldData(
267  FieldDef[n], FieldData[n]);
268  }
269  }
270  }
271 
272  m_f->m_fielddef = FieldDef;
273  m_f->m_data = FieldData;
274 }
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:213
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:343
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:373
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:299
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:183
FieldSharedPtr m_f
Field object.

Member Data Documentation

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

Definition at line 58 of file ProcessQCriterion.h.