12 using namespace Nektar;
14 int main(
int argc,
char *argv[])
20 fprintf(stderr,
"Usage: AddExprToField meshfile fieldfile\n");
30 string meshfile(argv[argc-2]);
36 string fieldfile(argv[argc-1]);
37 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
38 vector<vector<NekDouble> > fielddata;
46 int expdim = graphShPt->GetMeshDimension();
47 int nfields = fielddef[0]->m_fields.size();
48 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields);
54 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
56 if(fielddef[0]->m_numHomogeneousDir == 1)
63 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
68 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
73 for(i = 1; i < nfields; ++i)
78 else if(fielddef[0]->m_numHomogeneousDir == 2)
88 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
89 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
98 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
99 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
104 for(i = 1; i < nfields; ++i)
115 for(i = 1; i < nfields ; ++i)
125 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
127 if(fielddef[0]->m_numHomogeneousDir == 1)
135 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
141 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
146 for(i = 1; i < nfields; ++i)
158 for(i = 1; i < nfields; ++i)
173 for(i = 1; i < nfields; ++i)
181 ASSERTL0(
false,
"Expansion dimension not recognised");
188 for(j = 0; j < nfields; ++j)
190 for(
int i = 0; i < fielddata.size(); ++i)
192 Exp[j]->ExtractDataToCoeffs(fielddef [i],
194 fielddef [i]->m_fields[j],
195 Exp[j]->UpdateCoeffs());
197 Exp[j]->BwdTrans_IterPerExp(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
204 int nq = Exp[0]->GetNpoints();
205 Array<OneD, NekDouble> x(nq);
206 Array<OneD, NekDouble> y(nq);
207 Exp[0]->GetCoords(x,y);
212 ASSERTL0(Exp.num_elements()==1,
"the field is not a streak");
213 cout<<
"before Exp[0][1]="<<Exp[0]->GetPhys()[9]<<endl;
214 for (
int i = 0; i < nq; ++i)
217 tmp = 0.01*sin(pi*y[i])*cos(x[i]);
220 Exp[0]->UpdatePhys()[i] = Exp[0]->GetPhys()[i] +tmp;
225 string fldfilename(argv[2]);
226 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
227 string endfile(
"_add.fld");
229 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
230 = Exp[0]->GetFieldDefinitions();
231 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
232 Array<OneD, Array<OneD, NekDouble> > fieldcoeffs(Exp.num_elements());
234 for(
int j = 0; j < nfields ; ++j)
236 Exp[j]->FwdTrans_IterPerExp(Exp[j]->GetPhys(),Exp[j]->UpdateCoeffs());
237 cout<<
" Exp[0][0]="<<Exp[0]->GetPhys()[9]<<endl;
238 fieldcoeffs[j] = Exp[j]->UpdateCoeffs();
239 for(
int i = 0; i < FieldDef.size(); ++i)
241 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
242 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i], fieldcoeffs[j]);