54 "Writes a Tecplot file.");
59 if(f->m_setUpEquiSpacedFields)
79 m_doError = (vm.count(
"error") == 1)?
true:
false;
89 if(
m_f->m_comm->TreatAsRankZero())
91 cout <<
"OutputTecplot: Writing file..." << endl;
97 string filename =
m_config[
"outfile"].as<
string>();
99 int nprocs =
m_f->m_comm->GetSize();
100 int rank =
m_f->m_comm->GetRank();
104 int dot = filename.find_last_of(
'.');
105 string ext = filename.substr(dot,filename.length()-dot);
106 string procId =
"_P" + boost::lexical_cast<std::string>(rank);
107 string start = filename.substr(0,dot);
108 filename = start + procId + ext;
115 int dim = fPts->GetDim();
117 if(fPts->GetNpoints() == 0)
123 ofstream outfile(filename.c_str());
128 vector<Array<OneD, int> > ptsConn;
129 fPts->GetConnectivity(ptsConn);
138 outfile <<
"VARIABLES = x";
141 outfile <<
"VARIABLES = x,y";
144 outfile <<
"VARIABLES = x,y,z";
148 for(i = 0; i < fPts->GetNFields(); ++i)
150 outfile <<
"," << fPts->GetFieldName(i);
155 bool DumpAsFEPoint =
true;
156 switch(fPts->GetPtsType())
163 outfile <<
" ZONE I="
164 << fPts->GetNpoints()
165 <<
" F=POINT" << endl;
173 outfile <<
" ZONE I=" << fPts->GetPointsPerEdge(0)
174 <<
" J=" << fPts->GetPointsPerEdge(1)
175 <<
" F=POINT" << endl;
183 outfile <<
" ZONE I=" << fPts->GetPointsPerEdge(0)
184 <<
" J=" << fPts->GetPointsPerEdge(1)
185 <<
" K=" << fPts->GetPointsPerEdge(2)
186 <<
" F=POINT" << endl;
194 for(i = 0; i < ptsConn.size(); ++i)
197 ptsConn[i].num_elements()/3;
199 outfile <<
"Zone, N="
200 << fPts->GetNpoints()
201 <<
", E=" << numBlocks
202 <<
", F=FEBlock" <<
", ET=TRIANGLE"
204 DumpAsFEPoint =
false;
210 for(i = 0; i < ptsConn.size(); ++i)
213 ptsConn[i].num_elements()/4;
215 outfile <<
"Zone, N="
216 << fPts->GetNpoints()
217 <<
", E=" << numBlocks
218 <<
", F=FEBlock" <<
", ET=TETRAHEDRON"
220 DumpAsFEPoint =
false;
224 ASSERTL0(
false,
"ptsType not supported yet.");
229 for(i = 0; i < fPts->GetNpoints(); ++i)
231 for(j = 0; j < dim; ++j)
233 outfile << std::setw(12)
234 << fPts->GetPointVal(j, i) <<
" ";
237 for(j = 0; j < fPts->GetNFields(); ++j)
239 outfile << std::setw(12)
240 <<
m_f->m_data[j][i] <<
" ";
250 std::string coordval[] = {
"x",
"y",
"z"};
251 int rank =
m_f->m_comm->GetRank();
253 for(i = 0; i < dim; ++i)
257 for(j = 0; j < fPts->GetNpoints(); ++j)
259 l2err += fPts->GetPointVal(i,j)*fPts->GetPointVal(i,j);
263 int npts = fPts->GetNpoints();
271 cout <<
"L 2 error (variable "
272 << coordval[i] <<
") : "
277 for(i = 0; i < fPts->GetNFields(); ++i)
281 for(j = 0; j < fPts->GetNpoints(); ++j)
283 l2err +=
m_f->m_data[i][j]*
m_f->m_data[i][j];
285 m_f->m_comm->AllReduce(l2err,
288 int npts = fPts->GetNpoints();
289 m_f->m_comm->AllReduce(npts,
297 cout <<
"L 2 error (variable "
298 << fPts->GetFieldName(i) <<
") : "
304 m_f->m_comm->Block();
308 for(j = 0; j < dim + fPts->GetNFields(); ++j)
310 for(i = 0; i < fPts->GetNpoints(); ++i)
312 outfile << fPts->GetPointVal(j, i) <<
" ";
315 outfile << std::endl;
322 for(i = 0; i < ptsConn.size();++i)
324 for(j = 0; j < ptsConn[i].num_elements(); ++j)
326 outfile << ptsConn[i][j] +1 <<
" ";
327 if( ( !(j % 10 * dim) ) && j )
329 outfile << std::endl;
337 std::string coordval[] = {
"x",
"y",
"z"};
338 int rank =
m_f->m_comm->GetRank();
340 for(
int i = 0; i < dim + fPts->GetNFields(); ++i)
344 for(j = 0; j < fPts->GetNpoints(); ++j)
346 l2err += fPts->GetPointVal(i,j)*fPts->GetPointVal(i,j);
348 m_f->m_comm->AllReduce(l2err,
351 int npts = fPts->GetNpoints();
352 m_f->m_comm->AllReduce(npts,
362 cout <<
"L 2 error (variable "
363 << coordval[i] <<
") : "
368 cout <<
"L 2 error (variable "
369 << fPts->GetFieldName(i-dim) <<
") : "
381 ofstream outfile(filename.c_str());
383 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fDef =
387 var = fDef[0]->m_fields[0];
389 for (
int j = 1; j < fDef[0]->m_fields.size(); ++j)
391 var = var +
", " + fDef[0]->m_fields[j];
399 for(
int j = 0; j <
m_f->m_exp.size(); ++j)
408 cout <<
"Written file: " << filename << endl;
419 int coordim =
m_f->m_exp[0]->GetExp(0)->GetCoordim();
424 if(
m_f->m_session->DefinesSolverInfo(
"ModeType")&&
425 boost::iequals(
m_f->m_session->GetSolverInfo(
"ModeType"),
"HalfMode"))
438 outfile <<
"Variables = x";
444 else if (coordim == 3)
451 outfile <<
", "<< var << std::endl << std::endl;
455 outfile << std::endl << std::endl;
472 int coordim =
m_f->m_exp[0]->GetCoordim(0);
473 int totpoints =
m_f->m_exp[0]->GetTotPoints();
482 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
487 std::string coordval[] = {
"x",
"y",
"z"};
488 int rank =
m_f->m_comm->GetRank();
490 for(
int i = 0; i < coordim; ++i)
492 l2err =
m_f->m_exp[0]->L2(coords[i]);
495 cout <<
"L 2 error (variable "
496 << coordval[i] <<
") : " << l2err << endl;
502 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
506 int nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
516 numBlocks = (int)tmp;
525 outfile <<
"Zone, N=" << totpoints <<
", E="<<
526 numBlocks <<
", F=FEBlock" ;
531 outfile <<
", ET=LINESEG" << std::endl;
534 outfile <<
", ET=QUADRILATERAL" << std::endl;
537 outfile <<
", ET=BRICK" << std::endl;
542 for(j = 0; j < coordim; ++j)
544 for(i = 0; i < totpoints; ++i)
546 outfile << coords[j][i] <<
" ";
549 outfile << std::endl;
552 outfile << std::endl;
558 for(
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
560 m_f->m_exp[0]->WriteTecplotZone(outfile,i);
566 "Should not have this option in this method");
575 if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
577 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
579 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1);
582 else if(
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
584 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
586 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
587 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1);
592 for(
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
594 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0)-1)*
595 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1)-1)*
596 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2)-1);
610 std::ofstream &outfile)
615 int totpoints =
m_f->m_exp[0]->GetTotPoints();
617 if(
m_f->m_exp[field]->GetPhysState() ==
false)
619 m_f->m_exp[field]->BwdTrans(
m_f->m_exp[field]->GetCoeffs(),
620 m_f->m_exp[field]->UpdatePhys());
627 if(
m_f->m_comm->GetRank() == 0)
629 cout <<
"L 2 error (variable "
630 <<
m_f->m_fielddef[0]->m_fields[field] <<
") : "
636 for(
int i = 0; i < totpoints; ++i)
638 outfile <<
m_f->m_exp[field]->GetPhys()[i] <<
" ";
641 outfile << std::endl;
645 outfile << std::endl;
649 for(
int e = 0; e <
m_f->m_exp[field]->GetExpSize(); ++e)
651 m_f->m_exp[field]->WriteTecplotField(outfile,e);
659 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
662 for(i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
664 cnt =
m_f->m_exp[0]->GetPhys_Offset(i);
668 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
670 for(k = 1; k < np0; ++k)
672 outfile << cnt + k +1 <<
" ";
673 outfile << cnt + k << endl;
680 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
681 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
682 int totPoints =
m_f->m_exp[0]->GetTotPoints();
687 nPlanes =
m_f->m_exp[0]->GetZIDs().num_elements();
691 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
694 for(
int n = 1; n < nPlanes; ++n)
696 for(j = 1; j < np1; ++j)
698 for(k = 1; k < np0; ++k)
700 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k
702 outfile << cnt + (n-1)*totPoints + (j-1)*np0 + k + 1
704 outfile << cnt + (n-1)*totPoints + j*np0 + k + 1
706 outfile << cnt + (n-1)*totPoints + j*np0 + k
709 outfile << cnt + n*totPoints + (j-1)*np0 + k
711 outfile << cnt + n*totPoints + (j-1)*np0 + k + 1
713 outfile << cnt + n*totPoints + j*np0 + k + 1
715 outfile << cnt + n*totPoints + j*np0 + k << endl;
725 for(j = 1; j < np1; ++j)
727 for(k = 1; k < np0; ++k)
729 outfile << cnt + (j-1)*np0 + k <<
" ";
730 outfile << cnt + (j-1)*np0 + k +1 <<
" ";
731 outfile << cnt + j*np0 + k +1 <<
" ";
732 outfile << cnt + j*np0 + k << endl;
739 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
740 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
741 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
743 for(j = 1; j < np2; ++j)
745 for(k = 1; k < np1; ++k)
747 for(l = 1; l < np0; ++l)
749 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l <<
" ";
750 outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 <<
" ";
751 outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 <<
" ";
752 outfile << cnt + (j-1)*np0*np1 + k*np0 + l <<
" ";
754 outfile << cnt + j*np0*np1 + (k-1)*np0 + l <<
" ";
755 outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 <<
" ";
756 outfile << cnt + j*np0*np1 + k*np0 + l +1 <<
" ";
757 outfile << cnt + j*np0*np1 + k*np0 + l << endl;
764 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.