13 using namespace Nektar;
19 if ( stat( filename, &buffer ) )
return 0 ;
23 int main(
int argc,
char *argv[])
29 fprintf(stderr,
"Usage: FldToPts meshfile fieldfile(s)\n");
38 vSession->LoadParameter(
"OutputExtraPoints",nExtraPoints,0);
45 for (
int n = 2; n < argc; ++n)
47 string fname = std::string(argv[n]);
48 int fdot = fname.find_last_of(
'.');
49 if (fdot != std::string::npos)
51 string ending = fname.substr(fdot);
52 if (ending ==
".chk" || ending ==
".fld")
54 fname = fname.substr(0,fdot);
57 fname = fname +
".pts";
63 cout <<
"Skipping converted file: " << argv[n] << endl;
66 cout <<
"Processing " << argv[n] << endl;
71 string fieldfile(argv[n]);
72 vector<SpatialDomains::FieldDefinitionsSharedPtr> fielddef;
73 vector<vector<NekDouble> > fielddata;
74 graphShPt->Import(fieldfile,fielddef,fielddata);
76 bool dealiasing =
false;
81 for(i = 0; i < fielddef.size(); ++i)
83 vector<LibUtilities::PointsType> ptype;
84 for(j = 0; j < 3; ++j)
89 fielddef[i]->m_pointsDef =
true;
90 fielddef[i]->m_points = ptype;
92 vector<unsigned int> porder;
93 if(fielddef[i]->m_numPointsDef ==
false)
95 for(j = 0; j < fielddef[i]->m_numModes.size(); ++j)
97 porder.push_back(fielddef[i]->m_numModes[j]+nExtraPoints);
100 fielddef[i]->m_numPointsDef =
true;
104 for(j = 0; j < fielddef[i]->m_numPoints.size(); ++j)
106 porder.push_back(fielddef[i]->m_numPoints[j]+nExtraPoints);
109 fielddef[i]->m_numPoints = porder;
112 graphShPt->SetExpansions(fielddef);
118 int expdim = graphShPt->GetMeshDimension();
119 int nfields = fielddef[0]->m_fields.size();
120 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields);
126 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"NumHomogeneousDir is only set up for 1 or 2");
128 if(fielddef[0]->m_numHomogeneousDir == 1)
135 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
140 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
144 for(i = 1; i < nfields; ++i)
149 else if(fielddef[0]->m_numHomogeneousDir == 2)
159 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
160 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
170 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
171 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
176 for(i = 1; i < nfields; ++i)
187 for(i = 1; i < nfields; ++i)
197 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
199 if(fielddef[0]->m_numHomogeneousDir == 1)
207 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
213 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
218 for(i = 1; i < nfields; ++i)
230 for(i = 1; i < nfields; ++i)
245 for(i = 1; i < nfields; ++i)
253 ASSERTL0(
false,
"Expansion dimension not recognised");
260 for(j = 0; j < nfields; ++j)
262 for(
int i = 0; i < fielddata.size(); ++i)
264 Exp[j]->ExtractDataToCoeffs(fielddef [i],
266 fielddef [i]->m_fields[j],
267 Exp[j]->UpdateCoeffs());
269 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
277 ofstream outfile(fname.c_str());
280 outfile <<
"Fields: x y ";
281 for(i = 0; i < Exp.num_elements(); ++i)
283 outfile << fielddef[0]->m_fields[i];
287 Array<OneD,NekDouble> x(Exp[0]->GetNpoints());
288 Array<OneD,NekDouble> y(Exp[0]->GetNpoints());
289 Exp[0]->GetCoords(x,y);
291 for(i = 0; i < Exp[0]->GetNpoints(); ++i)
294 outfile << x[i] <<
" " << y[i] <<
" ";
296 for(j = 0; j < Exp.num_elements(); ++j)
298 outfile << (Exp[j]->GetPhys())[i] <<
" ";
302 cout <<
"Written file: " << fname << endl;