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

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

Referenced by OutputFromExp().

938 {
939  int i, j, k, l;
940  int nbase = m_f->m_exp[0]->GetExp(0)->GetNumBases();
941  int cnt = 0;
942 
943  m_conn.resize(m_f->m_exp[0]->GetNumElmts());
944 
945  for (i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
946  {
947  cnt = m_f->m_exp[0]->GetPhys_Offset(i);
948 
949  if (nbase == 1)
950  {
951  int cnt2 = 0;
952  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
953  int nPlanes = 1;
954 
955  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e2DH1D)
956  {
957  nPlanes = m_f->m_exp[0]->GetZIDs().num_elements();
958 
959  if (nPlanes > 1)
960  {
961  int totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
962 
963  Array<OneD, int> conn(4 * (np0 - 1) * (nPlanes - 1));
964  for (int n = 1; n < nPlanes; ++n)
965  {
966  for (k = 1; k < np0; ++k)
967  {
968  conn[cnt2++] = cnt + (n - 1) * totPoints + k;
969  conn[cnt2++] = cnt + (n - 1) * totPoints + k - 1;
970  conn[cnt2++] = cnt + n * totPoints + k - 1;
971  conn[cnt2++] = cnt + n * totPoints + k;
972  }
973  }
974  m_conn[i] = conn;
975  }
976  }
977 
978  if (nPlanes == 1)
979  {
980  Array<OneD, int> conn(2 * (np0 - 1));
981 
982  for (k = 1; k < np0; ++k)
983  {
984  conn[cnt2++] = cnt + k;
985  conn[cnt2++] = cnt + k - 1;
986  }
987 
988  m_conn[i] = conn;
989  }
990  }
991  else if (nbase == 2)
992  {
993  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
994  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
995  int totPoints = m_f->m_exp[0]->GetTotPoints();
996  int nPlanes = 1;
997  int cnt2 = 0;
998 
999  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
1000  {
1001  nPlanes = m_f->m_exp[0]->GetZIDs().num_elements();
1002 
1003  // default to 2D case for HalfMode when nPlanes = 1
1004  if (nPlanes > 1)
1005  {
1006  totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1007 
1008  Array<OneD, int> conn(8 * (np1 - 1) * (np0 - 1) * (nPlanes - 1));
1009 
1010  for (int n = 1; n < nPlanes; ++n)
1011  {
1012  for (j = 1; j < np1; ++j)
1013  {
1014  for (k = 1; k < np0; ++k)
1015  {
1016  conn[cnt2++] = cnt + (n - 1) * totPoints +
1017  (j - 1) * np0 + k - 1;
1018  conn[cnt2++] = cnt + (n - 1) * totPoints +
1019  (j - 1) * np0 + k;
1020  conn[cnt2++] = cnt + (n - 1) * totPoints +
1021  j * np0 + k;
1022  conn[cnt2++] = cnt + (n - 1) * totPoints +
1023  j * np0 + k - 1;
1024  conn[cnt2++] = cnt + n * totPoints +
1025  (j - 1) * np0 + k - 1;
1026  conn[cnt2++] = cnt + n * totPoints +
1027  (j - 1) * np0 + k;
1028  conn[cnt2++] = cnt + n * totPoints +
1029  j * np0 + k;
1030  conn[cnt2++] = cnt + n * totPoints +
1031  j * np0 + k - 1;
1032  }
1033  }
1034  }
1035  m_conn[i] = conn;
1036  }
1037  }
1038 
1039  if (nPlanes == 1)
1040  {
1041  Array<OneD, int> conn(4 * (np0 - 1) * (np1 - 1));
1042  for (j = 1; j < np1; ++j)
1043  {
1044  for (k = 1; k < np0; ++k)
1045  {
1046  conn[cnt2++] = cnt + (j - 1) * np0 + k - 1;
1047  conn[cnt2++] = cnt + (j - 1) * np0 + k;
1048  conn[cnt2++] = cnt + j * np0 + k;
1049  conn[cnt2++] = cnt + j * np0 + k - 1;
1050  }
1051  }
1052  m_conn[i] = conn;
1053  }
1054  }
1055  else if (nbase == 3)
1056  {
1057  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1058  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1059  int np2 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
1060  int cnt2 = 0;
1061 
1062  Array<OneD, int> conn(8 * (np0 - 1) * (np1 - 1) * (np2 - 1));
1063 
1064  for (j = 1; j < np2; ++j)
1065  {
1066  for (k = 1; k < np1; ++k)
1067  {
1068  for (l = 1; l < np0; ++l)
1069  {
1070  conn[cnt2++] =
1071  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l - 1;
1072  conn[cnt2++] =
1073  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l;
1074  conn[cnt2++] =
1075  cnt + (j - 1) * np0 * np1 + k * np0 + l;
1076  conn[cnt2++] =
1077  cnt + (j - 1) * np0 * np1 + k * np0 + l - 1;
1078  conn[cnt2++] =
1079  cnt + j * np0 * np1 + (k - 1) * np0 + l - 1;
1080  conn[cnt2++] =
1081  cnt + j * np0 * np1 + (k - 1) * np0 + l;
1082  conn[cnt2++] =
1083  cnt + j * np0 * np1 + k * np0 + l;
1084  conn[cnt2++] =
1085  cnt + j * np0 * np1 + k * np0 + l - 1;
1086  }
1087  }
1088  }
1089 
1090  m_conn[i] = conn;
1091  }
1092  else
1093  {
1094  ASSERTL0(false, "Not set up for this dimension");
1095  }
1096 
1097  }
1098 }
#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 334 of file OutputTecplot.cpp.

References GetPath().

Referenced by GetModuleName(), and WriteTecplotFile().

336 {
337  return GetPath(filename, vm);
338 }
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 900 of file OutputTecplot.cpp.

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

Referenced by OutputFromExp().

901 {
902  int returnval = 0;
903 
904  if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
905  {
906  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
907  {
908  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
909  }
910  }
911  else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
912  {
913  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
914  {
915  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
916  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
917  }
918  }
919  else
920  {
921  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
922  {
923  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
924  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
925  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
926  }
927  }
928 
929  return returnval;
930 }
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 313 of file OutputTecplot.cpp.

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

Referenced by GetFullOutName(), and GetModuleName().

315 {
316  boost::ignore_unused(vm);
317 
318  int nprocs = m_f->m_comm->GetSize();
319  string returnstr(filename);
320 
321  // Amend for parallel output if required
322  if (nprocs != 1 && !m_oneOutputFile)
323  {
324  int rank = m_f->m_comm->GetRank();
325  int dot = filename.find_last_of('.');
326  string ext = filename.substr(dot, filename.length() - dot);
327  string procId = "_P" + boost::lexical_cast<std::string>(rank);
328  string start = filename.substr(0, dot);
329  returnstr = start + procId + ext;
330  }
331  return fs::path(returnstr);
332 }
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 305 of file OutputTecplot.cpp.

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

Referenced by GetModuleName().

306 {
307  boost::ignore_unused(vm);
308 
310  "OutputTecplot can't write using only FieldData.");
311 }
#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(), GetNumTecplotBlocks(), m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_writeHeader, m_zoneType, 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 
250  if (m_f->m_numHomogeneousDir > 0)
251  {
252  int nPlanes = m_f->m_exp[0]->GetZIDs().num_elements();
253  if (nPlanes == 1) // halfMode case
254  {
255  // do nothing
256  }
257  else
258  {
259  nBases += m_f->m_numHomogeneousDir;
260  m_coordim += m_f->m_numHomogeneousDir;
261  NekDouble tmp = m_numBlocks * (nPlanes - 1);
262  m_numBlocks = (int)tmp;
263  }
264  }
265 
266  m_zoneType = (TecplotZoneType)(2*(nBases-1) + 1);
267 
268  // Calculate connectivity
270 
271  // Set up storage for output fields
272  m_fields =
273  Array<OneD, Array<OneD, NekDouble> >(m_f->m_variables.size()+m_coordim);
274 
275  // Get coordinates
276  int totpoints = m_f->m_exp[0]->GetTotPoints();
277 
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  // Add references to m_fields
297  for (int i = 0; i < m_f->m_variables.size(); ++i)
298  {
299  m_fields[i + m_coordim] = m_f->m_exp[i]->UpdatePhys();
300  }
301 
302  WriteTecplotFile(vm);
303 }
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 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.
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 785 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().

786 {
787  // Ordered data have no connectivity information.
788  if (m_zoneType == eOrdered)
789  {
790  return;
791  }
792 
793  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
794  {
795  // Need to amalgamate connectivity information
796  if (m_totConn)
797  {
798  Array<OneD, int> conn(m_totConn);
799  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
800  {
801  if(m_conn[i].num_elements())
802  {
803  Vmath::Vcopy(m_conn[i].num_elements(), &m_conn[i][0], 1,
804  &conn[cnt], 1);
805  cnt += m_conn[i].num_elements();
806  }
807  }
808  m_f->m_comm->Send(0, conn);
809  }
810  }
811  else
812  {
813  int cnt = 1;
814  for (int i = 0; i < m_conn.size(); ++i)
815  {
816  const int nConn = m_conn[i].num_elements();
817  for (int j = 0; j < nConn; ++j,++cnt)
818  {
819  outfile << m_conn[i][j] + 1 << " ";
820  if (!(cnt % 1000))
821  {
822  outfile << std::endl;
823  }
824  }
825  }
826  outfile << endl;
827 
828  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
829  {
830  int offset = m_rankFieldSizes[0];
831 
832  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
833  {
834  if(m_rankConnSizes[n])
835  {
836  Array<OneD, int> conn(m_rankConnSizes[n]);
837  m_f->m_comm->Recv(n, conn);
838  for (int j = 0; j < conn.num_elements(); ++j)
839  {
840  outfile << conn[j] + offset + 1 << " ";
841  if ((!(j % 1000)) && j)
842  {
843  outfile << std::endl;
844  }
845  }
846  }
847  offset += m_rankFieldSizes[n];
848  }
849  }
850  }
851 }
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 340 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().

341 {
342  // Variable names
343  std::string coordVars[] = { "x", "y", "z" };
344  vector<string> variables = m_f->m_variables;
345  variables.insert(variables.begin(), coordVars, coordVars + m_coordim);
346 
347  int nprocs = m_f->m_comm->GetSize();
348  int rank = m_f->m_comm->GetRank();
349 
350 
351  // Extract the output filename and extension
352  string filename = m_config["outfile"].as<string>();
353  string outFile = LibUtilities::PortablePath(GetFullOutName(filename, vm));
354  // Open output file
355  ofstream outfile;
356  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
357  {
358  outfile.open(outFile.c_str(), m_binary ? ios::binary : ios::out);
359  }
360 
361  if (m_oneOutputFile)
362  {
363  // Reduce on number of blocks and number of points.
364  m_f->m_comm->AllReduce(m_numBlocks, LibUtilities::ReduceSum);
365 
366  // Root process needs to know how much data everyone else has for
367  // writing in parallel.
368  m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
369  m_rankConnSizes = Array<OneD, int>(nprocs, 0);
370  m_rankFieldSizes[rank] = m_fields[0].num_elements();
371 
372  m_totConn = 0;
373  for (int i = 0; i < m_conn.size(); ++i)
374  {
375  m_totConn += m_conn[i].num_elements();
376  }
377 
378  m_rankConnSizes[rank] = m_totConn;
379 
380  m_f->m_comm->AllReduce(m_rankFieldSizes, LibUtilities::ReduceSum);
381  m_f->m_comm->AllReduce(m_rankConnSizes, LibUtilities::ReduceSum);
382  }
383 
384  if (m_writeHeader)
385  {
386  WriteTecplotHeader(outfile, variables);
387  }
388 
389  // Write zone data.
390  WriteTecplotZone(outfile);
391 
392  // If we're a FE block format, write connectivity (m_conn will be empty for
393  // point data).
394  WriteTecplotConnectivity(outfile);
395 
396  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
397  {
398  cout << "Written file: " << GetFullOutName(filename,vm) << endl;
399  }
400 }
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 408 of file OutputTecplot.cpp.

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

410 {
411  outfile << "Variables = " << var[0];
412 
413  for (int i = 1; i < var.size(); ++i)
414  {
415  outfile << ", " << var[i];
416  }
417 
418  outfile << std::endl << std::endl;
419 }

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

465 {
466  bool useDoubles = m_config["double"].as<bool>();
467 
468  if (useDoubles)
469  {
470  int precision = std::numeric_limits<double>::max_digits10;
471  outfile << std::setprecision(precision);
472 
473  }
474 
475  // Write either points or finite element block
476  if (m_zoneType != eOrdered)
477  {
478  if ((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
479  {
480  // Number of points in zone
481  int nPoints = m_oneOutputFile ?
482  Vmath::Vsum(m_f->m_comm->GetSize(), m_rankFieldSizes, 1) :
483  m_fields[0].num_elements();
484 
485  outfile << "Zone, N=" << nPoints << ", E="
486  << m_numBlocks << ", F=FEBlock, ET="
487  << TecplotZoneTypeMap[m_zoneType] << std::endl;
488  }
489 
490 
491  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
492  {
493  for (int j = 0; j < m_fields.num_elements(); ++j)
494  {
495  for (int i = 0; i < m_fields[j].num_elements(); ++i)
496  {
497  if ((!(i % 1000)) && i)
498  {
499  outfile << std::endl;
500  }
501  outfile << m_fields[j][i] << " ";
502  }
503 
504  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
505  {
506  if(m_rankFieldSizes[n])
507  {
508  Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
509  m_f->m_comm->Recv(n, tmp);
510 
511  for (int i = 0; i < m_rankFieldSizes[n]; ++i)
512  {
513  if ((!(i % 1000)) && i)
514  {
515  outfile << std::endl;
516  }
517  outfile << tmp[i] << " ";
518  }
519  }
520  }
521  outfile << std::endl;
522  }
523  }
524  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
525  {
526  if(m_fields[0].num_elements())
527  {
528  for (int i = 0; i < m_fields.num_elements(); ++i)
529  {
530  m_f->m_comm->Send(0, m_fields[i]);
531  }
532  }
533  }
534  else
535  {
536  // Write out coordinates and field data: ordered by field
537  // and then its data.
538  for (int j = 0; j < m_fields.num_elements(); ++j)
539  {
540  for (int i = 0; i < m_fields[j].num_elements(); ++i)
541  {
542  if ((!(i % 1000)) && i)
543  {
544  outfile << std::endl;
545  }
546  outfile << m_fields[j][i] << " ";
547  }
548  outfile << std::endl;
549  }
550  }
551  }
552  else
553  {
554  if((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
555  {
556  std::string dirs[] = { "I", "J", "K" };
557  outfile << "Zone";
558  for (int i = 0; i < m_numPoints.size(); ++i)
559  {
560  outfile << ", " << dirs[i] << "=" << m_numPoints[i];
561  }
562  outfile << ", F=POINT" << std::endl;
563  }
564 
565  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
566  {
567  Array<OneD, NekDouble> tmp(m_fields.num_elements());
568  for (int i = 0; i < m_fields[0].num_elements(); ++i)
569  {
570  for (int j = 0; j < m_fields.num_elements(); ++j)
571  {
572  outfile << setw(12) << m_fields[j][i] << " ";
573  }
574  outfile << std::endl;
575  }
576 
577  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
578  {
579  for (int i = 0; i < m_rankFieldSizes[n]; ++i)
580  {
581  m_f->m_comm->Recv(n, tmp);
582  for (int j = 0; j < m_fields.num_elements(); ++j)
583  {
584  outfile << setw(12) << tmp[j] << " ";
585  }
586  outfile << std::endl;
587  }
588  }
589  }
590  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
591  {
592  Array<OneD, NekDouble> tmp(m_fields.num_elements());
593  for (int i = 0; i < m_fields[0].num_elements(); ++i)
594  {
595  for (int j = 0; j < m_fields.num_elements(); ++j)
596  {
597  tmp[j] = m_fields[j][i];
598  }
599  m_f->m_comm->Send(0, tmp);
600  }
601  }
602  else
603  {
604  // Write out coordinates and field data: ordered by each
605  // point then each field.
606  for (int i = 0; i < m_fields[0].num_elements(); ++i)
607  {
608  for (int j = 0; j < m_fields.num_elements(); ++j)
609  {
610  outfile << setw(12) << m_fields[j][i] << " ";
611  }
612  outfile << std::endl;
613  }
614  }
615  }
616 }
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