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::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::FieldUtils::ProcessVorticity:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::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...
 
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 vorticity and adds it as an extra-field to the output file.

Definition at line 49 of file ProcessVorticity.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::ProcessVorticity::ProcessVorticity ( FieldSharedPtr  f)

Definition at line 58 of file ProcessVorticity.cpp.

Nektar::FieldUtils::ProcessVorticity::~ProcessVorticity ( )
virtual

Definition at line 62 of file ProcessVorticity.cpp.

63 {
64 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 53 of file ProcessVorticity.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::FieldUtils::ProcessVorticity::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessVorticity.h.

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

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessVorticity.cpp.

References ASSERTL0, Nektar::FieldUtils::ProcessMapping::GetMapping(), Nektar::iterator, Nektar::FieldUtils::Module::m_f, Nektar::GlobalMapping::MappingSharedPtr, Vmath::Vcopy(), and Vmath::Vsub().

67 {
68  if (m_f->m_verbose)
69  {
70  if (m_f->m_comm->TreatAsRankZero())
71  {
72  cout << "ProcessVorticity: Calculating vorticity..." << endl;
73  }
74  }
75 
76  int i, j, s;
77  int expdim = m_f->m_graph->GetMeshDimension();
78  int spacedim = expdim;
79  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
80  (m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
81  {
82  spacedim = 3;
83  }
84  int nfields = m_f->m_fielddef[0]->m_fields.size();
85  if (spacedim == 1)
86  {
87  ASSERTL0(false, "Error: Vorticity for a 1D problem cannot "
88  "be computed")
89  }
90  int addfields = (spacedim == 2) ? 1 : 3;
91 
92  int npoints = m_f->m_exp[0]->GetNpoints();
93  Array<OneD, Array<OneD, NekDouble> > grad(spacedim * spacedim);
94  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
95 
96  int nstrips;
97 
98  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
99 
100  m_f->m_exp.resize(nfields * nstrips);
101 
102  for (i = 0; i < spacedim * spacedim; ++i)
103  {
104  grad[i] = Array<OneD, NekDouble>(npoints);
105  }
106 
107  for (i = 0; i < addfields; ++i)
108  {
109  outfield[i] = Array<OneD, NekDouble>(npoints);
110  }
111 
112  Array<OneD, Array<OneD, NekDouble> > tmp(spacedim);
113  for (int i = 0; i < spacedim; i++)
114  {
115  tmp[i] = Array<OneD, NekDouble>(npoints);
116  }
117 
118  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips * addfields);
119 
120  // Get mapping
122 
123  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
124  {
125  // Get velocity and convert to Cartesian system,
126  // if it is still in transformed system
127  Array<OneD, Array<OneD, NekDouble> > vel(spacedim);
128  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
129  {
130  if (m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
131  {
132  // Initialize arrays and copy velocity
133  for (int i = 0; i < spacedim; ++i)
134  {
135  vel[i] = Array<OneD, NekDouble>(npoints);
136  if (m_f->m_exp[0]->GetWaveSpace())
137  {
138  m_f->m_exp[0]->HomogeneousBwdTrans(
139  m_f->m_exp[s * nfields + i]->GetPhys(), vel[i]);
140  }
141  else
142  {
143  Vmath::Vcopy(npoints,
144  m_f->m_exp[s * nfields + i]->GetPhys(), 1,
145  vel[i], 1);
146  }
147  }
148  // Convert velocity to cartesian system
149  mapping->ContravarToCartesian(vel, vel);
150  // Convert back to wavespace if necessary
151  if (m_f->m_exp[0]->GetWaveSpace())
152  {
153  for (int i = 0; i < spacedim; ++i)
154  {
155  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
156  }
157  }
158  }
159  else
160  {
161  for (int i = 0; i < spacedim; ++i)
162  {
163  vel[i] = Array<OneD, NekDouble>(npoints);
164  Vmath::Vcopy(npoints,
165  m_f->m_exp[s * nfields + i]->GetPhys(), 1,
166  vel[i], 1);
167  }
168  }
169  }
170  else
171  {
172  for (int i = 0; i < spacedim; ++i)
173  {
174  vel[i] = Array<OneD, NekDouble>(npoints);
175  Vmath::Vcopy(npoints, m_f->m_exp[s * nfields + i]->GetPhys(), 1,
176  vel[i], 1);
177  }
178  }
179 
180  // Calculate Gradient & Vorticity
181  if (spacedim == 2)
182  {
183  for (i = 0; i < spacedim; ++i)
184  {
185  m_f->m_exp[s * nfields + i]->PhysDeriv(vel[i], tmp[0], tmp[1]);
186  mapping->CovarToCartesian(tmp, tmp);
187  for (int j = 0; j < spacedim; j++)
188  {
189  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * spacedim + j], 1);
190  }
191  }
192  // W_z = Vx - Uy
193  Vmath::Vsub(npoints, grad[1 * spacedim + 0], 1,
194  grad[0 * spacedim + 1], 1, outfield[0], 1);
195  }
196  else
197  {
198  for (i = 0; i < spacedim; ++i)
199  {
200  m_f->m_exp[s * nfields + i]->PhysDeriv(vel[i], tmp[0], tmp[1],
201  tmp[2]);
202  mapping->CovarToCartesian(tmp, tmp);
203  for (int j = 0; j < spacedim; j++)
204  {
205  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * spacedim + j], 1);
206  }
207  }
208 
209  // W_x = Wy - Vz
210  Vmath::Vsub(npoints, grad[2 * spacedim + 1], 1,
211  grad[1 * spacedim + 2], 1, outfield[0], 1);
212  // W_y = Uz - Wx
213  Vmath::Vsub(npoints, grad[0 * spacedim + 2], 1,
214  grad[2 * spacedim + 0], 1, outfield[1], 1);
215  // W_z = Vx - Uy
216  Vmath::Vsub(npoints, grad[1 * spacedim + 0], 1,
217  grad[0 * spacedim + 1], 1, outfield[2], 1);
218  }
219 
220  for (i = 0; i < addfields; ++i)
221  {
222  int n = s * addfields + i;
223  Exp[n] =
224  m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
225  Vmath::Vcopy(npoints, outfield[i], 1, Exp[n]->UpdatePhys(), 1);
226  Exp[n]->FwdTrans_IterPerExp(outfield[i], Exp[n]->UpdateCoeffs());
227  }
228  }
229 
231  for (s = 0; s < nstrips; ++s)
232  {
233  for (i = 0; i < addfields; ++i)
234  {
235  it = m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
236  m_f->m_exp.insert(it, Exp[s * addfields + i]);
237  }
238  }
239 
240  vector<string> outname;
241  if (addfields == 1)
242  {
243  outname.push_back("W_z");
244  }
245  else
246  {
247  outname.push_back("W_x");
248  outname.push_back("W_y");
249  outname.push_back("W_z");
250  }
251 
252  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
253  m_f->m_exp[0]->GetFieldDefinitions();
254  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
255 
256  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
257  {
258  for (j = 0; j < nfields + addfields; ++j)
259  {
260  for (i = 0; i < FieldDef.size() / nstrips; ++i)
261  {
262  int n = s * FieldDef.size() / nstrips + i;
263 
264  if (j >= nfields)
265  {
266  FieldDef[n]->m_fields.push_back(outname[j - nfields]);
267  }
268  else
269  {
270  FieldDef[n]->m_fields.push_back(
271  m_f->m_fielddef[0]->m_fields[j]);
272  }
273  m_f->m_exp[s * (nfields + addfields) + j]->AppendFieldData(
274  FieldDef[n], FieldData[n]);
275  }
276  }
277  }
278 
279  m_f->m_fielddef = FieldDef;
280  m_f->m_data = FieldData;
281 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
GLOBAL_MAPPING_EXPORT typedef boost::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:51
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 Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
FieldSharedPtr m_f
Field object.

Member Data Documentation

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

Definition at line 57 of file ProcessVorticity.h.