Skip to content

Commit

Permalink
Paving the way to VisIt displaying quadratic elements. (#19491)
Browse files Browse the repository at this point in the history
  • Loading branch information
cessenat committed May 9, 2024
1 parent 3aed075 commit 45a14f5
Showing 1 changed file with 113 additions and 1 deletion.
114 changes: 113 additions & 1 deletion src/databases/Silo/avtSiloFileFormat.C
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
#include <string>
#include <vector>

#ifndef DB_ZONETYPE_QUAD_BEAM
// Define fake elts for avoiding ifdef all the time
#define DB_ZONETYPE_QUAD_BEAM 11
#define DB_ZONETYPE_QUAD_TRIANGLE 25
#define DB_ZONETYPE_QUAD_QUAD 26
#define DB_ZONETYPE_QUAD_TET 118
#define DB_ZONETYPE_QUAD_PYRAMID 120
#define DB_ZONETYPE_QUAD_PRISM 113
#define DB_ZONETYPE_QUAD_HEX 116
#endif

using std::map;
using std::set;
Expand Down Expand Up @@ -6556,6 +6566,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
int edge[4][2];
switch (zl->shapetype[seg])
{
case DB_ZONETYPE_QUAD_TRIANGLE:
case DB_ZONETYPE_TRIANGLE:
{
edge[0][0] = zl->nodelist[nlIdx+0];
Expand All @@ -6566,6 +6577,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
edge[2][1] = zl->nodelist[nlIdx+0];
nedges = 3;
}
case DB_ZONETYPE_QUAD_QUAD:
case DB_ZONETYPE_QUAD:
{
edge[0][0] = zl->nodelist[nlIdx+0];
Expand Down Expand Up @@ -6673,6 +6685,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
int face[6][4];
switch (zl->shapetype[seg])
{
case DB_ZONETYPE_QUAD_TET:
case DB_ZONETYPE_TET:
{
face[0][0] = zl->nodelist[nlIdx+0];
Expand All @@ -6693,6 +6706,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
face[3][3] = -1;
nfaces = 4;
}
case DB_ZONETYPE_QUAD_PYRAMID:
case DB_ZONETYPE_PYRAMID:
{
face[0][0] = zl->nodelist[nlIdx+0];
Expand All @@ -6717,6 +6731,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
face[4][3] = -1;
nfaces = 5;
}
case DB_ZONETYPE_QUAD_PRISM:
case DB_ZONETYPE_PRISM:
{
face[0][0] = zl->nodelist[nlIdx+0];
Expand All @@ -6741,6 +6756,7 @@ PaintNodesForAnnotIntFacelist(vtkBitArray *nlvar,
face[4][3] = zl->nodelist[nlIdx+3];
nfaces = 5;
}
case DB_ZONETYPE_QUAD_HEX:
case DB_ZONETYPE_HEX:
{
face[0][0] = zl->nodelist[nlIdx+0];
Expand Down Expand Up @@ -10387,7 +10403,80 @@ avtSiloFileFormat::ReadInConnectivity(vtkUnstructuredGrid *ugrid,
vtk_zonetype != -1)
{
*nl++ = shapesize;
for (k = 0 ; k < (size_t)shapesize ; k++)
int nblinnod = 0 ;
#ifdef DB_ZONETYPE_QUAD_BEAM
// Handle quadratic elements assuming the first nodes are in Silo convention.
// This is to be more easily compatible with an external face extractor that would consider only
// the first linear nodes. This is not an issue for both TETs and HEXs.
switch (vtk_zonetype)
{
case VTK_QUADRATIC_WEDGE:
{
nblinnod = 6 ;
vtkIdType vtk_wedge[nblinnod];
TranslateSiloWedgeToVTKWedge(nodelist, vtk_wedge);
for (k = 0 ; k < nblinnod ; k++)
{
*nl++ = vtk_wedge[k]-origin;
}
break ;
}
case VTK_QUADRATIC_PYRAMID:
{
nblinnod = 5 ;
vtkIdType vtk_pyramid[nblinnod];
TranslateSiloPyramidToVTKPyramid(nodelist, vtk_pyramid);
for (k = 0 ; k < nblinnod ; k++)
{
*nl++ = vtk_pyramid[k]-origin;
}
break ;
}
case VTK_QUADRATIC_TETRA:
{
nblinnod = 4 ;
// Apply the same logic for Silo quadratic tetras : make sure linear nodes are in the Silo convention,
// i.e. not the VTK one.
// Practically, this means that the user may input tetras into Silo using VTK convention without issue.
if (firstTet)
{
firstTet = false;
tetsAreInverted = TetIsInverted(nodelist, ugrid);
static bool haveIssuedWarning = false; (void) haveIssuedWarning;
if (tetsAreInverted)
{
haveIssuedWarning = true;
char msg[1024];
snprintf(msg, sizeof(msg), "An examination of the first quad tet "
"element in this mesh indicates that the node order is "
"inverted from Silo's standard conventions. All tets are "
"being automatically re-ordered.\n"
"Further messages of this issue will be suppressed.");
avtCallback::IssueWarning(msg);
}
}

vtkIdType vtk_tetra[nblinnod];
if (tetsAreInverted)
{
for (k = 0 ; k < 4 ; k++)
vtk_tetra[k] = nodelist[k];
}
else
{
TranslateSiloTetrahedronToVTKTetrahedron(nodelist,
vtk_tetra);
}

for (k = 0 ; k < nblinnod ; k++)
{
*nl++ = vtk_tetra[k]-origin;
}
break ;
}
}
#endif
for (k = nblinnod ; k < (size_t)shapesize ; k++)
*nl++ = *(nodelist+k) - origin;
}
else if (vtk_zonetype == VTK_POLYGON)
Expand Down Expand Up @@ -16239,6 +16328,29 @@ SiloZoneTypeToVTKZoneType(int zonetype)
case DB_ZONETYPE_BEAM:
vtk_zonetype = VTK_LINE;
break;
#ifdef DB_ZONETYPE_QUAD_BEAM
case DB_ZONETYPE_QUAD_BEAM:
vtk_zonetype = VTK_QUADRATIC_EDGE;
break;
case DB_ZONETYPE_QUAD_TRIANGLE:
vtk_zonetype = VTK_QUADRATIC_TRIANGLE;
break;
case DB_ZONETYPE_QUAD_QUAD:
vtk_zonetype = VTK_QUADRATIC_QUAD;
break;
case DB_ZONETYPE_QUAD_TET:
vtk_zonetype = VTK_QUADRATIC_TETRA;
break;
case DB_ZONETYPE_QUAD_PYRAMID:
vtk_zonetype = VTK_QUADRATIC_PYRAMID;
break;
case DB_ZONETYPE_QUAD_PRISM:
vtk_zonetype = VTK_QUADRATIC_WEDGE;
break;
case DB_ZONETYPE_QUAD_HEX:
vtk_zonetype = VTK_QUADRATIC_HEXAHEDRON;
break;
#endif
}

return vtk_zonetype;
Expand Down

0 comments on commit 45a14f5

Please sign in to comment.