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)
 
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 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...
 
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...
 
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
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. 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.

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

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.
bool m_oneOutputFile
True if writing a single output file.
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:98

◆ ~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 981 of file OutputTecplot.cpp.

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

Referenced by OutputFromExp().

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

◆ 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.

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

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

◆ GetFullOutName()

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

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 378 of file OutputTecplot.cpp.

References GetPath().

Referenced by GetModuleName(), and WriteTecplotFile().

380 {
381  return GetPath(filename, vm);
382 }
virtual fs::path GetPath(std::string &filename, po::variables_map &vm)

◆ GetModuleName()

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

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 76 of file OutputTecplot.h.

References GetFullOutName(), GetPath(), OutputFromData(), OutputFromExp(), and OutputFromPts().

77  {
78  return "OutputTecplot";
79  }

◆ GetNumTecplotBlocks()

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

Calculate number of Tecplot blocks.

Parameters
outfileOutput file

Definition at line 944 of file OutputTecplot.cpp.

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

Referenced by OutputFromExp().

945 {
946  int returnval = 0;
947 
948  if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
949  {
950  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
951  {
952  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
953  }
954  }
955  else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
956  {
957  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
958  {
959  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
960  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
961  }
962  }
963  else
964  {
965  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
966  {
967  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
968  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
969  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
970  }
971  }
972 
973  return returnval;
974 }
FieldSharedPtr m_f
Field object.

◆ GetPath()

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

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 357 of file OutputTecplot.cpp.

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

Referenced by GetFullOutName(), and GetModuleName().

359 {
360  boost::ignore_unused(vm);
361 
362  int nprocs = m_f->m_comm->GetSize();
363  string returnstr(filename);
364 
365  // Amend for parallel output if required
366  if (nprocs != 1 && !m_oneOutputFile)
367  {
368  int rank = m_f->m_comm->GetRank();
369  int dot = filename.find_last_of('.');
370  string ext = filename.substr(dot, filename.length() - dot);
371  string procId = "_P" + boost::lexical_cast<std::string>(rank);
372  string start = filename.substr(0, dot);
373  returnstr = start + procId + ext;
374  }
375  return fs::path(returnstr);
376 }
bool m_oneOutputFile
True if writing a single output file.
FieldSharedPtr m_f
Field object.

◆ OutputFromData()

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

Write from data to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 349 of file OutputTecplot.cpp.

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

Referenced by GetModuleName().

350 {
351  boost::ignore_unused(vm);
352 
354  "OutputTecplot can't write using only FieldData.");
355 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:209

◆ 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 237 of file OutputTecplot.cpp.

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().

Referenced by GetModuleName().

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

◆ OutputFromPts()

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

Write from pts to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 155 of file OutputTecplot.cpp.

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().

Referenced by GetModuleName().

156 {
157  LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
158 
159  // do not output if zone is empty
160  if (fPts->GetNpoints() == 0)
161  {
162  return;
163  }
164 
165  int rank = m_f->m_comm->GetRank();
166  m_numBlocks = 0;
167 
168  m_coordim = fPts->GetDim();
169 
170  // Grab connectivity information.
171  fPts->GetConnectivity(m_conn);
172 
173  switch (fPts->GetPtsType())
174  {
176  m_numPoints.resize(1);
177  m_numPoints[0] = fPts->GetNpoints();
178  m_f->m_comm->AllReduce(m_numPoints[0], LibUtilities::ReduceSum);
180  break;
182  m_numPoints.resize(1);
183  m_numPoints[0] = fPts->GetPointsPerEdge(0);
185  break;
187  m_numPoints.resize(2);
188  m_numPoints[0] = fPts->GetPointsPerEdge(0);
189  m_numPoints[1] = fPts->GetPointsPerEdge(1);
191  break;
193  m_numPoints.resize(3);
194  m_numPoints[0] = fPts->GetPointsPerEdge(0);
195  m_numPoints[1] = fPts->GetPointsPerEdge(1);
196  m_numPoints[2] = fPts->GetPointsPerEdge(2);
198  break;
200  {
202  for (int i = 0; i < m_conn.size(); ++i)
203  {
204  m_numBlocks += m_conn[i].num_elements() / 3;
205  }
206  break;
207  }
209  {
211  for (int i = 0; i < m_conn.size(); ++i)
212  {
213  m_numBlocks += m_conn[i].num_elements() / 4;
214  }
215  break;
216  }
217  default:
218  ASSERTL0(false, "This points type is not supported yet.");
219  }
220 
221  // Get fields and coordinates
222  m_fields =
223  Array<OneD, Array<OneD, NekDouble> >(m_f->m_variables.size()+m_coordim);
224 
225  // We can just grab everything from points. This should be a
226  // reference, not a copy.
227  fPts->GetPts(m_fields);
228 
229  // Only write header if we're root or FE block; binary files always
230  // write header
231  m_writeHeader =
232  (m_zoneType != eOrdered || rank == 0) || m_binary;
233 
234  WriteTecplotFile(vm);
235 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
TecplotZoneType m_zoneType
Tecplot zone type of output.
bool m_writeHeader
True if writing header.
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:179
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
int m_numBlocks
Number of blocks in Tecplot file.
void WriteTecplotFile(po::variables_map &vm)
int m_coordim
Coordinate dimension of output.
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:98
vector< int > m_numPoints
Number of points per block in Tecplot file.
FieldSharedPtr m_f
Field object.

◆ 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.

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

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 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
bool m_oneOutputFile
True if writing a single output file.
virtual void Process(po::variables_map &vm)
Write fld to output file.
FieldSharedPtr m_f
Field object.

◆ 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 829 of file OutputTecplot.cpp.

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(), and Nektar::FieldUtils::OutputTecplotBinary::~OutputTecplotBinary().

830 {
831  // Ordered data have no connectivity information.
832  if (m_zoneType == eOrdered)
833  {
834  return;
835  }
836 
837  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
838  {
839  // Need to amalgamate connectivity information
840  if (m_totConn)
841  {
842  Array<OneD, int> conn(m_totConn);
843  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
844  {
845  if(m_conn[i].num_elements())
846  {
847  Vmath::Vcopy(m_conn[i].num_elements(), &m_conn[i][0], 1,
848  &conn[cnt], 1);
849  cnt += m_conn[i].num_elements();
850  }
851  }
852  m_f->m_comm->Send(0, conn);
853  }
854  }
855  else
856  {
857  int cnt = 1;
858  for (int i = 0; i < m_conn.size(); ++i)
859  {
860  const int nConn = m_conn[i].num_elements();
861  for (int j = 0; j < nConn; ++j,++cnt)
862  {
863  outfile << m_conn[i][j] + 1 << " ";
864  if (!(cnt % 1000))
865  {
866  outfile << std::endl;
867  }
868  }
869  }
870  outfile << endl;
871 
872  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
873  {
874  int offset = m_rankFieldSizes[0];
875 
876  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
877  {
878  if(m_rankConnSizes[n])
879  {
880  Array<OneD, int> conn(m_rankConnSizes[n]);
881  m_f->m_comm->Recv(n, conn);
882  for (int j = 0; j < conn.num_elements(); ++j)
883  {
884  outfile << conn[j] + offset + 1 << " ";
885  if ((!(j % 1000)) && j)
886  {
887  outfile << std::endl;
888  }
889  }
890  }
891  offset += m_rankFieldSizes[n];
892  }
893  }
894  }
895 }
TecplotZoneType m_zoneType
Tecplot zone type of output.
Array< OneD, int > m_rankConnSizes
Each rank&#39;s connectivity sizes.
bool m_oneOutputFile
True if writing a single output file.
Array< OneD, int > m_rankFieldSizes
Each rank&#39;s field sizes.
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
int m_totConn
Total number of connectivity entries.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
FieldSharedPtr m_f
Field object.

◆ WriteTecplotFile()

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

Definition at line 384 of file OutputTecplot.cpp.

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().

385 {
386  // Variable names
387  std::string coordVars[] = { "x", "y", "z" };
388  vector<string> variables = m_f->m_variables;
389  variables.insert(variables.begin(), coordVars, coordVars + m_coordim);
390 
391  int nprocs = m_f->m_comm->GetSize();
392  int rank = m_f->m_comm->GetRank();
393 
394 
395  // Extract the output filename and extension
396  string filename = m_config["outfile"].as<string>();
397  string outFile = LibUtilities::PortablePath(GetFullOutName(filename, vm));
398  // Open output file
399  ofstream outfile;
400  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
401  {
402  outfile.open(outFile.c_str(), m_binary ? ios::binary : ios::out);
403  }
404 
405  if (m_oneOutputFile)
406  {
407  // Reduce on number of blocks and number of points.
408  m_f->m_comm->AllReduce(m_numBlocks, LibUtilities::ReduceSum);
409 
410  // Root process needs to know how much data everyone else has for
411  // writing in parallel.
412  m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
413  m_rankConnSizes = Array<OneD, int>(nprocs, 0);
414  m_rankFieldSizes[rank] = m_fields[0].num_elements();
415 
416  m_totConn = 0;
417  for (int i = 0; i < m_conn.size(); ++i)
418  {
419  m_totConn += m_conn[i].num_elements();
420  }
421 
422  m_rankConnSizes[rank] = m_totConn;
423 
424  m_f->m_comm->AllReduce(m_rankFieldSizes, LibUtilities::ReduceSum);
425  m_f->m_comm->AllReduce(m_rankConnSizes, LibUtilities::ReduceSum);
426  }
427 
428  if (m_writeHeader)
429  {
430  WriteTecplotHeader(outfile, variables);
431  }
432 
433  // Write zone data.
434  WriteTecplotZone(outfile);
435 
436  // If we're a FE block format, write connectivity (m_conn will be empty for
437  // point data).
438  WriteTecplotConnectivity(outfile);
439 
440  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
441  {
442  cout << "Written file: " << GetFullOutName(filename,vm) << endl;
443  }
444 }
virtual fs::path GetFullOutName(std::string &filename, po::variables_map &vm)
std::map< std::string, ConfigOption > m_config
List of configuration values.
Array< OneD, int > m_rankConnSizes
Each rank&#39;s connectivity sizes.
bool m_oneOutputFile
True if writing a single output file.
bool m_writeHeader
True if writing header.
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.
Array< OneD, int > m_rankFieldSizes
Each rank&#39;s field sizes.
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
Definition: FileSystem.cpp:41
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
int m_numBlocks
Number of blocks in Tecplot file.
int m_totConn
Total number of connectivity entries.
int m_coordim
Coordinate dimension of output.
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:98
virtual void WriteTecplotZone(std::ofstream &outfile)
FieldSharedPtr m_f
Field object.

◆ 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 452 of file OutputTecplot.cpp.

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

454 {
455  outfile << "Variables = " << var[0];
456 
457  for (int i = 1; i < var.size(); ++i)
458  {
459  outfile << ", " << var[i];
460  }
461 
462  outfile << std::endl << std::endl;
463 }

◆ 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 508 of file OutputTecplot.cpp.

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, and Vmath::Vsum().

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

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

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:

Definition at line 69 of file OutputTecplot.h.

◆ m_conn

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

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