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 ()
 
- 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)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
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 AddFile (std::string fileType, std::string fileName)
 
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

virtual void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
virtual ModulePriority v_GetModulePriority () override
 
void GetVelocity (Array< OneD, Array< OneD, NekDouble >> &vel, int totfields, int strip=0)
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Private Attributes

int m_spacedim
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. 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 57 of file ProcessVorticity.cpp.

57  : ProcessModule(f)
58 {
59 }

◆ ~ProcessVorticity()

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

Definition at line 61 of file ProcessVorticity.cpp.

62 {
63 }

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.

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

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

◆ GetVelocity()

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

Definition at line 224 of file ProcessVorticity.cpp.

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

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

Referenced by v_Process().

◆ v_GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessVorticity::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessVorticity.h.

71  {
72  return "Calculating vorticity";
73  }

◆ v_GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessVorticity::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessVorticity.h.

66  {
67  return "ProcessVorticity";
68  }

◆ v_GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessVorticity::v_GetModulePriority ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessVorticity.h.

76  {
77  return eModifyExp;
78  }

References Nektar::FieldUtils::eModifyExp.

◆ v_Process()

void Nektar::FieldUtils::ProcessVorticity::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessVorticity.cpp.

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

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessVorticity::className
static
Initial value:
=
"Computes vorticity field.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 56 of file ProcessVorticity.h.

◆ m_spacedim

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

Definition at line 85 of file ProcessVorticity.h.

Referenced by GetVelocity(), and v_Process().