Nektar++
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:
[legend]

Public Member Functions

 OutputTecplotBinary (FieldSharedPtr f)
 
 ~OutputTecplotBinary () override
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputTecplot
 OutputTecplot (FieldSharedPtr f)
 
 ~OutputTecplot () override
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
 ~OutputFileBase () override
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputModule
 OutputModule (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::FieldUtils::OutputTecplot
static std::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...
 
void v_WriteTecplotHeader (std::ofstream &outfile, std::vector< std::string > &var) override
 Write Tecplot files header in binary format. More...
 
void v_WriteTecplotZone (std::ofstream &outfile) override
 
void v_WriteTecplotConnectivity (std::ofstream &outfile) override
 Write Tecplot connectivity information (ASCII) More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::OutputTecplot
void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
std::string v_GetModuleName () override
 
void v_OutputFromPts (po::variables_map &vm) override
 Write from pts to output file. More...
 
void v_OutputFromExp (po::variables_map &vm) override
 Write from m_exp to output file. More...
 
void v_OutputFromData (po::variables_map &vm) override
 Write from data to output file. More...
 
fs::path v_GetPath (std::string &filename, po::variables_map &vm) override
 
fs::path v_GetFullOutName (std::string &filename, po::variables_map &vm) override
 
virtual void v_WriteTecplotHeader (std::ofstream &outfile, std::vector< std::string > &var)
 Write Tecplot files header. More...
 
void WriteTecplotHeader (std::ofstream &outfile, std::vector< std::string > &var)
 
virtual void v_WriteTecplotZone (std::ofstream &outfile)
 
void WriteTecplotZone (std::ofstream &outfile)
 
virtual void v_WriteTecplotConnectivity (std::ofstream &outfile)
 Write Tecplot connectivity information (ASCII) More...
 
void WriteTecplotConnectivity (std::ofstream &outfile)
 
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::OutputFileBase
void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
ModulePriority v_GetModulePriority () override
 
virtual void v_OutputFromPts (po::variables_map &vm)=0
 Write from pts to output file. More...
 
virtual void v_OutputFromExp (po::variables_map &vm)=0
 Write from m_exp to output file. More...
 
virtual void v_OutputFromData (po::variables_map &vm)=0
 Write from data to output file. More...
 
virtual fs::path v_GetPath (std::string &filename, po::variables_map &vm)
 
fs::path GetPath (std::string &filename, po::variables_map &vm)
 
virtual fs::path v_GetFullOutName (std::string &filename, po::variables_map &vm)
 
fs::path GetFullOutName (std::string &filename, po::variables_map &vm)
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- 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...
 
bool m_writeHeader
 True if writing header. More...
 
TecplotZoneType m_zoneType
 Tecplot zone type of output. More...
 
std::vector< int > m_numPoints
 Number of points per block in Tecplot file. More...
 
int m_numBlocks
 Number of blocks in Tecplot file. More...
 
int m_coordim
 Coordinate dimension of output. More...
 
int m_totConn
 Total number of connectivity entries. More...
 
std::vector< Array< OneD, int > > m_conn
 Connectivty for each block: one per element. More...
 
Array< OneD, int > m_rankFieldSizes
 Each rank's field sizes. More...
 
Array< OneD, int > m_rankConnSizes
 Each rank's connectivity sizes. More...
 
Array< OneD, Array< OneD, NekDouble > > m_fields
 Field data to output. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputFileBase
bool m_requireEquiSpaced
 
bool m_prohibitWrite = false
 
bool m_equispacedSetup = false
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
std::ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Detailed Description

Tecplot output class, specifically for binary field output.

Definition at line 146 of file OutputTecplot.h.

Constructor & Destructor Documentation

◆ OutputTecplotBinary()

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

Definition at line 156 of file OutputTecplot.h.

156 : OutputTecplot(f)
157 {
158 m_binary = true;
159 }
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:95

References Nektar::FieldUtils::OutputTecplot::m_binary.

◆ ~OutputTecplotBinary()

Nektar::FieldUtils::OutputTecplotBinary::~OutputTecplotBinary ( )
inlineoverride

Definition at line 161 of file OutputTecplot.h.

162 {
163 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 150 of file OutputTecplot.h.

151 {
153 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

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

◆ v_WriteTecplotConnectivity()

void Nektar::FieldUtils::OutputTecplotBinary::v_WriteTecplotConnectivity ( std::ofstream &  outfile)
overrideprotectedvirtual

Write Tecplot connectivity information (ASCII)

Parameters
outfileOutput file

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 901 of file OutputTecplot.cpp.

902{
903 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
904 {
905 // Need to amalgamate connectivity information
906 Array<OneD, int> conn(m_totConn);
907 for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
908 {
909 Vmath::Vcopy(m_conn[i].size(), &m_conn[i][0], 1, &conn[cnt], 1);
910 cnt += m_conn[i].size();
911 }
912 m_f->m_comm->GetSpaceComm()->Send(0, conn);
913 }
914 else
915 {
916 for (int i = 0; i < m_conn.size(); ++i)
917 {
918 WriteStream(outfile, m_conn[i]);
919 }
920
921 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0)
922 {
923 int offset = m_rankFieldSizes[0];
924
925 for (int n = 1; n < m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
926 {
927 Array<OneD, int> conn(m_rankConnSizes[n]);
928 m_f->m_comm->GetSpaceComm()->Recv(n, conn);
929
930 for (int j = 0; j < conn.size(); ++j)
931 {
932 conn[j] += offset;
933 }
934
935 WriteStream(outfile, conn);
936 offset += m_rankFieldSizes[n];
937 }
938 }
939 }
940}
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
int m_totConn
Total number of connectivity entries.
std::vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:97
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.
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.hpp:825

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

◆ v_WriteTecplotHeader()

void Nektar::FieldUtils::OutputTecplotBinary::v_WriteTecplotHeader ( std::ofstream &  outfile,
std::vector< std::string > &  var 
)
overrideprotectedvirtual

Write Tecplot files header in binary format.

Parameters
outfileOutput file name
varVariables names

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 466 of file OutputTecplot.cpp.

468{
469 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
470 {
471 return;
472 }
473
474 // Version number
475 outfile << "#!TDV112";
476
477 // Int value of 1 for endian check
478 WriteStream(outfile, 1);
479
480 // We'll probably write a full solution field
481 WriteStream(outfile, 0);
482
483 // Title
484 std::string title = "";
485 WriteStream(outfile, title);
486
487 // Number of variables
488 WriteStream(outfile, (int)var.size());
489
490 for (int i = 0; i < var.size(); ++i)
491 {
492 WriteStream(outfile, var[i]);
493 }
494}

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

◆ v_WriteTecplotZone()

void Nektar::FieldUtils::OutputTecplotBinary::v_WriteTecplotZone ( std::ofstream &  outfile)
overrideprotectedvirtual

Write Tecplot zone output in binary

Parameters
outfileOutput file name.
expansionExpansion that is considered

Reimplemented from Nektar::FieldUtils::OutputTecplot.

Definition at line 696 of file OutputTecplot.cpp.

697{
698 Array<OneD, NekDouble> fieldMin(m_fields.size());
699 Array<OneD, NekDouble> fieldMax(m_fields.size());
700
701 // Data format: either double or single depending on user options
702 bool useDoubles = m_config["double"].as<bool>();
703
704 if ((m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0) ||
706 {
707 // Don't bother naming zone
708 WriteStream(outfile, 299.0f); // Zone marker
709
710 // Write same name as preplot
711 int rank = m_f->m_comm->GetSpaceComm()->GetRank();
712 string zonename = "ZONE " + boost::lexical_cast<string>(rank);
713 WriteStream(outfile, zonename);
714
715 WriteStream(outfile, -1); // No parent zone
716 WriteStream(outfile, -1); // No strand ID
717 WriteStream(outfile, 0.0); // Solution time
718 WriteStream(outfile, -1); // Unused, set to -1
719
720 // Zone type: 1 = lineseg, 3 = quad, 5 = brick
721 WriteStream(outfile, (int)m_zoneType);
722
723 WriteStream(outfile, 0); // Data at nodes
724 WriteStream(outfile, 0); // No 1-1 face neighbours
725 WriteStream(outfile, 0); // No user-defined connections
726
727 if (m_zoneType == eOrdered)
728 {
729 for (int i = 0; i < m_numPoints.size(); ++i)
730 {
731 WriteStream(outfile, m_numPoints[i]);
732 }
733
734 for (int i = m_numPoints.size(); i < 3; ++i)
735 {
736 WriteStream(outfile, 0);
737 }
738 }
739 else
740 {
741 // Number of points in zone
742 int nPoints =
744 ? Vmath::Vsum(m_f->m_comm->GetSpaceComm()->GetSize(),
746 : m_fields[0].size();
747
748 WriteStream(outfile, nPoints); // Total number of points
749 WriteStream(outfile, m_numBlocks); // Number of blocks
750 WriteStream(outfile, 0); // Unused
751 WriteStream(outfile, 0); // Unused
752 WriteStream(outfile, 0); // Unused
753 }
754
755 WriteStream(outfile, 0); // No auxiliary data names
756
757 // Finalise header
758 WriteStream(outfile, 357.0f);
759
760 // Now start to write data section so that we can dump geometry
761 // information
762
763 // Data marker
764 WriteStream(outfile, 299.0f);
765
766 for (int j = 0; j < m_fields.size(); ++j)
767 {
768 WriteStream(outfile, useDoubles ? 2 : 1);
769 }
770
771 // No passive variables or variable sharing, no zone connectivity
772 // sharing (we only dump one zone)
773 WriteStream(outfile, 0);
774 WriteStream(outfile, 0);
775 WriteStream(outfile, -1);
776 }
777
778 for (int i = 0; i < m_fields.size(); ++i)
779 {
780 fieldMin[i] = Vmath::Vmin(m_fields[i].size(), m_fields[i], 1);
781 fieldMax[i] = Vmath::Vmax(m_fields[i].size(), m_fields[i], 1);
782 }
783
784 m_f->m_comm->GetSpaceComm()->AllReduce(fieldMin, LibUtilities::ReduceMin);
785 m_f->m_comm->GetSpaceComm()->AllReduce(fieldMax, LibUtilities::ReduceMax);
786
787 // Write out min/max of field data
788 if ((m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0) ||
790 {
791 for (int i = 0; i < m_fields.size(); ++i)
792 {
793 WriteStream(outfile, fieldMin[i]);
794 WriteStream(outfile, fieldMax[i]);
795 }
796 }
797
798 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0)
799 {
800 for (int i = 0; i < m_fields.size(); ++i)
801 {
802 WriteDoubleOrFloat(outfile, m_fields[i]);
803
804 for (int n = 1; n < m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
805 {
806 Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
807 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
808 WriteDoubleOrFloat(outfile, tmp);
809 }
810 }
811 }
812 else if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
813 {
814 for (int i = 0; i < m_fields.size(); ++i)
815 {
816 m_f->m_comm->GetSpaceComm()->Send(0, m_fields[i]);
817 }
818 }
819 else
820 {
821 for (int i = 0; i < m_fields.size(); ++i)
822 {
823 WriteDoubleOrFloat(outfile, m_fields[i]);
824 }
825 }
826}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272
void WriteDoubleOrFloat(std::ofstream &outfile, Array< OneD, NekDouble > &data)
Write either double-precision or single-precision output of field data.
TecplotZoneType m_zoneType
Tecplot zone type of output.
std::vector< int > m_numPoints
Number of points per block in Tecplot file.
int m_numBlocks
Number of blocks in Tecplot file.
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
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.hpp:725
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.hpp:608
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.hpp:644

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

◆ WriteDoubleOrFloat()

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

671{
672 // Data format: either double or single depending on user options
673 bool useDoubles = m_config["double"].as<bool>();
674
675 if (useDoubles)
676 {
677 // For doubles, we can just write data.
678 WriteStream(outfile, data);
679 }
680 else
681 {
682 // For single precision, needs typecast first.
683 int nPts = data.size();
684 std::vector<float> tmp(data.size());
685 std::copy(&data[0], &data[0] + nPts, &tmp[0]);
686 WriteStream(outfile, tmp);
687 }
688}
def copy(self)
Definition: pycml.py:2663

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

Referenced by v_WriteTecplotZone().

Member Data Documentation

◆ m_className

ModuleKey Nektar::FieldUtils::OutputTecplotBinary::m_className
static
Initial value:
=
"Writes a Tecplot file in binary plt format.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 155 of file OutputTecplot.h.