Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Nektar::FieldUtils::OutputTecplot Class Reference

Tecplot output class. More...

#include <OutputTecplot.h>

Inheritance diagram for Nektar::FieldUtils::OutputTecplot:
[legend]

Public Member Functions

 OutputTecplot (FieldSharedPtr f)
 
virtual ~OutputTecplot ()
 
virtual void Process (po::variables_map &vm)
 Write fld to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
virtual ~OutputFileBase ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputModule
 OutputModule (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
virtual ~Module ()=default
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey m_className
 

Protected Member Functions

virtual void OutputFromPts (po::variables_map &vm)
 Write from pts to output file. More...
 
virtual void OutputFromExp (po::variables_map &vm)
 Write from m_exp to output file. More...
 
virtual void OutputFromData (po::variables_map &vm)
 Write from data to output file. More...
 
virtual fs::path GetPath (std::string &filename, po::variables_map &vm)
 
virtual fs::path GetFullOutName (std::string &filename, po::variables_map &vm)
 
virtual void WriteTecplotHeader (std::ofstream &outfile, std::vector< std::string > &var)
 Write Tecplot files header. More...
 
virtual void WriteTecplotZone (std::ofstream &outfile)
 
virtual void WriteTecplotConnectivity (std::ofstream &outfile)
 Write Tecplot connectivity information (ASCII) More...
 
void WriteTecplotFile (po::variables_map &vm)
 
int GetNumTecplotBlocks ()
 Calculate number of Tecplot blocks. More...
 
void CalculateConnectivity ()
 Calculate connectivity information for each expansion dimension. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Protected Attributes

bool m_binary
 True if writing binary field output. More...
 
bool m_oneOutputFile
 True if writing a single output file. More...
 
bool m_writeHeader
 True if writing header. More...
 
TecplotZoneType m_zoneType
 Tecplot zone type of output. More...
 
std::vector< int > m_numPoints
 Number of points per block in Tecplot file. More...
 
int m_numBlocks
 Number of blocks in Tecplot file. More...
 
int m_coordim
 Coordinate dimension of output. More...
 
int m_totConn
 Total number of connectivity entries. More...
 
std::vector< Array< OneD, int > > m_conn
 Connectivty for each block: one per element. More...
 
Array< OneD, int > m_rankFieldSizes
 Each rank's field sizes. More...
 
Array< OneD, int > m_rankConnSizes
 Each rank's connectivity sizes. More...
 
Array< OneD, Array< OneD, NekDouble > > m_fields
 Field data to output. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputFileBase
bool m_requireEquiSpaced
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
std::ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 

Detailed Description

Tecplot output class.

Definition at line 60 of file OutputTecplot.h.

Constructor & Destructor Documentation

◆ OutputTecplot()

Nektar::FieldUtils::OutputTecplot::OutputTecplot ( FieldSharedPtr  f)

Definition at line 74 of file OutputTecplot.cpp.

74  : OutputFileBase(f),
75  m_binary(false),
76  m_oneOutputFile(false)
77 {
78  m_requireEquiSpaced = true;
79  m_config["double"] =
80  ConfigOption(true, "0", "Write double-precision format data:"
81  "more accurate but more disk space"
82  " required");
83 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:233
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:98
bool m_oneOutputFile
True if writing a single output file.

References Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::OutputFileBase::m_requireEquiSpaced.

◆ ~OutputTecplot()

Nektar::FieldUtils::OutputTecplot::~OutputTecplot ( )
virtual

Definition at line 85 of file OutputTecplot.cpp.

86 {
87 }

Member Function Documentation

◆ CalculateConnectivity()

void Nektar::FieldUtils::OutputTecplot::CalculateConnectivity ( )
protected

Calculate connectivity information for each expansion dimension.

Parameters
outfileOutput file

Definition at line 987 of file OutputTecplot.cpp.

988 {
989  int i, j, k, l;
990  int nbase = m_f->m_exp[0]->GetExp(0)->GetNumBases();
991  int cnt = 0;
992 
993  m_conn.resize(m_f->m_exp[0]->GetNumElmts());
994 
995  for (i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
996  {
997  cnt = m_f->m_exp[0]->GetPhys_Offset(i);
998 
999  if (nbase == 1)
1000  {
1001  int cnt2 = 0;
1002  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1003  int nPlanes = 1;
1004 
1005  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e2DH1D)
1006  {
1007  nPlanes = m_f->m_exp[0]->GetZIDs().size();
1008 
1009  if (nPlanes > 1)
1010  {
1011  int totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1012 
1013  Array<OneD, int> conn(4 * (np0 - 1) * (nPlanes - 1));
1014  for (int n = 1; n < nPlanes; ++n)
1015  {
1016  for (k = 1; k < np0; ++k)
1017  {
1018  conn[cnt2++] = cnt + (n - 1) * totPoints + k;
1019  conn[cnt2++] = cnt + (n - 1) * totPoints + k - 1;
1020  conn[cnt2++] = cnt + n * totPoints + k - 1;
1021  conn[cnt2++] = cnt + n * totPoints + k;
1022  }
1023  }
1024  m_conn[i] = conn;
1025  }
1026  }
1027 
1028  if (nPlanes == 1)
1029  {
1030  Array<OneD, int> conn(2 * (np0 - 1));
1031 
1032  for (k = 1; k < np0; ++k)
1033  {
1034  conn[cnt2++] = cnt + k;
1035  conn[cnt2++] = cnt + k - 1;
1036  }
1037 
1038  m_conn[i] = conn;
1039  }
1040  }
1041  else if (nbase == 2)
1042  {
1043  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1044  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1045  int totPoints = m_f->m_exp[0]->GetTotPoints();
1046  int nPlanes = 1;
1047  int cnt2 = 0;
1048 
1049  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
1050  {
1051  nPlanes = m_f->m_exp[0]->GetZIDs().size();
1052 
1053  // default to 2D case for HalfMode when nPlanes = 1
1054  if (nPlanes > 1)
1055  {
1056  // If Fourier points, output extra plane to fill domain
1057  nPlanes += 1;
1058  totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1059 
1060  Array<OneD, int>
1061  conn(8 * (np1 - 1) * (np0 - 1) * (nPlanes - 1));
1062 
1063  for (int n = 1; n < nPlanes; ++n)
1064  {
1065  for (j = 1; j < np1; ++j)
1066  {
1067  for (k = 1; k < np0; ++k)
1068  {
1069  conn[cnt2++] = cnt + (n - 1) * totPoints +
1070  (j - 1) * np0 + k - 1;
1071  conn[cnt2++] = cnt + (n - 1) * totPoints +
1072  (j - 1) * np0 + k;
1073  conn[cnt2++] = cnt + (n - 1) * totPoints +
1074  j * np0 + k;
1075  conn[cnt2++] = cnt + (n - 1) * totPoints +
1076  j * np0 + k - 1;
1077  conn[cnt2++] = cnt + n * totPoints +
1078  (j - 1) * np0 + k - 1;
1079  conn[cnt2++] = cnt + n * totPoints +
1080  (j - 1) * np0 + k;
1081  conn[cnt2++] = cnt + n * totPoints +
1082  j * np0 + k;
1083  conn[cnt2++] = cnt + n * totPoints +
1084  j * np0 + k - 1;
1085  }
1086  }
1087  }
1088  m_conn[i] = conn;
1089  }
1090  }
1091 
1092  if (nPlanes == 1)
1093  {
1094  Array<OneD, int> conn(4 * (np0 - 1) * (np1 - 1));
1095  for (j = 1; j < np1; ++j)
1096  {
1097  for (k = 1; k < np0; ++k)
1098  {
1099  conn[cnt2++] = cnt + (j - 1) * np0 + k - 1;
1100  conn[cnt2++] = cnt + (j - 1) * np0 + k;
1101  conn[cnt2++] = cnt + j * np0 + k;
1102  conn[cnt2++] = cnt + j * np0 + k - 1;
1103  }
1104  }
1105  m_conn[i] = conn;
1106  }
1107  }
1108  else if (nbase == 3)
1109  {
1110  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1111  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1112  int np2 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
1113  int cnt2 = 0;
1114 
1115  Array<OneD, int> conn(8 * (np0 - 1) * (np1 - 1) * (np2 - 1));
1116 
1117  for (j = 1; j < np2; ++j)
1118  {
1119  for (k = 1; k < np1; ++k)
1120  {
1121  for (l = 1; l < np0; ++l)
1122  {
1123  conn[cnt2++] =
1124  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l - 1;
1125  conn[cnt2++] =
1126  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l;
1127  conn[cnt2++] =
1128  cnt + (j - 1) * np0 * np1 + k * np0 + l;
1129  conn[cnt2++] =
1130  cnt + (j - 1) * np0 * np1 + k * np0 + l - 1;
1131  conn[cnt2++] =
1132  cnt + j * np0 * np1 + (k - 1) * np0 + l - 1;
1133  conn[cnt2++] =
1134  cnt + j * np0 * np1 + (k - 1) * np0 + l;
1135  conn[cnt2++] =
1136  cnt + j * np0 * np1 + k * np0 + l;
1137  conn[cnt2++] =
1138  cnt + j * np0 * np1 + k * np0 + l - 1;
1139  }
1140  }
1141  }
1142 
1143  m_conn[i] = conn;
1144  }
1145  else
1146  {
1147  ASSERTL0(false, "Not set up for this dimension");
1148  }
1149 
1150  }
1151 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
FieldSharedPtr m_f
Field object.
Definition: Module.h:230
std::vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.

References ASSERTL0, Nektar::MultiRegions::e2DH1D, Nektar::MultiRegions::e3DH1D, m_conn, and Nektar::FieldUtils::Module::m_f.

Referenced by OutputFromExp().

◆ create()

static std::shared_ptr<Module> Nektar::FieldUtils::OutputTecplot::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 64 of file OutputTecplot.h.

65  {
67  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

◆ GetFullOutName()

fs::path Nektar::FieldUtils::OutputTecplot::GetFullOutName ( std::string &  filename,
po::variables_map &  vm 
)
protectedvirtual

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 384 of file OutputTecplot.cpp.

386 {
387  return GetPath(filename, vm);
388 }
virtual fs::path GetPath(std::string &filename, po::variables_map &vm)

References GetPath().

Referenced by WriteTecplotFile().

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::OutputTecplot::GetModuleName ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 76 of file OutputTecplot.h.

77  {
78  return "OutputTecplot";
79  }

◆ GetNumTecplotBlocks()

int Nektar::FieldUtils::OutputTecplot::GetNumTecplotBlocks ( )
protected

Calculate number of Tecplot blocks.

Parameters
outfileOutput file

Definition at line 950 of file OutputTecplot.cpp.

951 {
952  int returnval = 0;
953 
954  if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
955  {
956  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
957  {
958  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
959  }
960  }
961  else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
962  {
963  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
964  {
965  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
966  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
967  }
968  }
969  else
970  {
971  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
972  {
973  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
974  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
975  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
976  }
977  }
978 
979  return returnval;
980 }

References Nektar::FieldUtils::Module::m_f.

Referenced by OutputFromExp().

◆ GetPath()

fs::path Nektar::FieldUtils::OutputTecplot::GetPath ( std::string &  filename,
po::variables_map &  vm 
)
protectedvirtual

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 363 of file OutputTecplot.cpp.

365 {
366  boost::ignore_unused(vm);
367 
368  int nprocs = m_f->m_comm->GetSize();
369  string returnstr(filename);
370 
371  // Amend for parallel output if required
372  if (nprocs != 1 && !m_oneOutputFile)
373  {
374  int rank = m_f->m_comm->GetRank();
375  int dot = filename.find_last_of('.');
376  string ext = filename.substr(dot, filename.length() - dot);
377  string procId = "_P" + boost::lexical_cast<std::string>(rank);
378  string start = filename.substr(0, dot);
379  returnstr = start + procId + ext;
380  }
381  return fs::path(returnstr);
382 }

References Nektar::FieldUtils::Module::m_f, and m_oneOutputFile.

Referenced by GetFullOutName().

◆ OutputFromData()

void Nektar::FieldUtils::OutputTecplot::OutputFromData ( po::variables_map &  vm)
protectedvirtual

Write from data to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 355 of file OutputTecplot.cpp.

356 {
357  boost::ignore_unused(vm);
358 
360  "OutputTecplot can't write using only FieldData.");
361 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ OutputFromExp()

void Nektar::FieldUtils::OutputTecplot::OutputFromExp ( po::variables_map &  vm)
protectedvirtual

Write from m_exp to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 243 of file OutputTecplot.cpp.

244 {
245  m_numBlocks = 0;
246  m_writeHeader = true;
247 
248  // Calculate number of FE blocks
250 
251  // Calculate coordinate dimension
252  int nBases = m_f->m_exp[0]->GetExp(0)->GetNumBases();
253 
254  m_coordim = m_f->m_exp[0]->GetExp(0)->GetCoordim();
255  int totpoints = m_f->m_exp[0]->GetTotPoints();
256 
257  if (m_f->m_numHomogeneousDir > 0)
258  {
259  int nPlanes = m_f->m_exp[0]->GetZIDs().size();
260  if (nPlanes == 1) // halfMode case
261  {
262  // do nothing
263  }
264  else
265  {
266  // If Fourier points, output extra plane to fill domain
267  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
268  {
269  nPlanes += 1;
270  totpoints += m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
271  }
272  nBases += m_f->m_numHomogeneousDir;
273  m_coordim += m_f->m_numHomogeneousDir;
274  NekDouble tmp = m_numBlocks * (nPlanes - 1);
275  m_numBlocks = (int)tmp;
276  }
277  }
278 
279  m_zoneType = (TecplotZoneType)(2*(nBases-1) + 1);
280 
281  // Calculate connectivity
283 
284  // Set up storage for output fields
285  m_fields =
286  Array<OneD, Array<OneD, NekDouble> >(m_f->m_variables.size()+m_coordim);
287 
288  // Get coordinates
289  for (int i = 0; i < m_coordim; ++i)
290  {
291  m_fields[i] = Array<OneD, NekDouble>(totpoints);
292  }
293 
294  if (m_coordim == 1)
295  {
296  m_f->m_exp[0]->GetCoords(m_fields[0]);
297  }
298  else if (m_coordim == 2)
299  {
300  m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1]);
301  }
302  else
303  {
304  m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1], m_fields[2]);
305  }
306 
307  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
308  {
309  // Copy values
310  for (int i = 0; i < m_f->m_variables.size(); ++i)
311  {
312  m_fields[i + m_coordim] = Array<OneD, NekDouble>(totpoints);
313  Vmath::Vcopy( m_f->m_exp[0]->GetTotPoints(),
314  m_f->m_exp[i]->UpdatePhys(), 1,
315  m_fields[i + m_coordim], 1);
316  }
317  }
318  else
319  {
320  // Add references to m_fields
321  for (int i = 0; i < m_f->m_variables.size(); ++i)
322  {
323  m_fields[i + m_coordim] = m_f->m_exp[i]->UpdatePhys();
324  }
325  }
326 
327  // If Fourier, fill extra plane with data
328  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
329  {
330  int points_on_plane = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
331  const int offset = totpoints-points_on_plane;
332  NekDouble z = m_fields[m_coordim-1][totpoints-2*points_on_plane] +
333  (m_fields[m_coordim-1][points_on_plane] - m_fields[m_coordim-1][0]);
334  // x and y
335  Array<OneD, NekDouble> tmp = m_fields[0] + offset;
336  Vmath::Vcopy(points_on_plane, m_fields[0], 1, tmp, 1 );
337  tmp = m_fields[1] + offset;
338  Vmath::Vcopy(points_on_plane, m_fields[1], 1, tmp, 1 );
339  // z coordinate
340  tmp = m_fields[2] + offset;
341  Vmath::Vcopy(points_on_plane, m_fields[2], 1, tmp, 1 );
342  Vmath::Sadd(points_on_plane, z, m_fields[2], 1, tmp, 1 );
343 
344  //variables
345  for (int i = 0; i < m_f->m_variables.size(); ++i)
346  {
347  tmp = m_fields[i + m_coordim] + offset;
348  Vmath::Vcopy(points_on_plane, m_fields[i + m_coordim], 1, tmp, 1 );
349  }
350  }
351 
352  WriteTecplotFile(vm);
353 }
void CalculateConnectivity()
Calculate connectivity information for each expansion dimension.
bool m_writeHeader
True if writing header.
TecplotZoneType m_zoneType
Tecplot zone type of output.
void WriteTecplotFile(po::variables_map &vm)
int m_numBlocks
Number of blocks in Tecplot file.
int m_coordim
Coordinate dimension of output.
int GetNumTecplotBlocks()
Calculate number of Tecplot blocks.
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
double NekDouble
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha - x.
Definition: Vmath.cpp:341
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199

References CalculateConnectivity(), Nektar::MultiRegions::e3DH1D, GetNumTecplotBlocks(), m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_writeHeader, m_zoneType, Vmath::Sadd(), Vmath::Vcopy(), and WriteTecplotFile().

◆ OutputFromPts()

void Nektar::FieldUtils::OutputTecplot::OutputFromPts ( po::variables_map &  vm)
protectedvirtual

Write from pts to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 161 of file OutputTecplot.cpp.

162 {
163  LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
164 
165  // do not output if zone is empty
166  if (fPts->GetNpoints() == 0)
167  {
168  return;
169  }
170 
171  int rank = m_f->m_comm->GetRank();
172  m_numBlocks = 0;
173 
174  m_coordim = fPts->GetDim();
175 
176  // Grab connectivity information.
177  fPts->GetConnectivity(m_conn);
178 
179  switch (fPts->GetPtsType())
180  {
182  m_numPoints.resize(1);
183  m_numPoints[0] = fPts->GetNpoints();
184  m_f->m_comm->AllReduce(m_numPoints[0], LibUtilities::ReduceSum);
186  break;
188  m_numPoints.resize(1);
189  m_numPoints[0] = fPts->GetPointsPerEdge(0);
191  break;
193  m_numPoints.resize(2);
194  m_numPoints[0] = fPts->GetPointsPerEdge(0);
195  m_numPoints[1] = fPts->GetPointsPerEdge(1);
197  break;
199  m_numPoints.resize(3);
200  m_numPoints[0] = fPts->GetPointsPerEdge(0);
201  m_numPoints[1] = fPts->GetPointsPerEdge(1);
202  m_numPoints[2] = fPts->GetPointsPerEdge(2);
204  break;
206  {
208  for (int i = 0; i < m_conn.size(); ++i)
209  {
210  m_numBlocks += m_conn[i].size() / 3;
211  }
212  break;
213  }
215  {
217  for (int i = 0; i < m_conn.size(); ++i)
218  {
219  m_numBlocks += m_conn[i].size() / 4;
220  }
221  break;
222  }
223  default:
224  ASSERTL0(false, "This points type is not supported yet.");
225  }
226 
227  // Get fields and coordinates
228  m_fields =
229  Array<OneD, Array<OneD, NekDouble> >(m_f->m_variables.size()+m_coordim);
230 
231  // We can just grab everything from points. This should be a
232  // reference, not a copy.
233  fPts->GetPts(m_fields);
234 
235  // Only write header if we're root or FE block; binary files always
236  // write header
237  m_writeHeader =
238  (m_zoneType != eOrdered || rank == 0) || m_binary;
239 
240  WriteTecplotFile(vm);
241 }
std::vector< int > m_numPoints
Number of points per block in Tecplot file.
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:182

References ASSERTL0, Nektar::FieldUtils::eFETetrahedron, Nektar::FieldUtils::eFETriangle, Nektar::FieldUtils::eOrdered, Nektar::LibUtilities::ePtsBox, Nektar::LibUtilities::ePtsFile, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, Nektar::LibUtilities::ePtsTetBlock, Nektar::LibUtilities::ePtsTriBlock, m_binary, m_conn, m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_numPoints, m_writeHeader, m_zoneType, Nektar::LibUtilities::ReduceSum, and WriteTecplotFile().

◆ Process()

void Nektar::FieldUtils::OutputTecplot::Process ( po::variables_map &  vm)
virtual

Write fld to output file.

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 89 of file OutputTecplot.cpp.

90 {
91 
92  if(m_config["writemultiplefiles"].as<bool>())
93  {
94  m_oneOutputFile = false;
95  }
96  else
97  {
98  m_oneOutputFile = (m_f->m_comm->GetSize()> 1);
99  }
100 
102 }
virtual void Process(po::variables_map &vm)
Write fld to output file.

References Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, m_oneOutputFile, and Nektar::FieldUtils::OutputFileBase::Process().

◆ WriteTecplotConnectivity()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotConnectivity ( std::ofstream &  outfile)
protectedvirtual

Write Tecplot connectivity information (ASCII)

Parameters
outfileOutput file

Reimplemented in Nektar::FieldUtils::OutputTecplotBinary.

Definition at line 835 of file OutputTecplot.cpp.

836 {
837  // Ordered data have no connectivity information.
838  if (m_zoneType == eOrdered)
839  {
840  return;
841  }
842 
843  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
844  {
845  // Need to amalgamate connectivity information
846  if (m_totConn)
847  {
848  Array<OneD, int> conn(m_totConn);
849  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
850  {
851  if(m_conn[i].size())
852  {
853  Vmath::Vcopy(m_conn[i].size(), &m_conn[i][0], 1,
854  &conn[cnt], 1);
855  cnt += m_conn[i].size();
856  }
857  }
858  m_f->m_comm->Send(0, conn);
859  }
860  }
861  else
862  {
863  int cnt = 1;
864  for (int i = 0; i < m_conn.size(); ++i)
865  {
866  const int nConn = m_conn[i].size();
867  for (int j = 0; j < nConn; ++j,++cnt)
868  {
869  outfile << m_conn[i][j] + 1 << " ";
870  if (!(cnt % 1000))
871  {
872  outfile << std::endl;
873  }
874  }
875  }
876  outfile << endl;
877 
878  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
879  {
880  int offset = m_rankFieldSizes[0];
881 
882  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
883  {
884  if(m_rankConnSizes[n])
885  {
886  Array<OneD, int> conn(m_rankConnSizes[n]);
887  m_f->m_comm->Recv(n, conn);
888  for (int j = 0; j < conn.size(); ++j)
889  {
890  outfile << conn[j] + offset + 1 << " ";
891  if ((!(j % 1000)) && j)
892  {
893  outfile << std::endl;
894  }
895  }
896  }
897  offset += m_rankFieldSizes[n];
898  }
899  }
900  }
901 }
int m_totConn
Total number of connectivity entries.
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.

References Nektar::FieldUtils::eOrdered, m_conn, Nektar::FieldUtils::Module::m_f, m_oneOutputFile, m_rankConnSizes, m_rankFieldSizes, m_totConn, m_zoneType, and Vmath::Vcopy().

Referenced by WriteTecplotFile().

◆ WriteTecplotFile()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotFile ( po::variables_map &  vm)
protected

Definition at line 390 of file OutputTecplot.cpp.

391 {
392  // Variable names
393  std::string coordVars[] = { "x", "y", "z" };
394  std::vector<string> variables = m_f->m_variables;
395  variables.insert(variables.begin(), coordVars, coordVars + m_coordim);
396 
397  int nprocs = m_f->m_comm->GetSize();
398  int rank = m_f->m_comm->GetRank();
399 
400 
401  // Extract the output filename and extension
402  string filename = m_config["outfile"].as<string>();
403  string outFile = LibUtilities::PortablePath(GetFullOutName(filename, vm));
404  // Open output file
405  ofstream outfile;
406  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
407  {
408  outfile.open(outFile.c_str(), m_binary ? ios::binary : ios::out);
409  }
410 
411  if (m_oneOutputFile)
412  {
413  // Reduce on number of blocks and number of points.
414  m_f->m_comm->AllReduce(m_numBlocks, LibUtilities::ReduceSum);
415 
416  // Root process needs to know how much data everyone else has for
417  // writing in parallel.
418  m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
419  m_rankConnSizes = Array<OneD, int>(nprocs, 0);
420  m_rankFieldSizes[rank] = m_fields[0].size();
421 
422  m_totConn = 0;
423  for (int i = 0; i < m_conn.size(); ++i)
424  {
425  m_totConn += m_conn[i].size();
426  }
427 
428  m_rankConnSizes[rank] = m_totConn;
429 
430  m_f->m_comm->AllReduce(m_rankFieldSizes, LibUtilities::ReduceSum);
431  m_f->m_comm->AllReduce(m_rankConnSizes, LibUtilities::ReduceSum);
432  }
433 
434  if (m_writeHeader)
435  {
436  WriteTecplotHeader(outfile, variables);
437  }
438 
439  // Write zone data.
440  WriteTecplotZone(outfile);
441 
442  // If we're a FE block format, write connectivity (m_conn will be empty for
443  // point data).
444  WriteTecplotConnectivity(outfile);
445 
446  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
447  {
448  cout << "Written file: " << GetFullOutName(filename,vm) << endl;
449  }
450 }
virtual fs::path GetFullOutName(std::string &filename, po::variables_map &vm)
virtual void WriteTecplotZone(std::ofstream &outfile)
virtual void WriteTecplotConnectivity(std::ofstream &outfile)
Write Tecplot connectivity information (ASCII)
virtual void WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
Write Tecplot files header.
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
Definition: FileSystem.cpp:41

References GetFullOutName(), m_binary, Nektar::FieldUtils::Module::m_config, m_conn, m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_oneOutputFile, m_rankConnSizes, m_rankFieldSizes, m_totConn, m_writeHeader, Nektar::LibUtilities::PortablePath(), Nektar::LibUtilities::ReduceSum, WriteTecplotConnectivity(), WriteTecplotHeader(), and WriteTecplotZone().

Referenced by OutputFromExp(), and OutputFromPts().

◆ WriteTecplotHeader()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotHeader ( std::ofstream &  outfile,
std::vector< std::string > &  var 
)
protectedvirtual

Write Tecplot files header.

Parameters
outfileOutput file name
varVariables names

Reimplemented in Nektar::FieldUtils::OutputTecplotBinary.

Definition at line 458 of file OutputTecplot.cpp.

460 {
461  outfile << "Variables = " << var[0];
462 
463  for (int i = 1; i < var.size(); ++i)
464  {
465  outfile << ", " << var[i];
466  }
467 
468  outfile << std::endl << std::endl;
469 }

Referenced by WriteTecplotFile().

◆ WriteTecplotZone()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotZone ( std::ofstream &  outfile)
protectedvirtual

Write Tecplot zone output in ASCII

Parameters
outfileOutput file name.
expansionExpansion that is considered

Reimplemented in Nektar::FieldUtils::OutputTecplotBinary.

Definition at line 514 of file OutputTecplot.cpp.

515 {
516  bool useDoubles = m_config["double"].as<bool>();
517 
518  if (useDoubles)
519  {
520  int precision = std::numeric_limits<double>::max_digits10;
521  outfile << std::setprecision(precision);
522 
523  }
524 
525  // Write either points or finite element block
526  if (m_zoneType != eOrdered)
527  {
528  if ((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
529  {
530  // Number of points in zone
531  int nPoints = m_oneOutputFile ?
532  Vmath::Vsum(m_f->m_comm->GetSize(), m_rankFieldSizes, 1) :
533  m_fields[0].size();
534 
535  outfile << "Zone, N=" << nPoints << ", E="
536  << m_numBlocks << ", F=FEBlock, ET="
537  << TecplotZoneTypeMap[m_zoneType] << std::endl;
538  }
539 
540 
541  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
542  {
543  for (int j = 0; j < m_fields.size(); ++j)
544  {
545  for (int i = 0; i < m_fields[j].size(); ++i)
546  {
547  if ((!(i % 1000)) && i)
548  {
549  outfile << std::endl;
550  }
551  outfile << m_fields[j][i] << " ";
552  }
553 
554  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
555  {
556  if(m_rankFieldSizes[n])
557  {
558  Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
559  m_f->m_comm->Recv(n, tmp);
560 
561  for (int i = 0; i < m_rankFieldSizes[n]; ++i)
562  {
563  if ((!(i % 1000)) && i)
564  {
565  outfile << std::endl;
566  }
567  outfile << tmp[i] << " ";
568  }
569  }
570  }
571  outfile << std::endl;
572  }
573  }
574  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
575  {
576  if(m_fields[0].size())
577  {
578  for (int i = 0; i < m_fields.size(); ++i)
579  {
580  m_f->m_comm->Send(0, m_fields[i]);
581  }
582  }
583  }
584  else
585  {
586  // Write out coordinates and field data: ordered by field
587  // and then its data.
588  for (int j = 0; j < m_fields.size(); ++j)
589  {
590  for (int i = 0; i < m_fields[j].size(); ++i)
591  {
592  if ((!(i % 1000)) && i)
593  {
594  outfile << std::endl;
595  }
596  outfile << m_fields[j][i] << " ";
597  }
598  outfile << std::endl;
599  }
600  }
601  }
602  else
603  {
604  if((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
605  {
606  std::string dirs[] = { "I", "J", "K" };
607  outfile << "Zone";
608  for (int i = 0; i < m_numPoints.size(); ++i)
609  {
610  outfile << ", " << dirs[i] << "=" << m_numPoints[i];
611  }
612  outfile << ", F=POINT" << std::endl;
613  }
614 
615  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
616  {
617  Array<OneD, NekDouble> tmp(m_fields.size());
618  for (int i = 0; i < m_fields[0].size(); ++i)
619  {
620  for (int j = 0; j < m_fields.size(); ++j)
621  {
622  outfile << setw(12) << m_fields[j][i] << " ";
623  }
624  outfile << std::endl;
625  }
626 
627  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
628  {
629  for (int i = 0; i < m_rankFieldSizes[n]; ++i)
630  {
631  m_f->m_comm->Recv(n, tmp);
632  for (int j = 0; j < m_fields.size(); ++j)
633  {
634  outfile << setw(12) << tmp[j] << " ";
635  }
636  outfile << std::endl;
637  }
638  }
639  }
640  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
641  {
642  Array<OneD, NekDouble> tmp(m_fields.size());
643  for (int i = 0; i < m_fields[0].size(); ++i)
644  {
645  for (int j = 0; j < m_fields.size(); ++j)
646  {
647  tmp[j] = m_fields[j][i];
648  }
649  m_f->m_comm->Send(0, tmp);
650  }
651  }
652  else
653  {
654  // Write out coordinates and field data: ordered by each
655  // point then each field.
656  for (int i = 0; i < m_fields[0].size(); ++i)
657  {
658  for (int j = 0; j < m_fields.size(); ++j)
659  {
660  outfile << setw(12) << m_fields[j][i] << " ";
661  }
662  outfile << std::endl;
663  }
664  }
665  }
666 }
std::string TecplotZoneTypeMap[]
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:846

References Nektar::FieldUtils::eOrdered, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_numPoints, m_oneOutputFile, m_rankFieldSizes, m_zoneType, Nektar::FieldUtils::TecplotZoneTypeMap, and Vmath::Vsum().

Referenced by WriteTecplotFile().

Member Data Documentation

◆ m_binary

bool Nektar::FieldUtils::OutputTecplot::m_binary
protected

True if writing binary field output.

Definition at line 98 of file OutputTecplot.h.

Referenced by OutputFromPts(), Nektar::FieldUtils::OutputTecplotBinary::OutputTecplotBinary(), and WriteTecplotFile().

◆ m_className

ModuleKey Nektar::FieldUtils::OutputTecplot::m_className
static
Initial value:
=
"Writes a Tecplot file.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: OutputTecplot.h:64
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 69 of file OutputTecplot.h.

◆ m_conn

std::vector<Array<OneD, int> > Nektar::FieldUtils::OutputTecplot::m_conn
protected

◆ m_coordim

int Nektar::FieldUtils::OutputTecplot::m_coordim
protected

Coordinate dimension of output.

Definition at line 110 of file OutputTecplot.h.

Referenced by OutputFromExp(), OutputFromPts(), and WriteTecplotFile().

◆ m_fields

Array<OneD, Array<OneD, NekDouble> > Nektar::FieldUtils::OutputTecplot::m_fields
protected

◆ m_numBlocks

int Nektar::FieldUtils::OutputTecplot::m_numBlocks
protected

◆ m_numPoints

std::vector<int> Nektar::FieldUtils::OutputTecplot::m_numPoints
protected

Number of points per block in Tecplot file.

Definition at line 106 of file OutputTecplot.h.

Referenced by OutputFromPts(), WriteTecplotZone(), and Nektar::FieldUtils::OutputTecplotBinary::WriteTecplotZone().

◆ m_oneOutputFile

bool Nektar::FieldUtils::OutputTecplot::m_oneOutputFile
protected

◆ m_rankConnSizes

Array<OneD, int> Nektar::FieldUtils::OutputTecplot::m_rankConnSizes
protected

Each rank's connectivity sizes.

Definition at line 118 of file OutputTecplot.h.

Referenced by WriteTecplotConnectivity(), Nektar::FieldUtils::OutputTecplotBinary::WriteTecplotConnectivity(), and WriteTecplotFile().

◆ m_rankFieldSizes

Array<OneD, int> Nektar::FieldUtils::OutputTecplot::m_rankFieldSizes
protected

◆ m_totConn

int Nektar::FieldUtils::OutputTecplot::m_totConn
protected

Total number of connectivity entries.

Definition at line 112 of file OutputTecplot.h.

Referenced by WriteTecplotConnectivity(), Nektar::FieldUtils::OutputTecplotBinary::WriteTecplotConnectivity(), and WriteTecplotFile().

◆ m_writeHeader

bool Nektar::FieldUtils::OutputTecplot::m_writeHeader
protected

True if writing header.

Definition at line 102 of file OutputTecplot.h.

Referenced by OutputFromExp(), OutputFromPts(), and WriteTecplotFile().

◆ m_zoneType

TecplotZoneType Nektar::FieldUtils::OutputTecplot::m_zoneType
protected