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

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 47 of file ProcessQCriterion.h.

Constructor & Destructor Documentation

◆ ProcessQCriterion()

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

Definition at line 51 of file ProcessQCriterion.cpp.

◆ ~ProcessQCriterion()

Nektar::FieldUtils::ProcessQCriterion::~ProcessQCriterion ( )
override

Definition at line 55 of file ProcessQCriterion.cpp.

56{
57}

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 51 of file ProcessQCriterion.h.

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

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

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessQCriterion.h.

70 {
71 return "Calculating Q Criterion";
72 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessQCriterion.h.

65 {
66 return "ProcessQCriterion";
67 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 74 of file ProcessQCriterion.h.

75 {
76 return eModifyExp;
77 }

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 59 of file ProcessQCriterion.cpp.

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

Definition at line 55 of file ProcessQCriterion.h.