51 "Computes shear stress metrics.");
58 "First fld file. First underscore flags position of id in name.");
70 if (
m_f->m_exp[0]->GetNumElmts() == 0)
76 "Need to specify fromfld=file.fld ");
78 int nstart, i, j, nfields = 0;
81 string fromfld, basename, endname, nstartStr;
82 stringstream filename;
83 vector<string> infiles(nfld);
84 vector<std::shared_ptr<Field>> fromField(nfld);
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());
93 filename >> nstartStr;
95 endname = fromfld.substr(fromfld.find(nstartStr) + nstartStr.size(),
98 for (i = 0; i < nfld; ++i)
100 stringstream filename;
101 filename << basename << i + nstart << endname;
102 filename >> infiles[i];
103 cout << infiles[i] << endl;
106 for (i = 0; i < nfld; ++i)
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;
114 for (i = 0; i < nfld; ++i)
116 if (
m_f->m_exp.size())
120 for (j = 0; j <
m_f->m_exp[0]->GetExpSize(); ++j)
123 m_f->m_exp[0]->GetExp(j)->GetGeom()->GetGlobalID();
125 m_f->FieldIOForFile(infiles[i])
126 ->Import(infiles[i], fromField[i]->m_fielddef,
127 fromField[i]->m_data,
132 m_f->FieldIOForFile(infiles[i])
133 ->Import(infiles[i], fromField[i]->m_fielddef,
134 fromField[i]->m_data,
138 nfields = fromField[i]->m_fielddef[0]->m_fields.size();
139 int NumHomogeneousDir =
140 fromField[i]->m_fielddef[0]->m_numHomogeneousDir;
142 if (nfields == 5 || nfields == 7)
148 fromField[i]->m_graph->SetExpansionInfo(fromField[i]->m_fielddef);
151 fromField[i]->m_exp.resize(nfields);
152 fromField[i]->m_exp[0] =
153 fromField[i]->SetUpFirstExpList(NumHomogeneousDir,
true);
155 for (j = 1; j < nfields; ++j)
157 fromField[i]->m_exp[j] =
m_f->AppendExpList(NumHomogeneousDir);
160 for (j = 0; j < nfields; ++j)
162 for (
int k = 0; k < fromField[i]->m_data.size(); ++k)
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());
169 fromField[i]->m_exp[j]->BwdTrans(
170 fromField[i]->m_exp[j]->GetCoeffs(),
171 fromField[i]->m_exp[j]->UpdatePhys());
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)
188 int npoints = fromField[0]->m_exp[0]->GetNpoints();
190 normCrossDir(spacedim), outfield(nout), dtemp(spacedim);
192 DotProduct(npoints, 0.0), temp(npoints, 0.0);
194 for (i = 0; i < spacedim; ++i)
203 for (i = 0; i < nout; ++i)
211 for (i = 0; i < nfld; ++i)
213 for (j = 0; j < spacedim; ++j)
215 Vmath::Vadd(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
216 normTemporalMeanVec[j], 1, normTemporalMeanVec[j], 1);
220 for (i = 0; i < spacedim; ++i)
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);
228 Vmath::Vsqrt(npoints, TemporalMeanMag, 1, TemporalMeanMag, 1);
230 for (i = 0; i < spacedim; ++i)
232 Vmath::Vdiv(npoints, normTemporalMeanVec[i], 1, TemporalMeanMag, 1,
233 normTemporalMeanVec[i], 1);
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,
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,
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,
258 for (i = 0; i < nfld; ++i)
260 for (j = 0; j < spacedim; ++j)
262 Vmath::Vvtvp(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
263 normTemporalMeanVec[j], 1, DotProduct, 1, DotProduct,
267 Vmath::Vadd(npoints, fromField[i]->m_exp[spacedim]->GetPhys(), 1,
268 outfield[0], 1, outfield[0], 1);
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,
275 for (j = 0; j < npoints; ++j)
279 outfield[1][j] = outfield[1][j] +
sqrt(temp[j]);
285 fromField[i]->m_exp[spacedim]->GetPhys(), 1, temp, 1);
286 Vmath::Vadd(npoints, temp, 1, outfield[3], 1, outfield[3], 1);
289 for (j = 0; j < npoints; ++j)
291 temp[j] = 1 - temp[j] * temp[j];
294 outfield[4][j] = outfield[4][j] +
sqrt(temp[j]);
304 fromField[i]->m_exp[0]->PhysDeriv(DotProduct, dtemp[0], dtemp[1],
306 for (j = 0; j < spacedim; j++)
308 Vmath::Vvtvp(npoints, dtemp[j], 1, normTemporalMeanVec[j], 1,
316 for (j = 0; j < spacedim; ++j)
318 Vmath::Vvtvp(npoints, fromField[i]->m_exp[j]->GetPhys(), 1,
319 normCrossDir[j], 1, DotProduct, 1, DotProduct, 1);
321 fromField[i]->m_exp[0]->PhysDeriv(DotProduct, dtemp[0], dtemp[1],
325 for (j = 0; j < spacedim; j++)
328 DotProduct, 1, DotProduct, 1);
330 Vmath::Vvtvp(npoints, DotProduct, 1, DotProduct, 1, temp, 1, temp,
335 Vmath::Vadd(npoints, temp, 1, outfield[5], 1, outfield[5], 1);
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);
348 for (i = 0; i < npoints; ++i)
350 outfield[2][i] = 0.5 * (1 - TemporalMeanMag[i] / outfield[0][i]);
360 m_f->m_exp.resize(nout);
361 m_f->m_fielddef = fromField[0]->m_fielddef;
363 m_f->SetUpFirstExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
true);
365 for (i = 1; i < nout; ++i)
368 m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
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";
380 m_f->m_fielddef[0]->m_fields[5] =
"|WSSG|";
381 Vmath::Smul(npoints, 1.0 / nfld, outfield[5], 1, outfield[5], 1);
384 m_f->m_variables =
m_f->m_fielddef[0]->m_fields;
386 for (i = 0; i < nout; ++i)
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());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
~ProcessMultiShear() override
ProcessMultiShear(FieldSharedPtr f)
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static FieldMetaDataMap NullFieldMetaDataMap
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
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.
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 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 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
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
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.
void Zero(int n, T *x, const int incx)
Zero vector.
scalarT< T > sqrt(scalarT< T > in)
Represents a command-line configuration option.