49 "QUADRILATERAL",
"TETRAHEDRON",
"BRICK",
50 "POLYGON",
"POLYHEDRON"};
55 "Writes a Tecplot file.");
59 "Writes a Tecplot file in binary plt format.");
66 "Write double-precision format data:"
67 "more accurate but more disk space"
78 if (
m_config[
"writemultiplefiles"].as<bool>())
93template <
typename T>
void WriteStream(std::ostream &outfile, T data)
96 outfile.write(
reinterpret_cast<char *
>(&tmp),
sizeof(T));
106template <>
void WriteStream(std::ostream &outfile, std::string data)
109 for (std::string::size_type i = 0; i < data.size(); ++i)
111 char strChar = data[i];
129 outfile.write(
reinterpret_cast<char *
>(&data[0]),
130 data.size() *
sizeof(T));
142 outfile.write(
reinterpret_cast<char *
>(&data[0]),
143 data.size() *
sizeof(T));
152 if (fPts->GetNpoints() == 0)
157 int rank =
m_f->m_comm->GetSpaceComm()->GetRank();
163 fPts->GetConnectivity(
m_conn);
165 switch (fPts->GetPtsType())
198 for (
int i = 0; i <
m_conn.size(); ++i)
207 for (
int i = 0; i <
m_conn.size(); ++i)
214 ASSERTL0(
false,
"This points type is not supported yet.");
241 int nBases =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
244 int totpoints =
m_f->m_exp[0]->GetTotPoints();
246 if (
m_f->m_numHomogeneousDir > 0)
248 int nPlanes =
m_f->m_exp[0]->GetZIDs().size();
259 totpoints +=
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
261 nBases +=
m_f->m_numHomogeneousDir;
299 for (
int i = 0; i <
m_f->m_variables.size(); ++i)
304 m_f->m_exp[i]->UpdatePhys(), 1,
311 for (
int i = 0; i <
m_f->m_variables.size(); ++i)
320 int points_on_plane =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
321 const int offset = totpoints - points_on_plane;
336 for (
int i = 0; i <
m_f->m_variables.size(); ++i)
349 "OutputTecplot can't write using only FieldData.");
353 [[maybe_unused]] po::variables_map &vm)
355 int nprocs =
m_f->m_comm->GetSpaceComm()->GetSize();
356 string returnstr(filename);
361 int rank =
m_f->m_comm->GetSpaceComm()->GetRank();
362 int dot = filename.find_last_of(
'.');
363 string ext = filename.substr(dot, filename.length() - dot);
364 string procId =
"_P" + std::to_string(rank);
365 string start = filename.substr(0, dot);
366 returnstr = start + procId + ext;
368 return fs::path(returnstr);
372 po::variables_map &vm)
380 std::string coordVars[] = {
"x",
"y",
"z"};
381 std::vector<string> variables =
m_f->m_variables;
382 variables.insert(variables.begin(), coordVars, coordVars +
m_coordim);
384 int nprocs =
m_f->m_comm->GetSpaceComm()->GetSize();
385 int rank =
m_f->m_comm->GetSpaceComm()->GetRank();
388 string filename =
m_config[
"outfile"].as<
string>();
394 outfile.open(outFile.c_str(),
m_binary ? ios::binary : ios::out);
410 for (
int i = 0; i <
m_conn.size(); ++i)
448 std::vector<std::string> &var)
450 outfile <<
"Variables = " << var[0];
452 for (
int i = 1; i < var.size(); ++i)
454 outfile <<
", " << var[i];
457 outfile << std::endl << std::endl;
467 std::vector<std::string> &var)
475 outfile <<
"#!TDV112";
484 std::string
title =
"";
490 for (
int i = 0; i < var.size(); ++i)
504 bool useDoubles =
m_config[
"double"].as<
bool>();
508 int precision = std::numeric_limits<double>::max_digits10;
509 outfile << std::setprecision(precision);
525 outfile <<
"Zone, N=" << nPoints <<
", E=" <<
m_numBlocks
527 if (
m_f->m_fieldMetaDataMap.count(
"Time"))
529 outfile <<
", SOLUTIONTIME=" <<
m_f->m_fieldMetaDataMap[
"Time"];
531 outfile << std::endl;
536 for (
int j = 0; j <
m_fields.size(); ++j)
538 for (
int i = 0; i <
m_fields[j].size(); ++i)
540 if ((!(i % 1000)) && i)
542 outfile << std::endl;
547 for (
int n = 1; n <
m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
552 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
556 if ((!(i % 1000)) && i)
558 outfile << std::endl;
560 outfile << tmp[i] <<
" ";
564 outfile << std::endl;
571 for (
int i = 0; i <
m_fields.size(); ++i)
581 for (
int j = 0; j <
m_fields.size(); ++j)
583 for (
int i = 0; i <
m_fields[j].size(); ++i)
585 if ((!(i % 1000)) && i)
587 outfile << std::endl;
591 outfile << std::endl;
600 std::string dirs[] = {
"I",
"J",
"K"};
604 outfile <<
", " << dirs[i] <<
"=" <<
m_numPoints[i];
606 outfile <<
", F=POINT" << std::endl;
612 for (
int i = 0; i <
m_fields[0].size(); ++i)
614 for (
int j = 0; j <
m_fields.size(); ++j)
616 outfile << setw(12) <<
m_fields[j][i] <<
" ";
618 outfile << std::endl;
621 for (
int n = 1; n <
m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
625 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
626 for (
int j = 0; j <
m_fields.size(); ++j)
628 outfile << setw(12) << tmp[j] <<
" ";
630 outfile << std::endl;
637 for (
int i = 0; i <
m_fields[0].size(); ++i)
639 for (
int j = 0; j <
m_fields.size(); ++j)
643 m_f->m_comm->GetSpaceComm()->Send(0, tmp);
650 for (
int i = 0; i <
m_fields[0].size(); ++i)
652 for (
int j = 0; j <
m_fields.size(); ++j)
654 outfile << setw(12) <<
m_fields[j][i] <<
" ";
656 outfile << std::endl;
673 bool useDoubles =
m_config[
"double"].as<
bool>();
683 int nPts = data.size();
684 std::vector<float> tmp(data.size());
685 std::copy(&data[0], &data[0] + nPts, &tmp[0]);
702 bool useDoubles =
m_config[
"double"].as<
bool>();
711 int rank =
m_f->m_comm->GetSpaceComm()->GetRank();
712 string zonename =
"ZONE " + boost::lexical_cast<string>(rank);
766 for (
int j = 0; j <
m_fields.size(); ++j)
778 for (
int i = 0; i <
m_fields.size(); ++i)
791 for (
int i = 0; i <
m_fields.size(); ++i)
800 for (
int i = 0; i <
m_fields.size(); ++i)
804 for (
int n = 1; n <
m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
807 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
814 for (
int i = 0; i <
m_fields.size(); ++i)
821 for (
int i = 0; i <
m_fields.size(); ++i)
847 for (
int i = 0, cnt = 0; i <
m_conn.size(); ++i)
856 m_f->m_comm->GetSpaceComm()->Send(0, conn);
862 for (
int i = 0; i <
m_conn.size(); ++i)
864 const int nConn =
m_conn[i].size();
865 for (
int j = 0; j < nConn; ++j, ++cnt)
867 outfile <<
m_conn[i][j] + 1 <<
" ";
870 outfile << std::endl;
880 for (
int n = 1; n <
m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
885 m_f->m_comm->GetSpaceComm()->Recv(n, conn);
886 for (
int j = 0; j < conn.size(); ++j)
888 outfile << conn[j] + offset + 1 <<
" ";
889 if ((!(j % 1000)) && j)
891 outfile << std::endl;
907 for (
int i = 0, cnt = 0; i <
m_conn.size(); ++i)
912 m_f->m_comm->GetSpaceComm()->Send(0, conn);
916 for (
int i = 0; i <
m_conn.size(); ++i)
925 for (
int n = 1; n <
m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
928 m_f->m_comm->GetSpaceComm()->Recv(n, conn);
930 for (
int j = 0; j < conn.size(); ++j)
951 if (
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
953 for (
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
955 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
958 else if (
m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
960 for (
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
962 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
963 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
968 for (
int i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
970 returnval += (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
971 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
972 (
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
987 int nbase =
m_f->m_exp[0]->GetExp(0)->GetNumBases();
990 m_conn.resize(
m_f->m_exp[0]->GetNumElmts());
992 for (i = 0; i <
m_f->m_exp[0]->GetNumElmts(); ++i)
994 cnt =
m_f->m_exp[0]->GetPhys_Offset(i);
999 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1004 nPlanes =
m_f->m_exp[0]->GetZIDs().size();
1008 int totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1011 for (
int n = 1; n < nPlanes; ++n)
1013 for (k = 1; k < np0; ++k)
1015 conn[cnt2++] = cnt + (n - 1) * totPoints + k;
1016 conn[cnt2++] = cnt + (n - 1) * totPoints + k - 1;
1017 conn[cnt2++] = cnt + n * totPoints + k - 1;
1018 conn[cnt2++] = cnt + n * totPoints + k;
1029 for (k = 1; k < np0; ++k)
1031 conn[cnt2++] = cnt + k;
1032 conn[cnt2++] = cnt + k - 1;
1038 else if (nbase == 2)
1040 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1041 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1042 int totPoints =
m_f->m_exp[0]->GetTotPoints();
1048 nPlanes =
m_f->m_exp[0]->GetZIDs().size();
1055 totPoints =
m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1060 for (
int n = 1; n < nPlanes; ++n)
1062 for (j = 1; j < np1; ++j)
1064 for (k = 1; k < np0; ++k)
1066 conn[cnt2++] = cnt + (n - 1) * totPoints +
1067 (j - 1) * np0 + k - 1;
1068 conn[cnt2++] = cnt + (n - 1) * totPoints +
1071 cnt + (n - 1) * totPoints + j * np0 + k;
1073 cnt + (n - 1) * totPoints + j * np0 + k - 1;
1075 cnt + n * totPoints + (j - 1) * np0 + k - 1;
1077 cnt + n * totPoints + (j - 1) * np0 + k;
1079 cnt + n * totPoints + j * np0 + k;
1081 cnt + n * totPoints + j * np0 + k - 1;
1092 for (j = 1; j < np1; ++j)
1094 for (k = 1; k < np0; ++k)
1096 conn[cnt2++] = cnt + (j - 1) * np0 + k - 1;
1097 conn[cnt2++] = cnt + (j - 1) * np0 + k;
1098 conn[cnt2++] = cnt + j * np0 + k;
1099 conn[cnt2++] = cnt + j * np0 + k - 1;
1105 else if (nbase == 3)
1107 int np0 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1108 int np1 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1109 int np2 =
m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
1114 for (j = 1; j < np2; ++j)
1116 for (k = 1; k < np1; ++k)
1118 for (l = 1; l < np0; ++l)
1121 cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l - 1;
1123 cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l;
1124 conn[cnt2++] = cnt + (j - 1) * np0 * np1 + k * np0 + l;
1126 cnt + (j - 1) * np0 * np1 + k * np0 + l - 1;
1128 cnt + j * np0 * np1 + (k - 1) * np0 + l - 1;
1129 conn[cnt2++] = cnt + j * np0 * np1 + (k - 1) * np0 + l;
1130 conn[cnt2++] = cnt + j * np0 * np1 + k * np0 + l;
1131 conn[cnt2++] = cnt + j * np0 * np1 + k * np0 + l - 1;
1140 ASSERTL0(
false,
"Not set up for this dimension");
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Converter from fld to vtk.
fs::path GetFullOutName(std::string &filename, po::variables_map &vm)
fs::path GetPath(std::string &filename, po::variables_map &vm)
void v_Process(po::variables_map &vm) override
Write fld to output file.
void WriteDoubleOrFloat(std::ofstream &outfile, Array< OneD, NekDouble > &data)
Write either double-precision or single-precision output of field data.
void v_WriteTecplotConnectivity(std::ofstream &outfile) override
Write Tecplot connectivity information (ASCII)
static ModuleKey m_className
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
void v_WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var) override
Write Tecplot files header in binary format.
void v_WriteTecplotZone(std::ofstream &outfile) override
virtual void v_WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
Write Tecplot files header.
void v_Process(po::variables_map &vm) override
Write fld to output file.
fs::path v_GetPath(std::string &filename, po::variables_map &vm) override
int m_totConn
Total number of connectivity entries.
void v_OutputFromPts(po::variables_map &vm) override
Write from pts to output file.
std::vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
bool m_binary
True if writing binary field output.
bool m_oneOutputFile
True if writing a single output file.
void WriteTecplotZone(std::ofstream &outfile)
OutputTecplot(FieldSharedPtr f)
void CalculateConnectivity()
Calculate connectivity information for each expansion dimension.
void WriteTecplotConnectivity(std::ofstream &outfile)
~OutputTecplot() override
void v_OutputFromData(po::variables_map &vm) override
Write from data to output file.
bool m_writeHeader
True if writing header.
void v_OutputFromExp(po::variables_map &vm) override
Write from m_exp to output file.
static ModuleKey m_className
TecplotZoneType m_zoneType
Tecplot zone type of output.
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.
std::vector< int > m_numPoints
Number of points per block in Tecplot file.
void WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
void WriteTecplotFile(po::variables_map &vm)
fs::path v_GetFullOutName(std::string &filename, po::variables_map &vm) override
int m_numBlocks
Number of blocks in Tecplot file.
int m_coordim
Coordinate dimension of output.
virtual void v_WriteTecplotConnectivity(std::ofstream &outfile)
Write Tecplot connectivity information (ASCII)
int GetNumTecplotBlocks()
Calculate number of Tecplot blocks.
virtual void v_WriteTecplotZone(std::ofstream &outfile)
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void WriteStream(std::ostream &outfile, T data)
Helper function to write binary data to stream.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
std::string TecplotZoneTypeMap[]
ModuleFactory & GetModuleFactory()
static std::string PortablePath(const fs::path &path)
create portable path on different platforms for std::filesystem path.
std::shared_ptr< PtsField > PtsFieldSharedPtr
std::vector< double > z(NPUPPER)
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Represents a command-line configuration option.