12 #include "GmshConfig.h"
14 #if defined(HAVE_LIBCGNS)
17 #if CGNS_VERSION < 3100
21 template <
class scalar>
24 int cgnsError(
const char *file,
const int line,
const int fileIndex = -1);
26 void printProgress(
const char *cstr, std::size_t i, std::size_t num);
28 #if defined(HAVE_LIBCGNS_CPEX0045)
29 int evalMonomialBasis(
int mshType,
const std::vector<double> &u,
30 const std::vector<double> &v,
36 inline cgsize_t ijk2Ind(
const cgsize_t *ijk,
const cgsize_t *nijk);
40 inline cgsize_t ijk2Ind<2>(
const cgsize_t *ijk,
const cgsize_t *nijk)
42 return ijk[1] * nijk[0] + ijk[0];
47 inline cgsize_t ijk2Ind<3>(
const cgsize_t *ijk,
const cgsize_t *nijk)
49 return (ijk[2] * nijk[1] + ijk[1]) * nijk[0] + ijk[0];
53 template <
int DIM>
inline cgsize_t nbTotFromIJK(
const cgsize_t *nijk);
56 template <>
inline cgsize_t nbTotFromIJK<2>(
const cgsize_t *nijk)
58 return nijk[0] * nijk[1];
62 template <>
inline cgsize_t nbTotFromIJK<3>(
const cgsize_t *nijk)
64 return nijk[0] * nijk[1] * nijk[2];
68 struct UnstructuredIndexing {
69 static cgsize_t nbEntInRange(
const cgsize_t *range);
70 static void entFromRange(
const cgsize_t *range, std::vector<cgsize_t> &elt);
71 static void entFromList(
const std::vector<cgsize_t> &list,
72 std::vector<cgsize_t> &elt);
75 inline cgsize_t UnstructuredIndexing::nbEntInRange(
const cgsize_t *range)
77 return range[1] - range[0] + 1;
80 inline void UnstructuredIndexing::entFromRange(
const cgsize_t *range,
81 std::vector<cgsize_t> &ent)
83 std::size_t nb = range[1] - range[0] + 1;
85 cgsize_t iMin = range[0] - 1;
86 for(std::size_t i = 0; i < nb; i++) ent[i] = iMin + i;
89 inline void UnstructuredIndexing::entFromList(
const std::vector<cgsize_t> &list,
90 std::vector<cgsize_t> &ent)
92 std::size_t nb = list.size();
94 for(std::size_t i = 0; i < nb; i++) ent[i] = list[i] - 1;
99 template <
int DIM>
struct StructuredIndexing {
100 static cgsize_t nbEntInRange(
const cgsize_t *range);
101 static void entFromRange(
const cgsize_t *range,
const cgsize_t *nbEntIJK,
102 std::vector<cgsize_t> &elt);
103 static void entFromList(
const std::vector<cgsize_t> &list,
104 const cgsize_t *nbEntIJK, std::vector<cgsize_t> &elt);
108 inline cgsize_t StructuredIndexing<DIM>::nbEntInRange(
const cgsize_t *range)
111 for(
int d = 0; d < DIM; d++) {
112 const cgsize_t diff = range[DIM + d] - range[d];
113 nb *= (diff >= 0) ? diff + 1 : -diff + 1;
118 #endif // HAVE_LIBCGNS
120 #endif // CGNS_COMMON_H