Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::ProcessVorticity Class Reference

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

#include <ProcessVorticity.h>

Inheritance diagram for Nektar::Utilities::ProcessVorticity:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessVorticity:
Collaboration graph
[legend]

Public Member Functions

 ProcessVorticity (FieldSharedPtr f)
 
virtual ~ProcessVorticity ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
- 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 (string key, string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 

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 ()
 
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...
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, 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...
 

Detailed Description

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

Definition at line 49 of file ProcessVorticity.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessVorticity::ProcessVorticity ( FieldSharedPtr  f)

Definition at line 55 of file ProcessVorticity.cpp.

Nektar::Utilities::ProcessVorticity::~ProcessVorticity ( )
virtual

Definition at line 59 of file ProcessVorticity.cpp.

60 {
61 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 53 of file ProcessVorticity.h.

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

53  {
55  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::ProcessVorticity::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 63 of file ProcessVorticity.cpp.

References ASSERTL0, Nektar::iterator, Nektar::Utilities::Module::m_f, and Vmath::Vsub().

64 {
65  if (m_f->m_verbose)
66  {
67  cout << "ProcessVorticity: Calculating vorticity..." << endl;
68  }
69 
70  int i, j, s;
71  int expdim = m_f->m_graph->GetMeshDimension();
72  int spacedim = expdim;
73  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
74  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
75  {
76  spacedim = 3;
77  }
78  int nfields = m_f->m_fielddef[0]->m_fields.size();
79  if (spacedim == 1)
80  {
81  ASSERTL0(false, "Error: Vorticity for a 1D problem cannot "
82  "be computed")
83  }
84  int addfields = (spacedim == 2)? 1:3;
85 
86  int npoints = m_f->m_exp[0]->GetNpoints();
87  Array<OneD, Array<OneD, NekDouble> > grad(nfields*nfields);
88  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
89 
90  int nstrips;
91 
92  m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
93 
94  m_f->m_exp.resize(nfields*nstrips);
95 
96  for (i = 0; i < nfields*nfields; ++i)
97  {
98  grad[i] = Array<OneD, NekDouble>(npoints);
99  }
100 
101  for (i = 0; i < addfields; ++i)
102  {
103  outfield[i] = Array<OneD, NekDouble>(npoints);
104  }
105 
106  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips*addfields);
107 
108  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
109  {
110  // Calculate Gradient & Vorticity
111  if (spacedim == 2)
112  {
113  for (i = 0; i < nfields; ++i)
114  {
115  m_f->m_exp[s*nfields+i]->PhysDeriv(m_f->m_exp[s*nfields+i]->GetPhys(),
116  grad[i*nfields],
117  grad[i*nfields+1]);
118  }
119  // W_z = Vx - Uy
120  Vmath::Vsub(npoints, grad[1*nfields+0], 1,
121  grad[0*nfields+1], 1,
122  outfield[0], 1);
123  }
124  else
125  {
126  for (i = 0; i < nfields; ++i)
127  {
128 
129  m_f->m_exp[s*nfields+i]->PhysDeriv(m_f->m_exp[s*nfields+i]->GetPhys(),
130  grad[i*nfields],
131  grad[i*nfields+1],
132  grad[i*nfields+2]);
133  }
134 
135  // W_x = Wy - Vz
136  Vmath::Vsub(npoints, grad[2*nfields+1], 1, grad[1*nfields+2], 1,
137  outfield[0],1);
138  // W_y = Uz - Wx
139  Vmath::Vsub(npoints, grad[0*nfields+2], 1, grad[2*nfields+0], 1,
140  outfield[1], 1);
141  // W_z = Vx - Uy
142  Vmath::Vsub(npoints, grad[1*nfields+0], 1, grad[0*nfields+1], 1,
143  outfield[2], 1);
144  }
145 
146  for (i = 0; i < addfields; ++i)
147  {
148  int n = s*addfields + i;
149  Exp[n] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
150  Exp[n]->UpdatePhys() = outfield[i];
151  Exp[n]->FwdTrans_IterPerExp(outfield[i],
152  Exp[n]->UpdateCoeffs());
153  }
154  }
155 
157  for(s = 0; s < nstrips; ++s)
158  {
159  for(i = 0; i < addfields; ++i)
160  {
161  it = m_f->m_exp.begin()+s*(nfields+addfields)+nfields+i;
162  m_f->m_exp.insert(it, Exp[s*addfields+i]);
163  }
164  }
165 
166  vector<string > outname;
167  if (addfields == 1)
168  {
169  outname.push_back("W_z");
170  }
171  else
172  {
173  outname.push_back("W_x");
174  outname.push_back("W_y");
175  outname.push_back("W_z");
176  }
177 
178  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
179  = m_f->m_exp[0]->GetFieldDefinitions();
180  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
181 
182  for(s = 0; s < nstrips; ++s) //homogeneous strip varient
183  {
184  for (j = 0; j < nfields + addfields; ++j)
185  {
186  for (i = 0; i < FieldDef.size()/nstrips; ++i)
187  {
188  int n = s * FieldDef.size()/nstrips + i;
189 
190  if (j >= nfields)
191  {
192  FieldDef[n]->m_fields.push_back(outname[j-nfields]);
193  }
194  else
195  {
196  FieldDef[n]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
197  }
198  m_f->m_exp[s*(nfields + addfields)+j]->AppendFieldData(FieldDef[n], FieldData[n]);
199  }
200  }
201  }
202 
203  m_f->m_fielddef = FieldDef;
204  m_f->m_data = FieldData;
205 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
FieldSharedPtr m_f
Field object.
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

Member Data Documentation

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

Definition at line 56 of file ProcessVorticity.h.