Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private 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:
[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 ()
 
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
 

Protected Member Functions

void GetVelocity (Array< OneD, Array< OneD, NekDouble > > &vel, int strip=0)
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Private Attributes

int m_spacedim
 

Additional Inherited Members

- 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 vorticity and adds it as an extra-field to the output file.

Definition at line 48 of file ProcessVorticity.h.

Constructor & Destructor Documentation

◆ ProcessVorticity()

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

Definition at line 58 of file ProcessVorticity.cpp.

◆ ~ProcessVorticity()

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

Definition at line 62 of file ProcessVorticity.cpp.

63 {
64 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 52 of file ProcessVorticity.h.

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

53  {
55  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessVorticity::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessVorticity.h.

70  {
71  return "Calculating vorticity";
72  }

◆ GetModuleName()

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

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessVorticity.h.

65  {
66  return "ProcessVorticity";
67  }

◆ GetModulePriority()

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

Implements Nektar::FieldUtils::Module.

Definition at line 74 of file ProcessVorticity.h.

References Nektar::FieldUtils::eModifyExp, and GetVelocity().

◆ GetVelocity()

void Nektar::FieldUtils::ProcessVorticity::GetVelocity ( Array< OneD, Array< OneD, NekDouble > > &  vel,
int  strip = 0 
)
protected

Definition at line 220 of file ProcessVorticity.cpp.

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

Referenced by GetModulePriority(), and Process().

222 {
223  int nfields = m_f->m_variables.size();
224  int npoints = m_f->m_exp[0]->GetNpoints();
225  if(boost::iequals(m_f->m_variables[0], "u"))
226  {
227  // IncNavierStokesSolver
228  for (int i = 0; i < m_spacedim; ++i)
229  {
230  vel[i] = Array<OneD, NekDouble>(npoints);
231  Vmath::Vcopy(npoints,
232  m_f->m_exp[strip * nfields + i]->GetPhys(), 1,
233  vel[i], 1);
234  }
235  }
236  else if(boost::iequals(m_f->m_variables[0], "rho") &&
237  boost::iequals(m_f->m_variables[1], "rhou"))
238  {
239  // CompressibleFlowSolver
240  for (int i = 0; i < m_spacedim; ++i)
241  {
242  vel[i] = Array<OneD, NekDouble>(npoints);
243  Vmath::Vdiv(npoints,
244  m_f->m_exp[strip * nfields + i + 1]->GetPhys(), 1,
245  m_f->m_exp[strip * nfields + 0 ]->GetPhys(), 1,
246  vel[i], 1);
247  }
248  }
249  else
250  {
251  // Unknown
252  ASSERTL0(false, "Could not identify velocity for ProcessVorticity");
253  }
254 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
void Vdiv(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:244
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
FieldSharedPtr m_f
Field object.

◆ Process()

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(), GetVelocity(), Nektar::FieldUtils::Module::m_f, m_spacedim, Nektar::GlobalMapping::MappingSharedPtr, Vmath::Vcopy(), and Vmath::Vsub().

67 {
68  boost::ignore_unused(vm);
69 
70  int i, s;
71  int expdim = m_f->m_graph->GetMeshDimension();
72  m_spacedim = expdim;
73  if ((m_f->m_numHomogeneousDir) == 1 || (m_f->m_numHomogeneousDir) == 2)
74  {
75  m_spacedim = 3;
76  }
77  int nfields = m_f->m_variables.size();
78  ASSERTL0(m_spacedim != 1,
79  "Error: Vorticity for a 1D problem cannot be computed");
80  int addfields = (m_spacedim == 2) ? 1 : 3;
81 
82  // Append field names
83  if (addfields == 1)
84  {
85  m_f->m_variables.push_back("W_z");
86  }
87  else
88  {
89  m_f->m_variables.push_back("W_x");
90  m_f->m_variables.push_back("W_y");
91  m_f->m_variables.push_back("W_z");
92  }
93 
94  // Skip in case of empty partition
95  if (m_f->m_exp[0]->GetNumElmts() == 0)
96  {
97  return;
98  }
99  int npoints = m_f->m_exp[0]->GetNpoints();
100  Array<OneD, Array<OneD, NekDouble> > grad(m_spacedim * m_spacedim);
101  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
102 
103  int nstrips;
104 
105  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
106 
107  for (i = 0; i < m_spacedim * m_spacedim; ++i)
108  {
109  grad[i] = Array<OneD, NekDouble>(npoints);
110  }
111 
112  for (i = 0; i < addfields; ++i)
113  {
114  outfield[i] = Array<OneD, NekDouble>(npoints);
115  }
116 
117  Array<OneD, Array<OneD, NekDouble> > tmp(m_spacedim);
118  for (int i = 0; i < m_spacedim; i++)
119  {
120  tmp[i] = Array<OneD, NekDouble>(npoints);
121  }
122 
123  vector<MultiRegions::ExpListSharedPtr> Exp(nstrips * addfields);
124 
125  // Get mapping
127 
128  for (s = 0; s < nstrips; ++s) // homogeneous strip varient
129  {
130  // Get velocity and convert to Cartesian system,
131  // if it is still in transformed system
132  Array<OneD, Array<OneD, NekDouble> > vel(m_spacedim);
133  GetVelocity(vel, s);
134  if (m_f->m_fieldMetaDataMap.count("MappingCartesianVel"))
135  {
136  if (m_f->m_fieldMetaDataMap["MappingCartesianVel"] == "False")
137  {
138  // Initialize arrays and copy velocity
139  if (m_f->m_exp[0]->GetWaveSpace())
140  {
141  for (int i = 0; i < m_spacedim; ++i)
142  {
143  m_f->m_exp[0]->HomogeneousBwdTrans(vel[i], vel[i]);
144  }
145  }
146  // Convert velocity to cartesian system
147  mapping->ContravarToCartesian(vel, vel);
148  // Convert back to wavespace if necessary
149  if (m_f->m_exp[0]->GetWaveSpace())
150  {
151  for (int i = 0; i < m_spacedim; ++i)
152  {
153  m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
154  }
155  }
156  }
157  }
158 
159  // Calculate Gradient & Vorticity
160  if (m_spacedim == 2)
161  {
162  for (i = 0; i < m_spacedim; ++i)
163  {
164  m_f->m_exp[s * nfields + i]->PhysDeriv(vel[i], tmp[0], tmp[1]);
165  mapping->CovarToCartesian(tmp, tmp);
166  for (int j = 0; j < m_spacedim; j++)
167  {
168  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * m_spacedim + j], 1);
169  }
170  }
171  // W_z = Vx - Uy
172  Vmath::Vsub(npoints, grad[1 * m_spacedim + 0], 1,
173  grad[0 * m_spacedim + 1], 1, outfield[0], 1);
174  }
175  else
176  {
177  for (i = 0; i < m_spacedim; ++i)
178  {
179  m_f->m_exp[s * nfields + i]->PhysDeriv(vel[i], tmp[0], tmp[1],
180  tmp[2]);
181  mapping->CovarToCartesian(tmp, tmp);
182  for (int j = 0; j < m_spacedim; j++)
183  {
184  Vmath::Vcopy(npoints, tmp[j], 1, grad[i * m_spacedim + j], 1);
185  }
186  }
187 
188  // W_x = Wy - Vz
189  Vmath::Vsub(npoints, grad[2 * m_spacedim + 1], 1,
190  grad[1 * m_spacedim + 2], 1, outfield[0], 1);
191  // W_y = Uz - Wx
192  Vmath::Vsub(npoints, grad[0 * m_spacedim + 2], 1,
193  grad[2 * m_spacedim + 0], 1, outfield[1], 1);
194  // W_z = Vx - Uy
195  Vmath::Vsub(npoints, grad[1 * m_spacedim + 0], 1,
196  grad[0 * m_spacedim + 1], 1, outfield[2], 1);
197  }
198 
199  for (i = 0; i < addfields; ++i)
200  {
201  int n = s * addfields + i;
202  Exp[n] =
203  m_f->AppendExpList(m_f->m_numHomogeneousDir);
204  Vmath::Vcopy(npoints, outfield[i], 1, Exp[n]->UpdatePhys(), 1);
205  Exp[n]->FwdTrans_IterPerExp(outfield[i], Exp[n]->UpdateCoeffs());
206  }
207  }
208 
209  for (s = 0; s < nstrips; ++s)
210  {
211  for (i = 0; i < addfields; ++i)
212  {
213  m_f->m_exp.insert(
214  m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i,
215  Exp[s * addfields + i]);
216  }
217  }
218 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
void GetVelocity(Array< OneD, Array< OneD, NekDouble > > &vel, int strip=0)
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:346
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50
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::ProcessVorticity::className
static
Initial value:

Definition at line 56 of file ProcessVorticity.h.

◆ m_spacedim

int Nektar::FieldUtils::ProcessVorticity::m_spacedim
private

Definition at line 83 of file ProcessVorticity.h.

Referenced by GetVelocity(), and Process().