55 ProcessMultiShear::create,
"Computes shear stress metrics.");
61 "First fld file. First underscore flags position of id in name.");
64 "Need to specify fromfld=file.fld ");
66 m_f->m_fldToBnd =
false;
77 if(
m_f->m_comm->TreatAsRankZero())
79 cout <<
"ProcessMultiShear: Calculating shear stress metrics..."
84 int nstart, i, j, nfields;
87 string fromfld, basename, endname, nstartStr;
88 stringstream filename;
89 vector<string> infiles(nfld);
90 vector< boost::shared_ptr<Field> > m_fromField(nfld);
93 fromfld =
m_config[
"fromfld"].as<
string>();
94 basename = fromfld.substr(0, fromfld.find_first_of(
"_")+1);
95 filename << fromfld.substr(fromfld.find_first_of(
"_")+1, fromfld.size());
99 filename >> nstartStr;
101 endname = fromfld.substr(fromfld.find(nstartStr)+nstartStr.size(), fromfld.size());
103 for (i=0; i<nfld; ++i)
105 stringstream filename;
106 filename << basename << i+nstart << endname;
107 filename >> infiles[i];
108 cout << infiles[i]<<endl;
111 for ( i = 0; i<nfld; ++i)
113 m_fromField[i] = boost::shared_ptr<Field>(
new Field());
114 m_fromField[i]->m_session =
m_f->m_session;
115 m_fromField[i]->m_graph =
m_f->m_graph;
121 for (i = 0; i < nfld; ++i)
123 if(
m_f->m_exp.size())
127 for (j = 0; j <
m_f->m_exp[0]->GetExpSize(); ++j)
129 ElementGIDs[j] =
m_f->m_exp[0]->GetExp(j)->GetGeom()->GetGlobalID();
131 m_fromField[i]->m_fld->Import(infiles[i],m_fromField[i]->m_fielddef,
132 m_fromField[i]->m_data,
138 m_fromField[i]->m_fld->Import(infiles[i],m_fromField[i]->m_fielddef,
139 m_fromField[i]->m_data,
143 nfields = m_fromField[i]->m_fielddef[0]->m_fields.size();
144 int NumHomogeneousDir = m_fromField[i]->m_fielddef[0]->m_numHomogeneousDir;
146 if (nfields == 5 || nfields == 7)
152 m_fromField[i]->m_graph->SetExpansions(m_fromField[i]->m_fielddef);
155 m_fromField[i]->m_exp.resize(nfields);
156 m_fromField[i]->m_exp[0] = m_fromField[i]->SetUpFirstExpList(NumHomogeneousDir,
true);
158 for(j = 1; j < nfields; ++j)
160 m_fromField[i]->m_exp[j] =
m_f->AppendExpList(NumHomogeneousDir);
163 for (j = 0; j < nfields; ++j)
165 for (
int k = 0; k < m_fromField[i]->m_data.size(); ++k)
167 m_fromField[i]->m_exp[j]->ExtractDataToCoeffs(
168 m_fromField[i]->m_fielddef[k],
169 m_fromField[i]->m_data[k],
170 m_fromField[i]->m_fielddef[k]->m_fields[j],
171 m_fromField[i]->m_exp[j]->UpdateCoeffs());
173 m_fromField[i]->m_exp[j]->BwdTrans(m_fromField[i]->m_exp[j]->GetCoeffs(),
174 m_fromField[i]->m_exp[j]->UpdatePhys());
179 int spacedim =
m_f->m_graph->GetSpaceDimension();
180 if ((m_fromField[0]->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
181 (m_fromField[0]->m_fielddef[0]->m_numHomogeneousDir) == 2)
188 if (wssg) { nout = 6; }
190 int npoints = m_fromField[0]->m_exp[0]->GetNpoints();
195 for (i = 0; i < spacedim; ++i)
204 for (i = 0; i < nout; ++i)
212 for (i = 0; i < nfld; ++i)
214 for (j = 0; j < spacedim; ++j)
216 Vmath::Vadd(npoints,m_fromField[i]->m_exp[j]->GetPhys(), 1, normTemporalMeanVec[j], 1, normTemporalMeanVec[j], 1);
220 for (i = 0; i < spacedim; ++i)
222 Vmath::Smul(npoints, 1.0/nfld, normTemporalMeanVec[i], 1, normTemporalMeanVec[i], 1);
223 Vmath::Vvtvp(npoints, normTemporalMeanVec[i], 1, normTemporalMeanVec[i], 1,
224 TemporalMeanMag, 1, TemporalMeanMag, 1);
227 Vmath::Vsqrt(npoints, TemporalMeanMag, 1, TemporalMeanMag, 1);
229 for (i = 0; i < spacedim; ++i)
231 Vmath::Vdiv(npoints, normTemporalMeanVec[i], 1, TemporalMeanMag, 1, normTemporalMeanVec[i], 1);
237 Vmath::Vmul(npoints,m_fromField[0]->m_exp[nfields-1]->GetPhys(),1,normTemporalMeanVec[1],1,normCrossDir[0],1);
238 Vmath::Vvtvm(npoints,m_fromField[0]->m_exp[nfields-2]->GetPhys(),1,normTemporalMeanVec[2],1,normCrossDir[0],1,
241 Vmath::Vmul(npoints,m_fromField[0]->m_exp[nfields-3]->GetPhys(),1,normTemporalMeanVec[2],1,normCrossDir[1],1);
242 Vmath::Vvtvm(npoints,m_fromField[0]->m_exp[nfields-1]->GetPhys(),1,normTemporalMeanVec[0],1,normCrossDir[1],1,
245 Vmath::Vmul(npoints,m_fromField[0]->m_exp[nfields-2]->GetPhys(),1,normTemporalMeanVec[0],1,normCrossDir[2],1);
246 Vmath::Vvtvm(npoints,m_fromField[0]->m_exp[nfields-3]->GetPhys(),1,normTemporalMeanVec[1],1,normCrossDir[2],1,
252 for (i = 0; i < nfld; ++i)
254 for (j = 0; j < spacedim; ++j)
256 Vmath::Vvtvp(npoints, m_fromField[i]->m_exp[j]->GetPhys(), 1, normTemporalMeanVec[j], 1,
257 DotProduct, 1, DotProduct, 1);
261 Vmath::Vadd(npoints, m_fromField[i]->m_exp[spacedim]->GetPhys(), 1, outfield[0], 1, outfield[0], 1);
264 Vmath::Vmul(npoints, DotProduct, 1, DotProduct, 1, temp,1);
265 Vmath::Vvtvm(npoints, m_fromField[i]->m_exp[spacedim]->GetPhys(), 1,
266 m_fromField[i]->m_exp[spacedim]->GetPhys(), 1, temp, 1, temp, 1);
268 for (j = 0; j < npoints; ++j)
272 outfield[1][j] = outfield[1][j] + sqrt(temp[j]);
277 Vmath::Vdiv(npoints, DotProduct, 1, m_fromField[i]->m_exp[spacedim]->GetPhys(), 1, temp, 1);
278 Vmath::Vadd(npoints, temp, 1, outfield[3], 1, outfield[3], 1);
281 for (j = 0; j < npoints; ++j)
283 temp[j] = 1 - temp[j]*temp[j];
286 outfield[4][j] = outfield[4][j] + sqrt(temp[j]);
296 m_fromField[i]->m_exp[0]->PhysDeriv(DotProduct,dtemp[0],dtemp[1],dtemp[2]);
297 for(j=0; j<spacedim; j++)
299 Vmath::Vvtvp(npoints,dtemp[j],1,normTemporalMeanVec[j],1,temp,1,temp,1);
307 for(j = 0; j < spacedim; ++j)
309 Vmath::Vvtvp(npoints,m_fromField[i]->m_exp[j]->GetPhys(),1,normCrossDir[j],1,
310 DotProduct, 1, DotProduct, 1);
313 m_fromField[i]->m_exp[0]->PhysDeriv(DotProduct,dtemp[0],dtemp[1],dtemp[2]);
316 for(j=0; j<spacedim; j++)
318 Vmath::Vvtvp(npoints,dtemp[j],1,normCrossDir[j],1,DotProduct,1,DotProduct,1);
320 Vmath::Vvtvp(npoints,DotProduct,1,DotProduct,1,temp,1, temp,1);
324 Vmath::Vadd(npoints, temp, 1, outfield[5], 1, outfield[5], 1);
332 Vmath::Smul(npoints, 1.0/nfld, outfield[0], 1, outfield[0], 1);
333 Vmath::Smul(npoints, 1.0/nfld, outfield[1], 1, outfield[1], 1);
334 Vmath::Smul(npoints, 1.0/nfld, outfield[3], 1, outfield[3], 1);
335 Vmath::Smul(npoints, 1.0/nfld, outfield[4], 1, outfield[4], 1);
338 for (i = 0; i < npoints; ++i)
340 outfield[2][i] = 0.5 * (1 - TemporalMeanMag[i]/outfield[0][i]);
350 m_f->m_exp.resize(nout);
351 m_f->m_fielddef = m_fromField[0]->m_fielddef;
352 m_f->m_exp[0] =
m_f->SetUpFirstExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
true);
354 for(i = 1; i < nout; ++i)
356 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
359 m_f->m_fielddef[0]->m_fields.resize(nout);
360 m_f->m_fielddef[0]->m_fields[0] =
"TAWSS";
361 m_f->m_fielddef[0]->m_fields[1] =
"transWSS";
362 m_f->m_fielddef[0]->m_fields[2] =
"OSI";
363 m_f->m_fielddef[0]->m_fields[3] =
"TAAFI";
364 m_f->m_fielddef[0]->m_fields[4] =
"TACFI";
368 m_f->m_fielddef[0]->m_fields[5] =
"|WSSG|";
369 Vmath::Smul(npoints, 1.0/nfld, outfield[5], 1, outfield[5], 1);
373 for(i = 0; i < nout; ++i)
375 m_f->m_exp[i]->FwdTrans(outfield[i],
376 m_f->m_exp[i]->UpdateCoeffs());
377 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
378 m_f->m_exp[i]->UpdatePhys());
382 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
383 = m_fromField[0]->m_exp[0]->GetFieldDefinitions();
384 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
386 for( i = 0; i < nout; ++i)
388 for ( j = 0; j < FieldDef.size(); ++j)
390 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
391 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
395 m_f->m_fielddef = FieldDef;
396 m_f->m_data = FieldData;
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
map< string, ConfigOption > m_config
List of configuration values.
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
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.
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
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
virtual ~ProcessMultiShear()
void Zero(int n, T *x, const int incx)
Zero vector.
static FieldMetaDataMap NullFieldMetaDataMap
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.
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.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.