49 using namespace Nektar;
55 if ( stat( filename, &buffer ) )
return 0 ;
59 int main(
int argc,
char *argv[])
63 fprintf(stderr,
"Usage: %s meshfile fieldfile\n",argv[0]);
68 Array<OneD,NekDouble> fce;
69 Array<OneD,NekDouble> xc0,xc1,xc2;
71 bool Extrude2DWithHomogeneous =
false;
73 bool SingleModePlot=
false;
74 bool HalfModePlot=
false;
76 int nExtraPoints, nExtraPlanes;
81 vSession->LoadParameter(
"OutputExtraPoints",nExtraPoints,0);
82 vSession->LoadParameter(
"OutputExtraPlanes",nExtraPlanes,0);
84 vSession->MatchSolverInfo(
"Extrude2DWithHomogeneous",
"True",Extrude2DWithHomogeneous,
false);
85 vSession->MatchSolverInfo(
"ModeType",
"SingleMode",SingleModePlot,
false);
86 vSession->MatchSolverInfo(
"ModeType",
"HalfMode",HalfModePlot,
false);
92 for (
int n = 1; n < argc; ++n)
94 string fname = std::string(argv[n]);
95 int fdot = fname.find_last_of(
'.');
96 if (fdot != std::string::npos)
98 string ending = fname.substr(fdot);
103 if (ending ==
".chk" || ending ==
".fld")
105 fname = fname.substr(0,fdot);
107 else if (ending ==
".gz")
109 fname = fname.substr(0,fdot);
110 fdot = fname.find_last_of(
'.');
112 "Error: expected file extension before .gz.");
113 ending = fname.substr(fdot);
115 "Compressed non-xml files are not supported.");
118 else if (ending ==
".xml")
124 fname = fname +
".dat";
128 if (
fexist(fname.c_str()))
130 cout <<
"Skipping converted file: " << argv[n] << endl;
133 cout <<
"Processing " << argv[n] << endl;
138 string fieldfile(argv[n]);
139 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
140 vector<vector<NekDouble> > fielddata;
144 if(Extrude2DWithHomogeneous)
147 vSession->LoadParameter(
"LZ",length,1);
148 fielddef[0]->m_numHomogeneousDir = 1;
149 fielddef[0]->m_numModes.push_back(2);
150 fielddef[0]->m_homogeneousZIDs.push_back(0);
151 fielddef[0]->m_homogeneousLengths.push_back(length);
157 fielddef[0]->m_numModes.push_back(4);
163 fielddef[0]->m_numModes.push_back(4);
171 for(i = 0; i < fielddef.size(); ++i)
173 vector<LibUtilities::PointsType> ptype;
174 for(j = 0; j < 3; ++j)
179 fielddef[i]->m_pointsDef =
true;
180 fielddef[i]->m_points = ptype;
182 vector<unsigned int> porder;
183 if(fielddef[i]->m_numPointsDef ==
false)
185 for(j = 0; j < fielddef[i]->m_numModes.size(); ++j)
187 porder.push_back(fielddef[i]->m_numModes[j]+nExtraPoints);
190 fielddef[i]->m_numPointsDef =
true;
194 for(j = 0; j < fielddef[i]->m_numPoints.size(); ++j)
196 porder.push_back(fielddef[i]->m_numPoints[j]+nExtraPoints);
199 fielddef[i]->m_numPoints = porder;
202 graphShPt->SetExpansions(fielddef);
204 bool dealiasing =
false;
210 int expdim = graphShPt->GetMeshDimension();
211 int nfields = fielddef[0]->m_fields.size();
212 Array<OneD, MultiRegions::ExpListSharedPtr> Exp(nfields);
215 Array<OneD, MultiRegions::ExpListSharedPtr> Exp1(nfields);
221 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 2,
"NumHomogeneousDir is only set up for 1 or 2");
223 if(fielddef[0]->m_numHomogeneousDir == 1)
230 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[1]);
235 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
240 for(i = 1; i < nfields; ++i)
245 else if(fielddef[0]->m_numHomogeneousDir == 2)
255 vSession->LoadParameter(
"HomModesY",nylines,fielddef[0]->m_numModes[1]);
256 vSession->LoadParameter(
"HomModesZ",nzlines,fielddef[0]->m_numModes[2]);
265 NekDouble ly = fielddef[0]->m_homogeneousLengths[0];
266 NekDouble lz = fielddef[0]->m_homogeneousLengths[1];
271 for(i = 1; i < nfields; ++i)
281 for(i = 1; i < nfields; ++i)
290 ASSERTL0(fielddef[0]->m_numHomogeneousDir <= 1,
"NumHomogeneousDir is only set up for 1");
292 if(fielddef[0]->m_numHomogeneousDir == 1)
300 int nplanes = fielddef[0]->m_numModes[2];
311 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
318 Exp1[0]= Exp3DH1_aux;
322 for(i = 1; i < nfields; ++i)
330 else if(HalfModePlot)
332 int nplanes = fielddef[0]->m_numModes[2];
346 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
355 Exp1[0]= Exp3DH1_aux;
359 for(i = 1; i < nfields; ++i)
371 vSession->LoadParameter(
"HomModesZ",nplanes,fielddef[0]->m_numModes[2]);
377 NekDouble lz = fielddef[0]->m_homogeneousLengths[0];
388 for(i = 1; i < nfields; ++i)
408 for(i = 1; i < nfields; ++i)
422 for(i = 1; i < nfields; ++i)
437 for(i = 1; i < nfields; ++i)
445 ASSERTL0(
false,
"Expansion dimension not recognised");
450 if(Extrude2DWithHomogeneous)
454 fielddef[0]->m_numModes[2] = 1;
459 for(j = 0; j < nfields; ++j)
461 for(
int i = 0; i < fielddata.size(); ++i)
464 Exp[j]->ExtractDataToCoeffs(fielddef[i],fielddata[i],
465 fielddef[i]->m_fields[j],
466 Exp[j]->UpdateCoeffs());
472 int dim=Exp[j]->GetNcoeffs();
474 Vmath::Vcopy(dim,&Exp[j]->GetCoeffs()[0],1,&Exp1[j]->UpdateCoeffs()[dim],1);
476 Exp1[j]->BwdTrans(Exp1[j]->GetCoeffs(),Exp1[j]->UpdatePhys());
479 else if(HalfModePlot)
482 int dim=Exp[j]->GetNcoeffs();
488 Vmath::Vcopy(dim,&Exp[j]->GetCoeffs()[0],1,&Exp1[j]->UpdateCoeffs()[2*dim],1);
493 Vmath::Vcopy(dim,&Exp[j]->GetCoeffs()[0],1,&Exp1[j]->UpdateCoeffs()[2*dim],1);
496 Exp1[j]->BwdTrans(Exp1[j]->GetCoeffs(),Exp1[j]->UpdatePhys());
501 Exp[j]->BwdTrans(Exp[j]->GetCoeffs(),Exp[j]->UpdatePhys());
509 if(SingleModePlot || HalfModePlot)
511 std::string var =
"";
513 for(
int j = 0; j < Exp1.num_elements(); ++j)
515 var = var +
", " + fielddef[0]->m_fields[j];
518 ofstream outfile(fname.c_str());
520 Exp1[0]->WriteTecplotHeader(outfile,var);
521 for(
int i = 0; i < Exp1[0]->GetNumElmts(); ++i)
523 Exp1[0]->WriteTecplotZone(outfile,i);
524 for(
int j = 0; j < Exp1.num_elements(); ++j)
526 Exp1[j]->WriteTecplotField(outfile,i);
528 Exp1[0]->WriteTecplotConnectivity(outfile,i);
533 std::string var =
"";
535 for(
int j = 0; j < Exp.num_elements(); ++j)
537 var = var +
", " + fielddef[0]->m_fields[j];
540 ofstream outfile(fname.c_str());
541 Exp[0]->WriteTecplotHeader(outfile, var);
542 Exp[0]->WriteTecplotZone(outfile);
543 for(
int j = 0; j < Exp.num_elements(); ++j)
545 Exp[j]->WriteTecplotField(outfile);
547 Exp[0]->WriteTecplotConnectivity(outfile);