21 fprintf(stderr,
"Usage: AddExprToField meshfile fieldfile\n");
26 = LibUtilities::SessionReader::CreateInstance(argc, argv);
31 string meshfile(argv[argc-2]);
37 string fieldfile(argv[argc-1]);
38 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
39 vector<vector<NekDouble> > fielddata;
47 int expdim = graphShPt->GetMeshDimension();
48 int nfields = fielddef[0]->m_fields.size();
55 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"Quasi-3D approach is only set up for 1 or 2 homogeneous directions");
57 if(fielddef[0]->m_numHomogeneousDir == 1)
64 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
69 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
74 for(i = 1; i < nfields; ++i)
79 else if(fielddef[0]->m_numHomogeneousDir == 2)
89 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
90 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
99 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
100 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
105 for(i = 1; i < nfields; ++i)
116 for(i = 1; i < nfields ; ++i)
126 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
128 if(fielddef[0]->m_numHomogeneousDir == 1)
136 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
142 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
147 for(i = 1; i < nfields; ++i)
159 for(i = 1; i < nfields; ++i)
174 for(i = 1; i < nfields; ++i)
182 ASSERTL0(
false,
"Expansion dimension not recognised");
189 for(j = 0; j < nfields; ++j)
191 for(
int i = 0; i < fielddata.size(); ++i)
193 Exp[j]->ExtractDataToCoeffs(fielddef [i],
195 fielddef [i]->m_fields[j],
196 Exp[j]->UpdateCoeffs());
198 Exp[j]->BwdTrans_IterPerExp(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
205 int nq = Exp[0]->GetNpoints();
208 Exp[0]->GetCoords(x,y);
213 ASSERTL0(Exp.num_elements()==1,
"the field is not a streak");
214 cout<<
"before Exp[0][1]="<<Exp[0]->GetPhys()[9]<<endl;
215 for (
int i = 0; i < nq; ++i)
218 tmp = 0.01*sin(pi*y[i])*cos(x[i]);
221 Exp[0]->UpdatePhys()[i] = Exp[0]->GetPhys()[i] +tmp;
226 string fldfilename(argv[2]);
227 string out = fldfilename.substr(0, fldfilename.find_last_of(
"."));
228 string endfile(
"_add.fld");
230 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
231 = Exp[0]->GetFieldDefinitions();
232 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
235 for(
int j = 0; j < nfields ; ++j)
237 Exp[j]->FwdTrans_IterPerExp(Exp[j]->GetPhys(),Exp[j]->UpdateCoeffs());
238 cout<<
" Exp[0][0]="<<Exp[0]->GetPhys()[9]<<endl;
239 fieldcoeffs[j] = Exp[j]->UpdateCoeffs();
240 for(
int i = 0; i < FieldDef.size(); ++i)
242 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
243 Exp[j]->AppendFieldData(FieldDef[i], FieldData[i], fieldcoeffs[j]);
#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
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.
boost::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Describes the specification for a Basis.