51 "Writes a Tecplot file.");
56 if(f->m_setUpEquiSpacedFields)
74 m_doError = (vm.count(
"error") == 1)?
true:
false;
78 cout <<
"OutputTecplot: Writing file..." << endl;
87 string filename =
m_config[
"outfile"].as<
string>();
93 int dim = f->m_ptsDim;
95 if(f->m_pts[0].num_elements() == 0)
101 ofstream outfile(filename.c_str());
106 outfile <<
"VARIABLES = x";
109 outfile <<
"VARIABLES = x,y";
112 outfile <<
"VARIABLES = x,y,z";
116 for(i = 0; i < f->m_fields.size(); ++i)
118 outfile <<
"," << f->m_fields[i];
121 bool DumpAsFEPoint =
true;
126 outfile <<
" ZONE I="
127 << f->m_pts[0].num_elements()
128 <<
" F=POINT" << endl;
131 outfile <<
" ZONE I=" << f->m_npts[0]
132 <<
" J=" << f->m_npts[1]
133 <<
" F=POINT" << endl;
138 for(i = 0; i < f->m_ptsConn.size(); ++i)
141 f->m_ptsConn[i].num_elements()/3;
143 outfile <<
"Zone, N="
144 << f->m_pts[0].num_elements()
145 <<
", E=" << numBlocks
146 <<
", F=FEBlock" <<
", ET=TRIANGLE"
148 DumpAsFEPoint =
false;
154 for(i = 0; i < f->m_ptsConn.size(); ++i)
157 f->m_ptsConn[i].num_elements()/4;
159 outfile <<
"Zone, N="
160 << f->m_pts[0].num_elements()
161 <<
", E=" << numBlocks
162 <<
", F=FEBlock" <<
", ET=TETRAHEDRON"
164 DumpAsFEPoint =
false;
171 for(i = 0; i < f->m_pts[0].num_elements(); ++i)
173 for(j = 0; j < dim; ++j)
175 outfile << std::setw(12)
176 << f->m_pts[j][i] <<
" ";
179 for(j = 0; j < f->m_fields.size(); ++j)
181 outfile << std::setw(12)
182 <<
m_f->m_data[j][i] <<
" ";
189 for(j = 0; j < dim + f->m_fields.size(); ++j)
191 for(i = 0; i < f->m_pts[0].num_elements(); ++i)
193 outfile << f->m_pts[j][i] <<
" ";
196 outfile << std::endl;
204 for(i = 0; i < f->m_ptsConn.size();++i)
206 for(j = 0; j < f->m_ptsConn[i].num_elements(); ++j)
208 outfile << f->m_ptsConn[i][j] +1 <<
" ";
209 if( ( !(j % 10 * dim) ) && j )
211 outfile << std::endl;
220 if(
m_f->m_session->GetComm()->GetSize() != 1)
222 int dot = filename.find_last_of(
'.');
223 string ext = filename.substr(dot,filename.length()-dot);
224 string procId =
"_P" + boost::lexical_cast<std::string>(
225 m_f->m_session->GetComm()->GetRank());
226 string start = filename.substr(0,dot);
227 filename = start + procId + ext;
231 ofstream outfile(filename.c_str());
233 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fDef =
237 var = fDef[0]->m_fields[0];
239 for (
int j = 1; j < fDef[0]->m_fields.size(); ++j)
241 var = var +
", " + fDef[0]->m_fields[j];
249 for(
int j = 0; j <
m_f->m_exp.size(); ++j)
258 cout <<
"Written file: " << filename << endl;
269 int coordim =
m_f->m_exp[0]->GetExp(0)->GetCoordim();
281 outfile <<
"Variables = x";
287 else if (coordim == 3)
294 outfile <<
", "<< var << std::endl << std::endl;
298 outfile << std::endl << std::endl;
315 int coordim =
m_f->m_exp[0]->GetCoordim(0);
316 int totpoints =
m_f->m_exp[0]->GetTotPoints();
319 Array<OneD,NekDouble> coords[3];
321 coords[0] = Array<OneD,NekDouble>(totpoints);
322 coords[1] = Array<OneD,NekDouble>(totpoints);
323 coords[2] = Array<OneD,NekDouble>(totpoints);
325 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
330 std::string coordval[] = {
"x",
"y",
"z"};
331 int rank =
m_f->m_session->GetComm()->GetRank();
333 for(
int i = 0; i < coordim; ++i)
335 l2err =
m_f->m_exp[0]->L2(coords[i]);
338 cout <<
"L 2 error (variable "
339 << coordval[i] <<
") : " << l2err << endl;
345 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
351 int nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
353 numBlocks = (int)tmp;
361 outfile <<
"Zone, N=" << totpoints <<
", E="<<
362 numBlocks <<
", F=FEBlock" ;
367 outfile <<
", ET=LINESEG" << std::endl;
370 outfile <<
", ET=QUADRILATERAL" << std::endl;
373 outfile <<
", ET=BRICK" << std::endl;
378 for(j = 0; j < coordim; ++j)
380 for(i = 0; i < totpoints; ++i)
382 outfile << coords[j][i] <<
" ";
385 outfile << std::endl;
388 outfile << std::endl;
394 for(
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
396 m_f->m_exp[0]->WriteTecplotZone(outfile,i);
402 "Should not have this option in this method");
411 if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
413 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
415 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1);
418 else if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
420 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
422 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
423 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1);
428 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
430 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
431 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1)*
432 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2)-1);
446 std::ofstream &outfile)
451 int totpoints =
m_f->m_exp[0]->GetTotPoints();
453 if(
m_f->m_exp[field]->GetPhysState() ==
false)
455 m_f->m_exp[field]->BwdTrans(
m_f->m_exp[field]->GetCoeffs(),
456 m_f->m_exp[field]->UpdatePhys());
463 if(
m_f->m_session->GetComm()->GetRank() == 0)
465 cout <<
"L 2 error (variable "
466 <<
m_f->m_fielddef[0]->m_fields[field] <<
") : "
472 for(
int i = 0; i < totpoints; ++i)
474 outfile <<
m_f->m_exp[field]->GetPhys()[i] <<
" ";
477 outfile << std::endl;
481 outfile << std::endl;
485 for(
int e = 0; e <
m_f->m_exp[field]->GetExpSize(); ++e)
487 m_f->m_exp[field]->WriteTecplotField(outfile,e);
495 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
498 for(i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
502 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
504 for(k = 1; k < np0; ++k)
506 outfile << cnt + k +1 <<
" ";
507 outfile << cnt + k << endl;
514 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
515 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
516 int totPoints =
m_f->m_exp[0]->GetTotPoints();
521 nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
522 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
525 for(
int n = 1; n < nPlanes; ++n)
527 for(j = 1; j < np1; ++j)
529 for(k = 1; k < np0; ++k)
531 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k
533 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k + 1
535 outfile << cnt + (n-1)*totPoints + j*np0 + k + 1
537 outfile << cnt + (n-1)*totPoints + j*np0 + k
540 outfile << cnt + n*totPoints + (j-1)*np0 + k
542 outfile << cnt + n*totPoints + (j-1)*np0 + k + 1
544 outfile << cnt + n*totPoints + j*np0 + k + 1
546 outfile << cnt + n*totPoints + j*np0 + k << endl;
554 for(j = 1; j < np1; ++j)
556 for(k = 1; k < np0; ++k)
558 outfile << cnt + (j-1)*np0 + k <<
" ";
559 outfile << cnt + (j-1)*np0 + k +1 <<
" ";
560 outfile << cnt + j*np0 + k +1 <<
" ";
561 outfile << cnt + j*np0 + k << endl;
569 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
570 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
571 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
573 for(j = 1; j < np2; ++j)
575 for(k = 1; k < np1; ++k)
577 for(l = 1; l < np0; ++l)
579 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l <<
" ";
580 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 <<
" ";
581 outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 <<
" ";
582 outfile << cnt + (j-1)*np0*np1 + k*np0 + l <<
" ";
584 outfile << cnt + j*np0*np1 + (k-1)*np0 + l <<
" ";
585 outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 <<
" ";
586 outfile << cnt + j*np0*np1 + k*np0 + l +1 <<
" ";
587 outfile << cnt + j*np0*np1 + k*np0 + l << endl;
595 ASSERTL0(
false,
"Not set up for this dimension");