19 int main(
int argc,
char *argv[])
25 fprintf(stderr,
"Usage: ./CalcGrad ifield file.xml file.fld\n");
33 int ifield = atoi(argv[argc-3]);
37 string meshfile(argv[argc-2]);
43 string fieldfile(argv[argc-1]);
44 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
45 vector<vector<NekDouble> > fielddata;
48 bool dealiasing =
false;
53 int expdim = graphShPt->GetMeshDimension();
54 int nfields = fielddef[0]->m_fields.size();
58 if(fielddef[0]->m_numHomogeneousDir == 2)
69 if(fielddef[0]->m_numHomogeneousDir == 1)
91 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
93 if(fielddef[0]->m_numHomogeneousDir == 1)
98 int nplanes = fielddef[0]->m_numModes[1];
103 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
108 for(i = 1; i < nfields + graddim; ++i)
113 else if(fielddef[0]->m_numHomogeneousDir == 2)
118 int nylines = fielddef[0]->m_numModes[1];
119 int nzlines = fielddef[0]->m_numModes[2];
128 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
129 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
134 for(i = 1; i < nfields + graddim; ++i)
145 for(i = 1; i < nfields + graddim; ++i)
155 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
157 if(fielddef[0]->m_numHomogeneousDir == 1)
162 int nplanes = fielddef[0]->m_numModes[2];
168 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
173 for(i = 1; i < nfields + graddim; ++i)
185 for(i = 1; i < nfields + graddim; ++i)
200 for(i = 1; i < nfields + graddim; ++i)
208 ASSERTL0(
false,
"Expansion dimension not recognised");
214 for(j = 0; j < nfields; ++j)
216 for(
unsigned int i = 0; i < fielddata.size(); ++i)
218 Exp[j]->ExtractDataToCoeffs(fielddef [i],
220 fielddef [i]->m_fields[j],
221 Exp[j]->UpdateCoeffs());
223 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
227 int nq = Exp[0]->GetNpoints();
237 if(fielddef[0]->m_numHomogeneousDir == 1)
239 ASSERTL0(
false,
"Not implemented yet");
241 else if(fielddef[0]->m_numHomogeneousDir == 2)
244 Exp[ifield]->GetPhys(),Dx);
246 Exp[ifield]->GetPhys(),Dy);
248 Exp[ifield]->GetPhys(),Dz);
249 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
250 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
251 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
256 ASSERTL0(
false,
"Not implemented yet");
262 if(fielddef[0]->m_numHomogeneousDir == 1)
267 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
268 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
269 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
275 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
276 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
285 Exp[nfields ]->FwdTrans(Dx,Exp[nfields ]->UpdateCoeffs());
286 Exp[nfields+1]->FwdTrans(Dy,Exp[nfields+1]->UpdateCoeffs());
287 Exp[nfields+2]->FwdTrans(Dz,Exp[nfields+2]->UpdateCoeffs());
292 ASSERTL0(
false,
"Expansion dimension not recognised");
299 string fldfilename(argv[2]);
300 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
301 string endfile(
"_with_grad.fld");
303 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
304 = Exp[0]->GetFieldDefinitions();
305 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
307 for(j = 0; j < nfields + graddim; ++j)
309 for(i = 0; i < FieldDef.size(); ++i)
315 std::string val = FieldDef[i]->m_fields[ifield] +
"_x";
316 FieldDef[i]->m_fields.push_back(val.c_str());
318 else if(j == nfields+1)
320 std::string val = FieldDef[i]->m_fields[ifield] +
"_y";
321 FieldDef[i]->m_fields.push_back(val.c_str());
325 std::string val = FieldDef[i]->m_fields[ifield] +
"_z";
326 FieldDef[i]->m_fields.push_back(val.c_str());
331 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
333 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
#define ASSERTL0(condition, msg)
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
boost::shared_ptr< ExpList3DHomogeneous2D > ExpList3DHomogeneous2DSharedPtr
Shared pointer to an ExpList3DHomogeneous2D object.
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
1D Evenly-spaced points using Lagrange polynomial
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
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.
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.
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Describes the specification for a Basis.