예제 #1
0
void centroid_algorithm(
  const BulkData & bulkData ,
  const VectorFieldType             & elem_centroid ,
  const ElementNodePointerFieldType & elem_node_coord ,
  Part & elem_part,
  EntityRank element_rank )
{
  // Use the "homogeneous subset" concept (see the Domain Model document)
  // for field data storage.  A "homogeneous subset" is called
  // a 'Bucket'.

  // Iterate the set of element buckets:

  const std::vector<Bucket*> & buckets = bulkData.buckets( element_rank );

  for ( std::vector<Bucket*>::const_iterator
        k = buckets.begin() ; k != buckets.end() ; ++k ) {
    Bucket & bucket = **k ;

    // If this bucket is a subset of the given elem_part
    // then want to compute on it.

    if ( has_superset( bucket, elem_part ) ) {

      // Number of elements in the bucket:

      const unsigned size = bucket.size();

      // Aggressive "gather" field data for the elements
      // in the bucket.
      //   double * node_ptr[ nodes_per_element * number_of_elements ]

      double ** node_ptr = field_data( elem_node_coord , bucket.begin() );

      // Element centroid field data
      //   double elem_ptr[ SpatialDim * number_of_elements ]

      double *  elem_ptr = field_data( elem_centroid , bucket.begin() );

      // Call an element function to calculate centroid for
      // contiguous arrays of element field data.

      centroid< ElementTraits >( size , elem_ptr , node_ptr );
    }
  }
}
예제 #2
0
bool comm_mesh_counts( BulkData & M ,
                       std::vector<size_t> & counts ,
                       bool local_flag )
{
  const size_t zero = 0 ;

  // Count locally owned entities

  const FEMMetaData & S = FEMMetaData::get(M);
  const unsigned entity_rank_count = S.entity_rank_count();
  const size_t   comm_count        = entity_rank_count + 1 ;

  std::vector<size_t> local(  comm_count , zero );
  std::vector<size_t> global( comm_count , zero );

  ParallelMachine comm = M.parallel();
  Part & owns = S.locally_owned_part();

  for ( unsigned i = 0 ; i < entity_rank_count ; ++i ) {
    const std::vector<Bucket*> & ks = M.buckets( i );

    std::vector<Bucket*>::const_iterator ik ;

    for ( ik = ks.begin() ; ik != ks.end() ; ++ik ) {
      if ( has_superset( **ik , owns ) ) {
        local[i] += (*ik)->size();
      }
    }
  }

  local[ entity_rank_count ] = local_flag ;

  stk::all_reduce_sum( comm , & local[0] , & global[0] , comm_count );

  counts.assign( global.begin() , global.begin() + entity_rank_count );

  return 0 < global[ entity_rank_count ] ;
}
예제 #3
0
bool has_superset( const Bucket & bucket , const Part & p )
{
  const unsigned ordinal = p.mesh_meta_data_ordinal();
  return has_superset(bucket,ordinal);
}
예제 #4
0
bool centroid_algorithm_unit_test_dimensions(
  const BulkData & bulkData ,
  const VectorFieldType             & elem_centroid ,
  const ElementNodePointerFieldType & elem_node_coord ,
  Part & elem_part,
  EntityRank element_rank )
{
  bool result = true;
  // Use the "homogeneous subset" concept (see the Domain Model document)
  // for field data storage.  A "homogeneous subset" is called
  // a 'Bucket'.

  // Iterate the set of element buckets:

  const std::vector<Bucket*> & buckets = bulkData.buckets( element_rank );

  for ( std::vector<Bucket*>::const_iterator
        k = buckets.begin() ; k != buckets.end() ; ++k ) {
     Bucket & bucket = **k ;

    // If this bucket is a subset of the given elem_part
    // then want to compute on it.

    if ( has_superset( bucket, elem_part ) ) {

      // Number of elements in the bucket:

      const unsigned size = bucket.size();

      // Unit testing the dimension feature
      {
        BucketArray< ElementNodePointerFieldType >
          array( elem_node_coord, bucket.begin(), bucket.end() );
        const unsigned n1 = array.template dimension<0>();
        const unsigned n2 = array.template dimension<1>();
        if ( n1 != ElementTraits::node_count ) {
          std::cerr << "Error!  n1 == " << n1 << " != " << ElementTraits::node_count << " == ElementTraits::node_count" << std::endl;
          result = false;
        }
        if ( n2 != size ) {
          std::cerr << "Error!  n2 == " << n2 << " != " << size << " == size" << std::endl;
          result = false;
        }
        if ( (unsigned) array.size() != n1 * n2 ) {
          std::cerr << "Error!  array.size() == " << array.size() << " != " << n1*n2 << " == n1*n2" << std::endl;
          result = false;
        }
      }

      {
        BucketArray< VectorFieldType > array( elem_centroid , bucket.begin(), bucket.end()  );
        const unsigned n1 = array.template dimension<0>();
        const unsigned n2 = array.template dimension<1>();
        if ( n1 != (unsigned) SpatialDim ) {
          std::cerr << "Error!  n1 == " << n1 << " != " << SpatialDim << " == SpatialDim" << std::endl;
          result = false;
        }
        if ( n2 != size ) {
          std::cerr << "Error!  n2 == " << n2 << " != " << size << " == size" << std::endl;
          result = false;
        }
        if ( (unsigned) array.size() != n1 * n2 ) {
          std::cerr << "Error!  array.size() == " << array.size() << " != " << n1*n2 << " == n1*n2" << std::endl;
          result = false;
        }
      }
    }
  }
  return result;
}