18 int nfiles, nStart, surfID;
21 fprintf(stderr,
"Usage: FldAddMultiShear meshfile nfiles FirstInFile BoundaryID\n");
25 nfiles = boost::lexical_cast<
int>(argv[2]);
26 surfID = boost::lexical_cast<
int>(argv[4]);
28 vector<string> infiles(nfiles);
32 stringstream filename2;
33 filename2 <<
"multishear.fld";
37 string basename = argv[3];
38 basename = basename.substr(basename.find_last_of(
"t")+1, basename.find_last_of(
".")-basename.find_last_of(
"t"));
39 stringstream filename3;
40 filename3 << basename;
43 for (i = 0; i< nfiles; ++i)
46 string extension =
".fld";
47 basename = basename.substr(0, basename.find_first_of(
"_"));
48 stringstream filename;
49 filename << basename <<
"_t" << i+nStart <<
"_wss.fld";
50 filename >> infiles[i];
51 cout << infiles[i]<<endl;
58 = LibUtilities::SessionReader::CreateInstance(argc, argv);
63 string meshfile(argv[1]);
70 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
71 vector<vector<NekDouble> > fielddata;
79 int expdim = graphShPt->GetMeshDimension();
80 int nfields = fielddef[0]->m_fields.size();
82 int sfields = nfields - expdim;
90 ASSERTL0(
false,
"Expansion dimension not recognised");
95 ASSERTL0(
false,
"Expansion dimension not recognised");
104 vSession->GetVariable(i));
106 m_locToGlobalMap = firstfield->GetLocalToGlobalMap();
109 for(i = 1; i < expdim; ++i)
113 vSession->GetVariable(i));
116 for(i = 0; i < sfields; ++i)
120 vSession->GetVariable(i));
123 for(i = 0; i < addfields; ++i)
127 vSession->GetVariable(0));
133 ASSERTL0(
false,
"Expansion dimension not recognised");
150 for(i = 0; i < fielddata.size(); ++i)
152 Exp[0]->ExtractDataToCoeffs(fielddef[i],
154 fielddef[i]->m_fields[0],
155 Exp[0]->UpdateCoeffs());
157 Exp[0]->BwdTrans(Exp[0]->GetCoeffs(),Exp[0]->UpdatePhys());
159 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
160 BndExp[0] = Exp[0]->GetBndCondExpansions();
166 int nelem = BndExp[0][surfID]->GetExpSize();
169 int nt = Exp[0]->GetNpoints();
174 int n, cnt, elmtid, offset, boundary, bndOffset;
179 for (i = 0; i < sfields; i++)
193 for (
int fileNo = 0; fileNo < nfiles ; ++fileNo)
201 for(j = 0; j < nfields; ++j)
203 for(
int i = 0; i < fielddata.size(); ++i)
205 Exp[j]->ExtractDataToCoeffs(fielddef[i],
207 fielddef[i]->m_fields[j],
208 Exp[j]->UpdateCoeffs());
210 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
213 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
214 BndExp[0] = Exp[0]->GetBndCondExpansions();
216 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
220 for(i = 0; i < nelem; ++i, cnt++)
223 elmtid = BoundarytoElmtID[cnt];
224 elmt = Exp[0]->GetExp(elmtid);
225 offset = Exp[0]->GetPhys_Offset(elmtid);
238 boundary = BoundarytoTraceID[cnt];
241 for (
int t = 0; t< expdim; t++)
243 elmt->GetFacePhysVals(boundary,bc, Exp[t+expdim]->GetPhys() + offset, temp[t]);
246 for (
int m = 0; m < nfq; m++)
248 Sxr[bndOffset + m] = temp[0][m];
249 Syr[bndOffset + m] = temp[1][m];
250 Szr[bndOffset + m] = temp[2][m];
266 cnt += BndExp[0][n]->GetExpSize();
278 Vmath::Vvtvvtp(nbq, Sx, 1, Sx, 1, Sy, 1, Sy, 1, Save, 1);
298 for (
int fileNo = 0; fileNo < nfiles ; ++fileNo)
310 for(j = 0; j < nfields; ++j)
312 for(
int i = 0; i < fielddata.size(); ++i)
314 Exp[j]->ExtractDataToCoeffs(fielddef[i],
316 fielddef[i]->m_fields[j],
317 Exp[j]->UpdateCoeffs());
319 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
322 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
323 BndExp[0] = Exp[0]->GetBndCondExpansions();
325 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
329 for(i = 0; i < nelem; ++i, cnt++)
332 elmtid = BoundarytoElmtID[cnt];
333 elmt = Exp[0]->GetExp(elmtid);
334 offset = Exp[0]->GetPhys_Offset(elmtid);
346 boundary = BoundarytoTraceID[cnt];
349 for (
int t = 0; t< sfields; t++)
351 elmt->GetFacePhysVals(boundary,bc,Exp[t+expdim]->GetPhys() + offset, temp[t]);
354 for (
int m = 0; m < nfq; m++)
356 Sx[bndOffset + m] = temp[0][m];
357 Sy[bndOffset + m] = temp[1][m];
358 Sz[bndOffset + m] = temp[2][m];
364 Vmath::Vvtvvtp(nbq, Sx, 1, Sx, 1, Sy, 1, Sy, 1, S, 1);
370 Vmath::Vvtvvtp(nbq, Sx, 1, Sxr, 1, Sy, 1, Syr, 1, temp2, 1);
374 for (
int m = 0; m < nbq; m++)
378 trs[m] = trs[m] + sqrt(temp2[m]);
393 cnt += BndExp[0][n]->GetExpSize();
401 Vmath::Smul (nbq, (1.0/nfiles), TAwss, 1, TAwss, 1);
413 for(j = 0; j < nfields; ++j)
415 for(
int i = 0; i < fielddata.size(); ++i)
417 Exp[j]->ExtractDataToCoeffs(fielddef[i],
419 fielddef[i]->m_fields[j],
420 Exp[j]->UpdateCoeffs());
422 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
425 for(j = 0; j < addfields; ++j)
427 for(
int i = 0; i < fielddata.size(); ++i)
429 Exp[j+nfields]->ExtractDataToCoeffs(fielddef[i],
431 fielddef[i]->m_fields[j],
432 Exp[j+nfields]->UpdateCoeffs());
434 Exp[j+nfields]->BwdTrans(Exp[j+nfields]->GetCoeffs(),Exp[j+nfields]->UpdatePhys());
437 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
440 for(j = 0; j < nfields+addfields; ++j)
442 BndExp[j] = Exp[j]->GetBndCondExpansions();
445 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
449 for(i = 0; i < nelem; ++i, cnt++)
452 elmtid = BoundarytoElmtID[cnt];
453 offset = Exp[0]->GetPhys_Offset(elmtid);
465 boundary = BoundarytoTraceID[cnt];
468 for (j = 0; j < nfq; j++)
470 temp[0][j] = trs[bndOffset + j];
471 temp[1][j] = TAwss[bndOffset + j];
472 temp[2][j] = osi[bndOffset + j];
475 for (j = 0; j < 3; j++)
477 values[j] = BndExp[j+nfields][n]->UpdateCoeffs() + BndExp[j+nfields][n]->GetCoeff_Offset(i);
478 bc->FwdTrans(temp[j], values[j]);
483 for (j = 0; j < nfq; j++)
485 temp[0][j] = Sxr[bndOffset + j];
486 temp[1][j] = Syr[bndOffset + j];
487 temp[2][j] = Szr[bndOffset + j];
490 for (j = 0; j < 3; j++)
492 values[j] = BndExp[j+nfields+3][n]->UpdateCoeffs() + BndExp[j+nfields+3][n]->GetCoeff_Offset(i);
493 bc->FwdTrans(temp[j], values[j]);
499 for (j = 0; j < nfq; j++)
501 temp[0][j] = Save[bndOffset + j];
504 values[0] = BndExp[nfields+addfields-1][n]->UpdateCoeffs() + BndExp[nfields+addfields-1][n]->GetCoeff_Offset(i);
505 bc->FwdTrans(temp[0], values[0]);
512 cnt += BndExp[0][n]->GetExpSize();
516 for(j = 0; j < nfields + addfields; ++j)
518 int ncoeffs = Exp[j]->GetNcoeffs();
521 output=Exp[j]->UpdateCoeffs();
523 int nGlobal=m_locToGlobalMap->GetNumGlobalCoeffs();
531 for(i = 0; i < BndExp[j].num_elements(); ++i)
536 for(
int k = 0; k < (BndExp[j][i])->GetNcoeffs(); ++k)
538 sign = m_locToGlobalMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
539 outarray[map[bndcnt++]] = sign * coeffs[k];
544 bndcnt += BndExp[j][i]->GetNcoeffs();
547 m_locToGlobalMap->GlobalToLocal(outarray,output);
554 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
555 = Exp[0]->GetFieldDefinitions();
556 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
558 vector<string > outname;
560 outname.push_back(
"TransWSS");
561 outname.push_back(
"TAWSS");
562 outname.push_back(
"OSI");
563 outname.push_back(
"norm_mean_x");
564 outname.push_back(
"norm_mean_y");
565 outname.push_back(
"norm_mean_z");
566 outname.push_back(
"mean_mag");
568 for(j = 0; j < nfields+addfields; ++j)
570 for(i = 0; i < FieldDef.size(); ++i)
574 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
578 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
580 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
#define ASSERTL0(condition, msg)
#define sign(a, b)
return the sign(b)*a
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
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.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
boost::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector):
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
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only.
boost::shared_ptr< ContField3D > ContField3DSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
boost::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
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.