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 | List of all members
Nektar::FieldUtils::OutputTecplotBinary Class Reference

Tecplot output class, specifically for binary field output. More...

#include <OutputTecplot.h>

Inheritance diagram for Nektar::FieldUtils::OutputTecplotBinary:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::OutputTecplotBinary:
Collaboration graph
[legend]

Public Member Functions

 OutputTecplotBinary (FieldSharedPtr f)
 
virtual ~OutputTecplotBinary ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputTecplot
 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 Member Functions inherited from Nektar::FieldUtils::OutputTecplot
static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey m_className
 
- Static Public Attributes inherited from Nektar::FieldUtils::OutputTecplot
static ModuleKey m_className
 

Protected Member Functions

void WriteDoubleOrFloat (std::ofstream &outfile, Array< OneD, NekDouble > &data)
 Write either double-precision or single-precision output of field data. More...
 
virtual void WriteTecplotHeader (std::ofstream &outfile, std::vector< std::string > &var)
 Write Tecplot files header in binary format. More...
 
virtual void WriteTecplotZone (std::ofstream &outfile)
 
virtual void WriteTecplotConnectivity (std::ofstream &outfile)
 Write Tecplot connectivity information (ASCII) More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::OutputTecplot
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 ()
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::FieldUtils::OutputTecplot
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, specifically for binary field output.

Definition at line 118 of file OutputTecplot.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::OutputTecplotBinary::OutputTecplotBinary ( FieldSharedPtr  f)
inline

Definition at line 128 of file OutputTecplot.h.

References Nektar::FieldUtils::OutputTecplot::m_binary, and Nektar::FieldUtils::Module::m_config.

128  : OutputTecplot(f)
129  {
130  m_binary = true;
131  m_config["double"] =
132  ConfigOption(true, "0", "Write double-precision data: more "
133  "accurate but more disk space required");
134  }
map< string, ConfigOption > m_config
List of configuration values.
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:78
virtual Nektar::FieldUtils::OutputTecplotBinary::~OutputTecplotBinary ( )
inlinevirtual

Definition at line 136 of file OutputTecplot.h.

137  {
138  }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::FieldUtils::OutputTecplotBinary::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 122 of file OutputTecplot.h.

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

123  {
125  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::FieldUtils::OutputTecplotBinary::WriteDoubleOrFloat ( std::ofstream &  outfile,
Array< OneD, NekDouble > &  data 
)
protected

Write either double-precision or single-precision output of field data.

Parameters
outfileOutput file name.
expansionExpansion that is considered

Definition at line 616 of file OutputTecplot.cpp.

References CellMLToNektar.pycml::copy(), Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::WriteStream().

Referenced by WriteTecplotZone().

618 {
619  // Data format: either double or single depending on user options
620  bool useDoubles = m_config["double"].m_beenSet;
621 
622  if (useDoubles)
623  {
624  // For doubles, we can just write data.
625  WriteStream(outfile, data);
626  }
627  else
628  {
629  // For single precision, needs typecast first.
630  int nPts = data.num_elements();
631  vector<float> tmp(data.num_elements());
632  std::copy(&data[0], &data[0] + nPts, &tmp[0]);
633  WriteStream(outfile, tmp);
634  }
635 }
map< string, ConfigOption > m_config
List of configuration values.
void WriteStream(std::ostream &outfile, T data)
Helper function to write binary data to stream.
void Nektar::FieldUtils::OutputTecplotBinary::WriteTecplotConnectivity ( std::ofstream &  outfile)
protectedvirtual

Write Tecplot connectivity information (ASCII)

Parameters
outfileOutput file

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 835 of file OutputTecplot.cpp.

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

836 {
837  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
838  {
839  // Need to amalgamate connectivity information
840  Array<OneD, int> conn(m_totConn);
841  for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
842  {
843  Vmath::Vcopy(m_conn[i].num_elements(), &m_conn[i][0], 1,
844  &conn[cnt], 1);
845  cnt += m_conn[i].num_elements();
846  }
847  m_f->m_comm->Send(0, conn);
848  }
849  else
850  {
851  for (int i = 0; i < m_conn.size(); ++i)
852  {
853  WriteStream(outfile, m_conn[i]);
854  }
855 
856  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
857  {
858  int offset = m_rankFieldSizes[0];
859 
860  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
861  {
862  Array<OneD, int> conn(m_rankConnSizes[n]);
863  m_f->m_comm->Recv(n, conn);
864 
865  for (int j = 0; j < conn.num_elements(); ++j)
866  {
867  conn[j] += offset;
868  }
869 
870  WriteStream(outfile, conn);
871  offset += m_rankFieldSizes[n];
872  }
873  }
874  }
875 }
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 WriteStream(std::ostream &outfile, T data)
Helper function to write binary data to stream.
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::OutputTecplotBinary::WriteTecplotHeader ( std::ofstream &  outfile,
std::vector< std::string > &  var 
)
protectedvirtual

Write Tecplot files header in binary format.

Parameters
outfileOutput file name
varVariables names

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 476 of file OutputTecplot.cpp.

References Nektar::FieldUtils::Module::m_f, Nektar::FieldUtils::OutputTecplot::m_oneOutputFile, CG_Iterations::title, and Nektar::FieldUtils::WriteStream().

478 {
479  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
480  {
481  return;
482  }
483 
484  // Version number
485  outfile << "#!TDV112";
486 
487  // Int value of 1 for endian check
488  WriteStream(outfile, 1);
489 
490  // We'll probably write a full solution field
491  WriteStream(outfile, 0);
492 
493  // Title
494  std::string title = "";
495  WriteStream(outfile, title);
496 
497  // Number of variables
498  WriteStream(outfile, (int)var.size());
499 
500  for (int i = 0; i < var.size(); ++i)
501  {
502  WriteStream(outfile, var[i]);
503  }
504 }
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
void WriteStream(std::ostream &outfile, T data)
Helper function to write binary data to stream.
FieldSharedPtr m_f
Field object.
void Nektar::FieldUtils::OutputTecplotBinary::WriteTecplotZone ( std::ofstream &  outfile)
protectedvirtual

Write Tecplot zone output in binary

Parameters
outfileOutput file name.
expansionExpansion that is considered

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 643 of file OutputTecplot.cpp.

References Nektar::FieldUtils::eOrdered, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::FieldUtils::OutputTecplot::m_fields, Nektar::FieldUtils::OutputTecplot::m_numBlocks, Nektar::FieldUtils::OutputTecplot::m_numPoints, Nektar::FieldUtils::OutputTecplot::m_oneOutputFile, Nektar::FieldUtils::OutputTecplot::m_rankFieldSizes, Nektar::FieldUtils::OutputTecplot::m_zoneType, Nektar::LibUtilities::ReduceMax, Nektar::LibUtilities::ReduceMin, Vmath::Vmax(), Vmath::Vmin(), Vmath::Vsum(), WriteDoubleOrFloat(), and Nektar::FieldUtils::WriteStream().

644 {
645  Array<OneD, NekDouble> fieldMin(m_fields.num_elements());
646  Array<OneD, NekDouble> fieldMax(m_fields.num_elements());
647 
648  // Data format: either double or single depending on user options
649  bool useDoubles = m_config["double"].m_beenSet;
650 
651  if ((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
652  {
653  // Don't bother naming zone
654  WriteStream(outfile, 299.0f); // Zone marker
655 
656  // Write same name as preplot
657  int rank = m_f->m_comm->GetRank();
658  string zonename = "ZONE " + boost::lexical_cast<string>(rank);
659  WriteStream(outfile, zonename);
660 
661  WriteStream(outfile, -1); // No parent zone
662  WriteStream(outfile, -1); // No strand ID
663  WriteStream(outfile, 0.0); // Solution time
664  WriteStream(outfile, -1); // Unused, set to -1
665 
666  // Zone type: 1 = lineseg, 3 = quad, 5 = brick
667  WriteStream(outfile, (int)m_zoneType);
668 
669  WriteStream(outfile, 0); // Data at nodes
670  WriteStream(outfile, 0); // No 1-1 face neighbours
671  WriteStream(outfile, 0); // No user-defined connections
672 
673  if (m_zoneType == eOrdered)
674  {
675  for (int i = 0; i < m_numPoints.size(); ++i)
676  {
677  WriteStream(outfile, m_numPoints[i]);
678  }
679 
680  for (int i = m_numPoints.size(); i < 3; ++i)
681  {
682  WriteStream(outfile, 0);
683  }
684  }
685  else
686  {
687  // Number of points in zone
688  int nPoints = m_oneOutputFile ?
689  Vmath::Vsum(m_f->m_comm->GetSize(), m_rankFieldSizes, 1) :
690  m_fields[0].num_elements();
691 
692  WriteStream(outfile, nPoints); // Total number of points
693  WriteStream(outfile, m_numBlocks); // Number of blocks
694  WriteStream(outfile, 0); // Unused
695  WriteStream(outfile, 0); // Unused
696  WriteStream(outfile, 0); // Unused
697  }
698 
699  WriteStream(outfile, 0); // No auxiliary data names
700 
701  // Finalise header
702  WriteStream(outfile, 357.0f);
703 
704  // Now start to write data section so that we can dump geometry
705  // information
706 
707  // Data marker
708  WriteStream(outfile, 299.0f);
709 
710  for (int j = 0; j < m_fields.num_elements(); ++j)
711  {
712  WriteStream(outfile, useDoubles ? 2 : 1);
713  }
714 
715  // No passive variables or variable sharing, no zone connectivity
716  // sharing (we only dump one zone)
717  WriteStream(outfile, 0);
718  WriteStream(outfile, 0);
719  WriteStream(outfile, -1);
720  }
721 
722  for (int i = 0; i < m_fields.num_elements(); ++i)
723  {
724  fieldMin[i] = Vmath::Vmin(m_fields[i].num_elements(), m_fields[i], 1);
725  fieldMax[i] = Vmath::Vmax(m_fields[i].num_elements(), m_fields[i], 1);
726  }
727 
728  m_f->m_comm->AllReduce(fieldMin, LibUtilities::ReduceMin);
729  m_f->m_comm->AllReduce(fieldMax, LibUtilities::ReduceMax);
730 
731  // Write out min/max of field data
732  if ((m_oneOutputFile && m_f->m_comm->GetRank() == 0) || !m_oneOutputFile)
733  {
734  for (int i = 0; i < m_fields.num_elements(); ++i)
735  {
736  WriteStream(outfile, fieldMin[i]);
737  WriteStream(outfile, fieldMax[i]);
738  }
739  }
740 
741  if (m_oneOutputFile && m_f->m_comm->GetRank() == 0)
742  {
743  for (int i = 0; i < m_fields.num_elements(); ++i)
744  {
745  WriteDoubleOrFloat(outfile, m_fields[i]);
746 
747  for (int n = 1; n < m_f->m_comm->GetSize(); ++n)
748  {
749  Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
750  m_f->m_comm->Recv(n, tmp);
751  WriteDoubleOrFloat(outfile, tmp);
752  }
753  }
754  }
755  else if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
756  {
757  for (int i = 0; i < m_fields.num_elements(); ++i)
758  {
759  m_f->m_comm->Send(0, m_fields[i]);
760  }
761  }
762  else
763  {
764  for (int i = 0; i < m_fields.num_elements(); ++i)
765  {
766  WriteDoubleOrFloat(outfile, m_fields[i]);
767  }
768  }
769 }
map< string, ConfigOption > m_config
List of configuration values.
TecplotZoneType m_zoneType
Tecplot zone type of output.
Definition: OutputTecplot.h:82
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:779
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:871
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:80
void WriteDoubleOrFloat(std::ofstream &outfile, Array< OneD, NekDouble > &data)
Write either double-precision or single-precision output of field data.
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
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
void WriteStream(std::ostream &outfile, T data)
Helper function to write binary data to stream.
vector< int > m_numPoints
Number of points per block in Tecplot file.
Definition: OutputTecplot.h:84
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::OutputTecplotBinary::m_className
static
Initial value:
=
"Writes a Tecplot file in binary plt format.")

Definition at line 127 of file OutputTecplot.h.