Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::OutputTecplot:
Collaboration graph
[legend]

Public Member Functions

 OutputTecplot (FieldSharedPtr f)
 
virtual ~OutputTecplot ()
 
virtual void Process (po::variables_map &vm)
 Set up member variables to dump Tecplot format output. More...
 
- 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 (string key, 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 bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey m_className
 

Protected Member Functions

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...
 
int GetNumTecplotBlocks ()
 Calculate number of Tecplot blocks. More...
 
void CalculateConnectivity ()
 Calculate connectivity information for each expansion dimension. More...
 
virtual std::string GetModuleName ()
 Returns this module's name. 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...
 
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::OutputModule
ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

Tecplot output class.

Definition at line 61 of file OutputTecplot.h.

Constructor & Destructor Documentation

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

Definition at line 73 of file OutputTecplot.cpp.

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

73  : OutputModule(f),
74  m_binary(false),
75  m_oneOutputFile(false)
76 {
77  if (!f->m_setUpEquiSpacedFields)
78  {
79  m_requireEquiSpaced = true;
80  }
81  m_config["writemultiplefiles"] =
82  ConfigOption(true,"0","Write multiple files in parallel");
83 }
map< string, ConfigOption > m_config
List of configuration values.
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:78
Nektar::FieldUtils::OutputTecplot::~OutputTecplot ( )
virtual

Definition at line 85 of file OutputTecplot.cpp.

86 {
87 }

Member Function Documentation

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

Calculate connectivity information for each expansion dimension.

Parameters
outfileOutput file

Definition at line 919 of file OutputTecplot.cpp.

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

Referenced by Process().

920 {
921  int i, j, k, l;
922  int nbase = m_f->m_exp[0]->GetExp(0)->GetNumBases();
923  int cnt = 0;
924 
925  m_conn.resize(m_f->m_exp[0]->GetNumElmts());
926 
927  for (i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
928  {
929  cnt = m_f->m_exp[0]->GetPhys_Offset(i);
930 
931  if (nbase == 1)
932  {
933  int cnt2 = 0;
934  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
935 
936  Array<OneD, int> conn(2 * (np0 - 1));
937 
938  for (k = 1; k < np0; ++k)
939  {
940  conn[cnt2++] = cnt + k;
941  conn[cnt2++] = cnt + k - 1;
942  }
943 
944  m_conn[i] = conn;
945  }
946  else if (nbase == 2)
947  {
948  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
949  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
950  int totPoints = m_f->m_exp[0]->GetTotPoints();
951  int nPlanes = 1;
952  int cnt2 = 0;
953 
954  if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
955  {
956  nPlanes = m_f->m_exp[0]->GetZIDs().num_elements();
957 
958  // default to 2D case for HalfMode when nPlanes = 1
959  if (nPlanes > 1)
960  {
961  totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
962 
963  Array<OneD, int> conn(8 * (np1 - 1) * (np0 - 1) * (nPlanes - 1));
964 
965  for (int n = 1; n < nPlanes; ++n)
966  {
967  for (j = 1; j < np1; ++j)
968  {
969  for (k = 1; k < np0; ++k)
970  {
971  conn[cnt2++] = cnt + (n - 1) * totPoints +
972  (j - 1) * np0 + k - 1;
973  conn[cnt2++] = cnt + (n - 1) * totPoints +
974  (j - 1) * np0 + k;
975  conn[cnt2++] = cnt + (n - 1) * totPoints +
976  j * np0 + k;
977  conn[cnt2++] = cnt + (n - 1) * totPoints +
978  j * np0 + k - 1;
979  conn[cnt2++] = cnt + n * totPoints +
980  (j - 1) * np0 + k - 1;
981  conn[cnt2++] = cnt + n * totPoints +
982  (j - 1) * np0 + k;
983  conn[cnt2++] = cnt + n * totPoints +
984  j * np0 + k;
985  conn[cnt2++] = cnt + n * totPoints +
986  j * np0 + k - 1;
987  }
988  }
989  }
990  m_conn[i] = conn;
991  }
992  }
993 
994  if (nPlanes == 1)
995  {
996  Array<OneD, int> conn(4 * (np0 - 1) * (np1 - 1));
997  for (j = 1; j < np1; ++j)
998  {
999  for (k = 1; k < np0; ++k)
1000  {
1001  conn[cnt2++] = cnt + (j - 1) * np0 + k - 1;
1002  conn[cnt2++] = cnt + (j - 1) * np0 + k;
1003  conn[cnt2++] = cnt + j * np0 + k;
1004  conn[cnt2++] = cnt + j * np0 + k - 1;
1005  }
1006  }
1007  m_conn[i] = conn;
1008  }
1009  }
1010  else if (nbase == 3)
1011  {
1012  int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1013  int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1014  int np2 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
1015  int cnt2 = 0;
1016 
1017  Array<OneD, int> conn(8 * (np0 - 1) * (np1 - 1) * (np2 - 1));
1018 
1019  for (j = 1; j < np2; ++j)
1020  {
1021  for (k = 1; k < np1; ++k)
1022  {
1023  for (l = 1; l < np0; ++l)
1024  {
1025  conn[cnt2++] =
1026  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l - 1;
1027  conn[cnt2++] =
1028  cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l;
1029  conn[cnt2++] =
1030  cnt + (j - 1) * np0 * np1 + k * np0 + l;
1031  conn[cnt2++] =
1032  cnt + (j - 1) * np0 * np1 + k * np0 + l - 1;
1033  conn[cnt2++] =
1034  cnt + j * np0 * np1 + (k - 1) * np0 + l - 1;
1035  conn[cnt2++] =
1036  cnt + j * np0 * np1 + (k - 1) * np0 + l;
1037  conn[cnt2++] =
1038  cnt + j * np0 * np1 + k * np0 + l;
1039  conn[cnt2++] =
1040  cnt + j * np0 * np1 + k * np0 + l - 1;
1041  }
1042  }
1043  }
1044 
1045  m_conn[i] = conn;
1046  }
1047  else
1048  {
1049  ASSERTL0(false, "Not set up for this dimension");
1050  }
1051 
1052  }
1053 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
Definition: OutputTecplot.h:92
FieldSharedPtr m_f
Field object.
static boost::shared_ptr<Module> Nektar::FieldUtils::OutputTecplot::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 65 of file OutputTecplot.h.

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

66  {
68  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::OutputTecplot::GetModuleName ( )
inlineprotectedvirtual

Returns this module's name.

Implements Nektar::FieldUtils::Module.

Definition at line 109 of file OutputTecplot.h.

110  {
111  return "OutputTecplot";
112  }
int Nektar::FieldUtils::OutputTecplot::GetNumTecplotBlocks ( )
protected

Calculate number of Tecplot blocks.

Parameters
outfileOutput file

Definition at line 882 of file OutputTecplot.cpp.

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

Referenced by Process().

883 {
884  int returnval = 0;
885 
886  if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
887  {
888  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
889  {
890  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
891  }
892  }
893  else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
894  {
895  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
896  {
897  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
898  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
899  }
900  }
901  else
902  {
903  for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
904  {
905  returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
906  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
907  (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
908  }
909  }
910 
911  return returnval;
912 }
FieldSharedPtr m_f
Field object.
void Nektar::FieldUtils::OutputTecplot::Process ( po::variables_map &  vm)
virtual

Set up member variables to dump Tecplot format output.

Implements Nektar::FieldUtils::Module.

Definition at line 143 of file OutputTecplot.cpp.

References ASSERTL0, CalculateConnectivity(), Nektar::MultiRegions::e3DH1D, Nektar::MultiRegions::e3DH2D, 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, GetNumTecplotBlocks(), m_binary, Nektar::FieldUtils::Module::m_config, m_conn, m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_numPoints, m_oneOutputFile, m_rankConnSizes, m_rankFieldSizes, m_totConn, m_zoneType, npts, Nektar::LibUtilities::NullPtsField, Nektar::LibUtilities::ReduceSum, WriteTecplotConnectivity(), WriteTecplotHeader(), and WriteTecplotZone().

144 {
145  LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
146 
147  m_numBlocks = 0;
148 
149  // Do nothing if no expansion defined
150  if (fPts == LibUtilities::NullPtsField && !m_f->m_exp.size())
151  {
152  return;
153  }
154 
155 
156  if (m_f->m_verbose)
157  {
158  if (m_f->m_comm->TreatAsRankZero())
159  {
160  cout << "OutputTecplot: Writing file..." << endl;
161  }
162  }
163 
164  // Extract the output filename and extension
165  string filename = m_config["outfile"].as<string>();
166 
167  int nprocs = m_f->m_comm->GetSize();
168  int rank = m_f->m_comm->GetRank();
169 
170  if(m_config["writemultiplefiles"].as<bool>())
171  {
172  m_oneOutputFile = false;
173  }
174  else
175  {
176  m_oneOutputFile = nprocs > 1;
177  }
178 
179  // Amend for parallel output if required
180  if (nprocs != 1 && !m_oneOutputFile)
181  {
182  int dot = filename.find_last_of('.');
183  string ext = filename.substr(dot, filename.length() - dot);
184  string procId = "_P" + boost::lexical_cast<std::string>(rank);
185  string start = filename.substr(0, dot);
186  filename = start + procId + ext;
187  }
188 
189  std::string coordVars[] = { "x", "y", "z" };
190  bool doError = (vm.count("error") == 1) ? true : false;
191 
192  // Open output file
193  ofstream outfile;
194 
195  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
196  {
197  outfile.open(filename.c_str(), m_binary ? ios::binary : ios::out);
198  }
199 
200  std::vector<std::string> var;
201  bool writeHeader = true;
202 
203  if (fPts == LibUtilities::NullPtsField)
204  {
205  // Standard tensor-product element setup.
206  std::vector<LibUtilities::FieldDefinitionsSharedPtr> fDef =
207  m_f->m_fielddef;
208 
209  if (fDef.size())
210  {
211  var = fDef[0]->m_fields;
212  }
213 
214  // Calculate number of FE blocks
216 
217  // Calculate coordinate dimension
218  int nBases = m_f->m_exp[0]->GetExp(0)->GetNumBases();
219  MultiRegions::ExpansionType HomoExpType = m_f->m_exp[0]->GetExpType();
220 
221  m_coordim = m_f->m_exp[0]->GetExp(0)->GetCoordim();
222  var.insert(var.begin(), coordVars, coordVars + m_coordim);
223 
224  if (HomoExpType == MultiRegions::e3DH1D)
225  {
226  int nPlanes = m_f->m_exp[0]->GetZIDs().num_elements();
227  if (nPlanes == 1) // halfMode case
228  {
229  // do nothing
230  }
231  else
232  {
233  nBases += 1;
234  m_coordim += 1;
235  NekDouble tmp = m_numBlocks * (nPlanes - 1);
236  m_numBlocks = (int)tmp;
237  }
238  }
239  else if (HomoExpType == MultiRegions::e3DH2D)
240  {
241  nBases += 2;
242  m_coordim += 2;
243  }
244 
245  m_zoneType = (TecplotZoneType)(2*(nBases-1) + 1);
246 
247  // Calculate connectivity
249 
250  // Set up storage for output fields
251  m_fields = Array<OneD, Array<OneD, NekDouble> >(var.size());
252 
253  // Get coordinates
254  int totpoints = m_f->m_exp[0]->GetTotPoints();
255 
256  for (int i = 0; i < m_coordim; ++i)
257  {
258  m_fields[i] = Array<OneD, NekDouble>(totpoints);
259  }
260 
261  if (m_coordim == 1)
262  {
263  m_f->m_exp[0]->GetCoords(m_fields[0]);
264  }
265  else if (m_coordim == 2)
266  {
267  m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1]);
268  }
269  else
270  {
271  m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1], m_fields[2]);
272  }
273 
274  if (var.size() > m_coordim)
275  {
276  // Backward transform all data
277  for (int i = 0; i < m_f->m_exp.size(); ++i)
278  {
279  if (m_f->m_exp[i]->GetPhysState() == false)
280  {
281  m_f->m_exp[i]->BwdTrans(m_f->m_exp[i]->GetCoeffs(),
282  m_f->m_exp[i]->UpdatePhys());
283  }
284  }
285 
286  // Add references to m_fields
287  for (int i = 0; i < m_f->m_exp.size(); ++i)
288  {
289  m_fields[i + m_coordim] = m_f->m_exp[i]->UpdatePhys();
290  }
291  }
292 
293  // Dump L2 errors of fields.
294  if (doError)
295  {
296  for (int i = 0; i < m_fields.num_elements(); ++i)
297  {
298  NekDouble l2err = m_f->m_exp[0]->L2(m_fields[i]);
299  if (rank == 0)
300  {
301  cout << "L 2 error (variable " << var[i] << ") : "
302  << l2err << endl;
303  }
304  }
305  }
306  }
307  else
308  {
309  m_coordim = fPts->GetDim();
310 
311  if (fPts->GetNpoints() == 0)
312  {
313  return;
314  }
315 
316  // Grab connectivity information.
317  fPts->GetConnectivity(m_conn);
318 
319  // Get field names
320  var = fPts->GetFieldNames();
321  var.insert(var.begin(), coordVars, coordVars + m_coordim);
322 
323  switch (fPts->GetPtsType())
324  {
327  m_numPoints.resize(1);
328  m_numPoints[0] = fPts->GetNpoints();
330  break;
332  m_numPoints.resize(2);
333  m_numPoints[0] = fPts->GetPointsPerEdge(0);
334  m_numPoints[1] = fPts->GetPointsPerEdge(1);
336  break;
338  m_numPoints.resize(3);
339  m_numPoints[0] = fPts->GetPointsPerEdge(0);
340  m_numPoints[1] = fPts->GetPointsPerEdge(1);
341  m_numPoints[2] = fPts->GetPointsPerEdge(2);
343  break;
345  {
347  for (int i = 0; i < m_conn.size(); ++i)
348  {
349  m_numBlocks += m_conn[i].num_elements() / 3;
350  }
351  break;
352  }
354  {
356  for (int i = 0; i < m_conn.size(); ++i)
357  {
358  m_numBlocks += m_conn[i].num_elements() / 4;
359  }
360  break;
361  }
362  default:
363  ASSERTL0(false, "This points type is not supported yet.");
364  }
365 
366  // Get fields and coordinates
367  m_fields = Array<OneD, Array<OneD, NekDouble> >(var.size());
368 
369  // We can just grab everything from points. This should be a
370  // reference, not a copy.
371  fPts->GetPts(m_fields);
372 
373  // Only write header if we're root or FE block; binary files always
374  // write header
375  writeHeader = (m_zoneType != eOrdered || rank == 0) || m_binary;
376 
377  if (doError)
378  {
379  NekDouble l2err;
380  for (int i = 0; i < m_fields.num_elements(); ++i)
381  {
382  // calculate rms value
383  int npts = m_fields[i].num_elements();
384 
385  l2err = 0.0;
386  for (int j = 0; j < npts; ++j)
387  {
388  l2err += m_fields[i][j] * m_fields[i][j];
389  }
390 
391  m_f->m_comm->AllReduce(l2err, LibUtilities::ReduceSum);
392  m_f->m_comm->AllReduce(npts, LibUtilities::ReduceSum);
393 
394  l2err /= npts;
395  l2err = sqrt(l2err);
396 
397  if (rank == 0)
398  {
399  cout << "L 2 error (variable " << var[i] << ") : "
400  << l2err << endl;
401  }
402  }
403  }
404  }
405 
406  if (m_oneOutputFile)
407  {
408  // Reduce on number of blocks and number of points.
409  m_f->m_comm->AllReduce(m_numBlocks, LibUtilities::ReduceSum);
410  for (int i = 0; i < m_numPoints.size(); ++i)
411  {
412  m_f->m_comm->AllReduce(m_numPoints[i], LibUtilities::ReduceSum);
413  }
414 
415  // Root process needs to know how much data everyone else has for
416  // writing in parallel.
417  m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
418  m_rankConnSizes = Array<OneD, int>(nprocs, 0);
419  m_rankFieldSizes[rank] = m_fields[0].num_elements();
420 
421  m_totConn = 0;
422  for (int i = 0; i < m_conn.size(); ++i)
423  {
424  m_totConn += m_conn[i].num_elements();
425  }
426 
427  m_rankConnSizes[rank] = m_totConn;
428 
429  m_f->m_comm->AllReduce(m_rankFieldSizes, LibUtilities::ReduceSum);
430  m_f->m_comm->AllReduce(m_rankConnSizes, LibUtilities::ReduceSum);
431  }
432 
433  if (writeHeader)
434  {
435  WriteTecplotHeader(outfile, var);
436  }
437 
438  // Write zone data.
439  WriteTecplotZone(outfile);
440 
441  // If we're a FE block format, write connectivity (m_conn will be empty for
442  // point data).
443  WriteTecplotConnectivity(outfile);
444 
445  if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
446  {
447  cout << "Written file: " << filename << endl;
448  }
449 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
TecplotZoneType m_zoneType
Tecplot zone type of output.
Definition: OutputTecplot.h:82
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
Definition: OutputTecplot.h:96
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
boost::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:178
virtual void WriteTecplotConnectivity(std::ofstream &outfile)
Write Tecplot connectivity information (ASCII)
void CalculateConnectivity()
Calculate connectivity information for each expansion dimension.
virtual void WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
Write Tecplot files header.
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.
Definition: OutputTecplot.h:94
static std::string npts
Definition: InputFld.cpp:43
double NekDouble
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
Definition: OutputTecplot.h:92
int m_numBlocks
Number of blocks in Tecplot file.
Definition: OutputTecplot.h:86
int m_totConn
Total number of connectivity entries.
Definition: OutputTecplot.h:90
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:179
int GetNumTecplotBlocks()
Calculate number of Tecplot blocks.
int m_coordim
Coordinate dimension of output.
Definition: OutputTecplot.h:88
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
Definition: OutputTecplot.h:98
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:78
virtual void WriteTecplotZone(std::ofstream &outfile)
vector< int > m_numPoints
Number of points per block in Tecplot file.
Definition: OutputTecplot.h:84
FieldSharedPtr m_f
Field object.
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 776 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 Process().

777 {
778  // Ordered data have no connectivity information.
779  if (m_zoneType == eOrdered)
780  {
781  return;
782  }
783 
784  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
785  {
786  // Need to amalgamate connectivity information
787  Array<OneD, int> conn(m_totConn);
788  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
789  {
790  Vmath::Vcopy(m_conn[i].num_elements(), &m_conn[i][0], 1,
791  &conn[cnt], 1);
792  cnt += m_conn[i].num_elements();
793  }
794  m_f->m_comm->Send(0, conn);
795  }
796  else
797  {
798  int cnt = 1;
799  for (int i = 0; i < m_conn.size(); ++i)
800  {
801  const int nConn = m_conn[i].num_elements();
802  for (int j = 0; j < nConn; ++j,++cnt)
803  {
804  outfile << m_conn[i][j] + 1 << " ";
805  if (!(cnt % 1000))
806  {
807  outfile << std::endl;
808  }
809  }
810  }
811  outfile << endl;
812 
813  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
814  {
815  int offset = m_rankFieldSizes[0];
816 
817  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
818  {
819  Array<OneD, int> conn(m_rankConnSizes[n]);
820  m_f->m_comm->Recv(n, conn);
821  for (int j = 0; j < conn.num_elements(); ++j)
822  {
823  outfile << conn[j] + offset + 1 << " ";
824  if ((!(j % 1000)) && j)
825  {
826  outfile << std::endl;
827  }
828  }
829  offset += m_rankFieldSizes[n];
830  }
831  }
832  }
833 }
TecplotZoneType m_zoneType
Tecplot zone type of output.
Definition: OutputTecplot.h:82
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
Definition: OutputTecplot.h:96
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.
Definition: OutputTecplot.h:94
vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
Definition: OutputTecplot.h:92
int m_totConn
Total number of connectivity entries.
Definition: OutputTecplot.h:90
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
FieldSharedPtr m_f
Field object.
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 457 of file OutputTecplot.cpp.

Referenced by Process().

459 {
460  outfile << "Variables = " << var[0];
461 
462  for (int i = 1; i < var.size(); ++i)
463  {
464  outfile << ", " << var[i];
465  }
466 
467  outfile << std::endl << std::endl;
468 }
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 513 of file OutputTecplot.cpp.

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

Referenced by Process().

514 {
515  // Write either points or finite element block
516  if (m_zoneType != eOrdered)
517  {
518  if ((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
519  {
520  // Number of points in zone
521  int nPoints = m_oneOutputFile ?
522  Vmath::Vsum(m_f->m_comm->GetSize(), m_rankFieldSizes, 1) :
523  m_fields[0].num_elements();
524 
525  outfile << "Zone, N=" << nPoints << ", E="
526  << m_numBlocks << ", F=FEBlock, ET="
527  << TecplotZoneTypeMap[m_zoneType] << std::endl;
528  }
529 
530 
531  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
532  {
533  for (int j = 0; j < m_fields.num_elements(); ++j)
534  {
535  for (int i = 0; i < m_fields[j].num_elements(); ++i)
536  {
537  if ((!(i % 1000)) && i)
538  {
539  outfile << std::endl;
540  }
541  outfile << m_fields[j][i] << " ";
542  }
543 
544  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
545  {
546  Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
547  m_f->m_comm->Recv(n, tmp);
548 
549  for (int i = 0; i < m_rankFieldSizes[n]; ++i)
550  {
551  if ((!(i % 1000)) && i)
552  {
553  outfile << std::endl;
554  }
555  outfile << tmp[i] << " ";
556  }
557  }
558  outfile << std::endl;
559  }
560  }
561  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
562  {
563  for (int i = 0; i < m_fields.num_elements(); ++i)
564  {
565  m_f->m_comm->Send(0, m_fields[i]);
566  }
567  }
568  else
569  {
570  // Write out coordinates and field data: ordered by field
571  // and then its data.
572  for (int j = 0; j < m_fields.num_elements(); ++j)
573  {
574  for (int i = 0; i < m_fields[j].num_elements(); ++i)
575  {
576  if ((!(i % 1000)) && i)
577  {
578  outfile << std::endl;
579  }
580  outfile << m_fields[j][i] << " ";
581  }
582  outfile << std::endl;
583  }
584  }
585  }
586  else
587  {
588  std::string dirs[] = { "I", "J", "K" };
589  outfile << "Zone";
590  for (int i = 0; i < m_numPoints.size(); ++i)
591  {
592  outfile << ", " << dirs[i] << "=" << m_numPoints[i];
593  }
594  outfile << ", F=POINT" << std::endl;
595 
596  // Write out coordinates and field data: ordered by each point then each
597  // field.
598  for (int i = 0; i < m_fields[0].num_elements(); ++i)
599  {
600  for (int j = 0; j < m_fields.num_elements(); ++j)
601  {
602  outfile << setw(12) << m_fields[j][i] << " ";
603  }
604  outfile << std::endl;
605  }
606  }
607 }
TecplotZoneType m_zoneType
Tecplot zone type of output.
Definition: OutputTecplot.h:82
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.
Definition: OutputTecplot.h:94
int m_numBlocks
Number of blocks in Tecplot file.
Definition: OutputTecplot.h:86
std::string TecplotZoneTypeMap[]
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
Definition: OutputTecplot.h:98
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:737
vector< int > m_numPoints
Number of points per block in Tecplot file.
Definition: OutputTecplot.h:84
FieldSharedPtr m_f
Field object.

Member Data Documentation

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

True if writing binary field output.

Definition at line 78 of file OutputTecplot.h.

Referenced by Nektar::FieldUtils::OutputTecplotBinary::OutputTecplotBinary(), and Process().

ModuleKey Nektar::FieldUtils::OutputTecplot::m_className
static
Initial value:

Definition at line 70 of file OutputTecplot.h.

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

Connectivty for each block: one per element.

Definition at line 92 of file OutputTecplot.h.

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

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

Coordinate dimension of output.

Definition at line 88 of file OutputTecplot.h.

Referenced by Process().

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

Field data to output.

Definition at line 98 of file OutputTecplot.h.

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

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

Number of blocks in Tecplot file.

Definition at line 86 of file OutputTecplot.h.

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

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

Number of points per block in Tecplot file.

Definition at line 84 of file OutputTecplot.h.

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

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

Each rank's connectivity sizes.

Definition at line 96 of file OutputTecplot.h.

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

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

Total number of connectivity entries.

Definition at line 90 of file OutputTecplot.h.

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

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

Tecplot zone type of output.

Definition at line 82 of file OutputTecplot.h.

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