Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::FieldUtils::ProcessForceDecompose Class Reference

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

#include <ProcessForceDecompose.h>

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

Public Member Functions

 ProcessForceDecompose ()
 
 ProcessForceDecompose (FieldSharedPtr f)
 
- 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.
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module.
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set.
 
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)
 

Protected Member Functions

NekDouble PhysIntegral (MultiRegions::ExpListSharedPtr exp, Array< OneD, NekDouble > value)
 
void GetQ (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)
 
void QFromField (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)
 
void QFromPressure (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)
 
NekDouble GetViscosity ()
 
void GetGradPressure (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &gradp)
 
void GetVelocity (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &vel)
 
void GetLaplaceVelocity (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &lapvel)
 
void GetStressTensor (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &shear)
 
void GetPhi (const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &phi, std::map< int, std::string > &Iphi)
 
void GetInfoPhi (std::map< int, std::string > &Iphi)
 
void VolumeIntegrateForce (const MultiRegions::ExpListSharedPtr &field, const Array< OneD, Array< OneD, NekDouble > > &data, const LibUtilities::CommSharedPtr &comm, std::map< int, std::string > &Iphi, Array< OneD, NekDouble > &BoundBox, int dir)
 
int FindVariable (const std::string &var)
 
- 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 ()
 

Protected Attributes

int m_spacedim
 
int m_expdim
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values.
 
std::set< std::string > m_allowedFiles
 List of allowed file formats.
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object.
 

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 ProcessForceDecompose.h.

Constructor & Destructor Documentation

◆ ProcessForceDecompose() [1/2]

Nektar::FieldUtils::ProcessForceDecompose::ProcessForceDecompose ( )
inline

Definition at line 50 of file ProcessForceDecompose.h.

50{};

◆ ProcessForceDecompose() [2/2]

Nektar::FieldUtils::ProcessForceDecompose::ProcessForceDecompose ( FieldSharedPtr  f)

Definition at line 46 of file ProcessForceDecompose.cpp.

Member Function Documentation

◆ FindVariable()

int Nektar::FieldUtils::ProcessForceDecompose::FindVariable ( const std::string &  var)
protected

Definition at line 84 of file ProcessForceDecompose.cpp.

85{
86 auto index = find(m_f->m_variables.begin(), m_f->m_variables.end(), var);
87 if (index == m_f->m_variables.end())
88 {
89 NEKERROR(ErrorUtil::efatal, var + " field not found.");
90 }
91 return index - m_f->m_variables.begin();
92}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
FieldSharedPtr m_f
Field object.
Definition Module.h:239
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)

References Nektar::ErrorUtil::efatal, Nektar::FieldUtils::Module::m_f, and NEKERROR.

Referenced by GetGradPressure(), GetVelocity(), QFromField(), and QFromPressure().

◆ GetGradPressure()

void Nektar::FieldUtils::ProcessForceDecompose::GetGradPressure ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, Array< OneD, NekDouble > > &  gradp 
)
protected

Definition at line 164 of file ProcessForceDecompose.cpp.

167{
168 int npoints = exp[0]->GetNpoints();
169 if (gradp.size() < m_spacedim)
170 {
171 gradp = Array<OneD, Array<OneD, NekDouble>>(m_spacedim);
172 }
173 for (size_t i = 0; i < gradp.size(); ++i)
174 {
175 if (gradp[i].size() < npoints)
176 {
177 gradp[i] = Array<OneD, NekDouble>(npoints, 0.);
178 }
179 }
180 int iv;
181 try
182 {
183 iv = FindVariable("p");
184 }
185 catch (...)
186 {
187 return;
188 }
189 Array<OneD, NekDouble> pressure(npoints, 0.);
190 Vmath::Vcopy(npoints, exp[iv]->GetPhys(), 1, pressure, 1);
191 for (int i = 0; i < m_spacedim; ++i)
192 {
193 exp[0]->PhysDeriv(i, pressure, gradp[i]);
194 }
195}
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References FindVariable(), m_spacedim, and Vmath::Vcopy().

Referenced by Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ GetInfoPhi()

void Nektar::FieldUtils::ProcessForceDecompose::GetInfoPhi ( std::map< int, std::string > &  Iphi)
protected

Definition at line 152 of file ProcessForceDecompose.cpp.

153{
154 Iphi.clear();
155 for (size_t i = 0; i < m_f->m_variables.size(); ++i)
156 {
157 if (std::string::npos != m_f->m_variables[i].find("phi"))
158 {
159 Iphi[i] = m_f->m_variables[i];
160 }
161 }
162}

References Nektar::FieldUtils::Module::m_f.

Referenced by Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ GetLaplaceVelocity()

void Nektar::FieldUtils::ProcessForceDecompose::GetLaplaceVelocity ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, Array< OneD, NekDouble > > &  lapvel 
)
protected

Definition at line 277 of file ProcessForceDecompose.cpp.

280{
281 int npoints = exp[0]->GetNpoints();
282 Array<OneD, Array<OneD, NekDouble>> vel;
283 GetVelocity(exp, vel);
284 if (lapvel.size() != vel.size())
285 {
286 lapvel = Array<OneD, Array<OneD, NekDouble>>(vel.size());
287 }
288 for (size_t i = 0; i < lapvel.size(); ++i)
289 {
290 if (lapvel[i].size() < npoints)
291 {
292 lapvel[i] = Array<OneD, NekDouble>(npoints);
293 }
294 }
295 Array<OneD, Array<OneD, NekDouble>> grad(m_spacedim);
296 Array<OneD, NekDouble> tmp(npoints);
297 for (int i = 0; i < m_spacedim; ++i)
298 {
299 grad[i] = Array<OneD, NekDouble>(npoints);
300 }
301 for (size_t i = 0; i < lapvel.size(); ++i)
302 {
303 Vmath::Zero(npoints, lapvel[i], 1);
304 for (int j = 0; j < m_spacedim; ++j)
305 {
306 exp[i]->PhysDeriv(j, vel[i], grad[j]);
307 exp[i]->PhysDeriv(j, grad[j], tmp);
308 Vmath::Vadd(npoints, tmp, 1, lapvel[i], 1, lapvel[i], 1);
309 }
310 }
311}
void GetVelocity(const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, Array< OneD, NekDouble > > &vel)
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 Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:273

References GetVelocity(), m_spacedim, Vmath::Vadd(), and Vmath::Zero().

Referenced by Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ GetPhi()

void Nektar::FieldUtils::ProcessForceDecompose::GetPhi ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, Array< OneD, NekDouble > > &  phi,
std::map< int, std::string > &  Iphi 
)
protected

Definition at line 123 of file ProcessForceDecompose.cpp.

126{
127 Iphi.clear();
128 int npoints = exp[0]->GetNpoints();
129 for (size_t i = 0; i < m_f->m_variables.size(); ++i)
130 {
131 if (std::string::npos != m_f->m_variables[i].find("phi"))
132 {
133 Iphi[i] = m_f->m_variables[i];
134 }
135 }
136 if (phi.size() != Iphi.size())
137 {
138 phi = Array<OneD, Array<OneD, NekDouble>>(Iphi.size());
139 }
140 int i = 0;
141 for (const auto &p : Iphi)
142 {
143 if (phi[i].size() < npoints)
144 {
145 phi[i] = Array<OneD, NekDouble>(npoints, 0.);
146 }
147 Vmath::Vcopy(npoints, exp[p.first]->GetPhys(), 1, phi[i], 1);
148 ++i;
149 }
150}
std::vector< double > p(NPUPPER)

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

Referenced by Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ GetQ()

void Nektar::FieldUtils::ProcessForceDecompose::GetQ ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, NekDouble > &  Q 
)
protected

Definition at line 56 of file ProcessForceDecompose.cpp.

59{
60 int method = m_config["Q"].as<int>();
61 if (method == 1)
62 {
63 QFromPressure(exp, Q);
64 }
65 else
66 {
67 QFromField(exp, Q);
68 }
69}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition Module.h:272
void QFromField(const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)
void QFromPressure(const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)

References Nektar::FieldUtils::Module::m_config, QFromField(), and QFromPressure().

Referenced by Nektar::FieldUtils::ProcessForceDecomposeVol::v_Process().

◆ GetStressTensor()

void Nektar::FieldUtils::ProcessForceDecompose::GetStressTensor ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, Array< OneD, NekDouble > > &  shear 
)
protected

Definition at line 218 of file ProcessForceDecompose.cpp.

221{
222 int npoints = exp[0]->GetNpoints();
223 Array<OneD, Array<OneD, NekDouble>> vel;
224 GetVelocity(exp, vel);
225 Array<OneD, Array<OneD, NekDouble>> grad(m_spacedim * m_spacedim);
226 Array<OneD, NekDouble> tmp(npoints);
227 for (size_t i = 0; i < grad.size(); ++i)
228 {
229 grad[i] = Array<OneD, NekDouble>(npoints);
230 }
231
232 if (stress.size() < m_spacedim * m_spacedim)
233 {
234 stress = Array<OneD, Array<OneD, NekDouble>>(m_spacedim * m_spacedim);
235 }
236
237 for (size_t i = 0; i < stress.size(); ++i)
238 {
239 if (stress[i].size() < npoints)
240 {
241 stress[i] = Array<OneD, NekDouble>(npoints);
242 }
243 }
244
245 for (int i = 0; i < m_spacedim; ++i)
246 {
247 for (int j = 0; j < m_spacedim; ++j)
248 {
249 exp[i]->PhysDeriv(j, vel[i], grad[i * m_spacedim + j]);
250 }
251 }
252
253 // Compute stress component terms
254 // tau_ij = mu*(u_i,j + u_j,i) + mu*lambda*delta_ij*div(u)
255 for (int i = 0; i < m_spacedim; ++i)
256 {
257 for (int j = i; j < m_spacedim; ++j)
258 {
259 Vmath::Vadd(npoints, grad[i * m_spacedim + j], 1,
260 grad[j * m_spacedim + i], 1, stress[i * m_spacedim + j],
261 1);
262
263 Vmath::Smul(npoints, GetViscosity(), stress[i * m_spacedim + j], 1,
264 stress[i * m_spacedim + j], 1);
265 }
266 }
267 for (int i = 0; i < m_spacedim; ++i)
268 {
269 for (int j = 0; j < i; ++j)
270 {
271 Vmath::Vcopy(npoints, stress[j * m_spacedim + i], 1,
272 stress[i * m_spacedim + j], 1);
273 }
274 }
275}
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

References GetVelocity(), GetViscosity(), m_spacedim, Vmath::Smul(), Vmath::Vadd(), and Vmath::Vcopy().

Referenced by Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ GetVelocity()

void Nektar::FieldUtils::ProcessForceDecompose::GetVelocity ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, Array< OneD, NekDouble > > &  vel 
)
protected

Definition at line 197 of file ProcessForceDecompose.cpp.

200{
201 int npoints = exp[0]->GetNpoints();
202 if (vel.size() < m_spacedim)
203 {
204 vel = Array<OneD, Array<OneD, NekDouble>>(m_spacedim);
205 }
206 std::vector<std::string> vars = {"u", "v", "w"};
207 for (size_t i = 0; i < m_spacedim; ++i)
208 {
209 int iv = FindVariable(vars[i]);
210 if (vel[i].size() < npoints)
211 {
212 vel[i] = Array<OneD, NekDouble>(npoints);
213 }
214 Vmath::Vcopy(npoints, exp[iv]->GetPhys(), 1, vel[i], 1);
215 }
216}

References FindVariable(), m_spacedim, and Vmath::Vcopy().

Referenced by GetLaplaceVelocity(), and GetStressTensor().

◆ GetViscosity()

NekDouble Nektar::FieldUtils::ProcessForceDecompose::GetViscosity ( )
protected

Definition at line 51 of file ProcessForceDecompose.cpp.

52{
53 return m_f->m_session->GetParameter("Kinvis");
54}

References Nektar::FieldUtils::Module::m_f.

Referenced by GetStressTensor(), and Nektar::FieldUtils::ProcessForceDecomposeBnd::v_Process().

◆ PhysIntegral()

NekDouble Nektar::FieldUtils::ProcessForceDecompose::PhysIntegral ( MultiRegions::ExpListSharedPtr  exp,
Array< OneD, NekDouble value 
)
protected

Definition at line 313 of file ProcessForceDecompose.cpp.

315{
316 NekDouble sum = 0.;
317 for (int i = 0; i < exp->GetExpSize(); ++i)
318 {
319 sum += exp->GetExp(i)->Integral(value + exp->GetPhys_Offset(i));
320 }
321 return sum;
322}

◆ QFromField()

void Nektar::FieldUtils::ProcessForceDecompose::QFromField ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, NekDouble > &  Q 
)
protected

Definition at line 71 of file ProcessForceDecompose.cpp.

74{
75 int npoints = m_f->m_exp[0]->GetNpoints();
76 int IQ = FindVariable("Q");
77 if (Q.size() < npoints)
78 {
79 Q = Array<OneD, NekDouble>(npoints);
80 }
81 Vmath::Vcopy(npoints, exp[IQ]->GetPhys(), 1, Q, 1);
82}

References FindVariable(), Nektar::FieldUtils::Module::m_f, and Vmath::Vcopy().

Referenced by GetQ().

◆ QFromPressure()

void Nektar::FieldUtils::ProcessForceDecompose::QFromPressure ( const Array< OneD, MultiRegions::ExpListSharedPtr exp,
Array< OneD, NekDouble > &  Q 
)
protected

Definition at line 94 of file ProcessForceDecompose.cpp.

97{
98 int npoints = exp[0]->GetNpoints();
99 int ip = FindVariable("p");
100 if (Q.size() < npoints)
101 {
102 Q = Array<OneD, NekDouble>(npoints);
103 }
104
105 Array<OneD, Array<OneD, NekDouble>> grad(m_spacedim);
106 Array<OneD, NekDouble> tmp(npoints, 0.);
107
108 for (int i = 0; i < m_spacedim; ++i)
109 {
110 grad[i] = Array<OneD, NekDouble>(npoints);
111 }
112 Vmath::Zero(npoints, Q, 1);
113
114 for (int i = 0; i < m_spacedim; ++i)
115 {
116 exp[ip]->PhysDeriv(i, m_f->m_exp[ip]->GetPhys(), grad[i]);
117 exp[ip]->PhysDeriv(i, grad[i], tmp);
118 Vmath::Vadd(npoints, tmp, 1, Q, 1, Q, 1);
119 }
120 Vmath::Smul(npoints, 0.5, Q, 1, Q, 1);
121}

References FindVariable(), Nektar::FieldUtils::Module::m_f, m_spacedim, Vmath::Smul(), Vmath::Vadd(), and Vmath::Zero().

Referenced by GetQ().

◆ VolumeIntegrateForce()

void Nektar::FieldUtils::ProcessForceDecompose::VolumeIntegrateForce ( const MultiRegions::ExpListSharedPtr field,
const Array< OneD, Array< OneD, NekDouble > > &  data,
const LibUtilities::CommSharedPtr comm,
std::map< int, std::string > &  Iphi,
Array< OneD, NekDouble > &  BoundBox,
int  dir 
)
protected

Definition at line 324 of file ProcessForceDecompose.cpp.

329{
330 int Nslots = 100;
331 int ndata = data.size();
332 NekDouble dh = (BoundBox[dir * 2 + 1] - BoundBox[dir * 2]) / Nslots;
333 Array<OneD, Array<OneD, NekDouble>> slots(ndata);
334 for (int i = 0; i < ndata; ++i)
335 {
336 slots[i] = Array<OneD, NekDouble>(Nslots, 0.);
337 }
338
339 for (size_t e = 0; e < field->GetExpSize(); ++e)
340 {
342 SpatialDomains::Geometry *geom = exp->GetGeom();
343 int nv = geom->GetNumVerts();
344 NekDouble gc[3] = {0., 0., 0.};
345 NekDouble gct[3] = {0., 0., 0.};
346 bool inside = false;
347 for (size_t j = 0; j < nv; ++j)
348 {
349 SpatialDomains::PointGeom *vertex = geom->GetVertex(j);
350 vertex->GetCoords(gct[0], gct[1], gct[2]);
351 gc[0] += gct[0] / NekDouble(nv);
352 gc[1] += gct[1] / NekDouble(nv);
353 gc[2] += gct[2] / NekDouble(nv);
354 if (BoundBox[0] <= gct[0] && gct[0] <= BoundBox[1] &&
355 BoundBox[2] <= gct[1] && gct[1] <= BoundBox[3] &&
356 BoundBox[4] <= gct[2] && gct[2] <= BoundBox[5])
357 {
358 inside = true;
359 }
360 }
361 if (inside)
362 {
363 int index = floor((gc[dir] - BoundBox[2 * dir]) / dh);
364 index = std::max(std::min(index, Nslots - 1), 0);
365 for (int j = 0; j < ndata; ++j)
366 {
367 slots[j][index] +=
368 exp->Integral(data[j] + field->GetPhys_Offset(e));
369 }
370 }
371 }
372 for (int j = 0; j < ndata; ++j)
373 {
374 comm->AllReduce(slots[j], LibUtilities::ReduceSum);
375 }
376 if (comm->TreatAsRankZero())
377 {
378 Array<OneD, NekDouble> sum(ndata, 0.);
379 cout << "variables = x";
380 for (const auto &phi : Iphi)
381 {
382 cout << ", f" + phi.second;
383 }
384 cout << "\n";
385 for (int i = 0; i < Nslots; ++i)
386 {
387 cout << (BoundBox[2 * dir] + (i + 0.5) * dh) << " ";
388 for (int j = 0; j < ndata; ++j)
389 {
390 sum[j] += slots[j][i];
391 cout << sum[j] << " ";
392 }
393 cout << "\n";
394 }
395 cout << endl;
396 }
397}
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66

References Nektar::SpatialDomains::PointGeom::GetCoords(), Nektar::SpatialDomains::Geometry::GetNumVerts(), Nektar::SpatialDomains::Geometry::GetVertex(), and Nektar::LibUtilities::ReduceSum.

Referenced by Nektar::FieldUtils::ProcessForceDecomposeVol::v_Process().

Member Data Documentation

◆ m_expdim

int Nektar::FieldUtils::ProcessForceDecompose::m_expdim
protected

◆ m_spacedim

int Nektar::FieldUtils::ProcessForceDecompose::m_spacedim
protected