18 using namespace Nektar;
20 int main(
int argc,
char *argv[])
26 fprintf(stderr,
"Usage: ./CalcDivergence file.xml file.fld\n");
36 string meshfile(argv[argc-2]);
42 string fieldfile(argv[argc-1]);
43 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
44 vector<vector<NekDouble> > fielddata;
47 bool dealiasing =
false;
52 int expdim = graphShPt->GetMeshDimension();
53 int nfields = fielddef[0]->m_fields.size();
55 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields + 1);
61 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
63 if(fielddef[0]->m_numHomogeneousDir == 1)
71 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
76 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
81 for(i = 1; i < nfields + 1; ++i)
86 else if(fielddef[0]->m_numHomogeneousDir == 2)
96 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
97 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
106 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
107 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
112 for(i = 1; i < nfields + 1; ++i)
123 for(i = 1; i < nfields + 1; ++i)
133 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
135 if(fielddef[0]->m_numHomogeneousDir == 1)
143 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
149 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
154 for(i = 1; i < nfields + 1; ++i)
166 for(i = 1; i < nfields + 1; ++i)
181 for(i = 1; i < nfields + 1; ++i)
189 ASSERTL0(
false,
"Expansion dimension not recognised");
195 for(j = 0; j < nfields; ++j)
197 for(
unsigned int i = 0; i < fielddata.size(); ++i)
199 Exp[j]->ExtractDataToCoeffs(fielddef [i],
201 fielddef [i]->m_fields[j],
202 Exp[j]->UpdateCoeffs());
204 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
208 int nq = Exp[0]->GetNpoints();
210 Array<OneD, NekDouble> Ux(nq);
211 Array<OneD, NekDouble> Vy(nq);
212 Array<OneD, NekDouble> Div(nq);
218 if(fielddef[0]->m_numHomogeneousDir == 1)
220 ASSERTL0(
false,
"Not implemented yet");
222 else if(fielddef[0]->m_numHomogeneousDir == 2)
224 ASSERTL0(
false,
"Not implemented yet");
228 ASSERTL0(
false,
"Not implemented yet");
234 if(fielddef[0]->m_numHomogeneousDir == 1)
236 ASSERTL0(
false,
"Not implemented yet");
245 Exp[3]->FwdTrans(Div,Exp[3]->UpdateCoeffs());
251 ASSERTL0(
false,
"Not implemented yet");
256 ASSERTL0(
false,
"Expansion dimension not recognised");
263 string fldfilename(argv[2]);
264 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
265 string endfile(
"_with_divergence.fld");
267 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
268 = Exp[0]->GetFieldDefinitions();
269 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
271 for(j = 0; j < nfields + 1; ++j)
273 for(i = 0; i < FieldDef.size(); ++i)
277 FieldDef[i]->m_fields.push_back(
"Div");
281 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
283 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);