13#ifndef vtkCGNSReaderInternal_h
14#define vtkCGNSReaderInternal_h
31#include VTK_CGNS(cgnslib.h)
32#include VTK_CGNS(cgns_io.h)
39VTK_ABI_NAMESPACE_BEGIN
43 static const bool value =
false;
55 static const bool value =
false;
68VTK_ABI_NAMESPACE_BEGIN
101VTK_ABI_NAMESPACE_BEGIN
107 { CGNS_ENUMV(ElementTypeUserDefined), -1 }, { CGNS_ENUMV(ElementTypeNull), -1 },
108 { CGNS_ENUMV(
NODE), 0 }, { CGNS_ENUMV(BAR_2), 1 }, { CGNS_ENUMV(BAR_3), 1 },
109 { CGNS_ENUMV(TRI_3), 2 }, { CGNS_ENUMV(TRI_6), 2 }, { CGNS_ENUMV(QUAD_4), 2 },
110 { CGNS_ENUMV(QUAD_8), 2 }, { CGNS_ENUMV(QUAD_9), 2 }, { CGNS_ENUMV(TETRA_4), 3 },
111 { CGNS_ENUMV(TETRA_10), 3 }, { CGNS_ENUMV(PYRA_5), 3 }, { CGNS_ENUMV(PYRA_14), 3 },
112 { CGNS_ENUMV(PENTA_6), 3 }, { CGNS_ENUMV(PENTA_15), 3 }, { CGNS_ENUMV(PENTA_18), 3 },
113 { CGNS_ENUMV(HEXA_8), 3 }, { CGNS_ENUMV(HEXA_20), 3 }, { CGNS_ENUMV(HEXA_27), 3 },
114 { CGNS_ENUMV(MIXED), -1 }, { CGNS_ENUMV(PYRA_13), 3 }, { CGNS_ENUMV(NGON_n), 2 },
115 { CGNS_ENUMV(NFACE_n), 3 }, { CGNS_ENUMV(BAR_4), 1 }, { CGNS_ENUMV(TRI_9), 2 },
116 { CGNS_ENUMV(TRI_10), 2 }, { CGNS_ENUMV(QUAD_12), 2 }, { CGNS_ENUMV(QUAD_16), 2 },
117 { CGNS_ENUMV(TETRA_16), 3 }, { CGNS_ENUMV(TETRA_20), 3 }, { CGNS_ENUMV(PYRA_21), 3 },
118 { CGNS_ENUMV(PYRA_29), 3 }, { CGNS_ENUMV(PYRA_30), 3 }, { CGNS_ENUMV(PENTA_24), 3 },
119 { CGNS_ENUMV(PENTA_38), 3 }, { CGNS_ENUMV(PENTA_40), 3 }, { CGNS_ENUMV(HEXA_32), 3 },
120 { CGNS_ENUMV(HEXA_56), 3 }, { CGNS_ENUMV(HEXA_64), 3 }, { CGNS_ENUMV(BAR_5), 1 },
121 { CGNS_ENUMV(TRI_12), 2 }, { CGNS_ENUMV(TRI_15), 2 }, { CGNS_ENUMV(QUAD_P4_16), 2 },
122 { CGNS_ENUMV(QUAD_25), 2 }, { CGNS_ENUMV(TETRA_22), 3 }, { CGNS_ENUMV(TETRA_34), 3 },
123 { CGNS_ENUMV(TETRA_35), 3 }, { CGNS_ENUMV(PYRA_P4_29), 3 }, { CGNS_ENUMV(PYRA_50), 3 },
124 { CGNS_ENUMV(PYRA_55), 3 }, { CGNS_ENUMV(PENTA_33), 3 }, { CGNS_ENUMV(PENTA_66), 3 },
125 { CGNS_ENUMV(PENTA_75), 3 }, { CGNS_ENUMV(HEXA_44), 3 }, { CGNS_ENUMV(HEXA_98), 3 },
126 { CGNS_ENUMV(HEXA_125), 3 }
135 vtkCGNSArraySelection::const_iterator iter = other.begin();
136 for (; iter != other.end(); ++iter)
138 (*this)[iter->first] = iter->second;
142 void AddArray(
const char* name,
bool status =
true) { (*this)[name] = status; }
146 vtkCGNSArraySelection::iterator iter = this->find(name);
147 if (iter != this->end())
158 vtkCGNSArraySelection::iterator iter = this->find(name);
159 return (iter != this->end());
169 for (vtkCGNSArraySelection::iterator iter = this->begin(); iter != this->end(); ++iter)
174 return iter->first.c_str();
229 this->name[0] =
'\0';
239 std::vector<CGNSRead::ZoneBCInformation>
bcs;
243 this->name[0] =
'\0';
291 std::vector<CGNSRead::FamilyInformation>
family;
294 std::vector<CGNSRead::ZoneInformation>
zones;
317 const std::string& patchFamilyname);
328 bool Parse(
const char* cgnsFileName);
343 std::vector<double>&
GetTimes() {
return this->GlobalTime; }
364 std::vector<CGNSRead::BaseInformation> baseList;
365 std::string LastReadFilename;
367 std::vector<double> GlobalTime;
374 return (strncmp(nameOne, nameTwo, 32) == 0);
381 char* end = name + strlen(name) - 1;
382 while (end >= name && isspace(*end))
387 assert(end >= name && end < name + 33);
394 std::vector<CGNSVector>& vectorList,
const char_33 name)
396 for (std::vector<CGNSVector>::iterator iter = vectorList.begin(); iter != vectorList.end();
399 if (strncmp(iter->name, name, 31) == 0)
404 return vectorList.end();
410 for (std::vector<CGNSVariable>::const_iterator iter = varList.begin(); iter != varList.end();
413 if (strncmp(iter->name, name, 32) == 0)
423 std::vector<CGNSRead::CGNSVector>& vectors,
int physicalDim);
432 int cgioNum,
double parentId,
const char* label,
double*
id,
const char* name =
nullptr);
435 const cgsize_t* srcEnd,
const cgsize_t* srcStride,
const cgsize_t* memStart,
436 const cgsize_t* memEnd,
const cgsize_t* memStride,
const cgsize_t* memDim,
440 const cgsize_t* srcEnd,
const cgsize_t* srcStride,
const cgsize_t* memStart,
441 const cgsize_t* memEnd,
const cgsize_t* memStride,
const cgsize_t* memDim,
445 const cgsize_t* srcStart,
const cgsize_t* srcEnd,
const cgsize_t* srcStride,
446 const cgsize_t* memStart,
const cgsize_t* memEnd,
const cgsize_t* memStride,
447 const cgsize_t* memDim,
vtkIdType* localElementsIdx);
450 CGNS_ENUMT(ElementType_t) elemType,
bool& higherOrderWarning,
bool& cgnsOrderFlag);
457template <
typename T,
typename Y>
459 const std::size_t& nCoordsArray,
int cellDim,
vtkIdType nPts,
const cgsize_t* srcStart,
460 const cgsize_t* srcEnd,
const cgsize_t* srcStride,
const cgsize_t* memStart,
461 const cgsize_t* memEnd,
const cgsize_t* memStride,
const cgsize_t* memDims,
vtkPoints* points)
463 T* coords =
static_cast<T*
>(points->GetVoidPointer(0));
464 T* currentCoord =
static_cast<T*
>(&(coords[0]));
468 bool sameType =
true;
471 memset(coords, 0, 3 * nPts *
sizeof(T));
473 for (std::size_t c = 1; c <= nCoordsArray; ++c)
476 if (cgio_get_name(cgioNum, gridChildId[c - 1], coordName) != CG_OK)
479 cgio_error_message(message);
480 std::cerr <<
"get_XYZ_mesh : cgio_get_name :" << message;
485 if (cgio_get_data_type(cgioNum, gridChildId[c - 1], dataType))
490 if (strcmp(dataType,
"R8") == 0)
493 sameType = doubleType;
495 else if (strcmp(dataType,
"R4") == 0)
498 sameType = floatType;
502 std::cerr <<
"Invalid datatype for GridCoordinates\n";
507 len = strlen(coordName) - 1;
508 switch (coordName[len])
511 currentCoord =
static_cast<T*
>(&(coords[0]));
514 currentCoord =
static_cast<T*
>(&(coords[1]));
517 currentCoord =
static_cast<T*
>(&(coords[2]));
521 coordId = gridChildId[c - 1];
524 if (sameType ==
true)
526 constexpr const char* dtNameT = detail::cgns_type_name<T>();
527 if (cgio_read_data_type(cgioNum, coordId, srcStart, srcEnd, srcStride, dtNameT, cellDim,
528 memEnd, memStart, memEnd, memStride, (
void*)currentCoord))
531 cgio_error_message(message);
532 std::cerr <<
"cgio_read_data_type :" << message;
537 constexpr const char* dtNameY = detail::cgns_type_name<Y>();
538 Y* dataArray =
nullptr;
539 const cgsize_t memNoStride[3] = { 1, 1, 1 };
542 dataArray =
new Y[nPts];
543 if (dataArray ==
nullptr)
545 std::cerr <<
"Error allocating buffer array\n";
548 if (cgio_read_data_type(cgioNum, coordId, srcStart, srcEnd, srcStride, dtNameY, cellDim,
549 memDims, memStart, memDims, memNoStride, (
void*)dataArray))
553 cgio_error_message(message);
554 std::cerr <<
"Buffer array cgio_read_data_type :" << message;
559 currentCoord[memStride[0] * ii] =
static_cast<T
>(dataArray[ii]);
bool HasArray(const char *name)
bool ArrayIsEnabled(const char *name)
void Merge(const vtkCGNSArraySelection &other)
int GetArraySetting(const char *name)
const char * GetArrayName(int index)
void AddArray(const char *name, bool status=true)
void SetArrayStatus(const char *name, bool status)
vtkCGNSReader creates a multi-block dataset and reads unstructured grids and structured meshes from b...
Multiprocessing communication superclass.
represent and manipulate 3D points
constexpr const char * cgns_type_name< float >() noexcept
constexpr const char * cgns_type_name< vtkTypeInt64 >() noexcept
constexpr const char * cgns_type_name() noexcept
constexpr const char * cgns_type_name< double >() noexcept
constexpr const char * cgns_type_name< vtkTypeInt32 >() noexcept
This file defines functions used by vtkCGNSReader and vtkCGNSReaderInternal.
void ReorderMonoCellPointsCGNS2VTK(vtkIdType size, int cell_type, vtkIdType numPointsPerCell, vtkIdType *elements)
int get_section_parent_elements(int cgioNum, double cgioSectionId, int dim, const cgsize_t *srcStart, const cgsize_t *srcEnd, const cgsize_t *srcStride, const cgsize_t *memStart, const cgsize_t *memEnd, const cgsize_t *memStride, const cgsize_t *memDim, vtkIdType *localElementsIdx)
void CGNS2VTKorder(vtkIdType size, const int *cells_types, vtkIdType *elements)
int getFirstNodeId(int cgioNum, double parentId, const char *label, double *id, const char *name=nullptr)
Find the first node with the given label.
int get_XYZ_mesh(int cgioNum, const std::vector< double > &gridChildId, const std::size_t &nCoordsArray, int cellDim, vtkIdType nPts, const cgsize_t *srcStart, const cgsize_t *srcEnd, const cgsize_t *srcStride, const cgsize_t *memStart, const cgsize_t *memEnd, const cgsize_t *memStride, const cgsize_t *memDims, vtkPoints *points)
void removeTrailingWhiteSpaces(char_33 name)
bool isACGNSVariable(const std::vector< CGNSVariable > &varList, const char_33 name)
bool ReadGridForZone(vtkCGNSReader *reader, const BaseInformation &baseInfo, const ZoneInformation &zoneInfo)
Helpers to encapsulate all logic to read various nodes (zones, bc patches etc.).
bool ReadBase(vtkCGNSReader *reader, const BaseInformation &baseInfo)
Helpers to encapsulate all logic to read various nodes (zones, bc patches etc.).
const std::map< CGNS_ENUMT(ElementType_t), int > CellDimensions
int get_section_connectivity(int cgioNum, double cgioSectionId, int dim, const cgsize_t *srcStart, const cgsize_t *srcEnd, const cgsize_t *srcStride, const cgsize_t *memStart, const cgsize_t *memEnd, const cgsize_t *memStride, const cgsize_t *memDim, vtkIdType *localElements)
int GetVTKElemType(CGNS_ENUMT(ElementType_t) elemType, bool &higherOrderWarning, bool &cgnsOrderFlag)
void fillVectorsFromVars(std::vector< CGNSRead::CGNSVariable > &vars, std::vector< CGNSRead::CGNSVector > &vectors, int physicalDim)
int get_section_start_offset(int cgioNum, double cgioSectionId, int dim, const cgsize_t *srcStart, const cgsize_t *srcEnd, const cgsize_t *srcStride, const cgsize_t *memStart, const cgsize_t *memEnd, const cgsize_t *memStride, const cgsize_t *memDim, vtkIdType *localElementsIdx)
std::vector< CGNSVector >::iterator getVectorFromName(std::vector< CGNSVector > &vectorList, const char_33 name)
int setUpRind(int cgioNum, double rindId, int *rind)
bool ReadPatchesForBase(vtkCGNSReader *reader, const BaseInformation &)
Helpers to encapsulate all logic to read various nodes (zones, bc patches etc.).
bool ReadPatch(vtkCGNSReader *reader, const BaseInformation &, const ZoneInformation &zoneInfo, const std::string &patchFamilyname)
Helpers to encapsulate all logic to read various nodes (zones, bc patches etc.).
bool ReadSurfacesForBase(vtkCGNSReader *reader, const BaseInformation &)
Helpers to encapsulate all logic to read various nodes (zones, bc patches etc.).
bool compareName(const char_33 nameOne, const char_33 nameTwo)
CGNS_ENUMT(DataType_t) dt
CGNS_ENUMT(DataType_t) dt