Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::FieldUtils::ProcessQCriterion Class Reference

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

#include <ProcessQCriterion.h>

Inheritance diagram for Nektar::FieldUtils::ProcessQCriterion:
[legend]

Public Member Functions

 ProcessQCriterion (FieldSharedPtr f)
 
virtual ~ProcessQCriterion ()
 
- 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
 
- 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 ()
 

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

Definition at line 49 of file ProcessQCriterion.h.

Constructor & Destructor Documentation

◆ ProcessQCriterion()

Nektar::FieldUtils::ProcessQCriterion::ProcessQCriterion ( FieldSharedPtr  f)

Definition at line 55 of file ProcessQCriterion.cpp.

◆ ~ProcessQCriterion()

Nektar::FieldUtils::ProcessQCriterion::~ProcessQCriterion ( )
virtual

Definition at line 59 of file ProcessQCriterion.cpp.

60{
61}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 53 of file ProcessQCriterion.h.

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

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

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 71 of file ProcessQCriterion.h.

72 {
73 return "Calculating Q Criterion";
74 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessQCriterion.h.

67 {
68 return "ProcessQCriterion";
69 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 76 of file ProcessQCriterion.h.

77 {
78 return eModifyExp;
79 }

References Nektar::FieldUtils::eModifyExp.

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 63 of file ProcessQCriterion.cpp.

64{
65 m_f->SetUpExp(vm);
66
67 int nfields = m_f->m_variables.size();
68 m_f->m_variables.push_back("Q");
69 // Skip in case of empty partition
70 if (m_f->m_exp[0]->GetNumElmts() == 0)
71 {
72 return;
73 }
74
75 int i, s;
76 int expdim = m_f->m_graph->GetMeshDimension();
77 int spacedim = expdim + (m_f->m_numHomogeneousDir);
78
80 spacedim == 3 || spacedim == 2,
81 "ProcessQCriterion must be computed for a 2D, quasi-3D, or 3D case.");
82
83 int npoints = m_f->m_exp[0]->GetNpoints();
84
85 Array<OneD, Array<OneD, NekDouble>> grad(spacedim * spacedim);
86
87 Array<OneD, NekDouble> omega(npoints, 0.);
88 Array<OneD, NekDouble> S(npoints, 0.);
89
90 // Will store the Q-Criterion
91 Array<OneD, NekDouble> outfield(npoints);
92
93 int nstrips;
94
95 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
96
97 for (i = 0; i < spacedim * spacedim; ++i)
98 {
99 grad[i] = Array<OneD, NekDouble>(npoints);
100 }
101
103
104 for (s = 0; s < nstrips; ++s) // homogeneous strip varient
105 {
106 Exp = m_f->AppendExpList(m_f->m_numHomogeneousDir);
107 auto it = m_f->m_exp.begin() + s * (nfields + 1) + nfields;
108 m_f->m_exp.insert(it, Exp);
109 }
110
111 NekDouble fac = 0.5;
112 if (spacedim == 2)
113 {
114 for (s = 0; s < nstrips; ++s) // homogeneous strip varient
115 {
116 for (i = 0; i < spacedim; ++i)
117 {
118 m_f->m_exp[s * nfields + i]->PhysDeriv(
119 m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
120 grad[i * spacedim + 1]);
121 }
122
123 // W_z = Vx - Uy
124 Vmath::Vsub(npoints, grad[1 * spacedim + 0], 1,
125 grad[0 * spacedim + 1], 1, outfield, 1);
126 // W_z^2
127 Vmath::Vmul(npoints, outfield, 1, outfield, 1, omega, 1);
128
129 // Ux^2
130 Vmath::Vmul(npoints, grad[0 * spacedim + 0], 1,
131 grad[0 * spacedim + 0], 1, S, 1);
132 // Vy^2
133 Vmath::Vvtvp(npoints, grad[1 * spacedim + 1], 1,
134 grad[1 * spacedim + 1], 1, S, 1, S, 1);
135
136 // Vx + Uy
137 Vmath::Vadd(npoints, grad[1 * spacedim + 0], 1,
138 grad[0 * spacedim + 1], 1, outfield, 1);
139 Vmath::Vmul(npoints, outfield, 1, outfield, 1, outfield, 1);
140 Vmath::Svtvp(npoints, fac, outfield, 1, S, 1, S, 1);
141
142 Vmath::Svtvm(npoints, fac, omega, 1, S, 1, outfield, 1);
143 Vmath::Smul(npoints, fac, outfield, 1, outfield, 1);
144
145 int fid = s * (nfields + 1) + nfields;
146 Vmath::Vcopy(npoints, outfield, 1, m_f->m_exp[fid]->UpdatePhys(),
147 1);
148 Exp->FwdTransLocalElmt(outfield, m_f->m_exp[fid]->UpdateCoeffs());
149 }
150 }
151 else if (spacedim == 3)
152 {
153 Array<OneD, NekDouble> outfield1(npoints);
154 Array<OneD, NekDouble> outfield2(npoints);
155 Array<OneD, NekDouble> outfield3(npoints);
156 for (s = 0; s < nstrips; ++s) // homogeneous strip varient
157 {
158 for (i = 0; i < spacedim; ++i)
159 {
160 m_f->m_exp[s * nfields + i]->PhysDeriv(
161 m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
162 grad[i * spacedim + 1], grad[i * spacedim + 2]);
163 }
164
165 // W_x = Wy - Vz
166 Vmath::Vsub(npoints, grad[2 * spacedim + 1], 1,
167 grad[1 * spacedim + 2], 1, outfield1, 1);
168 // W_x^2
169 Vmath::Vmul(npoints, outfield1, 1, outfield1, 1, outfield1, 1);
170
171 // W_y = Uz - Wx
172 Vmath::Vsub(npoints, grad[0 * spacedim + 2], 1,
173 grad[2 * spacedim + 0], 1, outfield2, 1);
174 // W_y^2
175 Vmath::Vmul(npoints, outfield2, 1, outfield2, 1, outfield2, 1);
176
177 // W_z = Vx - Uy
178 Vmath::Vsub(npoints, grad[1 * spacedim + 0], 1,
179 grad[0 * spacedim + 1], 1, outfield3, 1);
180 // W_z^2
181 Vmath::Vmul(npoints, outfield3, 1, outfield3, 1, outfield3, 1);
182
183 // Omega = 0.5*(W_x^2 + W_y^2 + W_z^2)
184 Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, omega, 1);
185 Vmath::Vadd(npoints, omega, 1, outfield3, 1, omega, 1);
186 Vmath::Smul(npoints, fac, omega, 1, omega, 1);
187
188 // Ux^2
189 Vmath::Vmul(npoints, grad[0 * spacedim + 0], 1,
190 grad[0 * spacedim + 0], 1, outfield1, 1);
191 // Vy^2
192 Vmath::Vmul(npoints, grad[1 * spacedim + 1], 1,
193 grad[1 * spacedim + 1], 1, outfield2, 1);
194 // Wz^2
195 Vmath::Vmul(npoints, grad[2 * spacedim + 2], 1,
196 grad[2 * spacedim + 2], 1, outfield3, 1);
197
198 //
199 Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, S, 1);
200 Vmath::Vadd(npoints, S, 1, outfield3, 1, S, 1);
201
202 // Wy + Vz
203 Vmath::Vadd(npoints, grad[2 * spacedim + 1], 1,
204 grad[1 * spacedim + 2], 1, outfield1, 1);
205 Vmath::Vmul(npoints, outfield1, 1, outfield1, 1, outfield1, 1);
206
207 // Uz + Wx
208 Vmath::Vadd(npoints, grad[0 * spacedim + 2], 1,
209 grad[2 * spacedim + 0], 1, outfield2, 1);
210 Vmath::Vmul(npoints, outfield2, 1, outfield2, 1, outfield2, 1);
211
212 // Vx + Uy
213 Vmath::Vadd(npoints, grad[1 * spacedim + 0], 1,
214 grad[0 * spacedim + 1], 1, outfield3, 1);
215 Vmath::Vmul(npoints, outfield3, 1, outfield3, 1, outfield3, 1);
216
217 Vmath::Vadd(npoints, outfield1, 1, outfield2, 1, outfield2, 1);
218 Vmath::Vadd(npoints, outfield2, 1, outfield3, 1, outfield3, 1);
219
220 Vmath::Smul(npoints, fac, outfield3, 1, outfield3, 1);
221
222 Vmath::Vadd(npoints, outfield3, 1, S, 1, S, 1);
223 Vmath::Vsub(npoints, omega, 1, S, 1, outfield, 1);
224
225 Vmath::Smul(npoints, fac, outfield, 1, outfield, 1);
226
227 int fid = s * (nfields + 1) + nfields;
228 Vmath::Vcopy(npoints, outfield, 1, m_f->m_exp[fid]->UpdatePhys(),
229 1);
230 Exp->FwdTransLocalElmt(outfield, m_f->m_exp[fid]->UpdateCoeffs());
231 }
232 }
233}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
FieldSharedPtr m_f
Field object.
Definition: Module.h:234
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
double NekDouble
void Vmul(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:207
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:617
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:569
void Svtvm(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvm (scalar times vector minus vector): z = alpha*x - y
Definition: Vmath.cpp:659
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:354
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:245
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191
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:414

References ASSERTL0, Nektar::FieldUtils::Module::m_f, Vmath::Smul(), Vmath::Svtvm(), Vmath::Svtvp(), Vmath::Vadd(), Vmath::Vcopy(), Vmath::Vmul(), Vmath::Vsub(), and Vmath::Vvtvp().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessQCriterion::className
static
Initial value:
=
"Computes Q-Criterion.")
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 57 of file ProcessQCriterion.h.