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

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

Referenced by WriteTecplotZone().

619 {
620  // Data format: either double or single depending on user options
621  bool useDoubles = m_config["double"].m_beenSet;
622 
623  if (useDoubles)
624  {
625  // For doubles, we can just write data.
626  WriteStream(outfile, data);
627  }
628  else
629  {
630  // For single precision, needs typecast first.
631  int nPts = data.num_elements();
632  vector<float> tmp(data.num_elements());
633  std::copy(&data[0], &data[0] + nPts, &tmp[0]);
634  WriteStream(outfile, tmp);
635  }
636 }
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 836 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().

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

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

479 {
480  if (m_oneOutputFile && m_f->m_comm->GetRank() > 0)
481  {
482  return;
483  }
484 
485  // Version number
486  outfile << "#!TDV112";
487 
488  // Int value of 1 for endian check
489  WriteStream(outfile, 1);
490 
491  // We'll probably write a full solution field
492  WriteStream(outfile, 0);
493 
494  // Title
495  std::string title = "";
496  WriteStream(outfile, title);
497 
498  // Number of variables
499  WriteStream(outfile, (int)var.size());
500 
501  for (int i = 0; i < var.size(); ++i)
502  {
503  WriteStream(outfile, var[i]);
504  }
505 }
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 644 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().

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