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)
 
 ~ProcessVorticity () override
 
- 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 ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
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

void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
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 ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

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 46 of file ProcessVorticity.h.

Constructor & Destructor Documentation

◆ ProcessVorticity()

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

Definition at line 53 of file ProcessVorticity.cpp.

◆ ~ProcessVorticity()

Nektar::FieldUtils::ProcessVorticity::~ProcessVorticity ( )
override

Definition at line 57 of file ProcessVorticity.cpp.

58{
59}

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 50 of file ProcessVorticity.h.

51 {
53 }
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 220 of file ProcessVorticity.cpp.

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

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

Referenced by v_Process().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 68 of file ProcessVorticity.h.

69 {
70 return "Calculating vorticity";
71 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 63 of file ProcessVorticity.h.

64 {
65 return "ProcessVorticity";
66 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 73 of file ProcessVorticity.h.

74 {
75 return eModifyExp;
76 }

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 61 of file ProcessVorticity.cpp.

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

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:197
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 54 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 v_Process().