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)
 
virtual ~OutputTecplot ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
virtual ~OutputFileBase ()
 
- 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 ()
 
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

virtual void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual void v_OutputFromPts (po::variables_map &vm) override
 Write from pts to output file. More...
 
virtual void v_OutputFromExp (po::variables_map &vm) override
 Write from m_exp to output file. More...
 
virtual void v_OutputFromData (po::variables_map &vm) override
 Write from data to output file. More...
 
virtual fs::path v_GetPath (std::string &filename, po::variables_map &vm) override
 
virtual 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
virtual void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
virtual 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 ()
 

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

Constructor & Destructor Documentation

◆ OutputTecplot()

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

Definition at line 65 of file OutputTecplot.cpp.

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

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

◆ ~OutputTecplot()

Nektar::FieldUtils::OutputTecplot::~OutputTecplot ( )
virtual

Definition at line 75 of file OutputTecplot.cpp.

76{
77}

Member Function Documentation

◆ CalculateConnectivity()

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

Calculate connectivity information for each expansion dimension.

Parameters
outfileOutput file

Definition at line 988 of file OutputTecplot.cpp.

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

66 {
68 }
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 951 of file OutputTecplot.cpp.

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

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

377{
378 return GetPath(filename, vm);
379}
fs::path GetPath(std::string &filename, po::variables_map &vm)

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

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 77 of file OutputTecplot.h.

78 {
79 return "OutputTecplot";
80 }

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

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

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

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

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

234{
235 m_numBlocks = 0;
236 m_writeHeader = true;
237
238 // Calculate number of FE blocks
240
241 // Calculate coordinate dimension
242 int nBases = m_f->m_exp[0]->GetExp(0)->GetNumBases();
243
244 m_coordim = m_f->m_exp[0]->GetExp(0)->GetCoordim();
245 int totpoints = m_f->m_exp[0]->GetTotPoints();
246
247 if (m_f->m_numHomogeneousDir > 0)
248 {
249 int nPlanes = m_f->m_exp[0]->GetZIDs().size();
250 if (nPlanes == 1) // halfMode case
251 {
252 // do nothing
253 }
254 else
255 {
256 // If Fourier points, output extra plane to fill domain
257 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
258 {
259 nPlanes += 1;
260 totpoints += m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
261 }
262 nBases += m_f->m_numHomogeneousDir;
263 m_coordim += m_f->m_numHomogeneousDir;
264 NekDouble tmp = m_numBlocks * (nPlanes - 1);
265 m_numBlocks = (int)tmp;
266 }
267 }
268
269 m_zoneType = (TecplotZoneType)(2 * (nBases - 1) + 1);
270
271 // Calculate connectivity
273
274 // Set up storage for output fields
275 m_fields = Array<OneD, Array<OneD, NekDouble>>(m_f->m_variables.size() +
276 m_coordim);
277
278 // Get coordinates
279 for (int i = 0; i < m_coordim; ++i)
280 {
281 m_fields[i] = Array<OneD, NekDouble>(totpoints);
282 }
283
284 if (m_coordim == 1)
285 {
286 m_f->m_exp[0]->GetCoords(m_fields[0]);
287 }
288 else if (m_coordim == 2)
289 {
290 m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1]);
291 }
292 else
293 {
294 m_f->m_exp[0]->GetCoords(m_fields[0], m_fields[1], m_fields[2]);
295 }
296
297 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
298 {
299 // Copy values
300 for (int i = 0; i < m_f->m_variables.size(); ++i)
301 {
302 m_fields[i + m_coordim] = Array<OneD, NekDouble>(totpoints);
303
304 Vmath::Vcopy(m_f->m_exp[0]->GetTotPoints(),
305 m_f->m_exp[i]->UpdatePhys(), 1,
306 m_fields[i + m_coordim], 1);
307 }
308 }
309 else
310 {
311 // Add references to m_fields
312 for (int i = 0; i < m_f->m_variables.size(); ++i)
313 {
314 m_fields[i + m_coordim] = m_f->m_exp[i]->UpdatePhys();
315 }
316 }
317
318 // If Fourier, fill extra plane with data
319 if (m_f->m_exp[0]->GetExpType() == MultiRegions::e3DH1D)
320 {
321 int points_on_plane = m_f->m_exp[0]->GetPlane(0)->GetTotPoints();
322 const int offset = totpoints - points_on_plane;
323 NekDouble z = m_fields[m_coordim - 1][totpoints - 2 * points_on_plane] +
324 (m_fields[m_coordim - 1][points_on_plane] -
325 m_fields[m_coordim - 1][0]);
326 // x and y
327 Array<OneD, NekDouble> tmp = m_fields[0] + offset;
328 Vmath::Vcopy(points_on_plane, m_fields[0], 1, tmp, 1);
329 tmp = m_fields[1] + offset;
330 Vmath::Vcopy(points_on_plane, m_fields[1], 1, tmp, 1);
331 // z coordinate
332 tmp = m_fields[2] + offset;
333 Vmath::Vcopy(points_on_plane, m_fields[2], 1, tmp, 1);
334 Vmath::Sadd(points_on_plane, z, m_fields[2], 1, tmp, 1);
335
336 // variables
337 for (int i = 0; i < m_f->m_variables.size(); ++i)
338 {
339 tmp = m_fields[i + m_coordim] + offset;
340 Vmath::Vcopy(points_on_plane, m_fields[i + m_coordim], 1, tmp, 1);
341 }
342 }
343
345}
void CalculateConnectivity()
Calculate connectivity information for each expansion dimension.
bool m_writeHeader
True if writing header.
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 scalar y = alpha + x.
Definition: Vmath.cpp:379
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191

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

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

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

80{
81
82 if (m_config["writemultiplefiles"].as<bool>())
83 {
84 m_oneOutputFile = false;
85 }
86 else
87 {
88 m_oneOutputFile = (m_f->m_comm->GetSpaceComm()->GetSize() > 1);
89 }
90
92}
virtual 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 837 of file OutputTecplot.cpp.

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

453{
454 outfile << "Variables = " << var[0];
455
456 for (int i = 1; i < var.size(); ++i)
457 {
458 outfile << ", " << var[i];
459 }
460
461 outfile << std::endl << std::endl;
462}

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

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

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

136 {
138 }
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 381 of file OutputTecplot.cpp.

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

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

126 {
127 v_WriteTecplotHeader(outfile, var);
128 }
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 130 of file OutputTecplot.h.

131 {
132 v_WriteTecplotZone(outfile);
133 }
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 98 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:65
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 70 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 110 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 106 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 112 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 102 of file OutputTecplot.h.

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

◆ m_zoneType

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