nodes without edges
Issue #31
resolved
I have a mesh that I'm reading in with this simple example code.
#include "moab/Core.hpp"
#include <iostream>
using namespace std;
using namespace moab;
#ifndef MESH_DIR
#define MESH_DIR "."
#endif
string test_file_name = string(MESH_DIR) + string("/screw.h5m");
int main(int argc, char **argv)
{
// Get MOAB instance
Interface* mb = new (std::nothrow) Core;
if (NULL == mb) {
return EXIT_FAILURE;
}
// Load the mesh from file
ErrorCode rval = mb->load_mesh(test_file_name.c_str());MB_CHK_ERR(rval);
// Get verts entities, by type
Range verts;
rval = mb->get_entities_by_type(0, MBVERTEX, verts);MB_CHK_ERR(rval);
// Get edge entities, by type
Range edges;
rval = mb->get_entities_by_type(0, MBEDGE, edges);MB_CHK_ERR(rval);
// Get faces, by dimension, so we stay generic to entity type
Range faces;
rval = mb->get_entities_by_dimension(0, 2, faces);MB_CHK_ERR(rval);
// Get regions, by dimension, so we stay generic to entity type
Range elems;
rval = mb->get_entities_by_dimension(0, 3, elems);MB_CHK_ERR(rval);
// get and create all faces adjacent to cells
faces.clear();
rval = mb->get_adjacencies(elems, 2, true, faces, Interface::UNION); MB_CHK_ERR(rval);
cout << "Number of faces adjacent to cells: " << faces.size() << endl;
// get and create all edges adjacent to cells
edges.clear();
rval = mb->get_adjacencies(elems, 1, true, edges, Interface::UNION); MB_CHK_ERR(rval);
cout << "Number of edges adjacent to cells: " << edges.size() << endl;
std::cout << "verts.size() " << verts.size() << std::endl;
std::cout << "edges.size() " << edges.size() << std::endl;
std::cout << "faces.size() " << faces.size() << std::endl;
std::cout << "elems.size() " << elems.size() << std::endl;
const int n = 17;
std::cout << "Counting edges for node " << n << ":" << std::endl;
for (size_t k = 0; k < edges.size(); k++) {
moab::Range verts;
const EntityHandle kk = edges[k];
mb->get_adjacencies(
&kk,
1,
0,
true,
verts,
moab::Interface::UNION
);
if (verts[0] == n || verts[1] == n) {
std::cout << " beep" << std::endl;
}
}
std::cout << "done." << std::endl;
delete mb;
return 0;
}
The number of entities appears to be reported correctly,
verts.size() 21218
edges.size() 124000
faces.size() 194030
elems.size() 91215
but there are nodes which don't seem to have an edge. The example code checks for node 17, and finds no edge.
Any idea what might be going on?
Comments (4)
-
-
reporter Makes sense.
Is there a smart way to detect "free" nodes to give the user some meaningful feedback? So far, the best thing I can think of is to iterate over all of them and count the adjacent edges.
-
you can use connectivity, something like this
Range verts; rval = mb->get_entities_by_type(0, MBVERTEX, verts);MB_CHK_ERR(rval); Range elems; rval = mb->get_entities_by_dimension(0, 3, elems);MB_CHK_ERR(rval); // if these are your primary elements Range connectedVertices; rval = mb->get_connectivity(elems, connectedVertices);MB_CHK_ERR(rval); Range freeVertices = subtract (verts, connectedVertices);
-
reporter - changed status to resolved
Thanks!
- Log in to comment
those nodes were "free" from the beginning, they are not connected to any element ,face or edge They were probably left-over from mesh generation; some geometry vertices used to describe some splines, probably
these nodes cause issues with vtk writer, because we create extra cells , one-node cells for them
https://bitbucket.org/fathomteam/moab/issues/23/mbconvert-cell-array-global_id-with-1
on this branch, we do not create them anymore (except some write option "CREATE_ONE_NODE_CELLS;")
https://bitbucket.org/fathomteam/moab/branch/iulian07/extrude_poly
still issues when we create them, the reader does not work