20 int main(
int argc,
char *argv[])
26 fprintf(stderr,
"Usage: ./CalcGrad ifield file.xml file.fld\n");
31 = LibUtilities::SessionReader::CreateInstance(argc-1, argv+1);
34 int ifield = atoi(argv[argc-3]);
38 string meshfile(argv[argc-2]);
44 string fieldfile(argv[argc-1]);
45 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
46 vector<vector<NekDouble> > fielddata;
49 bool dealiasing =
false;
54 int expdim = graphShPt->GetMeshDimension();
55 int nfields = fielddef[0]->m_fields.size();
59 if(fielddef[0]->m_numHomogeneousDir == 2)
70 if(fielddef[0]->m_numHomogeneousDir == 1)
92 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
94 if(fielddef[0]->m_numHomogeneousDir == 1)
99 int nplanes = fielddef[0]->m_numModes[1];
104 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
109 for(i = 1; i < nfields + graddim; ++i)
114 else if(fielddef[0]->m_numHomogeneousDir == 2)
119 int nylines = fielddef[0]->m_numModes[1];
120 int nzlines = fielddef[0]->m_numModes[2];
129 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
130 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
135 for(i = 1; i < nfields + graddim; ++i)
146 for(i = 1; i < nfields + graddim; ++i)
156 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
158 if(fielddef[0]->m_numHomogeneousDir == 1)
163 int nplanes = fielddef[0]->m_numModes[2];
169 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
174 for(i = 1; i < nfields + graddim; ++i)
186 for(i = 1; i < nfields + graddim; ++i)
201 for(i = 1; i < nfields + graddim; ++i)
209 ASSERTL0(
false,
"Expansion dimension not recognised");
215 for(j = 0; j < nfields; ++j)
217 for(
unsigned int i = 0; i < fielddata.size(); ++i)
219 Exp[j]->ExtractDataToCoeffs(fielddef [i],
221 fielddef [i]->m_fields[j],
222 Exp[j]->UpdateCoeffs());
224 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
228 int nq = Exp[0]->GetNpoints();
238 if(fielddef[0]->m_numHomogeneousDir == 1)
240 ASSERTL0(
false,
"Not implemented yet");
242 else if(fielddef[0]->m_numHomogeneousDir == 2)
245 Exp[ifield]->GetPhys(),Dx);
247 Exp[ifield]->GetPhys(),Dy);
249 Exp[ifield]->GetPhys(),Dz);
250 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
251 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
252 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
257 ASSERTL0(
false,
"Not implemented yet");
263 if(fielddef[0]->m_numHomogeneousDir == 1)
268 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
269 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
270 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
276 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
277 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
286 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
287 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
288 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
293 ASSERTL0(
false,
"Expansion dimension not recognised");
300 string fldfilename(argv[2]);
301 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
302 string endfile(
"_with_grad.fld");
304 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
305 = Exp[0]->GetFieldDefinitions();
306 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
308 for(j = 0; j < nfields + graddim; ++j)
310 for(i = 0; i < FieldDef.size(); ++i)
316 std::string val = FieldDef[i]->m_fields[ifield] +
"_x";
317 FieldDef[i]->m_fields.push_back(val.c_str());
319 else if(j == nfields+1)
321 std::string val = FieldDef[i]->m_fields[ifield] +
"_y";
322 FieldDef[i]->m_fields.push_back(val.c_str());
326 std::string val = FieldDef[i]->m_fields[ifield] +
"_z";
327 FieldDef[i]->m_fields.push_back(val.c_str());
332 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
334 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
#define ASSERTL0(condition, msg)
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
boost::shared_ptr< ExpList3DHomogeneous2D > ExpList3DHomogeneous2DSharedPtr
Shared pointer to an ExpList3DHomogeneous2D object.
1D Evenly-spaced points using Lagrange polynomial
int main(int argc, char *argv[])
boost::shared_ptr< ExpList1D > ExpList1DSharedPtr
Shared pointer to an ExpList1D object.
Defines a specification for a set of points.
boost::shared_ptr< ExpList2D > ExpList2DSharedPtr
Shared pointer to an ExpList2D object.
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
boost::shared_ptr< ExpList2DHomogeneous1D > ExpList2DHomogeneous1DSharedPtr
Shared pointer to an ExpList2DHomogeneous1D object.
boost::shared_ptr< ExpList3D > ExpList3DSharedPtr
Shared pointer to an ExpList3D object.
MultiRegions::Direction const DirCartesianMap[]
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Describes the specification for a Basis.