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)
 
 ~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 Attributes

static ModuleKey m_className
 

Protected Member Functions

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

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

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 

Detailed Description

Tecplot output class.

Definition at line 59 of file OutputTecplot.h.

Constructor & Destructor Documentation

◆ OutputTecplot()

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

Definition at line 61 of file OutputTecplot.cpp.

62 : OutputFileBase(f), m_binary(false), m_oneOutputFile(false)
63{
65 m_config["double"] = ConfigOption(true, "0",
66 "Write double-precision format data:"
67 "more accurate but more disk space"
68 " required");
69}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272
bool m_binary
True if writing binary field output.
Definition: OutputTecplot.h:95
bool m_oneOutputFile
True if writing a single output file.
Definition: OutputTecplot.h:97

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

◆ ~OutputTecplot()

Nektar::FieldUtils::OutputTecplot::~OutputTecplot ( )
override

Definition at line 71 of file OutputTecplot.cpp.

72{
73}

Member Function Documentation

◆ CalculateConnectivity()

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

Calculate connectivity information for each expansion dimension.

Parameters
outfileOutput file

Definition at line 984 of file OutputTecplot.cpp.

985{
986 int i, j, k, l;
987 int nbase = m_f->m_exp[0]->GetExp(0)->GetNumBases();
988 int cnt = 0;
989
990 m_conn.resize(m_f->m_exp[0]->GetNumElmts());
991
992 for (i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
993 {
994 cnt = m_f->m_exp[0]->GetPhys_Offset(i);
995
996 if (nbase == 1)
997 {
998 int cnt2 = 0;
999 int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1000 int nPlanes = 1;
1001
1002 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e2DH1D)
1003 {
1004 nPlanes = m_f->m_exp[0]->GetZIDs().size();
1005
1006 if (nPlanes > 1)
1007 {
1008 int totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1009
1010 Array<OneD, int> conn(4 * (np0 - 1) * (nPlanes - 1));
1011 for (int n = 1; n < nPlanes; ++n)
1012 {
1013 for (k = 1; k < np0; ++k)
1014 {
1015 conn[cnt2++] = cnt + (n - 1) * totPoints + k;
1016 conn[cnt2++] = cnt + (n - 1) * totPoints + k - 1;
1017 conn[cnt2++] = cnt + n * totPoints + k - 1;
1018 conn[cnt2++] = cnt + n * totPoints + k;
1019 }
1020 }
1021 m_conn[i] = conn;
1022 }
1023 }
1024
1025 if (nPlanes == 1)
1026 {
1027 Array<OneD, int> conn(2 * (np0 - 1));
1028
1029 for (k = 1; k < np0; ++k)
1030 {
1031 conn[cnt2++] = cnt + k;
1032 conn[cnt2++] = cnt + k - 1;
1033 }
1034
1035 m_conn[i] = conn;
1036 }
1037 }
1038 else if (nbase == 2)
1039 {
1040 int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1041 int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1042 int totPoints = m_f->m_exp[0]->GetTotPoints();
1043 int nPlanes = 1;
1044 int cnt2 = 0;
1045
1046 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
1047 {
1048 nPlanes = m_f->m_exp[0]->GetZIDs().size();
1049
1050 // default to 2D case for HalfMode when nPlanes = 1
1051 if (nPlanes > 1)
1052 {
1053 // If Fourier points, output extra plane to fill domain
1054 nPlanes += 1;
1055 totPoints = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
1056
1057 Array<OneD, int> conn(8 * (np1 - 1) * (np0 - 1) *
1058 (nPlanes - 1));
1059
1060 for (int n = 1; n < nPlanes; ++n)
1061 {
1062 for (j = 1; j < np1; ++j)
1063 {
1064 for (k = 1; k < np0; ++k)
1065 {
1066 conn[cnt2++] = cnt + (n - 1) * totPoints +
1067 (j - 1) * np0 + k - 1;
1068 conn[cnt2++] = cnt + (n - 1) * totPoints +
1069 (j - 1) * np0 + k;
1070 conn[cnt2++] =
1071 cnt + (n - 1) * totPoints + j * np0 + k;
1072 conn[cnt2++] =
1073 cnt + (n - 1) * totPoints + j * np0 + k - 1;
1074 conn[cnt2++] =
1075 cnt + n * totPoints + (j - 1) * np0 + k - 1;
1076 conn[cnt2++] =
1077 cnt + n * totPoints + (j - 1) * np0 + k;
1078 conn[cnt2++] =
1079 cnt + n * totPoints + j * np0 + k;
1080 conn[cnt2++] =
1081 cnt + n * totPoints + j * np0 + k - 1;
1082 }
1083 }
1084 }
1085 m_conn[i] = conn;
1086 }
1087 }
1088
1089 if (nPlanes == 1)
1090 {
1091 Array<OneD, int> conn(4 * (np0 - 1) * (np1 - 1));
1092 for (j = 1; j < np1; ++j)
1093 {
1094 for (k = 1; k < np0; ++k)
1095 {
1096 conn[cnt2++] = cnt + (j - 1) * np0 + k - 1;
1097 conn[cnt2++] = cnt + (j - 1) * np0 + k;
1098 conn[cnt2++] = cnt + j * np0 + k;
1099 conn[cnt2++] = cnt + j * np0 + k - 1;
1100 }
1101 }
1102 m_conn[i] = conn;
1103 }
1104 }
1105 else if (nbase == 3)
1106 {
1107 int np0 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(0);
1108 int np1 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(1);
1109 int np2 = m_f->m_exp[0]->GetExp(i)->GetNumPoints(2);
1110 int cnt2 = 0;
1111
1112 Array<OneD, int> conn(8 * (np0 - 1) * (np1 - 1) * (np2 - 1));
1113
1114 for (j = 1; j < np2; ++j)
1115 {
1116 for (k = 1; k < np1; ++k)
1117 {
1118 for (l = 1; l < np0; ++l)
1119 {
1120 conn[cnt2++] =
1121 cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l - 1;
1122 conn[cnt2++] =
1123 cnt + (j - 1) * np0 * np1 + (k - 1) * np0 + l;
1124 conn[cnt2++] = cnt + (j - 1) * np0 * np1 + k * np0 + l;
1125 conn[cnt2++] =
1126 cnt + (j - 1) * np0 * np1 + k * np0 + l - 1;
1127 conn[cnt2++] =
1128 cnt + j * np0 * np1 + (k - 1) * np0 + l - 1;
1129 conn[cnt2++] = cnt + j * np0 * np1 + (k - 1) * np0 + l;
1130 conn[cnt2++] = cnt + j * np0 * np1 + k * np0 + l;
1131 conn[cnt2++] = cnt + j * np0 * np1 + k * np0 + l - 1;
1132 }
1133 }
1134 }
1135
1136 m_conn[i] = conn;
1137 }
1138 else
1139 {
1140 ASSERTL0(false, "Not set up for this dimension");
1141 }
1142 }
1143}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
std::vector< Array< OneD, int > > m_conn
Connectivty for each block: one per element.

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

Referenced by v_OutputFromExp().

◆ create()

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

Creates an instance of this class.

Definition at line 63 of file OutputTecplot.h.

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

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

◆ GetNumTecplotBlocks()

int Nektar::FieldUtils::OutputTecplot::GetNumTecplotBlocks ( )
protected

Calculate number of Tecplot blocks.

Parameters
outfileOutput file

Definition at line 947 of file OutputTecplot.cpp.

948{
949 int returnval = 0;
950
951 if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 1)
952 {
953 for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
954 {
955 returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1);
956 }
957 }
958 else if (m_f->m_exp[0]->GetExp(0)->GetNumBases() == 2)
959 {
960 for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
961 {
962 returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
963 (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1);
964 }
965 }
966 else
967 {
968 for (int i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
969 {
970 returnval += (m_f->m_exp[0]->GetExp(i)->GetNumPoints(0) - 1) *
971 (m_f->m_exp[0]->GetExp(i)->GetNumPoints(1) - 1) *
972 (m_f->m_exp[0]->GetExp(i)->GetNumPoints(2) - 1);
973 }
974 }
975
976 return returnval;
977}

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

Referenced by v_OutputFromExp().

◆ v_GetFullOutName()

fs::path Nektar::FieldUtils::OutputTecplot::v_GetFullOutName ( std::string &  filename,
po::variables_map &  vm 
)
overrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 371 of file OutputTecplot.cpp.

373{
374 return GetPath(filename, vm);
375}
fs::path GetPath(std::string &filename, po::variables_map &vm)

References Nektar::FieldUtils::OutputFileBase::GetPath().

◆ v_GetModuleName()

std::string Nektar::FieldUtils::OutputTecplot::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 75 of file OutputTecplot.h.

76 {
77 return "OutputTecplot";
78 }

◆ v_GetPath()

fs::path Nektar::FieldUtils::OutputTecplot::v_GetPath ( std::string &  filename,
po::variables_map &  vm 
)
overrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 352 of file OutputTecplot.cpp.

354{
355 int nprocs = m_f->m_comm->GetSpaceComm()->GetSize();
356 string returnstr(filename);
357
358 // Amend for parallel output if required
359 if (nprocs != 1 && !m_oneOutputFile)
360 {
361 int rank = m_f->m_comm->GetSpaceComm()->GetRank();
362 int dot = filename.find_last_of('.');
363 string ext = filename.substr(dot, filename.length() - dot);
364 string procId = "_P" + std::to_string(rank);
365 string start = filename.substr(0, dot);
366 returnstr = start + procId + ext;
367 }
368 return fs::path(returnstr);
369}

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

◆ v_OutputFromData()

void Nektar::FieldUtils::OutputTecplot::v_OutputFromData ( po::variables_map &  vm)
overrideprotectedvirtual

Write from data to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 346 of file OutputTecplot.cpp.

347{
349 "OutputTecplot can't write using only FieldData.");
350}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

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

◆ v_OutputFromExp()

void Nektar::FieldUtils::OutputTecplot::v_OutputFromExp ( po::variables_map &  vm)
overrideprotectedvirtual

Write from m_exp to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 232 of file OutputTecplot.cpp.

233{
234 m_numBlocks = 0;
235 m_writeHeader = true;
236
237 // Calculate number of FE blocks
239
240 // Calculate coordinate dimension
241 int nBases = m_f->m_exp[0]->GetExp(0)->GetNumBases();
242
243 m_coordim = m_f->m_exp[0]->GetExp(0)->GetCoordim();
244 int totpoints = m_f->m_exp[0]->GetTotPoints();
245
246 if (m_f->m_numHomogeneousDir > 0)
247 {
248 int nPlanes = m_f->m_exp[0]->GetZIDs().size();
249 if (nPlanes == 1) // halfMode case
250 {
251 // do nothing
252 }
253 else
254 {
255 // If Fourier points, output extra plane to fill domain
256 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
257 {
258 nPlanes += 1;
259 totpoints += m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
260 }
261 nBases += m_f->m_numHomogeneousDir;
262 m_coordim += m_f->m_numHomogeneousDir;
263 NekDouble tmp = m_numBlocks * (nPlanes - 1);
264 m_numBlocks = (int)tmp;
265 }
266 }
267
268 m_zoneType = (TecplotZoneType)(2 * (nBases - 1) + 1);
269
270 // Calculate connectivity
272
273 // Set up storage for output fields
274 m_fields = Array<OneD, Array<OneD, NekDouble>>(m_f->m_variables.size() +
275 m_coordim);
276
277 // Get coordinates
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 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
297 {
298 // Copy values
299 for (int i = 0; i < m_f->m_variables.size(); ++i)
300 {
301 m_fields[i + m_coordim] = Array<OneD, NekDouble>(totpoints);
302
303 Vmath::Vcopy(m_f->m_exp[0]->GetTotPoints(),
304 m_f->m_exp[i]->UpdatePhys(), 1,
305 m_fields[i + m_coordim], 1);
306 }
307 }
308 else
309 {
310 // Add references to m_fields
311 for (int i = 0; i < m_f->m_variables.size(); ++i)
312 {
313 m_fields[i + m_coordim] = m_f->m_exp[i]->UpdatePhys();
314 }
315 }
316
317 // If Fourier, fill extra plane with data
318 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
319 {
320 int points_on_plane = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
321 const int offset = totpoints - points_on_plane;
322 NekDouble z = m_fields[m_coordim - 1][totpoints - 2 * points_on_plane] +
323 (m_fields[m_coordim - 1][points_on_plane] -
324 m_fields[m_coordim - 1][0]);
325 // x and y
326 Array<OneD, NekDouble> tmp = m_fields[0] + offset;
327 Vmath::Vcopy(points_on_plane, m_fields[0], 1, tmp, 1);
328 tmp = m_fields[1] + offset;
329 Vmath::Vcopy(points_on_plane, m_fields[1], 1, tmp, 1);
330 // z coordinate
331 tmp = m_fields[2] + offset;
332 Vmath::Vcopy(points_on_plane, m_fields[2], 1, tmp, 1);
333 Vmath::Sadd(points_on_plane, z, m_fields[2], 1, tmp, 1);
334
335 // variables
336 for (int i = 0; i < m_f->m_variables.size(); ++i)
337 {
338 tmp = m_fields[i + m_coordim] + offset;
339 Vmath::Vcopy(points_on_plane, m_fields[i + m_coordim], 1, tmp, 1);
340 }
341 }
342
344}
void CalculateConnectivity()
Calculate connectivity information for each expansion dimension.
bool m_writeHeader
True if writing header.
Definition: OutputTecplot.h:99
TecplotZoneType m_zoneType
Tecplot zone type of output.
void WriteTecplotFile(po::variables_map &vm)
int m_numBlocks
Number of blocks in Tecplot file.
int m_coordim
Coordinate dimension of output.
int GetNumTecplotBlocks()
Calculate number of Tecplot blocks.
Array< OneD, Array< OneD, NekDouble > > m_fields
Field data to output.
std::vector< double > z(NPUPPER)
double NekDouble
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.hpp:194
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References CalculateConnectivity(), Nektar::MultiRegions::e3DH1D, GetNumTecplotBlocks(), m_coordim, Nektar::FieldUtils::Module::m_f, m_fields, m_numBlocks, m_writeHeader, m_zoneType, Vmath::Sadd(), Vmath::Vcopy(), WriteTecplotFile(), and Nektar::UnitTests::z().

◆ v_OutputFromPts()

void Nektar::FieldUtils::OutputTecplot::v_OutputFromPts ( po::variables_map &  vm)
overrideprotectedvirtual

Write from pts to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 147 of file OutputTecplot.cpp.

148{
149 LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
150
151 // do not output if zone is empty
152 if (fPts->GetNpoints() == 0)
153 {
154 return;
155 }
156
157 int rank = m_f->m_comm->GetSpaceComm()->GetRank();
158 m_numBlocks = 0;
159
160 m_coordim = fPts->GetDim();
161
162 // Grab connectivity information.
163 fPts->GetConnectivity(m_conn);
164
165 switch (fPts->GetPtsType())
166 {
168 m_numPoints.resize(1);
169 m_numPoints[0] = fPts->GetNpoints();
170 m_f->m_comm->GetSpaceComm()->AllReduce(m_numPoints[0],
173 break;
175 m_numPoints.resize(3);
176 m_numPoints[0] = fPts->GetPointsPerEdge(0);
177 m_numPoints[1] = 1;
178 m_numPoints[2] = 1;
180 break;
182 m_numPoints.resize(3);
183 m_numPoints[0] = fPts->GetPointsPerEdge(0);
184 m_numPoints[1] = fPts->GetPointsPerEdge(1);
185 m_numPoints[2] = 1;
187 break;
189 m_numPoints.resize(3);
190 m_numPoints[0] = fPts->GetPointsPerEdge(0);
191 m_numPoints[1] = fPts->GetPointsPerEdge(1);
192 m_numPoints[2] = fPts->GetPointsPerEdge(2);
194 break;
196 {
198 for (int i = 0; i < m_conn.size(); ++i)
199 {
200 m_numBlocks += m_conn[i].size() / 3;
201 }
202 break;
203 }
205 {
207 for (int i = 0; i < m_conn.size(); ++i)
208 {
209 m_numBlocks += m_conn[i].size() / 4;
210 }
211 break;
212 }
213 default:
214 ASSERTL0(false, "This points type is not supported yet.");
215 }
216
217 // Get fields and coordinates
218 m_fields = Array<OneD, Array<OneD, NekDouble>>(m_f->m_variables.size() +
219 m_coordim);
220
221 // We can just grab everything from points. This should be a
222 // reference, not a copy.
223 fPts->GetPts(m_fields);
224
225 // Only write header if we're root or FE block; binary files always
226 // write header
227 m_writeHeader = (m_zoneType != eOrdered || rank == 0) || m_binary;
228
230}
std::vector< int > m_numPoints
Number of points per block in Tecplot file.
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:184

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

◆ v_Process()

void Nektar::FieldUtils::OutputTecplot::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write fld to output file.

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 75 of file OutputTecplot.cpp.

76{
77
78 if (m_config["writemultiplefiles"].as<bool>())
79 {
80 m_oneOutputFile = false;
81 }
82 else
83 {
84 m_oneOutputFile = (m_f->m_comm->GetSpaceComm()->GetSize() > 1);
85 }
86
88}
void v_Process(po::variables_map &vm) override
Write fld to output file.

References Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, m_oneOutputFile, and Nektar::FieldUtils::OutputFileBase::v_Process().

◆ v_WriteTecplotConnectivity()

void Nektar::FieldUtils::OutputTecplot::v_WriteTecplotConnectivity ( std::ofstream &  outfile)
protectedvirtual

Write Tecplot connectivity information (ASCII)

Parameters
outfileOutput file

Reimplemented in Nektar::FieldUtils::OutputTecplotBinary.

Definition at line 833 of file OutputTecplot.cpp.

834{
835 // Ordered data have no connectivity information.
836 if (m_zoneType == eOrdered)
837 {
838 return;
839 }
840
841 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
842 {
843 // Need to amalgamate connectivity information
844 if (m_totConn)
845 {
846 Array<OneD, int> conn(m_totConn);
847 for (int i = 0, cnt = 0; i < m_conn.size(); ++i)
848 {
849 if (m_conn[i].size())
850 {
851 Vmath::Vcopy(m_conn[i].size(), &m_conn[i][0], 1, &conn[cnt],
852 1);
853 cnt += m_conn[i].size();
854 }
855 }
856 m_f->m_comm->GetSpaceComm()->Send(0, conn);
857 }
858 }
859 else
860 {
861 int cnt = 1;
862 for (int i = 0; i < m_conn.size(); ++i)
863 {
864 const int nConn = m_conn[i].size();
865 for (int j = 0; j < nConn; ++j, ++cnt)
866 {
867 outfile << m_conn[i][j] + 1 << " ";
868 if (!(cnt % 1000))
869 {
870 outfile << std::endl;
871 }
872 }
873 }
874 outfile << endl;
875
876 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0)
877 {
878 int offset = m_rankFieldSizes[0];
879
880 for (int n = 1; n < m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
881 {
882 if (m_rankConnSizes[n])
883 {
884 Array<OneD, int> conn(m_rankConnSizes[n]);
885 m_f->m_comm->GetSpaceComm()->Recv(n, conn);
886 for (int j = 0; j < conn.size(); ++j)
887 {
888 outfile << conn[j] + offset + 1 << " ";
889 if ((!(j % 1000)) && j)
890 {
891 outfile << std::endl;
892 }
893 }
894 }
895 offset += m_rankFieldSizes[n];
896 }
897 }
898 }
899}
int m_totConn
Total number of connectivity entries.
Array< OneD, int > m_rankConnSizes
Each rank's connectivity sizes.
Array< OneD, int > m_rankFieldSizes
Each rank's field sizes.

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

◆ v_WriteTecplotHeader()

void Nektar::FieldUtils::OutputTecplot::v_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 447 of file OutputTecplot.cpp.

449{
450 outfile << "Variables = " << var[0];
451
452 for (int i = 1; i < var.size(); ++i)
453 {
454 outfile << ", " << var[i];
455 }
456
457 outfile << std::endl << std::endl;
458}

Referenced by WriteTecplotHeader().

◆ v_WriteTecplotZone()

void Nektar::FieldUtils::OutputTecplot::v_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 502 of file OutputTecplot.cpp.

503{
504 bool useDoubles = m_config["double"].as<bool>();
505
506 if (useDoubles)
507 {
508 int precision = std::numeric_limits<double>::max_digits10;
509 outfile << std::setprecision(precision);
510 }
511
512 // Write either points or finite element block
513 if (m_zoneType != eOrdered)
514 {
515 if ((m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0) ||
517 {
518 // Number of points in zone
519 int nPoints =
521 ? Vmath::Vsum(m_f->m_comm->GetSpaceComm()->GetSize(),
523 : m_fields[0].size();
524
525 outfile << "Zone, N=" << nPoints << ", E=" << m_numBlocks
526 << ", F=FEBlock, ET=" << TecplotZoneTypeMap[m_zoneType];
527 if (m_f->m_fieldMetaDataMap.count("Time"))
528 {
529 outfile << ", SOLUTIONTIME=" << m_f->m_fieldMetaDataMap["Time"];
530 }
531 outfile << std::endl;
532 }
533
534 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0)
535 {
536 for (int j = 0; j < m_fields.size(); ++j)
537 {
538 for (int i = 0; i < m_fields[j].size(); ++i)
539 {
540 if ((!(i % 1000)) && i)
541 {
542 outfile << std::endl;
543 }
544 outfile << m_fields[j][i] << " ";
545 }
546
547 for (int n = 1; n < m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
548 {
549 if (m_rankFieldSizes[n])
550 {
551 Array<OneD, NekDouble> tmp(m_rankFieldSizes[n]);
552 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
553
554 for (int i = 0; i < m_rankFieldSizes[n]; ++i)
555 {
556 if ((!(i % 1000)) && i)
557 {
558 outfile << std::endl;
559 }
560 outfile << tmp[i] << " ";
561 }
562 }
563 }
564 outfile << std::endl;
565 }
566 }
567 else if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
568 {
569 if (m_fields[0].size())
570 {
571 for (int i = 0; i < m_fields.size(); ++i)
572 {
573 m_f->m_comm->GetSpaceComm()->Send(0, m_fields[i]);
574 }
575 }
576 }
577 else
578 {
579 // Write out coordinates and field data: ordered by field
580 // and then its data.
581 for (int j = 0; j < m_fields.size(); ++j)
582 {
583 for (int i = 0; i < m_fields[j].size(); ++i)
584 {
585 if ((!(i % 1000)) && i)
586 {
587 outfile << std::endl;
588 }
589 outfile << m_fields[j][i] << " ";
590 }
591 outfile << std::endl;
592 }
593 }
594 }
595 else
596 {
597 if ((m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0) ||
599 {
600 std::string dirs[] = {"I", "J", "K"};
601 outfile << "Zone";
602 for (int i = 0; i < m_numPoints.size(); ++i)
603 {
604 outfile << ", " << dirs[i] << "=" << m_numPoints[i];
605 }
606 outfile << ", F=POINT" << std::endl;
607 }
608
609 if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() == 0)
610 {
611 Array<OneD, NekDouble> tmp(m_fields.size());
612 for (int i = 0; i < m_fields[0].size(); ++i)
613 {
614 for (int j = 0; j < m_fields.size(); ++j)
615 {
616 outfile << setw(12) << m_fields[j][i] << " ";
617 }
618 outfile << std::endl;
619 }
620
621 for (int n = 1; n < m_f->m_comm->GetSpaceComm()->GetSize(); ++n)
622 {
623 for (int i = 0; i < m_rankFieldSizes[n]; ++i)
624 {
625 m_f->m_comm->GetSpaceComm()->Recv(n, tmp);
626 for (int j = 0; j < m_fields.size(); ++j)
627 {
628 outfile << setw(12) << tmp[j] << " ";
629 }
630 outfile << std::endl;
631 }
632 }
633 }
634 else if (m_oneOutputFile && m_f->m_comm->GetSpaceComm()->GetRank() > 0)
635 {
636 Array<OneD, NekDouble> tmp(m_fields.size());
637 for (int i = 0; i < m_fields[0].size(); ++i)
638 {
639 for (int j = 0; j < m_fields.size(); ++j)
640 {
641 tmp[j] = m_fields[j][i];
642 }
643 m_f->m_comm->GetSpaceComm()->Send(0, tmp);
644 }
645 }
646 else
647 {
648 // Write out coordinates and field data: ordered by each
649 // point then each field.
650 for (int i = 0; i < m_fields[0].size(); ++i)
651 {
652 for (int j = 0; j < m_fields.size(); ++j)
653 {
654 outfile << setw(12) << m_fields[j][i] << " ";
655 }
656 outfile << std::endl;
657 }
658 }
659 }
660}
std::string TecplotZoneTypeMap[]
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.hpp:608

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, Nektar::FieldUtils::TecplotZoneTypeMap, and Vmath::Vsum().

Referenced by WriteTecplotZone().

◆ WriteTecplotConnectivity()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotConnectivity ( std::ofstream &  outfile)
inlineprotected

Definition at line 132 of file OutputTecplot.h.

133 {
135 }
virtual void v_WriteTecplotConnectivity(std::ofstream &outfile)
Write Tecplot connectivity information (ASCII)

References v_WriteTecplotConnectivity().

Referenced by WriteTecplotFile().

◆ WriteTecplotFile()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotFile ( po::variables_map &  vm)
protected

Definition at line 377 of file OutputTecplot.cpp.

378{
379 // Variable names
380 std::string coordVars[] = {"x", "y", "z"};
381 std::vector<string> variables = m_f->m_variables;
382 variables.insert(variables.begin(), coordVars, coordVars + m_coordim);
383
384 int nprocs = m_f->m_comm->GetSpaceComm()->GetSize();
385 int rank = m_f->m_comm->GetSpaceComm()->GetRank();
386
387 // Extract the output filename and extension
388 string filename = m_config["outfile"].as<string>();
389 string outFile = LibUtilities::PortablePath(GetFullOutName(filename, vm));
390 // Open output file
391 ofstream outfile;
392 if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
393 {
394 outfile.open(outFile.c_str(), m_binary ? ios::binary : ios::out);
395 }
396
397 if (m_oneOutputFile)
398 {
399 // Reduce on number of blocks and number of points.
400 m_f->m_comm->GetSpaceComm()->AllReduce(m_numBlocks,
402
403 // Root process needs to know how much data everyone else has for
404 // writing in parallel.
405 m_rankFieldSizes = Array<OneD, int>(nprocs, 0);
406 m_rankConnSizes = Array<OneD, int>(nprocs, 0);
407 m_rankFieldSizes[rank] = m_fields[0].size();
408
409 m_totConn = 0;
410 for (int i = 0; i < m_conn.size(); ++i)
411 {
412 m_totConn += m_conn[i].size();
413 }
414
416
417 m_f->m_comm->GetSpaceComm()->AllReduce(m_rankFieldSizes,
419 m_f->m_comm->GetSpaceComm()->AllReduce(m_rankConnSizes,
421 }
422
423 if (m_writeHeader)
424 {
425 WriteTecplotHeader(outfile, variables);
426 }
427
428 // Write zone data.
429 WriteTecplotZone(outfile);
430
431 // If we're a FE block format, write connectivity (m_conn will be empty for
432 // point data).
434
435 if ((m_oneOutputFile && rank == 0) || !m_oneOutputFile)
436 {
437 cout << "Written file: " << GetFullOutName(filename, vm) << endl;
438 }
439}
fs::path GetFullOutName(std::string &filename, po::variables_map &vm)
void WriteTecplotZone(std::ofstream &outfile)
void WriteTecplotConnectivity(std::ofstream &outfile)
void WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
static std::string PortablePath(const fs::path &path)
create portable path on different platforms for std::filesystem path.
Definition: Filesystem.hpp:56

References Nektar::FieldUtils::OutputFileBase::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 v_OutputFromExp(), and v_OutputFromPts().

◆ WriteTecplotHeader()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotHeader ( std::ofstream &  outfile,
std::vector< std::string > &  var 
)
inlineprotected

Definition at line 121 of file OutputTecplot.h.

123 {
124 v_WriteTecplotHeader(outfile, var);
125 }
virtual void v_WriteTecplotHeader(std::ofstream &outfile, std::vector< std::string > &var)
Write Tecplot files header.

References v_WriteTecplotHeader().

Referenced by WriteTecplotFile().

◆ WriteTecplotZone()

void Nektar::FieldUtils::OutputTecplot::WriteTecplotZone ( std::ofstream &  outfile)
inlineprotected

Definition at line 127 of file OutputTecplot.h.

128 {
129 v_WriteTecplotZone(outfile);
130 }
virtual void v_WriteTecplotZone(std::ofstream &outfile)

References v_WriteTecplotZone().

Referenced by WriteTecplotFile().

Member Data Documentation

◆ m_binary

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

True if writing binary field output.

Definition at line 95 of file OutputTecplot.h.

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

◆ m_className

ModuleKey Nektar::FieldUtils::OutputTecplot::m_className
static
Initial value:
=
"Writes a Tecplot file.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: OutputTecplot.h:63
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 68 of file OutputTecplot.h.

◆ m_conn

std::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 107 of file OutputTecplot.h.

Referenced by v_OutputFromExp(), v_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

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

Number of points per block in Tecplot file.

Definition at line 103 of file OutputTecplot.h.

Referenced by v_OutputFromPts(), v_WriteTecplotZone(), and Nektar::FieldUtils::OutputTecplotBinary::v_WriteTecplotZone().

◆ m_oneOutputFile

bool Nektar::FieldUtils::OutputTecplot::m_oneOutputFile
protected

◆ m_rankConnSizes

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

◆ 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 109 of file OutputTecplot.h.

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

◆ m_writeHeader

bool Nektar::FieldUtils::OutputTecplot::m_writeHeader
protected

True if writing header.

Definition at line 99 of file OutputTecplot.h.

Referenced by v_OutputFromExp(), v_OutputFromPts(), and WriteTecplotFile().

◆ m_zoneType

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