17 using namespace Nektar;
19 int main(
int argc,
char *argv[])
25 fprintf(stderr,
"Usage: ./CalcVorticity file.xml file.fld\n");
35 string meshfile(argv[argc-2]);
41 string fieldfile(argv[argc-1]);
42 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
43 vector<vector<NekDouble> > fielddata;
46 bool dealiasing =
false;
51 int expdim = graphShPt->GetMeshDimension();
52 int nfields = fielddef[0]->m_fields.size();
56 if(fielddef[0]->m_numHomogeneousDir == 2)
67 if(fielddef[0]->m_numHomogeneousDir == 1)
83 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields + vorticitydim);
89 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
91 if(fielddef[0]->m_numHomogeneousDir == 1)
99 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
104 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
109 for(i = 1; i < nfields + vorticitydim; ++i)
114 else if(fielddef[0]->m_numHomogeneousDir == 2)
124 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
125 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
134 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
135 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
140 for(i = 1; i < nfields + vorticitydim; ++i)
151 for(i = 1; i < nfields + vorticitydim; ++i)
161 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
163 if(fielddef[0]->m_numHomogeneousDir == 1)
171 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
177 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
182 for(i = 1; i < nfields + vorticitydim; ++i)
194 for(i = 1; i < nfields + vorticitydim; ++i)
209 for(i = 1; i < nfields + vorticitydim; ++i)
217 ASSERTL0(
false,
"Expansion dimension not recognised");
223 for(j = 0; j < nfields; ++j)
225 for(
unsigned int i = 0; i < fielddata.size(); ++i)
227 Exp[j]->ExtractDataToCoeffs(fielddef [i],
229 fielddef [i]->m_fields[j],
230 Exp[j]->UpdateCoeffs());
232 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
236 int nq = Exp[0]->GetNpoints();
238 Array<OneD, NekDouble> Uy(nq);
239 Array<OneD, NekDouble> Uz(nq);
240 Array<OneD, NekDouble> Vx(nq);
241 Array<OneD, NekDouble> Vz(nq);
242 Array<OneD, NekDouble> Wx(nq);
243 Array<OneD, NekDouble> Wy(nq);
244 Array<OneD, NekDouble> Qx(nq);
245 Array<OneD, NekDouble> Qy(nq);
246 Array<OneD, NekDouble> Qz(nq);
252 if(fielddef[0]->m_numHomogeneousDir == 1)
254 ASSERTL0(
false,
"Not implemented yet");
256 else if(fielddef[0]->m_numHomogeneousDir == 2)
269 Exp[4]->FwdTrans(Qx,Exp[4]->UpdateCoeffs());
270 Exp[5]->FwdTrans(Qy,Exp[5]->UpdateCoeffs());
271 Exp[6]->FwdTrans(Qz,Exp[6]->UpdateCoeffs());
275 ASSERTL0(
false,
"Not implemented yet");
281 if(fielddef[0]->m_numHomogeneousDir == 1)
294 Exp[4]->FwdTrans(Qx,Exp[4]->UpdateCoeffs());
295 Exp[5]->FwdTrans(Qy,Exp[5]->UpdateCoeffs());
296 Exp[6]->FwdTrans(Qz,Exp[6]->UpdateCoeffs());
305 Exp[3]->FwdTrans(Qz,Exp[3]->UpdateCoeffs());
322 Exp[4]->FwdTrans(Qx,Exp[4]->UpdateCoeffs());
323 Exp[5]->FwdTrans(Qy,Exp[5]->UpdateCoeffs());
324 Exp[6]->FwdTrans(Qz,Exp[6]->UpdateCoeffs());
329 ASSERTL0(
false,
"Expansion dimension not recognised");
336 string fldfilename(argv[2]);
337 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
338 string endfile(
"_with_vorticity.fld");
340 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
341 = Exp[0]->GetFieldDefinitions();
342 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
344 for(j = 0; j < nfields + vorticitydim; ++j)
346 for(i = 0; i < FieldDef.size(); ++i)
352 FieldDef[i]->m_fields.push_back(
"Qx");
356 FieldDef[i]->m_fields.push_back(
"Qy");
360 FieldDef[i]->m_fields.push_back(
"Qz");
365 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
367 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);