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();
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();
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());
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]);
#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
int main(int argc, char *argv[])
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.
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.
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.