13 #include "../general/binaryio.hpp"
26 int bmin = std::min(std::min(b[0], b[1]), b[2]);
37 for (
int d=0; d<3; ++d)
39 if (b[(d+2)%3] == max)
46 for (
int d=0; d<3; ++d)
48 if (b[(d+1)%3] == min)
51 return idx + b[d] - (min + 1);
53 idx += max - (min + 1);
66 int bmin = std::min(std::min(std::min(b[0], b[1]), b[2]), b[3]);
71 idx += 2*(ref*ref + 1);
80 static const int VertexMaxCoords[4] = {3,0,1,2};
84 static const int EdgeMinCoords[6][2] = {{1,2},{2,3},{0,2}, {0,1},{1,3},{0,3}};
87 static const int EdgeCountingCoord[6] = {0,1,3,2,2,2};
93 static const int FaceMinCoord[4] = {1,3,0,2};
99 static const int FaceBCoords[4][3] = {{0,2,3}, {2,0,1}, {2,1,3}, {1,0,3}};
102 for (
int vertex = 0; vertex < 4; vertex++)
104 if (b[VertexMaxCoords[vertex]] == max)
112 for (
int edge = 0; edge < 6; edge++)
114 if (b[EdgeMinCoords[edge][0]] == min && b[EdgeMinCoords[edge][1]] == min)
117 return idx + b[EdgeCountingCoord[edge]] - (min + 1);
119 idx += max - (min + 1);
122 for (
int face = 0; face < 4; face++)
124 if (b[FaceMinCoord[face]] == min)
128 for (
int i = 0; i < 3; i++)
130 projectedb[i] = b[FaceBCoords[face][i]] - min;
136 idx += (ref+1)*(ref+2)/2 - 3*ref;
143 return i + ref*(j - 1) - (j*(j + 1))/2;
152 int ijbdr = (i + j == ref);
153 int kbdr = (k == 0 || k == ref);
155 int nbdr = ibdr + jbdr + ijbdr + kbdr;
158 if (i < 0 || i > ref || j < 0 || j > ref || i + j > ref || k < 0 || k > ref)
160 MFEM_ABORT(
"Invalid index")
166 return (ibdr && jbdr ? 0 : (jbdr && ijbdr ? 1 : 2)) + (k ? 3 : 0);
176 return offset + (k-1)
177 + ((ibdr && jbdr) ? 0 : (jbdr && ijbdr ? 1 : 2))*om1;
183 offset += (k == ref ? 3*om1 : 0);
186 return offset + i - 1;
191 return offset + j - 1;
195 return offset + (ref - j - 1);
202 int ntfdof = (om1 - 1)*om1/2;
203 int nqfdof = om1*om1;
222 return offset + (i - 1) + om1*(k - 1);
227 return offset + (ref - i - 1) + om1*(k - 1);
230 return offset + j - 1 + om1*(k - 1);
234 offset += 2*ntfdof + 3*nqfdof;
249 if (idx_in == 0 || idx_in == ref)
251 return idx_in ? 1 : 0;
260 bool ibdr = (i == 0 || i == ref);
261 bool jbdr = (j == 0 || j == ref);
264 return (i ? (j ? 2 : 1) : (j ? 3 : 0));
269 return (i - 1) + (j ? ref - 1 + ref - 1 : 0) + offset;
273 return (j - 1) + (i ? ref - 1 : 2 * (ref - 1) + ref - 1) + offset;
277 offset += 2 * (ref - 1 + ref - 1);
278 return offset + (i - 1) + (ref - 1) * ((j - 1));
285 int j = (idx_in / n) % n;
286 int k = idx_in / (n*n);
287 bool ibdr = (i == 0 || i == ref);
288 bool jbdr = (j == 0 || j == ref);
289 bool kbdr = (k == 0 || k == ref);
291 int nbdr = (ibdr ? 1 : 0) + (jbdr ? 1 : 0) + (kbdr ? 1 : 0);
295 return (i ? (j ? 2 : 1) : (j ? 3 : 0)) + (k ? 4 : 0);
305 (j ? ref - 1 + ref - 1 : 0) +
306 (k ? 2*(ref - 1 + ref - 1) : 0) +
313 (i ? ref - 1 : 2*(ref - 1) + ref - 1) +
314 (k ? 2*(ref - 1 + ref - 1) : 0) +
318 offset += 4*(ref - 1) + 4*(ref - 1);
319 return (k - 1) + (ref - 1)*(i ? (j ? 3 : 1) : (j ? 2 : 0))
323 offset += 4*(ref - 1 + ref - 1 + ref - 1);
328 return (j - 1) + ((ref - 1)*(k - 1))
329 + (i ? (ref - 1)*(ref - 1) : 0) + offset;
331 offset += 2*(ref - 1)*(ref - 1);
335 + ((ref - 1)*(k - 1))
336 + (j ? (ref - 1)*(ref - 1) : 0) + offset;
338 offset += 2*(ref - 1)*(ref - 1);
340 return (i - 1) + ((ref - 1)*(j - 1))
341 + (k ? (ref - 1)*(ref - 1) : 0) + offset;
345 offset += 2*((ref - 1)*(ref - 1) +
346 (ref - 1)*(ref - 1) +
347 (ref - 1)*(ref - 1));
348 return offset + (i - 1) + (ref - 1)*((j - 1) + (ref - 1)*(k - 1));
351 MFEM_ABORT(
"CartesianToVTKOrderingTensor only supports tensor"
367 for (b[1]=0; b[1]<=ref; ++b[1])
369 for (b[0]=0; b[0]<=ref-b[1]; ++b[0])
371 b[2] = ref - b[0] - b[1];
380 for (
int k=0; k<=ref; k++)
382 for (
int j=0; j<=k; j++)
384 for (
int i=0; i<=j; i++)
389 b[3] = ref-b[0]-b[1]-b[2];
398 for (
int k=0; k<=ref; k++)
400 for (
int j=0; j<=ref; j++)
402 for (
int i=0; i<=ref-j; i++)
411 for (
int idx=0; idx<nnodes; ++idx)
419 uint32_t nbytes,
int compression_level)
421 if (compression_level == 0)
431 MFEM_ASSERT(compression_level >= -1 && compression_level <= 9,
432 "Compression level must be between -1 and 9 (inclusive).");
433 uLongf buf_sz = compressBound(nbytes);
434 std::vector<unsigned char> buf(buf_sz);
435 compress2(buf.data(), &buf_sz,
static_cast<const Bytef *
>(bytes), nbytes,
439 std::vector<uint32_t> header(4);
448 MFEM_ABORT(
"MFEM must be compiled with ZLib support to output "
449 "compressed binary data.")
457 int8_t *x8 =
reinterpret_cast<int8_t *
>(&x16);
469 return "LittleEndian";
int GetNPoints() const
Returns the number of the points in the integration rule.
int CartesianToVTKPrism(int i, int j, int k, int ref)
int BarycentricToVTKTetra(int *b, int ref)
int VTKTriangleDOFOffset(int ref, int i, int j)
int BarycentricToVTKTriangle(int *b, int ref)
void WriteBase64(std::ostream &out, const void *bytes, size_t nbytes)
GeometryRefiner GlobGeometryRefiner
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
int CartesianToVTKTensor(int idx_in, int ref, Geometry::Type geom)
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
const char * VTKByteOrder()
void WriteVTKEncodedCompressed(std::ostream &out, const void *bytes, uint32_t nbytes, int compression_level)
void CreateVTKElementConnectivity(Array< int > &con, Geometry::Type geom, int ref)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...