54 "Writes a Tecplot file.");
59 if(f->m_setUpEquiSpacedFields)
79 m_doError = (vm.count(
"error") == 1)?
true:
false;
89 cout <<
"OutputTecplot: Writing file..." << endl;
94 string filename =
m_config[
"outfile"].as<
string>();
96 int nprocs =
m_f->m_comm->GetSize();
97 int rank =
m_f->m_comm->GetRank();
101 int dot = filename.find_last_of(
'.');
102 string ext = filename.substr(dot,filename.length()-dot);
103 string procId =
"_P" + boost::lexical_cast<std::string>(rank);
104 string start = filename.substr(0,dot);
105 filename = start + procId + ext;
112 int dim = fPts->GetDim();
114 if(fPts->GetNpoints() == 0)
120 ofstream outfile(filename.c_str());
125 vector<Array<OneD, int> > ptsConn;
126 fPts->GetConnectivity(ptsConn);
135 outfile <<
"VARIABLES = x";
138 outfile <<
"VARIABLES = x,y";
141 outfile <<
"VARIABLES = x,y,z";
145 for(i = 0; i < fPts->GetNFields(); ++i)
147 outfile <<
"," << fPts->GetFieldName(i);
152 bool DumpAsFEPoint =
true;
153 switch(fPts->GetPtsType())
160 outfile <<
" ZONE I="
161 << fPts->GetNpoints()
162 <<
" F=POINT" << endl;
170 outfile <<
" ZONE I=" << fPts->GetPointsPerEdge(0)
171 <<
" J=" << fPts->GetPointsPerEdge(1)
172 <<
" F=POINT" << endl;
180 outfile <<
" ZONE I=" << fPts->GetPointsPerEdge(0)
181 <<
" J=" << fPts->GetPointsPerEdge(1)
182 <<
" K=" << fPts->GetPointsPerEdge(2)
183 <<
" F=POINT" << endl;
191 for(i = 0; i < ptsConn.size(); ++i)
194 ptsConn[i].num_elements()/3;
196 outfile <<
"Zone, N="
197 << fPts->GetNpoints()
198 <<
", E=" << numBlocks
199 <<
", F=FEBlock" <<
", ET=TRIANGLE"
201 DumpAsFEPoint =
false;
207 for(i = 0; i < ptsConn.size(); ++i)
210 ptsConn[i].num_elements()/4;
212 outfile <<
"Zone, N="
213 << fPts->GetNpoints()
214 <<
", E=" << numBlocks
215 <<
", F=FEBlock" <<
", ET=TETRAHEDRON"
217 DumpAsFEPoint =
false;
221 ASSERTL0(
false,
"ptsType not supported yet.");
226 for(i = 0; i < fPts->GetNpoints(); ++i)
228 for(j = 0; j < dim; ++j)
230 outfile << std::setw(12)
231 << fPts->GetPointVal(j, i) <<
" ";
234 for(j = 0; j < fPts->GetNFields(); ++j)
236 outfile << std::setw(12)
237 <<
m_f->m_data[j][i] <<
" ";
247 std::string coordval[] = {
"x",
"y",
"z"};
248 int rank =
m_f->m_comm->GetRank();
250 for(
int i = 0; i < dim; ++i)
254 for(j = 0; j < fPts->GetNpoints(); ++j)
256 l2err += fPts->GetPointVal(i,j)*fPts->GetPointVal(i,j);
260 int npts = fPts->GetNpoints();
268 cout <<
"L 2 error (variable "
269 << coordval[i] <<
") : "
274 for(i = 0; i < fPts->GetNFields(); ++i)
278 for(j = 0; j < fPts->GetNpoints(); ++j)
280 l2err +=
m_f->m_data[i][j]*
m_f->m_data[i][j];
282 m_f->m_comm->AllReduce(l2err,
285 int npts = fPts->GetNpoints();
286 m_f->m_comm->AllReduce(npts,
294 cout <<
"L 2 error (variable "
295 << fPts->GetFieldName(i) <<
") : "
301 m_f->m_comm->Block();
305 for(j = 0; j < dim + fPts->GetNFields(); ++j)
307 for(i = 0; i < fPts->GetNpoints(); ++i)
309 outfile << fPts->GetPointVal(j, i) <<
" ";
312 outfile << std::endl;
319 for(i = 0; i < ptsConn.size();++i)
321 for(j = 0; j < ptsConn[i].num_elements(); ++j)
323 outfile << ptsConn[i][j] +1 <<
" ";
324 if( ( !(j % 10 * dim) ) && j )
326 outfile << std::endl;
334 std::string coordval[] = {
"x",
"y",
"z"};
335 int rank =
m_f->m_comm->GetRank();
337 for(
int i = 0; i < dim + fPts->GetNFields(); ++i)
341 for(j = 0; j < fPts->GetNpoints(); ++j)
343 l2err += fPts->GetPointVal(i,j)*fPts->GetPointVal(i,j);
345 m_f->m_comm->AllReduce(l2err,
348 int npts = fPts->GetNpoints();
349 m_f->m_comm->AllReduce(npts,
359 cout <<
"L 2 error (variable "
360 << coordval[i] <<
") : "
365 cout <<
"L 2 error (variable "
366 << fPts->GetFieldName(i-dim) <<
") : "
378 ofstream outfile(filename.c_str());
380 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fDef =
384 var = fDef[0]->m_fields[0];
386 for (
int j = 1; j < fDef[0]->m_fields.size(); ++j)
388 var = var +
", " + fDef[0]->m_fields[j];
396 for(
int j = 0; j <
m_f->m_exp.size(); ++j)
405 cout <<
"Written file: " << filename << endl;
416 int coordim =
m_f->m_exp[0]->GetExp(0)->GetCoordim();
421 if(
m_f->m_session->DefinesSolverInfo(
"ModeType")&&
422 boost::iequals(
m_f->m_session->GetSolverInfo(
"ModeType"),
"HalfMode"))
435 outfile <<
"Variables = x";
441 else if (coordim == 3)
448 outfile <<
", "<< var << std::endl << std::endl;
452 outfile << std::endl << std::endl;
469 int coordim =
m_f->m_exp[0]->GetCoordim(0);
470 int totpoints =
m_f->m_exp[0]->GetTotPoints();
479 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
484 std::string coordval[] = {
"x",
"y",
"z"};
485 int rank =
m_f->m_comm->GetRank();
487 for(
int i = 0; i < coordim; ++i)
489 l2err =
m_f->m_exp[0]->L2(coords[i]);
492 cout <<
"L 2 error (variable "
493 << coordval[i] <<
") : " << l2err << endl;
499 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
503 int nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
513 numBlocks = (int)tmp;
522 outfile <<
"Zone, N=" << totpoints <<
", E="<<
523 numBlocks <<
", F=FEBlock" ;
528 outfile <<
", ET=LINESEG" << std::endl;
531 outfile <<
", ET=QUADRILATERAL" << std::endl;
534 outfile <<
", ET=BRICK" << std::endl;
539 for(j = 0; j < coordim; ++j)
541 for(i = 0; i < totpoints; ++i)
543 outfile << coords[j][i] <<
" ";
546 outfile << std::endl;
549 outfile << std::endl;
555 for(
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
557 m_f->m_exp[0]->WriteTecplotZone(outfile,i);
563 "Should not have this option in this method");
572 if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
574 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
576 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1);
579 else if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
581 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
583 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
584 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1);
589 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
591 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
592 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1)*
593 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2)-1);
607 std::ofstream &outfile)
612 int totpoints =
m_f->m_exp[0]->GetTotPoints();
614 if(
m_f->m_exp[field]->GetPhysState() ==
false)
616 m_f->m_exp[field]->BwdTrans(
m_f->m_exp[field]->GetCoeffs(),
617 m_f->m_exp[field]->UpdatePhys());
624 if(
m_f->m_comm->GetRank() == 0)
626 cout <<
"L 2 error (variable "
627 <<
m_f->m_fielddef[0]->m_fields[field] <<
") : "
633 for(
int i = 0; i < totpoints; ++i)
635 outfile <<
m_f->m_exp[field]->GetPhys()[i] <<
" ";
638 outfile << std::endl;
642 outfile << std::endl;
646 for(
int e = 0; e <
m_f->m_exp[field]->GetExpSize(); ++e)
648 m_f->m_exp[field]->WriteTecplotField(outfile,e);
656 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
659 for(i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
661 cnt =
m_f->m_exp[0]->GetPhys_Offset(i);
665 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
667 for(k = 1; k < np0; ++k)
669 outfile << cnt + k +1 <<
" ";
670 outfile << cnt + k << endl;
677 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
678 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
679 int totPoints =
m_f->m_exp[0]->GetTotPoints();
684 nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
688 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
691 for(
int n = 1; n < nPlanes; ++n)
693 for(j = 1; j < np1; ++j)
695 for(k = 1; k < np0; ++k)
697 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k
699 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k + 1
701 outfile << cnt + (n-1)*totPoints + j*np0 + k + 1
703 outfile << cnt + (n-1)*totPoints + j*np0 + k
706 outfile << cnt + n*totPoints + (j-1)*np0 + k
708 outfile << cnt + n*totPoints + (j-1)*np0 + k + 1
710 outfile << cnt + n*totPoints + j*np0 + k + 1
712 outfile << cnt + n*totPoints + j*np0 + k << endl;
722 for(j = 1; j < np1; ++j)
724 for(k = 1; k < np0; ++k)
726 outfile << cnt + (j-1)*np0 + k <<
" ";
727 outfile << cnt + (j-1)*np0 + k +1 <<
" ";
728 outfile << cnt + j*np0 + k +1 <<
" ";
729 outfile << cnt + j*np0 + k << endl;
736 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
737 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
738 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
740 for(j = 1; j < np2; ++j)
742 for(k = 1; k < np1; ++k)
744 for(l = 1; l < np0; ++l)
746 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l <<
" ";
747 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 <<
" ";
748 outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 <<
" ";
749 outfile << cnt + (j-1)*np0*np1 + k*np0 + l <<
" ";
751 outfile << cnt + j*np0*np1 + (k-1)*np0 + l <<
" ";
752 outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 <<
" ";
753 outfile << cnt + j*np0*np1 + k*np0 + l +1 <<
" ";
754 outfile << cnt + j*np0*np1 + k*np0 + l << endl;
761 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.