Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::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::Utilities::ProcessQCriterion:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::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::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

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::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_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 50 of file ProcessQCriterion.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessQCriterion::ProcessQCriterion ( FieldSharedPtr  f)

Definition at line 55 of file ProcessQCriterion.cpp.

Nektar::Utilities::ProcessQCriterion::~ProcessQCriterion ( )
virtual

Definition at line 60 of file ProcessQCriterion.cpp.

61 {
62 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 54 of file ProcessQCriterion.h.

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

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

Implements Nektar::Utilities::Module.

Definition at line 65 of file ProcessQCriterion.h.

66  {
67  return "ProcessQCriterion";
68  }
void Nektar::Utilities::ProcessQCriterion::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 64 of file ProcessQCriterion.cpp.

References Nektar::iterator, Nektar::Utilities::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" << endl;
87  }
88 
89  //For calculating Q-Criterion only 1 field must be added
90  int addfields = 1;
91 
92  int npoints = m_f->m_exp[0]->GetNpoints();
93 
94  Array<OneD, Array<OneD, NekDouble> > grad(nfields * nfields);
95 
96  Array<OneD, Array<OneD, NekDouble> > omega(nfields * nfields);
97  Array<OneD, Array<OneD, NekDouble> > S (nfields * nfields);
98 
99  Array<OneD, Array<OneD, NekDouble> > outfield (addfields);
100  Array<OneD, Array<OneD, NekDouble> > outfield1(addfields);
101  Array<OneD, Array<OneD, NekDouble> > outfield2(addfields);
102  Array<OneD, Array<OneD, NekDouble> > outfield3(addfields);
103 
104  int nstrips;
105 
106  m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
107 
108  m_f->m_exp.resize(nfields*nstrips);
109 
110  for (i = 0; i < nfields*nfields; ++i)
111  {
112  grad[i] = Array<OneD, NekDouble>(npoints);
113  }
114 
115  for (i = 0; i < addfields; ++i)
116  {
117  //Will store the Q-Criterion
118  outfield[i] = Array<OneD, NekDouble>(npoints);
119  outfield1[i] = Array<OneD, NekDouble>(npoints);
120  outfield2[i] = Array<OneD, NekDouble>(npoints);
121  outfield3[i] = Array<OneD, NekDouble>(npoints);
122 
123  omega[i] = Array<OneD, NekDouble>(npoints);
124  S[i] = Array<OneD, NekDouble>(npoints);
125  }
126 
127  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips*addfields);
128 
129  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
130  {
131  for (i = 0; i < nfields; ++i)
132  {
133  m_f->m_exp[s*nfields+i]->PhysDeriv(m_f->m_exp[s*nfields+i]->GetPhys(),
134  grad[i*nfields],
135  grad[i*nfields+1],
136  grad[i*nfields+2]);
137  }
138 
139  // W_x = Wy - Vz
140  Vmath::Vsub(npoints, grad[2 * nfields + 1], 1,
141  grad[1 * nfields + 2], 1,
142  outfield1[0], 1);
143  // W_x^2
144  Vmath::Vmul(npoints, outfield1[0], 1,
145  outfield1[0], 1,
146  outfield1[0], 1);
147 
148  // W_y = Uz - Wx
149  Vmath::Vsub(npoints, grad[0 * nfields + 2], 1,
150  grad[2 * nfields + 0], 1,
151  outfield2[0], 1);
152  // W_y^2
153  Vmath::Vmul(npoints, outfield2[0], 1,
154  outfield2[0], 1,
155  outfield2[0], 1);
156 
157  // W_z = Vx - Uy
158  Vmath::Vsub(npoints, grad[1 * nfields + 0], 1,
159  grad[0 * nfields + 1], 1,
160  outfield3[0], 1);
161  // W_z^2
162  Vmath::Vmul(npoints, outfield3[0], 1,
163  outfield3[0], 1,
164  outfield3[0], 1);
165 
166  // add fields omega = 0.5*(W_x^2 + W_y^2 + W_z^2)
167 
168  NekDouble fac = 0.5;
169  Vmath::Vadd(npoints, &outfield1[0][0], 1,
170  &outfield2[0][0], 1,
171  &omega[0][0], 1);
172  Vmath::Vadd(npoints, &omega[0][0], 1,
173  &outfield3[0][0], 1,
174  &omega[0][0], 1);
175 
176  for (int k = 0; k < addfields; ++k)
177  {
178  Vmath::Smul(npoints, fac, &omega[k][0], 1, &omega[k][0], 1);
179  }
180 
181  Vmath::Zero(npoints, &outfield1[0][0], 1);
182  Vmath::Zero(npoints, &outfield2[0][0], 1);
183  Vmath::Zero(npoints, &outfield3[0][0], 1);
184 
185  Vmath::Vmul(npoints, grad[0 * nfields + 0], 1,
186  grad[0 * nfields + 0], 1,
187  outfield1[0], 1);
188  Vmath::Vmul(npoints, grad[1 * nfields + 1], 1,
189  grad[1 * nfields + 1], 1,
190  outfield2[0], 1);
191  Vmath::Vmul(npoints, grad[2 * nfields + 2], 1,
192  grad[2 * nfields + 2], 1,
193  outfield3[0], 1);
194 
195  Vmath::Vadd(npoints, &outfield1[0][0], 1,
196  &outfield2[0][0], 1,
197  &S[0][0], 1);
198  Vmath::Vadd(npoints, &S[0][0], 1,
199  &outfield3[0][0], 1,
200  &S[0][0], 1);
201 
202  // W_y + V_z
203  Vmath::Vadd(npoints, grad[2 * nfields + 1], 1,
204  grad[1 * nfields + 2], 1,
205  outfield1[0], 1);
206  Vmath::Vmul(npoints, &outfield1[0][0], 1,
207  &outfield1[0][0], 1,
208  &outfield1[0][0], 1);
209 
210  // U_z + W_x
211  Vmath::Vadd(npoints, grad[0 * nfields + 2], 1,
212  grad[2 * nfields + 0], 1,
213  outfield2[0], 1);
214  Vmath::Vmul(npoints, &outfield2[0][0], 1,
215  &outfield2[0][0], 1,
216  &outfield2[0][0], 1);
217 
218  // V_x + U_y
219  Vmath::Vadd(npoints, grad[1 * nfields + 0], 1,
220  grad[0 * nfields + 1], 1,
221  outfield3[0], 1);
222  Vmath::Vmul(npoints, &outfield3[0][0], 1,
223  &outfield3[0][0], 1,
224  &outfield3[0][0], 1);
225 
226  Vmath::Vadd(npoints, &outfield1[0][0], 1,
227  &outfield2[0][0], 1,
228  &outfield2[0][0], 1);
229  Vmath::Vadd(npoints, &outfield2[0][0], 1,
230  &outfield3[0][0], 1,
231  &outfield3[0][0], 1);
232 
233  for (int k = 0; k < addfields; ++k)
234  {
235  Vmath::Smul(npoints, fac, &outfield3[k][0], 1,
236  &outfield3[k][0], 1);
237  }
238 
239  Vmath::Vadd(npoints, &outfield3[0][0], 1, &S[0][0], 1, &S[0][0], 1);
240  Vmath::Vsub(npoints, omega[0], 1, S[0], 1, outfield[0], 1);
241 
242  for (int k = 0; k < addfields; ++k)
243  {
244  Vmath::Smul(npoints, fac, &outfield[k][0], 1,
245  &outfield[k][0], 1);
246  }
247 
248 
249  for (i = 0; i < addfields; ++i)
250  {
251  int n = s*addfields + i;
252  Exp[n] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
253  Exp[n]->UpdatePhys() = outfield[i];
254  Exp[n]->FwdTrans(outfield[i],
255  Exp[n]->UpdateCoeffs());
256  }
257  }
258 
260 
261  for(s = 0; s < nstrips; ++s)
262  {
263  for(i = 0; i < addfields; ++i)
264  {
265  it = m_f->m_exp.begin()+s*(nfields+addfields)+nfields+i;
266  m_f->m_exp.insert(it, Exp[s*addfields+i]);
267  }
268  }
269 
270  vector<string> outname;
271  outname.push_back("Q");
272 
273  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
274  = m_f->m_exp[0]->GetFieldDefinitions();
275  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
276 
277  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
278  {
279  for (j = 0; j < nfields + addfields; ++j)
280  {
281  for (i = 0; i < FieldDef.size()/nstrips; ++i)
282  {
283  int n = s * FieldDef.size()/nstrips + i;
284 
285  if (j >= nfields)
286  {
287  FieldDef[n]->m_fields.push_back(outname[j-nfields]);
288  }
289  else
290  {
291  FieldDef[n]->m_fields.push_back(
292  m_f->m_fielddef[0]->m_fields[j]);
293  }
294  m_f->m_exp[s*(nfields + addfields)+j]->AppendFieldData(FieldDef[n], FieldData[n]);
295  }
296  }
297  }
298 
299  m_f->m_fielddef = FieldDef;
300  m_f->m_data = FieldData;
301 }
FieldSharedPtr m_f
Field 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:199
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:329
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:359
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
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:169

Member Data Documentation

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

Definition at line 57 of file ProcessQCriterion.h.