51 "Writes a Tecplot file.");
64 m_doError = (vm.count(
"error") == 1)?
true:
false;
68 cout <<
"OutputTecplot: Writing file..." << endl;
78 string filename =
m_config[
"outfile"].as<
string>();
82 int dim =
m_f->m_fieldPts->m_ptsDim;
84 ofstream outfile(filename.c_str());
89 outfile <<
"VARIABLES = x";
92 outfile <<
"VARIABLES = x y";
95 outfile <<
"VARIABLES = x y z";
99 for(
int i = 0; i <
m_f->m_fieldPts->m_fields.size(); ++i)
101 outfile <<
" " <<
m_f->m_fieldPts->m_fields[i];
105 switch(
m_f->m_fieldPts->m_ptype)
109 outfile <<
" ZONE I="
110 <<
m_f->m_fieldPts->m_pts[0].num_elements()
111 <<
" F=POINT" << endl;
114 outfile <<
" ZONE I=" <<
m_f->m_fieldPts->m_npts[0]
115 <<
" J=" <<
m_f->m_fieldPts->m_npts[1]
116 <<
" F=POINT" << endl;
120 for(
int i = 0; i <
m_f->m_fieldPts->m_pts[0].num_elements(); ++i)
122 for(
int j = 0; j < dim; ++j)
124 outfile << std::setw(12)
125 <<
m_f->m_fieldPts->m_pts[j][i] <<
" ";
128 for(
int j = 0; j <
m_f->m_fieldPts->m_fields.size(); ++j)
130 outfile << std::setw(12) <<
m_f->m_data[j][i] <<
" ";
138 if(
m_f->m_session->GetComm()->GetSize() != 1)
140 int dot = filename.find_last_of(
'.');
141 string ext = filename.substr(dot,filename.length()-dot);
142 string procId =
"_P" + boost::lexical_cast<std::string>(
143 m_f->m_session->GetComm()->GetRank());
144 string start = filename.substr(0,dot);
145 filename = start + procId + ext;
149 ofstream outfile(filename.c_str());
151 if(
m_f->m_fielddef.size())
153 var =
m_f->m_fielddef[0]->m_fields[0];
155 for (
int j = 1; j <
m_f->m_fielddef[0]->m_fields.size(); ++j)
157 var = var +
", " +
m_f->m_fielddef[0]->m_fields[j];
165 for(
int j = 0; j <
m_f->m_exp.size(); ++j)
174 cout <<
"Written file: " << filename << endl;
184 int coordim =
m_f->m_exp[0]->GetExp(0)->GetCoordim();
196 outfile <<
"Variables = x";
202 else if (coordim == 3)
209 outfile <<
", "<< var << std::endl << std::endl;
213 outfile << std::endl << std::endl;
229 int coordim =
m_f->m_exp[0]->GetCoordim(0);
230 int totpoints =
m_f->m_exp[0]->GetTotPoints();
233 Array<OneD,NekDouble> coords[3];
235 coords[0] = Array<OneD,NekDouble>(totpoints);
236 coords[1] = Array<OneD,NekDouble>(totpoints);
237 coords[2] = Array<OneD,NekDouble>(totpoints);
239 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
244 std::string coordval[] = {
"x",
"y",
"z"};
245 int rank =
m_f->m_session->GetComm()->GetRank();
247 for(
int i = 0; i < coordim; ++i)
249 l2err =
m_f->m_exp[0]->L2(coords[i]);
252 cout <<
"L 2 error (variable "
253 << coordval[i] <<
") : " << l2err << endl;
259 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
265 int nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
267 numBlocks = (int)tmp;
276 outfile <<
"Zone, N=" << totpoints <<
", E="<<
277 numBlocks <<
", F=FEBlock" ;
282 outfile <<
", ET=LINESEG" << std::endl;
285 outfile <<
", ET=QUADRILATERAL" << std::endl;
288 outfile <<
", ET=BRICK" << std::endl;
293 for(j = 0; j < coordim; ++j)
295 for(i = 0; i < totpoints; ++i)
297 outfile << coords[j][i] <<
" ";
300 outfile << std::endl;
303 outfile << std::endl;
309 m_f->m_exp[0]->WriteTecplotZone(outfile,expansion);
317 if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
319 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
321 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1);
324 else if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
326 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
328 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
329 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1);
334 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
336 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
337 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1)*
338 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2)-1);
352 std::ofstream &outfile,
358 int totpoints =
m_f->m_exp[0]->GetTotPoints();
360 if(
m_f->m_exp[field]->GetPhysState() ==
false)
362 m_f->m_exp[field]->BwdTrans(
m_f->m_exp[field]->GetCoeffs(),
363 m_f->m_exp[field]->UpdatePhys());
370 if(
m_f->m_session->GetComm()->GetRank() == 0)
372 cout <<
"L 2 error (variable "
373 <<
m_f->m_fielddef[0]->m_fields[field] <<
") : "
379 for(
int i = 0; i < totpoints; ++i)
381 outfile <<
m_f->m_exp[field]->GetPhys()[i] <<
" ";
384 outfile << std::endl;
388 outfile << std::endl;
392 m_f->m_exp[field]->WriteTecplotField(outfile,expansion);
399 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
402 for(i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
406 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
408 for(k = 1; k < np0; ++k)
410 outfile << cnt + k +1 <<
" ";
411 outfile << cnt + k << endl;
418 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
419 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
420 int totPoints =
m_f->m_exp[0]->GetTotPoints();
425 nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
426 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
429 for(
int n = 1; n < nPlanes; ++n)
431 for(j = 1; j < np1; ++j)
433 for(k = 1; k < np0; ++k)
435 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k
437 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k + 1
439 outfile << cnt + (n-1)*totPoints + j*np0 + k + 1
441 outfile << cnt + (n-1)*totPoints + j*np0 + k
444 outfile << cnt + n*totPoints + (j-1)*np0 + k
446 outfile << cnt + n*totPoints + (j-1)*np0 + k + 1
448 outfile << cnt + n*totPoints + j*np0 + k + 1
450 outfile << cnt + n*totPoints + j*np0 + k << endl;
458 for(j = 1; j < np1; ++j)
460 for(k = 1; k < np0; ++k)
462 outfile << cnt + (j-1)*np0 + k <<
" ";
463 outfile << cnt + (j-1)*np0 + k +1 <<
" ";
464 outfile << cnt + j*np0 + k +1 <<
" ";
465 outfile << cnt + j*np0 + k << endl;
473 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
474 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
475 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
477 for(j = 1; j < np2; ++j)
479 for(k = 1; k < np1; ++k)
481 for(l = 1; l < np0; ++l)
483 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l <<
" ";
484 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 <<
" ";
485 outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 <<
" ";
486 outfile << cnt + (j-1)*np0*np1 + k*np0 + l <<
" ";
488 outfile << cnt + j*np0*np1 + (k-1)*np0 + l <<
" ";
489 outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 <<
" ";
490 outfile << cnt + j*np0*np1 + k*np0 + l +1 <<
" ";
491 outfile << cnt + j*np0*np1 + k*np0 + l << endl;
499 ASSERTL0(
false,
"Not set up for this dimension");