Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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)
 
 ~ProcessMultiShear () 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 shear stress metrics and writes it to a surface output file.

Definition at line 47 of file ProcessMultiShear.h.

Constructor & Destructor Documentation

◆ ProcessMultiShear()

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

Definition at line 53 of file ProcessMultiShear.cpp.

53 : ProcessModule(f)
54{
55 m_config["N"] = ConfigOption(false, "1", "Number of chk or fld files");
56 m_config["fromfld"] = ConfigOption(
57 false, "NotSet",
58 "First fld file. First underscore flags position of id in name.");
59}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272

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

◆ ~ProcessMultiShear()

Nektar::FieldUtils::ProcessMultiShear::~ProcessMultiShear ( )
override

Definition at line 61 of file ProcessMultiShear.cpp.

62{
63}

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 51 of file ProcessMultiShear.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::ProcessMultiShear::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessMultiShear.h.

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

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessMultiShear.h.

65 {
66 return "ProcessMultiShear";
67 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 74 of file ProcessMultiShear.h.

75 {
76 return eModifyExp;
77 }

References Nektar::FieldUtils::eModifyExp.

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessMultiShear.cpp.

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

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

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessMultiShear::className
static
Initial value:
=
"Computes shear stress metrics.")
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 ProcessMultiShear.h.