13 using namespace Nektar;
15 int main(
int argc,
char *argv[])
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;
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;
83 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields+addfields), shear(sfields);
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(i));
133 ASSERTL0(
false,
"Expansion dimension not recognised");
145 Array<OneD, int> BoundarytoElmtID;
146 Array<OneD, int> BoundarytoTraceID;
147 Array<OneD, Array<OneD, MultiRegions::ExpListSharedPtr> > BndExp(nfields+addfields);
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();
170 Array<OneD, const NekDouble> testing(nt);
174 int n, cnt, elmtid, offset, boundary, bndOffset;
175 Array<OneD, NekDouble> Sx(nbq), Sy(nbq), Sz(nbq), S(nbq), Sxr(nbq), Syr(nbq), Szr(nbq), sx(nbq), sy(nbq), sz(nbq);
176 Array<OneD, NekDouble> Save(nbq), temp2(nbq), trs(nbq), TAwss(nbq), osi(nbq);
177 Array<OneD, Array<OneD, NekDouble> > temp(sfields), values(nfields);
179 for (i = 0; i < sfields; i++)
181 temp[i]= Array<OneD, NekDouble>(nfq);
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();
283 Vmath::Vvtvvtp(nbq, Sx, 1, Sx, 1, Sy, 1, Sy, 1, Save, 1);
303 for (
int fileNo = 0; fileNo < nfiles ; ++fileNo)
315 for(j = 0; j < nfields; ++j)
317 for(
int i = 0; i < fielddata.size(); ++i)
319 Exp[j]->ExtractDataToCoeffs(fielddef[i],
321 fielddef[i]->m_fields[j],
322 Exp[j]->UpdateCoeffs());
324 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
327 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
328 BndExp[0] = Exp[0]->GetBndCondExpansions();
330 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
334 for(i = 0; i < nelem; ++i, cnt++)
337 elmtid = BoundarytoElmtID[cnt];
338 elmt = Exp[0]->GetExp(elmtid);
339 offset = Exp[0]->GetPhys_Offset(elmtid);
351 boundary = BoundarytoTraceID[cnt];
354 for (
int t = 0; t< sfields; t++)
356 elmt->
GetFacePhysVals(boundary,bc,Exp[t+expdim]->GetPhys() + offset, temp[t]);
359 for (
int m = 0; m < nfq; m++)
361 Sx[bndOffset + m] = temp[0][m];
362 Sy[bndOffset + m] = temp[1][m];
363 Sz[bndOffset + m] = temp[2][m];
369 Vmath::Vvtvvtp(nbq, Sx, 1, Sx, 1, Sy, 1, Sy, 1, S, 1);
375 Vmath::Vvtvvtp(nbq, Sx, 1, Sxr, 1, Sy, 1, Syr, 1, temp2, 1);
379 for (
int m = 0; m < nbq; m++)
383 trs[m] = trs[m] + sqrt(temp2[m]);
398 cnt += BndExp[0][n]->GetExpSize();
406 Vmath::Smul (nbq, (1.0/nfiles), TAwss, 1, TAwss, 1);
419 for(j = 0; j < nfields; ++j)
421 for(
int i = 0; i < fielddata.size(); ++i)
423 Exp[j]->ExtractDataToCoeffs(fielddef[i],
425 fielddef[i]->m_fields[j],
426 Exp[j]->UpdateCoeffs());
428 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
431 for(j = 0; j < addfields; ++j)
433 for(
int i = 0; i < fielddata.size(); ++i)
435 Exp[j+nfields]->ExtractDataToCoeffs(fielddef[i],
437 fielddef[i]->m_fields[j],
438 Exp[j+nfields]->UpdateCoeffs());
440 Exp[j+nfields]->BwdTrans(Exp[j+nfields]->GetCoeffs(),Exp[j+nfields]->UpdatePhys());
443 Exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
446 for(j = 0; j < nfields+addfields; ++j)
448 BndExp[j] = Exp[j]->GetBndCondExpansions();
451 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
455 for(i = 0; i < nelem; ++i, cnt++)
458 elmtid = BoundarytoElmtID[cnt];
459 offset = Exp[0]->GetPhys_Offset(elmtid);
471 boundary = BoundarytoTraceID[cnt];
474 for (j = 0; j < nfq; j++)
476 temp[0][j] = trs[bndOffset + j];
477 temp[1][j] = TAwss[bndOffset + j];
478 temp[2][j] = osi[bndOffset + j];
481 for (j = 0; j < addfields; j++)
483 values[j] = BndExp[j+nfields][n]->UpdateCoeffs() + BndExp[j+nfields][n]->GetCoeff_Offset(i);
505 cnt += BndExp[0][n]->GetExpSize();
509 for(j = 0; j < nfields + addfields; ++j)
511 int ncoeffs = Exp[j]->GetNcoeffs();
512 Array<OneD, NekDouble> output(ncoeffs);
514 output=Exp[j]->UpdateCoeffs();
516 int nGlobal=m_locToGlobalMap->GetNumGlobalCoeffs();
517 Array<OneD, NekDouble> outarray(nGlobal,0.0);
521 const Array<OneD,const int>& map = m_locToGlobalMap->GetBndCondCoeffsToGlobalCoeffsMap();
524 for(i = 0; i < BndExp[j].num_elements(); ++i)
528 const Array<OneD,const NekDouble>& coeffs = BndExp[j][i]->GetCoeffs();
529 for(
int k = 0; k < (BndExp[j][i])->GetNcoeffs(); ++k)
531 sign = m_locToGlobalMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
532 outarray[map[bndcnt++]] = sign * coeffs[k];
537 bndcnt += BndExp[j][i]->GetNcoeffs();
540 m_locToGlobalMap->GlobalToLocal(outarray,output);
547 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
548 = Exp[0]->GetFieldDefinitions();
549 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
551 vector<string > outname;
553 outname.push_back(
"TransWSS");
554 outname.push_back(
"TAWSS");
555 outname.push_back(
"OSI");
557 for(j = 0; j < nfields+addfields; ++j)
559 for(i = 0; i < FieldDef.size(); ++i)
563 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
567 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
569 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);