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 61 of file OutputTecplot.h.

Constructor & Destructor Documentation

◆ OutputTecplot()

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

Definition at line 65 of file OutputTecplot.cpp.

66  : OutputFileBase(f), m_binary(false), m_oneOutputFile(false)
67 {
68  m_requireEquiSpaced = true;
69  m_config["double"] = ConfigOption(true, "0",
70  "Write double-precision format data:"
71  "more accurate but more disk space"
72  " required");
73 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:228
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:97
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:99

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

◆ ~OutputTecplot()

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

Definition at line 75 of file OutputTecplot.cpp.

76 {
77 }

Member Function Documentation

◆ CalculateConnectivity()

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

Calculate connectivity information for each expansion dimension.

Parameters
outfileOutput file

Definition at line 973 of file OutputTecplot.cpp.

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

66  {
68  }
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 373 of file OutputTecplot.cpp.

375 {
376  return GetPath(filename, vm);
377 }
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 936 of file OutputTecplot.cpp.

937 {
938  int returnval = 0;
939 
940  if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
941  {
942  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
943  {
944  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
945  }
946  }
947  else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
948  {
949  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
950  {
951  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
952  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
953  }
954  }
955  else
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  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
962  }
963  }
964 
965  return returnval;
966 }

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

354 {
355  boost::ignore_unused(vm);
356 
357  int nprocs = m_f->m_comm->GetSize();
358  string returnstr(filename);
359 
360  // Amend for parallel output if required
361  if (nprocs != 1 && !m_oneOutputFile)
362  {
363  int rank = m_f->m_comm->GetRank();
364  int dot = filename.find_last_of('.');
365  string ext = filename.substr(dot, filename.length() - dot);
366  string procId = "_P" + boost::lexical_cast<std::string>(rank);
367  string start = filename.substr(0, dot);
368  returnstr = start + procId + ext;
369  }
370  return fs::path(returnstr);
371 }

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

346 {
347  boost::ignore_unused(vm);
348 
350  "OutputTecplot can't write using only FieldData.");
351 }
#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 232 of file OutputTecplot.cpp.

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

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

152 {
153  LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
154 
155  // do not output if zone is empty
156  if (fPts->GetNpoints() == 0)
157  {
158  return;
159  }
160 
161  int rank = m_f->m_comm->GetRank();
162  m_numBlocks = 0;
163 
164  m_coordim = fPts->GetDim();
165 
166  // Grab connectivity information.
167  fPts->GetConnectivity(m_conn);
168 
169  switch (fPts->GetPtsType())
170  {
172  m_numPoints.resize(1);
173  m_numPoints[0] = fPts->GetNpoints();
174  m_f->m_comm->AllReduce(m_numPoints[0], LibUtilities::ReduceSum);
176  break;
178  m_numPoints.resize(1);
179  m_numPoints[0] = fPts->GetPointsPerEdge(0);
181  break;
183  m_numPoints.resize(2);
184  m_numPoints[0] = fPts->GetPointsPerEdge(0);
185  m_numPoints[1] = fPts->GetPointsPerEdge(1);
187  break;
189  m_numPoints.resize(3);
190  m_numPoints[0] = fPts->GetPointsPerEdge(0);
191  m_numPoints[1] = fPts->GetPointsPerEdge(1);
192  m_numPoints[2] = fPts->GetPointsPerEdge(2);
194  break;
196  {
198  for (int i = 0; i < m_conn.size(); ++i)
199  {
200  m_numBlocks += m_conn[i].size() / 3;
201  }
202  break;
203  }
205  {
207  for (int i = 0; i < m_conn.size(); ++i)
208  {
209  m_numBlocks += m_conn[i].size() / 4;
210  }
211  break;
212  }
213  default:
214  ASSERTL0(false, "This points type is not supported yet.");
215  }
216 
217  // Get fields and coordinates
218  m_fields = Array<OneD, Array<OneD, NekDouble>>(m_f->m_variables.size() +
219  m_coordim);
220 
221  // We can just grab everything from points. This should be a
222  // reference, not a copy.
223  fPts->GetPts(m_fields);
224 
225  // Only write header if we're root or FE block; binary files always
226  // write header
227  m_writeHeader = (m_zoneType != eOrdered || rank == 0) || m_binary;
228 
229  WriteTecplotFile(vm);
230 }
std::vector< int > m_numPoints
Number of points per block in Tecplot file.
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:190

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

80 {
81 
82  if (m_config["writemultiplefiles"].as<bool>())
83  {
84  m_oneOutputFile = false;
85  }
86  else
87  {
88  m_oneOutputFile = (m_f->m_comm->GetSize() > 1);
89  }
90 
92 }
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 822 of file OutputTecplot.cpp.

823 {
824  // Ordered data have no connectivity information.
825  if (m_zoneType == eOrdered)
826  {
827  return;
828  }
829 
830  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
831  {
832  // Need to amalgamate connectivity information
833  if (m_totConn)
834  {
835  Array<OneD, int> conn(m_totConn);
836  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
837  {
838  if (m_conn[i].size())
839  {
840  Vmath::Vcopy(m_conn[i].size(), &m_conn[i][0], 1, &conn[cnt],
841  1);
842  cnt += m_conn[i].size();
843  }
844  }
845  m_f->m_comm->Send(0, conn);
846  }
847  }
848  else
849  {
850  int cnt = 1;
851  for (int i = 0; i < m_conn.size(); ++i)
852  {
853  const int nConn = m_conn[i].size();
854  for (int j = 0; j < nConn; ++j, ++cnt)
855  {
856  outfile << m_conn[i][j] + 1 << " ";
857  if (!(cnt % 1000))
858  {
859  outfile << std::endl;
860  }
861  }
862  }
863  outfile << endl;
864 
865  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
866  {
867  int offset = m_rankFieldSizes[0];
868 
869  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
870  {
871  if (m_rankConnSizes[n])
872  {
873  Array<OneD, int> conn(m_rankConnSizes[n]);
874  m_f->m_comm->Recv(n, conn);
875  for (int j = 0; j < conn.size(); ++j)
876  {
877  outfile << conn[j] + offset + 1 << " ";
878  if ((!(j % 1000)) && j)
879  {
880  outfile << std::endl;
881  }
882  }
883  }
884  offset += m_rankFieldSizes[n];
885  }
886  }
887  }
888 }
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 379 of file OutputTecplot.cpp.

380 {
381  // Variable names
382  std::string coordVars[] = {"x", "y", "z"};
383  std::vector<string> variables = m_f->m_variables;
384  variables.insert(variables.begin(), coordVars, coordVars + m_coordim);
385 
386  int nprocs = m_f->m_comm->GetSize();
387  int rank = m_f->m_comm->GetRank();
388 
389  // Extract the output filename and extension
390  string filename = m_config["outfile"].as<string>();
391  string outFile = LibUtilities::PortablePath(GetFullOutName(filename, vm));
392  // Open output file
393  ofstream outfile;
394  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
395  {
396  outfile.open(outFile.c_str(), m_binary ? ios::binary : ios::out);
397  }
398 
399  if (m_oneOutputFile)
400  {
401  // Reduce on number of blocks and number of points.
402  m_f->m_comm->AllReduce(m_numBlocks, LibUtilities::ReduceSum);
403 
404  // Root process needs to know how much data everyone else has for
405  // writing in parallel.
406  m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
407  m_rankConnSizes = Array<OneD, int>(nprocs, 0);
408  m_rankFieldSizes[rank] = m_fields[0].size();
409 
410  m_totConn = 0;
411  for (int i = 0; i < m_conn.size(); ++i)
412  {
413  m_totConn += m_conn[i].size();
414  }
415 
416  m_rankConnSizes[rank] = m_totConn;
417 
418  m_f->m_comm->AllReduce(m_rankFieldSizes, LibUtilities::ReduceSum);
419  m_f->m_comm->AllReduce(m_rankConnSizes, LibUtilities::ReduceSum);
420  }
421 
422  if (m_writeHeader)
423  {
424  WriteTecplotHeader(outfile, variables);
425  }
426 
427  // Write zone data.
428  WriteTecplotZone(outfile);
429 
430  // If we're a FE block format, write connectivity (m_conn will be empty for
431  // point data).
432  WriteTecplotConnectivity(outfile);
433 
434  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
435  {
436  cout << "Written file: " << GetFullOutName(filename, vm) << endl;
437  }
438 }
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 446 of file OutputTecplot.cpp.

448 {
449  outfile << "Variables = " << var[0];
450 
451  for (int i = 1; i < var.size(); ++i)
452  {
453  outfile << ", " << var[i];
454  }
455 
456  outfile << std::endl << std::endl;
457 }

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

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

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 97 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:65
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:285
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 70 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 109 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 105 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 117 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 111 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 101 of file OutputTecplot.h.

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

◆ m_zoneType

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