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

This processing module calculates the shear stress metrics and writes it to a surface output file. More...

#include <ProcessMultiShear.h>

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

Public Member Functions

 ProcessMultiShear (FieldSharedPtr f)
 
virtual ~ProcessMultiShear ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- 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)
 
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 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
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

This processing module calculates the shear stress metrics and writes it to a surface output file.

Definition at line 49 of file ProcessMultiShear.h.

Constructor & Destructor Documentation

◆ ProcessMultiShear()

Nektar::FieldUtils::ProcessMultiShear::ProcessMultiShear ( FieldSharedPtr  f)

Definition at line 58 of file ProcessMultiShear.cpp.

References Nektar::FieldUtils::Module::m_config.

58  : ProcessModule(f)
59 {
60  m_config["N"] = ConfigOption(false, "1", "Number of chk or fld files");
61  m_config["fromfld"] = ConfigOption(
62  false, "NotSet",
63  "First fld file. First underscore flags position of id in name.");
64 }
std::map< std::string, ConfigOption > m_config
List of configuration values.

◆ ~ProcessMultiShear()

Nektar::FieldUtils::ProcessMultiShear::~ProcessMultiShear ( )
virtual

Definition at line 66 of file ProcessMultiShear.cpp.

67 {
68 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 53 of file ProcessMultiShear.h.

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

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

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessMultiShear::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessMultiShear.h.

71  {
72  return "Calculating shear stress metrics";
73  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessMultiShear::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessMultiShear.h.

66  {
67  return "ProcessMultiShear";
68  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessMultiShear::GetModulePriority ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessMultiShear.h.

References Nektar::FieldUtils::eModifyExp.

◆ Process()

void Nektar::FieldUtils::ProcessMultiShear::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessMultiShear.cpp.

References ASSERTL0, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::LibUtilities::NullFieldMetaDataMap, Vmath::Smul(), Vmath::Vadd(), Vmath::Vdiv(), Vmath::Vmul(), Vmath::Vsqrt(), Vmath::Vvtvm(), Vmath::Vvtvp(), and Vmath::Zero().

71 {
72  boost::ignore_unused(vm);
73 
74  // Skip in case of empty partition
75  if (m_f->m_exp[0]->GetNumElmts() == 0)
76  {
77  return;
78  }
79 
80  ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
81  "Need to specify fromfld=file.fld ");
82 
83  int nstart, i, j, nfields=0;
84  bool wssg = false;
85  NekDouble nfld = m_config["N"].as<NekDouble>();
86  string fromfld, basename, endname, nstartStr;
87  stringstream filename;
88  vector<string> infiles(nfld);
89  vector<std::shared_ptr<Field> > fromField(nfld);
90 
91  // Set up list of input fld files.
92  fromfld = m_config["fromfld"].as<string>();
93  basename = fromfld.substr(0, fromfld.find_first_of("_") + 1);
94  filename << fromfld.substr(fromfld.find_first_of("_") + 1, fromfld.size());
95  filename >> nstart;
96  filename.str("");
97  filename << nstart;
98  filename >> nstartStr;
99  filename.str("");
100  endname = fromfld.substr(fromfld.find(nstartStr) + nstartStr.size(),
101  fromfld.size());
102 
103  for (i = 0; i < nfld; ++i)
104  {
105  stringstream filename;
106  filename << basename << i + nstart << endname;
107  filename >> infiles[i];
108  cout << infiles[i] << endl;
109  }
110 
111  for (i = 0; i < nfld; ++i)
112  {
113  fromField[i] = std::shared_ptr<Field>(new Field());
114  fromField[i]->m_session = m_f->m_session;
115  fromField[i]->m_graph = m_f->m_graph;
116  }
117 
118  // Import all fld files.
119  for (i = 0; i < nfld; ++i)
120  {
121  if (m_f->m_exp.size())
122  {
123  // Set up ElementGIDs in case of parallel processing
124  Array<OneD, int> ElementGIDs(m_f->m_exp[0]->GetExpSize());
125  for (j = 0; j < m_f->m_exp[0]->GetExpSize(); ++j)
126  {
127  ElementGIDs[j] =
128  m_f->m_exp[0]->GetExp(j)->GetGeom()->GetGlobalID();
129  }
130  m_f->FieldIOForFile(infiles[i])->Import(
131  infiles[i], fromField[i]->m_fielddef, fromField[i]->m_data,
133  }
134  else
135  {
136  m_f->FieldIOForFile(infiles[i])->Import(
137  infiles[i], fromField[i]->m_fielddef, fromField[i]->m_data,
139  }
140 
141  nfields = fromField[i]->m_fielddef[0]->m_fields.size();
142  int NumHomogeneousDir =
143  fromField[i]->m_fielddef[0]->m_numHomogeneousDir;
144 
145  if (nfields == 5 || nfields == 7)
146  {
147  wssg = true;
148  }
149 
150  // Set up Expansion information to use mode order from field
151  fromField[i]->m_graph->SetExpansions(fromField[i]->m_fielddef);
152 
153  // Set up expansions, and extract data.
154  fromField[i]->m_exp.resize(nfields);
155  fromField[i]->m_exp[0] =
156  fromField[i]->SetUpFirstExpList(NumHomogeneousDir, true);
157 
158  for (j = 1; j < nfields; ++j)
159  {
160  fromField[i]->m_exp[j] = m_f->AppendExpList(NumHomogeneousDir);
161  }
162 
163  for (j = 0; j < nfields; ++j)
164  {
165  for (int k = 0; k < fromField[i]->m_data.size(); ++k)
166  {
167  fromField[i]->m_exp[j]->ExtractDataToCoeffs(
168  fromField[i]->m_fielddef[k], fromField[i]->m_data[k],
169  fromField[i]->m_fielddef[k]->m_fields[j],
170  fromField[i]->m_exp[j]->UpdateCoeffs());
171  }
172  fromField[i]->m_exp[j]->BwdTrans(
173  fromField[i]->m_exp[j]->GetCoeffs(),
174  fromField[i]->m_exp[j]->UpdatePhys());
175  }
176  }
177 
178  int spacedim = m_f->m_graph->GetSpaceDimension();
179  if ((fromField[0]->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
180  (fromField[0]->m_fielddef[0]->m_numHomogeneousDir) == 2)
181  {
182  spacedim = 3;
183  }
184 
185  int nout = 5; // TAWSS, OSI, transWSS, AFI, CFI (optional WSSG)
186  if (wssg)
187  {
188  nout = 6;
189  }
190 
191  int npoints = fromField[0]->m_exp[0]->GetNpoints();
192  Array<OneD, Array<OneD, NekDouble> > normTemporalMeanVec(spacedim),
193  normCrossDir(spacedim), outfield(nout), dtemp(spacedim);
194  Array<OneD, NekDouble> TemporalMeanMag(npoints, 0.0),
195  DotProduct(npoints, 0.0), temp(npoints, 0.0);
196 
197  for (i = 0; i < spacedim; ++i)
198  {
199  normTemporalMeanVec[i] = Array<OneD, NekDouble>(npoints);
200  normCrossDir[i] = Array<OneD, NekDouble>(npoints);
201  dtemp[i] = Array<OneD, NekDouble>(npoints);
202  Vmath::Zero(npoints, normTemporalMeanVec[i], 1);
203  Vmath::Zero(npoints, normCrossDir[i], 1);
204  }
205 
206  for (i = 0; i < nout; ++i)
207  {
208  outfield[i] = Array<OneD, NekDouble>(npoints, 0.0);
209  }
210 
211  // -----------------------------------------------------
212  // Compute temporal average wall shear stress vector,
213  // it's spatial average, and normalise it.
214  for (i = 0; i < nfld; ++i)
215  {
216  for (j = 0; j < spacedim; ++j)
217  {
218  Vmath::Vadd(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
219  normTemporalMeanVec[j], 1, normTemporalMeanVec[j], 1);
220  }
221  }
222 
223  for (i = 0; i < spacedim; ++i)
224  {
225  Vmath::Smul(npoints, 1.0 / nfld, normTemporalMeanVec[i], 1,
226  normTemporalMeanVec[i], 1);
227  Vmath::Vvtvp(npoints, normTemporalMeanVec[i], 1, normTemporalMeanVec[i],
228  1, TemporalMeanMag, 1, TemporalMeanMag, 1);
229  }
230 
231  Vmath::Vsqrt(npoints, TemporalMeanMag, 1, TemporalMeanMag, 1);
232 
233  for (i = 0; i < spacedim; ++i)
234  {
235  Vmath::Vdiv(npoints, normTemporalMeanVec[i], 1, TemporalMeanMag, 1,
236  normTemporalMeanVec[i], 1);
237  }
238  //---------------------------------------------------
239 
240  if (wssg) // cross product with normals to obtain direction parallel to
241  // temporal mean vector.
242  {
243  Vmath::Vmul(npoints, fromField[0]->m_exp[nfields - 1]->GetPhys(), 1,
244  normTemporalMeanVec[1], 1, normCrossDir[0], 1);
245  Vmath::Vvtvm(npoints, fromField[0]->m_exp[nfields - 2]->GetPhys(), 1,
246  normTemporalMeanVec[2], 1, normCrossDir[0], 1,
247  normCrossDir[0], 1);
248 
249  Vmath::Vmul(npoints, fromField[0]->m_exp[nfields - 3]->GetPhys(), 1,
250  normTemporalMeanVec[2], 1, normCrossDir[1], 1);
251  Vmath::Vvtvm(npoints, fromField[0]->m_exp[nfields - 1]->GetPhys(), 1,
252  normTemporalMeanVec[0], 1, normCrossDir[1], 1,
253  normCrossDir[1], 1);
254 
255  Vmath::Vmul(npoints, fromField[0]->m_exp[nfields - 2]->GetPhys(), 1,
256  normTemporalMeanVec[0], 1, normCrossDir[2], 1);
257  Vmath::Vvtvm(npoints, fromField[0]->m_exp[nfields - 3]->GetPhys(), 1,
258  normTemporalMeanVec[1], 1, normCrossDir[2], 1,
259  normCrossDir[2], 1);
260  }
261 
262  // Compute tawss, trs, osi, taafi, tacfi, WSSG.
263  for (i = 0; i < nfld; ++i)
264  {
265  for (j = 0; j < spacedim; ++j)
266  {
267  Vmath::Vvtvp(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
268  normTemporalMeanVec[j], 1, DotProduct, 1, DotProduct,
269  1);
270  }
271 
272  // TAWSS
273  Vmath::Vadd(npoints, fromField[i]->m_exp[spacedim]->GetPhys(), 1,
274  outfield[0], 1, outfield[0], 1);
275 
276  // transWSS
277  Vmath::Vmul(npoints, DotProduct, 1, DotProduct, 1, temp, 1);
278  Vmath::Vvtvm(npoints, fromField[i]->m_exp[spacedim]->GetPhys(), 1,
279  fromField[i]->m_exp[spacedim]->GetPhys(), 1, temp, 1,
280  temp, 1);
281 
282  for (j = 0; j < npoints; ++j)
283  {
284  if (temp[j] > 0.0)
285  {
286  outfield[1][j] = outfield[1][j] + sqrt(temp[j]);
287  }
288  }
289 
290  // TAAFI
291  Vmath::Vdiv(npoints, DotProduct, 1,
292  fromField[i]->m_exp[spacedim]->GetPhys(), 1, temp, 1);
293  Vmath::Vadd(npoints, temp, 1, outfield[3], 1, outfield[3], 1);
294 
295  // TACFI
296  for (j = 0; j < npoints; ++j)
297  {
298  temp[j] = 1 - temp[j] * temp[j];
299  if (temp[j] > 0.0)
300  {
301  outfield[4][j] = outfield[4][j] + sqrt(temp[j]);
302  }
303  }
304 
305  // WSSG
306  if (wssg)
307  {
308  // parallel component:
309  Vmath::Zero(npoints, temp, 1);
310 
311  fromField[i]->m_exp[0]->PhysDeriv(DotProduct, dtemp[0], dtemp[1],
312  dtemp[2]);
313  for (j = 0; j < spacedim; j++)
314  {
315  Vmath::Vvtvp(npoints, dtemp[j], 1, normTemporalMeanVec[j], 1,
316  temp, 1, temp, 1);
317  }
318  Vmath::Vmul(npoints, temp, 1, temp, 1, temp, 1);
319 
320  // perpendicular component:
321  Vmath::Zero(npoints, DotProduct, 1);
322 
323  for (j = 0; j < spacedim; ++j)
324  {
325  Vmath::Vvtvp(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
326  normCrossDir[j], 1, DotProduct, 1, DotProduct, 1);
327  }
328  fromField[i]->m_exp[0]->PhysDeriv(DotProduct, dtemp[0], dtemp[1],
329  dtemp[2]);
330  Vmath::Zero(npoints, DotProduct, 1);
331 
332  for (j = 0; j < spacedim; j++)
333  {
334  Vmath::Vvtvp(npoints, dtemp[j], 1, normCrossDir[j], 1,
335  DotProduct, 1, DotProduct, 1);
336  }
337  Vmath::Vvtvp(npoints, DotProduct, 1, DotProduct, 1, temp, 1, temp,
338  1);
339 
340  // Final wssg computation
341  Vmath::Vsqrt(npoints, temp, 1, temp, 1);
342  Vmath::Vadd(npoints, temp, 1, outfield[5], 1, outfield[5], 1);
343  }
344 
345  Vmath::Zero(npoints, DotProduct, 1);
346  }
347 
348  // Divide by nfld
349  Vmath::Smul(npoints, 1.0 / nfld, outfield[0], 1, outfield[0], 1);
350  Vmath::Smul(npoints, 1.0 / nfld, outfield[1], 1, outfield[1], 1);
351  Vmath::Smul(npoints, 1.0 / nfld, outfield[3], 1, outfield[3], 1);
352  Vmath::Smul(npoints, 1.0 / nfld, outfield[4], 1, outfield[4], 1);
353 
354  // OSI
355  for (i = 0; i < npoints; ++i)
356  {
357  outfield[2][i] = 0.5 * (1 - TemporalMeanMag[i] / outfield[0][i]);
358  }
359 
360  /* TAWSS = sum(wss)/nfld
361  * transWSS = sum( sqrt( wss^2 - (wss . normTempMean)^2) )/nfld.
362  * OSI = 0.5*(1-TemporalMeanMag/TAWSS)
363  * TAAFI = sum(cos)/nfld
364  * TACFI = sum(sin)/nfld = sum( sqrt(1-cos^2) )/nfld.
365  */
366 
367  m_f->m_exp.resize(nout);
368  m_f->m_fielddef = fromField[0]->m_fielddef;
369  m_f->m_exp[0] =
370  m_f->SetUpFirstExpList(m_f->m_fielddef[0]->m_numHomogeneousDir, true);
371 
372  for (i = 1; i < nout; ++i)
373  {
374  m_f->m_exp[i] =
375  m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir);
376  }
377 
378  m_f->m_fielddef[0]->m_fields.resize(nout);
379  m_f->m_fielddef[0]->m_fields[0] = "TAWSS";
380  m_f->m_fielddef[0]->m_fields[1] = "transWSS";
381  m_f->m_fielddef[0]->m_fields[2] = "OSI";
382  m_f->m_fielddef[0]->m_fields[3] = "TAAFI";
383  m_f->m_fielddef[0]->m_fields[4] = "TACFI";
384 
385  if (wssg)
386  {
387  m_f->m_fielddef[0]->m_fields[5] = "|WSSG|";
388  Vmath::Smul(npoints, 1.0 / nfld, outfield[5], 1, outfield[5], 1);
389  }
390 
391  m_f->m_variables = m_f->m_fielddef[0]->m_fields;
392 
393  for (i = 0; i < nout; ++i)
394  {
395  m_f->m_exp[i]->FwdTrans(outfield[i], m_f->m_exp[i]->UpdateCoeffs());
396  m_f->m_exp[i]->BwdTrans(m_f->m_exp[i]->GetCoeffs(),
397  m_f->m_exp[i]->UpdatePhys());
398  }
399 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::map< std::string, ConfigOption > m_config
List of configuration values.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
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:445
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:244
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
double NekDouble
void Vvtvm(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)
vvtvm (vector times vector plus vector): z = w*x - y
Definition: Vmath.cpp:468
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:53
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:302
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:186
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessMultiShear::className
static
Initial value:

Definition at line 57 of file ProcessMultiShear.h.