MOAB: Mesh Oriented datABase  (version 5.5.0)
test_adj.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
#include "TestUtil.hpp"
#include "Internals.hpp"
+ Include dependency graph for test_adj.cpp:

Go to the source code of this file.

Macros

#define IS_BUILDING_MB
 

Functions

int main ()
 

Macro Definition Documentation

◆ IS_BUILDING_MB

#define IS_BUILDING_MB

MOAB, a Mesh-Oriented datABase, is a software component for creating, storing and accessing finite element mesh data.

Copyright 2004 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

Definition at line 29 of file test_adj.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 37 of file test_adj.cpp.

38 {
39  Interface* iface = new Core;
40 
41  std::string filename;
42 
43 #ifdef MOAB_HAVE_HDF5
44  filename = TestDir + "unittest/testquad-cyl.h5m";
45 #else
46  filename = TestDir + "unittest/hexes_mixed.vtk";
47 #endif
48 
49  ErrorCode err;
50  err = iface->load_mesh( filename.c_str() );CHECK_ERR( err );
51 
52  Range quads, verts;
53  err = iface->get_entities_by_dimension( 0, 0, verts );CHECK_ERR( err );
54  err = iface->get_entities_by_dimension( 0, 2, quads );CHECK_ERR( err );
55 
56  for( Range::iterator it = verts.begin(); it != verts.end(); it++ )
57  std::cout << "verts[" << ( *it - *verts.begin() ) << "] = " << *it << std::endl;
58 
59  std::vector< EntityHandle > conn;
60  for( Range::iterator it = quads.begin(); it != quads.end(); it++ )
61  {
62  conn.clear();
63  err = iface->get_connectivity( &*it, 1, conn );CHECK_ERR( err );
64  std::cout << "quads[" << ( *it - *quads.begin() ) << "] = " << *it << " :: conn = [" << conn[0] << ", "
65  << conn[1] << ", " << conn[2] << ", " << conn[3] << "]" << std::endl;
66  }
67 
68  std::vector< EntityHandle > nodes;
69  int error;
71  CHECK_EQUAL( 0, error );
72  std::cout << "h = " << h << std::endl;
73 
74  err = iface->get_adjacencies( &h, 1, 0, true, nodes );CHECK_ERR( err );
75 
76  for( int i = 0; i < (int)nodes.size(); i++ )
77  std::cout << "nodes[" << i << "] = " << nodes[i] << " ";
78  std::cout << std::endl;
79 
80  std::vector< EntityHandle > edgs;
81  err = iface->get_adjacencies( &h, 1, 1, true, edgs );CHECK_ERR( err );
82 
83  for( int i = 0; i < (int)edgs.size(); i++ )
84  std::cout << "edgs[" << i << "] = " << edgs[i] << " ";
85  std::cout << std::endl;
86 
87  // faces to nodes
88 
89  for( unsigned int i = 0; i < edgs.size(); i++ )
90  {
91  nodes.clear();
92  err = iface->get_adjacencies( &edgs[i], 1, 0, true, nodes );CHECK_ERR( err );
93  std::cout << "edge " << ID_FROM_HANDLE( edgs[i] ) << std::endl;
94  std::cout << "nodes = ";
95  for( unsigned int j = 0; j < nodes.size(); j++ )
96  std::cout << nodes[j] << " ";
97  std::cout << std::endl;
98  }
99 
100  delete iface;
101 
102  return 0;
103 }

References moab::Range::begin(), CHECK_EQUAL, CHECK_ERR, moab::CREATE_HANDLE(), moab::Range::end(), moab::error(), ErrorCode, filename, moab::Interface::get_adjacencies(), moab::Interface::get_connectivity(), moab::Interface::get_entities_by_dimension(), moab::ID_FROM_HANDLE(), iface, moab::Interface::load_mesh(), MB_START_ID, and MBQUAD.