54 "Writes a Tecplot file.");
58 if(f->m_setUpEquiSpacedFields)
77 m_doError = (vm.count(
"error") == 1)?
true:
false;
81 cout <<
"OutputTecplot: Writing file..." << endl;
91 string filename =
m_config[
"outfile"].as<
string>();
94 if(
m_f->m_session->GetComm()->GetSize() != 1)
96 int dot = filename.find_last_of(
'.');
97 string ext = filename.substr(dot,filename.length()-dot);
98 string procId =
"_P" + boost::lexical_cast<std::string>(
99 m_f->m_session->GetComm()->GetRank());
100 string start = filename.substr(0,dot);
101 filename = start + procId + ext;
108 int dim = fPts->GetDim();
110 if(fPts->GetNpoints() == 0)
116 ofstream outfile(filename.c_str());
121 outfile <<
"VARIABLES = x";
124 outfile <<
"VARIABLES = x,y";
127 outfile <<
"VARIABLES = x,y,z";
131 vector<Array<OneD, int> > ptsConn;
132 fPts->GetConnectivity(ptsConn);
134 for(i = 0; i < fPts->GetNFields(); ++i)
136 outfile <<
"," << fPts->GetFieldName(i);
139 bool DumpAsFEPoint =
true;
140 switch(fPts->GetPtsType())
145 outfile <<
" ZONE I="
146 << fPts->GetNpoints()
147 <<
" F=POINT" << endl;
152 outfile <<
" ZONE I=" << fPts->GetPointsPerEdge(0)
153 <<
" J=" << fPts->GetPointsPerEdge(1)
154 <<
" F=POINT" << endl;
160 for(i = 0; i < ptsConn.size(); ++i)
163 ptsConn[i].num_elements()/3;
165 outfile <<
"Zone, N="
166 << fPts->GetNpoints()
167 <<
", E=" << numBlocks
168 <<
", F=FEBlock" <<
", ET=TRIANGLE"
170 DumpAsFEPoint =
false;
176 for(i = 0; i < ptsConn.size(); ++i)
179 ptsConn[i].num_elements()/4;
181 outfile <<
"Zone, N="
182 << fPts->GetNpoints()
183 <<
", E=" << numBlocks
184 <<
", F=FEBlock" <<
", ET=TETRAHEDRON"
186 DumpAsFEPoint =
false;
190 ASSERTL0(
false,
"ptsType not supported yet.");
195 for(i = 0; i < fPts->GetNpoints(); ++i)
197 for(j = 0; j < dim; ++j)
199 outfile << std::setw(12)
200 << fPts->GetPointVal(j, i) <<
" ";
203 for(j = 0; j < fPts->GetNFields(); ++j)
205 outfile << std::setw(12)
206 <<
m_f->m_data[j][i] <<
" ";
213 for(j = 0; j < dim + fPts->GetNFields(); ++j)
215 for(i = 0; i < fPts->GetNpoints(); ++i)
217 outfile << fPts->GetPointVal(j, i) <<
" ";
220 outfile << std::endl;
227 for(i = 0; i < ptsConn.size();++i)
229 for(j = 0; j < ptsConn[i].num_elements(); ++j)
231 outfile << ptsConn[i][j] +1 <<
" ";
232 if( ( !(j % 10 * dim) ) && j )
234 outfile << std::endl;
244 ofstream outfile(filename.c_str());
246 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fDef =
250 var = fDef[0]->m_fields[0];
252 for (
int j = 1; j < fDef[0]->m_fields.size(); ++j)
254 var = var +
", " + fDef[0]->m_fields[j];
262 for(
int j = 0; j <
m_f->m_exp.size(); ++j)
271 cout <<
"Written file: " << filename << endl;
282 int coordim =
m_f->m_exp[0]->GetExp(0)->GetCoordim();
294 outfile <<
"Variables = x";
300 else if (coordim == 3)
307 outfile <<
", "<< var << std::endl << std::endl;
311 outfile << std::endl << std::endl;
328 int coordim =
m_f->m_exp[0]->GetCoordim(0);
329 int totpoints =
m_f->m_exp[0]->GetTotPoints();
338 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
343 std::string coordval[] = {
"x",
"y",
"z"};
344 int rank =
m_f->m_session->GetComm()->GetRank();
346 for(
int i = 0; i < coordim; ++i)
348 l2err =
m_f->m_exp[0]->L2(coords[i]);
351 cout <<
"L 2 error (variable "
352 << coordval[i] <<
") : " << l2err << endl;
358 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
364 int nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
366 numBlocks = (int)tmp;
374 outfile <<
"Zone, N=" << totpoints <<
", E="<<
375 numBlocks <<
", F=FEBlock" ;
380 outfile <<
", ET=LINESEG" << std::endl;
383 outfile <<
", ET=QUADRILATERAL" << std::endl;
386 outfile <<
", ET=BRICK" << std::endl;
391 for(j = 0; j < coordim; ++j)
393 for(i = 0; i < totpoints; ++i)
395 outfile << coords[j][i] <<
" ";
398 outfile << std::endl;
401 outfile << std::endl;
407 for(
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
409 m_f->m_exp[0]->WriteTecplotZone(outfile,i);
415 "Should not have this option in this method");
424 if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
426 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
428 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1);
431 else if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
433 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
435 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
436 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1);
441 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
443 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
444 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1)*
445 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2)-1);
459 std::ofstream &outfile)
464 int totpoints =
m_f->m_exp[0]->GetTotPoints();
466 if(
m_f->m_exp[field]->GetPhysState() ==
false)
468 m_f->m_exp[field]->BwdTrans(
m_f->m_exp[field]->GetCoeffs(),
469 m_f->m_exp[field]->UpdatePhys());
476 if(
m_f->m_session->GetComm()->GetRank() == 0)
478 cout <<
"L 2 error (variable "
479 <<
m_f->m_fielddef[0]->m_fields[field] <<
") : "
485 for(
int i = 0; i < totpoints; ++i)
487 outfile <<
m_f->m_exp[field]->GetPhys()[i] <<
" ";
490 outfile << std::endl;
494 outfile << std::endl;
498 for(
int e = 0; e <
m_f->m_exp[field]->GetExpSize(); ++e)
500 m_f->m_exp[field]->WriteTecplotField(outfile,e);
508 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
511 for(i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
515 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
517 for(k = 1; k < np0; ++k)
519 outfile << cnt + k +1 <<
" ";
520 outfile << cnt + k << endl;
527 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
528 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
529 int totPoints =
m_f->m_exp[0]->GetTotPoints();
534 nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
535 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
538 for(
int n = 1; n < nPlanes; ++n)
540 for(j = 1; j < np1; ++j)
542 for(k = 1; k < np0; ++k)
544 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k
546 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k + 1
548 outfile << cnt + (n-1)*totPoints + j*np0 + k + 1
550 outfile << cnt + (n-1)*totPoints + j*np0 + k
553 outfile << cnt + n*totPoints + (j-1)*np0 + k
555 outfile << cnt + n*totPoints + (j-1)*np0 + k + 1
557 outfile << cnt + n*totPoints + j*np0 + k + 1
559 outfile << cnt + n*totPoints + j*np0 + k << endl;
567 for(j = 1; j < np1; ++j)
569 for(k = 1; k < np0; ++k)
571 outfile << cnt + (j-1)*np0 + k <<
" ";
572 outfile << cnt + (j-1)*np0 + k +1 <<
" ";
573 outfile << cnt + j*np0 + k +1 <<
" ";
574 outfile << cnt + j*np0 + k << endl;
582 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
583 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
584 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
586 for(j = 1; j < np2; ++j)
588 for(k = 1; k < np1; ++k)
590 for(l = 1; l < np0; ++l)
592 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l <<
" ";
593 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 <<
" ";
594 outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 <<
" ";
595 outfile << cnt + (j-1)*np0*np1 + k*np0 + l <<
" ";
597 outfile << cnt + j*np0*np1 + (k-1)*np0 + l <<
" ";
598 outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 <<
" ";
599 outfile << cnt + j*np0*np1 + k*np0 + l +1 <<
" ";
600 outfile << cnt + j*np0*np1 + k*np0 + l << endl;
608 ASSERTL0(
false,
"Not set up for this dimension");
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
Abstract base class for output modules.
map< string, ConfigOption > m_config
List of configuration values.
void WriteTecplotZone(std::ofstream &outfile)
FieldSharedPtr m_f
Field object.
boost::shared_ptr< PtsField > PtsFieldSharedPtr
void WriteTecplotHeader(std::ofstream &outfile, std::string var)
boost::shared_ptr< Field > FieldSharedPtr
static PtsFieldSharedPtr NullPtsField
void WriteTecplotField(const int field, std::ofstream &outfile)
void WriteTecplotConnectivity(std::ofstream &outfile)
ModuleFactory & GetModuleFactory()
int GetNumTecplotBlocks(void)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.