MOAB: Mesh Oriented datABase  (version 5.5.0)
test_determinism.cpp File Reference
#include <iostream>
#include "moab/Core.hpp"
#include "TestUtil.hpp"
#include "Internals.hpp"
+ Include dependency graph for test_determinism.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_determinism.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 37 of file test_determinism.cpp.

38 {
39  Interface* iface0 = new Core;
40  Interface* iface1 = new Core;
41 
42  std::string filename = TestDir + "unittest/tet_brick.vtk";
43 
44  ErrorCode err;
45  err = iface0->load_file( filename.c_str() );CHECK_ERR( err );
46  err = iface1->load_file( filename.c_str() );CHECK_ERR( err );
47 
48  Range tets0, verts0, edges0, edges1, tris0, tris1;
49  err = iface0->get_entities_by_dimension( 0, 3, tets0 );CHECK_ERR( err );
50  err = iface0->get_adjacencies( tets0, 1, true, edges0, Interface::UNION );CHECK_ERR( err );
51  err = iface1->get_adjacencies( tets0, 1, true, edges1, Interface::UNION );CHECK_ERR( err );
52  CHECK_EQUAL( edges0, edges1 );
53  err = iface0->get_adjacencies( tets0, 2, true, tris0, Interface::UNION );CHECK_ERR( err );
54  err = iface1->get_adjacencies( tets0, 2, true, tris1, Interface::UNION );CHECK_ERR( err );
55  CHECK_EQUAL( tris0, tris1 );
56 
57  std::vector< EntityHandle > conn_squence;
58 
59  // At that point iface0 and iface1 should have the same entity handler
60  // associated with entities, so we can use one or another, no difference.
61 
62  int repeat = 0;
63  for( ; repeat != 3; repeat++ )
64  {
65 
66  std::vector< EntityHandle > conn_seq;
67 
68  Range to_delete;
69  // Build range of quad to delete form iface0
70  int ii = 0;
71  for( Range::iterator qit = tets0.begin(); qit != tets0.end(); qit++, ii++ )
72  {
73  if( ii % 3 )
74  {
75  to_delete.insert( *qit );
76  const EntityHandle* conn;
77  int number_nodes = 0;
78  iface0->get_connectivity( *qit, conn, number_nodes );
79  conn_seq.insert( conn_seq.end(), conn, &conn[number_nodes] );
80  }
81  }
82  // Buidl tange of edges to delete from iface1
83  // Create gaps in sequence, to be filled later on.
84  for( Range::iterator eit = edges1.begin(); eit != edges1.end(); eit++, ii++ )
85  {
86  if( ii % 3 )
87  {
88  to_delete.insert( *eit );
89  }
90  }
91  for( Range::iterator eit = tris1.begin(); eit != tris1.end(); eit++, ii++ )
92  {
93  if( ii % 3 )
94  {
95  to_delete.insert( *eit );
96  }
97  }
98 
99  err = iface0->delete_entities( to_delete );
100  err = iface1->delete_entities( to_delete );
101 
102  for( unsigned qq = 0; qq != conn_seq.size() / 4; qq++ )
103  {
104  EntityHandle q0, q1;
105  err = iface1->create_element( MBTET, &conn_seq[4 * qq], 4, q1 );CHECK_ERR( err );
106  err = iface0->create_element( MBTET, &conn_seq[4 * qq], 4, q0 );CHECK_ERR( err );
107  CHECK( q0 == q1 );
108  }
109 
110  tets0.clear();
111  err = iface0->get_entities_by_dimension( 0, 3, tets0 );CHECK_ERR( err );
112  Range tets1;
113  err = iface1->get_entities_by_dimension( 0, 3, tets1 );CHECK_ERR( err );
114  CHECK_EQUAL( tets0, tets1 );
115 
116  // Finally check adjacency, this finally check if code is deterministic
117  for( Range::iterator tit = tets1.begin(); tit != tets1.end(); tit++ )
118  {
119  std::vector< EntityHandle > adj0, adj1;
120  err = iface0->get_adjacencies( &*tit, 1, 1, true, adj0 );CHECK_ERR( err );
121  err = iface1->get_adjacencies( &*tit, 1, 1, true, adj1 );CHECK_ERR( err );
122  CHECK_EQUAL( adj0, adj1 );
123  }
124  for( Range::iterator tit = tets1.begin(); tit != tets1.end(); tit++ )
125  {
126  std::vector< EntityHandle > adj0, adj1;
127  err = iface0->get_adjacencies( &*tit, 1, 2, true, adj0 );CHECK_ERR( err );
128  err = iface1->get_adjacencies( &*tit, 1, 2, true, adj1 );CHECK_ERR( err );
129  CHECK_EQUAL( adj0, adj1 );
130  }
131  }
132 
133  delete iface0;
134  delete iface1;
135 
136  return 0;
137 }

References moab::Range::begin(), CHECK, CHECK_EQUAL, CHECK_ERR, moab::Range::clear(), moab::Interface::create_element(), moab::Interface::delete_entities(), moab::Range::end(), ErrorCode, filename, moab::Interface::get_adjacencies(), moab::Interface::get_connectivity(), moab::Interface::get_entities_by_dimension(), moab::Range::insert(), moab::Interface::load_file(), MBTET, and moab::Interface::UNION.