Skip to content

Commit

Permalink
bye bye hexs and tets
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinPrivitera committed Jun 27, 2024
1 parent 423447f commit c6c58ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 178 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
- Changed `conduit::blueprint::mesh::partition_map_back()` function so it will attempt to reuse existing field memory when mapping fields back. This permits `partition_map_back()` to send data from a partitioned mesh into the original mesh where fields were provided from a host code using `Node::set_external()`.
- Changed `generate_sides` to be robust to the case where no fields exist.
- Deprecated braid `quads_and_tris` example in favor of `mixed_2d`.
- Deprecated braid `hexs_and_tris` example in favor of `mixed`.

#### Relay
- Changed `conduit::relay::mpi::communicate_using_schema` to avoid an invalid tag MPI error message on some MPI distributions.
Expand Down
172 changes: 2 additions & 170 deletions src/libs/blueprint/conduit_blueprint_mesh_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2414,177 +2414,9 @@ braid_hexs_and_tets(index_t npts_x,
index_t npts_z,
Node &res)
{
// TODO can we delete this one

res.reset();

int32 nele_hexs_x = (int32)(npts_x - 1);
int32 nele_hexs_y = (int32)(npts_y - 1);
int32 nele_hexs_z = (int32)(npts_z - 1);
int32 nele_hexs = nele_hexs_x * nele_hexs_y * nele_hexs_z;


// Set the number of voxels containing hexs and tets
int32 n_hex_hexs = (nele_hexs > 1)? nele_hexs / 2 : nele_hexs;
int32 n_hex_tets = nele_hexs - n_hex_hexs;

// Compute the sizes of the connectivity array for each element type
int32 hexs_per_hex = 1;
int32 verts_per_hex = 8;
int32 n_hexs_verts = n_hex_hexs * hexs_per_hex * verts_per_hex;

int32 tets_per_hex = 6;
int32 verts_per_tet = 4;
int32 n_tets_verts = n_hex_tets * tets_per_hex * verts_per_tet;


braid_init_example_state(res);
braid_init_explicit_coordset(npts_x,
npts_y,
npts_z,
res["coordsets/coords"]);

// Setup mesh as unstructured indexed_stream mesh of hexs and tets
res["topologies/mesh/type"] = "unstructured";
res["topologies/mesh/coordset"] = "coords";

res["topologies/mesh/elements/shape"] = "mixed";
res["topologies/mesh/elements/shape_map/hex"] = 12; // VTK_HEXAHEDRON
res["topologies/mesh/elements/shape_map/tet"] = 10; // VTK_TETRA


std::vector<int32> shapes;
std::vector<int32> sizes;
std::vector<int32> offsets;

res["topologies/mesh/elements/connectivity"].set( DataType::int32(n_hexs_verts + n_tets_verts) );
int32_array conn = res["topologies/mesh/elements/connectivity"].value();

int32 idx = 0;
int32 elem_count = 0;
int32 last_offset = 0;
for(int32 k = 0; k < nele_hexs_z ; k++)
{
int32 zoff = k * (nele_hexs_x+1)*(nele_hexs_y+1);
int32 zoff_n = (k+1) * (nele_hexs_x+1)*(nele_hexs_y+1);

for(int32 j = 0; j < nele_hexs_y ; j++)
{
int32 yoff = j * (nele_hexs_x+1);
int32 yoff_n = (j+1) * (nele_hexs_x+1);

CONDUIT_INFO("This braid example is deprecated in favor of mixed.")

for(int32 i = 0; i < nele_hexs_x; i++)
{
// Create a local array of the vertex indices
// ordering is same as VTK_HEXAHEDRON
int32 vidx[8] = {zoff + yoff + i
,zoff + yoff + i + 1
,zoff + yoff_n + i + 1
,zoff + yoff_n + i
,zoff_n + yoff + i
,zoff_n + yoff + i + 1
,zoff_n + yoff_n + i + 1
,zoff_n + yoff_n + i};

bool isHex = (elem_count == 0)
|| (elem_count > 1 && elem_count <= n_hex_hexs);


if(isHex)
{
conn[idx++] = vidx[0];
conn[idx++] = vidx[1];
conn[idx++] = vidx[2];
conn[idx++] = vidx[3];

conn[idx++] = vidx[4];
conn[idx++] = vidx[5];
conn[idx++] = vidx[6];
conn[idx++] = vidx[7];

shapes.push_back(12);
sizes.push_back(8);
offsets.push_back(last_offset);
last_offset += 8;
}
else // it is a tet
{
// Create six tets all sharing diagonal from vertex 0 to 6
// Uses SILO convention for vertex order (normals point in)
conn[idx++] = vidx[0];
conn[idx++] = vidx[2];
conn[idx++] = vidx[1];
conn[idx++] = vidx[6];

conn[idx++] = vidx[0];
conn[idx++] = vidx[3];
conn[idx++] = vidx[2];
conn[idx++] = vidx[6];

conn[idx++] = vidx[0];
conn[idx++] = vidx[7];
conn[idx++] = vidx[3];
conn[idx++] = vidx[6];

conn[idx++] = vidx[0];
conn[idx++] = vidx[4];
conn[idx++] = vidx[7];
conn[idx++] = vidx[6];

conn[idx++] = vidx[0];
conn[idx++] = vidx[5];
conn[idx++] = vidx[4];
conn[idx++] = vidx[6];

conn[idx++] = vidx[0];
conn[idx++] = vidx[1];
conn[idx++] = vidx[5];
conn[idx++] = vidx[6];

auto add_to_arrays = [&]()
{
shapes.push_back(10);
sizes.push_back(4);
offsets.push_back(last_offset);
last_offset += 4;
};

add_to_arrays();
add_to_arrays();
add_to_arrays();
add_to_arrays();
add_to_arrays();
add_to_arrays();
}

elem_count++;
}
}
}

res["topologies/mesh/elements/shapes"].set(shapes);
res["topologies/mesh/elements/sizes"].set(sizes);
res["topologies/mesh/elements/offsets"].set(offsets);

Node &fields = res["fields"];

braid_init_example_point_scalar_field(npts_x,
npts_y,
npts_z,
fields["braid"]);

braid_init_example_point_vector_field(npts_x,
npts_y,
npts_z,
fields["vel"]);

// // Omit for now -- the function assumes a uniform element type
// braid_init_example_element_scalar_field(nele_hexs_x,
// nele_hexs_y,
// nele_hexs_z,
// fields["radial"],
// tets_per_hex);
// TODO remove in conduit 0.9.4
}


Expand Down
10 changes: 2 additions & 8 deletions src/tests/blueprint/t_blueprint_mesh_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ TEST(conduit_blueprint_mesh_examples, mesh_3d)
npts_z,
dsets["hexs"]);

blueprint::mesh::examples::braid("hexs_and_tets",
npts_x,
npts_y,
npts_z,
dsets["hexs_and_tets"]);

blueprint::mesh::examples::braid("mixed",
npts_x,
npts_y,
Expand Down Expand Up @@ -332,14 +326,14 @@ TEST(conduit_blueprint_mesh_examples, mesh_3d)
const Node &mesh = itr.next();
std::string name = itr.name();

// Skip output of silo mesh for mixed mesh of hexs and tets for now.
// Skip output of silo mesh for mixed mesh for now.
// The silo output is not yet defined and it throws an exception
// in conduit_silo.cpp::silo_write_ucd_zonelist()
// in the following line that is looking for the 'shape' node:
// std::string topo_shape = shape_block->fetch("shape").as_string();
// which does not exist for indexed_stream meshes.
// The silo writer needs to be updated for this case.
if(name == "hexs_and_tets" || name == "mixed")
if (name == "mixed")
{
CONDUIT_INFO("\tNOTE: skipping output to SILO -- ")
CONDUIT_INFO("feature is unavailable for mixed element meshes")
Expand Down

0 comments on commit c6c58ca

Please sign in to comment.