Exemplo n.º 1
0
void get_selected_entities( const Selector & selector ,
                            const BucketVector & input_buckets ,
                            std::vector< Entity> & entities )
{
  size_t count = count_selected_entities(selector,input_buckets);

  entities.resize(count);

  const BucketVector::const_iterator ie = input_buckets.end();
        BucketVector::const_iterator ik = input_buckets.begin();

  for ( size_t j = 0 ; ik != ie ; ++ik ) {
    const Bucket & k = ** ik ;
    if ( selector( k ) ) {
      const size_t n = k.size();
      for ( size_t i = 0; i < n; ++i, ++j ) {
        entities[j] = k[i] ;
      }
    }
  }

  if (input_buckets.size() > 0) {
    std::sort(entities.begin(), entities.end(), EntityLess(input_buckets[0]->mesh()));
  }
}
Exemplo n.º 2
0
unsigned count_selected_entities(
  const Selector & selector ,
  const BucketVector & input_buckets )
{
  size_t count = 0;

  const BucketVector::const_iterator ie = input_buckets.end();
        BucketVector::const_iterator ik = input_buckets.begin();

  for ( ; ik != ie ; ++ik ) {
    const Bucket & k = ** ik ;
    if ( selector( k ) ) { count += k.size(); }
  }

  return count ;
}
Exemplo n.º 3
0
  void internal_check_no_null_buckets_invariant() const
  {
#ifndef NDEBUG
    for (int i = 0, e = m_buckets.size(); i < e; ++i) {
      ThrowAssert(m_buckets[i] != NULL);
    }
#endif
  }
Exemplo n.º 4
0
  void internal_check_size_invariant() const
  {
#ifndef NDEBUG
    size_t sum = 0;
    for (size_t i = 0, e = m_buckets.size(); i < e; ++i) {
      sum += m_buckets[i]->size();
      m_buckets[i]->check_size_invariant();
    }
    ThrowAssertMsg(sum == m_size, "Inconsistent sizes, bucket sum is " << sum << ", m_size is " << m_size);
#endif
  }
Exemplo n.º 5
0
 // The partition has no buckets, not even an empty one left after removing all its
 // entities.
 bool no_buckets() const { return m_buckets.empty(); }
Exemplo n.º 6
0
void UnitTestStkMeshBulkModification::test_all_local_elements()
{
  BulkData& bulk_data = initialize_ring_fixture();
  {
    const stk::mesh::Part& universal = m_ring_mesh.m_meta_data.universal_part();
    stk::mesh::Selector universal_selector(universal);

    BucketVector buckets = bulk_data.get_buckets(stk::topology::NODE_RANK, universal_selector);

    // get all the nodes that this process knows about
    std::vector< Entity> universal_entities;
    for (BucketVector::iterator itr = buckets.begin();
         itr != buckets.end(); ++itr) {
      Bucket& b = **itr;
      for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) {
        universal_entities.push_back(*bitr);
      }
    }
    buckets.clear();

    buckets = bulk_data.get_buckets(stk::topology::ELEMENT_RANK, universal_selector);

    // get all the elements that this process knows about
    for (BucketVector::iterator itr = buckets.begin();
         itr != buckets.end(); ++itr) {
      Bucket& b = **itr;
      for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) {
        universal_entities.push_back(*bitr);
      }
    }
    buckets.clear();

    // universal entities should now have all the universal nodes and elements
    stk::util::sort_and_unique(universal_entities, stk::mesh::EntityLess(bulk_data));

    // get the buckets that we need to traverse to get the locally used elements
    stk::mesh::Selector locally_used_selector =
      m_ring_mesh.m_meta_data.locally_owned_part() |
      m_ring_mesh.m_meta_data.globally_shared_part();

    buckets = bulk_data.get_buckets(stk::topology::ELEMENT_RANK, locally_used_selector);

    // get the locally used elements and store them in entities
    std::vector< Entity> entities;
    for (BucketVector::iterator itr = buckets.begin();
         itr != buckets.end(); ++itr) {
      Bucket& b = **itr;
      for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) {
        entities.push_back(*bitr);
      }
    }

    // call find_closure, passing in the locally used elements
    std::vector< Entity> entities_closure;
    stk::mesh::find_closure(bulk_data, entities, entities_closure);

    // The ghosted entities on this proc (element or node) should be contained
    // in the closure of the locally-used element on some other proc, so we
    // expect that they will be part of the closure. In other
    // words, the set of entities returned by find_closure should exactly match
    // the set of universal entities (nodes and elements).
    ASSERT_TRUE(universal_entities.size() == entities_closure.size());
    for (size_t i = 0; i < entities_closure.size(); ++i) {
      EXPECT_TRUE(universal_entities[i] == entities_closure[i]);
    }
  }
}
Exemplo n.º 7
0
void UnitTestStkMeshBulkModification::test_all_local_nodes()
{
  BulkData& bulk_data = initialize_ring_fixture();

  {
    std::vector< Entity> entities;
    std::vector< Entity> entities_closure;
    find_closure(bulk_data, entities, entities_closure);

    // the closure of the an empty set of entities on all procs should be empty
    EXPECT_TRUE(entities_closure.empty());
  }

  {
    // Get a selector for the univeral part (contains local, shared, and ghosted)
    const stk::mesh::Part& universal = m_ring_mesh.m_meta_data.universal_part();
    stk::mesh::Selector universal_selector(universal);

    // Get the buckets that will give us the universal nodes
    BucketVector buckets = bulk_data.get_buckets(NODE_RANK, universal_selector);

    // Get the universal nodes
    std::vector< Entity> universal_entities;
    for (BucketVector::iterator itr = buckets.begin();
         itr != buckets.end(); ++itr) {
      Bucket& b = **itr;
      for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) {
        universal_entities.push_back(*bitr);
      }
    }
    buckets.clear();

    stk::util::sort_and_unique(universal_entities, stk::mesh::EntityLess(bulk_data));

    // Get the buckets that will give us the locally used nodes
    stk::mesh::Selector locally_used_selector =
      m_ring_mesh.m_meta_data.locally_owned_part() |
      m_ring_mesh.m_meta_data.globally_shared_part();

    buckets = bulk_data.get_buckets(stk::topology::NODE_RANK, locally_used_selector);

    // Get the locally used nodes
    std::vector< Entity> entities;
    for (BucketVector::iterator itr = buckets.begin();
         itr != buckets.end(); ++itr) {
      Bucket& b = **itr;
      for (BucketIterator bitr = b.begin(); bitr != b.end(); ++bitr) {
        entities.push_back(*bitr);
      }
    }

    // Get the closure, passing in the locally used nodes on each proc
    std::vector< Entity> entities_closure;
    stk::mesh::find_closure(bulk_data, entities, entities_closure);

    // The ghosted nodes on this part will be locally used on one of the other
    // procs, so we expect that they will be part of the closure. In other
    // words, the set of nodes returned by find_closure should exactly match
    // the set of universal nodes.
    ASSERT_TRUE(universal_entities.size() == entities_closure.size());
    for (size_t i = 0; i < entities_closure.size(); ++i) {
      EXPECT_TRUE(universal_entities[i] == entities_closure[i]);
    }
  }
}