12 using namespace Nektar;
14 int main(
int argc,
char *argv[])
20 fprintf(stderr,
"Usage: FldAddVort meshfile infld outfld\n");
30 string meshfile(argv[argc-3]);
36 string fieldfile(argv[argc-2]);
37 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
38 vector<vector<NekDouble> > fielddata;
41 bool dealiasing =
false;
46 int expdim = graphShPt->GetMeshDimension();
47 int nfields = fielddef[0]->m_fields.size();
48 int addfields = (nfields == 4)? 3:1;
49 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields + addfields);
55 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
57 if(fielddef[0]->m_numHomogeneousDir == 1)
64 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
70 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
75 for(i = 1; i < nfields; ++i)
80 else if(fielddef[0]->m_numHomogeneousDir == 2)
90 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
91 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
101 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
102 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
107 for(i = 1; i < nfields; ++i)
118 for(i = 1; i < nfields + addfields; ++i)
128 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
130 if(fielddef[0]->m_numHomogeneousDir == 1)
138 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
144 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
149 for(i = 1; i < nfields + addfields; ++i)
162 for(i = 1; i < nfields + addfields; ++i)
177 for(i = 1; i < nfields + addfields; ++i)
185 ASSERTL0(
false,
"Expansion dimension not recognised");
192 for(j = 0; j < nfields; ++j)
194 for(
int i = 0; i < fielddata.size(); ++i)
196 Exp[j]->ExtractDataToCoeffs(fielddef [i],
198 fielddef [i]->m_fields[j],
199 Exp[j]->UpdateCoeffs());
201 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
207 ASSERTL0(nfields >= 3,
"Need two fields (u,v) to add reentricity");
208 int nq = Exp[0]->GetNpoints();
209 Array<OneD, Array<OneD, NekDouble> > grad(nfields*nfields);
210 Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
212 for(i = 0; i < nfields*nfields; ++i)
214 grad[i] = Array<OneD, NekDouble>(nq);
217 for(i = 0; i < addfields; ++i)
219 outfield[i] = Array<OneD, NekDouble>(nq);
225 for(i = 0; i < nfields; ++i)
227 Exp[i]->PhysDeriv(Exp[i]->GetPhys(), grad[i*nfields],grad[i*nfields+1]);
230 Vmath::Vsub(nq,grad[1*nfields+0],1,grad[0*nfields+1],1,outfield[0],1);
234 for(i = 0; i < nfields; ++i)
236 Exp[i]->PhysDeriv(Exp[i]->GetPhys(), grad[i*nfields],grad[i*nfields+1],grad[i*nfields+2]);
240 Vmath::Vsub(nq,grad[2*nfields+1],1,grad[1*nfields+2],1,outfield[0],1);
242 Vmath::Vsub(nq,grad[0*nfields+2],1,grad[2*nfields+0],1,outfield[1],1);
244 Vmath::Vsub(nq,grad[1*nfields+0],1,grad[0*nfields+1],1,outfield[2],1);
247 for (i = 0; i < addfields; ++i)
249 Exp[nfields + i]->FwdTrans(outfield[i], Exp[nfields+i]->UpdateCoeffs());
254 string out(argv[argc-1]);
255 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
256 = Exp[0]->GetFieldDefinitions();
257 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
259 vector<string > outname;
263 outname.push_back(
"W_z");
267 outname.push_back(
"W_x");
268 outname.push_back(
"W_y");
269 outname.push_back(
"W_z");
272 for(j = 0; j < nfields + addfields; ++j)
274 for(i = 0; i < FieldDef.size(); ++i)
278 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
282 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
284 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);