Esempio n. 1
0
bool stk::rebalance::rebalance(mesh::BulkData   & bulk_data  ,
                               const mesh::Selector  & selector ,
                               const VectorField     * rebal_coord_ref ,
                               const ScalarField     * rebal_elem_weight_ref ,
                               Partition & partition,
                               const stk::mesh::EntityRank rank)
{
  //stk::mesh::MetaData &fem_meta = stk::mesh::MetaData::get(bulk_data);
  const stk::mesh::EntityRank element_rank = (rank != stk::mesh::InvalidEntityRank) ? rank :
    stk::topology::ELEMENT_RANK;

  mesh::EntityVector rebal_elem_ptrs;
  mesh::EntityVector entities;

  mesh::MetaData &meta_data = mesh::MetaData::get(bulk_data);
  mesh::get_selected_entities(selector & meta_data.locally_owned_part(),
                              bulk_data.buckets(element_rank),
                              entities);

  //std::cout << "element_rank= " << element_rank << " selector= " << selector << std::endl;
  //stk::rebalance::check_ownership(bulk_data, entities, "here 1");
  for (mesh::EntityVector::iterator iA = entities.begin() ; iA != entities.end() ; ++iA ) {
    if(rebal_elem_weight_ref)
    {
      double * const w = mesh::field_data( *rebal_elem_weight_ref, *iA );
      ThrowRequireMsg( NULL != w,
        "Rebalance weight field is not defined on entities but should be defined on all entities.");
      // Should this be a throw instead???
      if ( *w <= 0.0 ) {
        *w = 1.0 ;
      }
    }
    rebal_elem_ptrs.push_back( *iA );
  }

  (&partition)->set_mesh_info(
      rebal_elem_ptrs,
      rebal_coord_ref,
      rebal_elem_weight_ref);

  bool rebalancingHasOccurred = full_rebalance(bulk_data, &partition, rank);

  return rebalancingHasOccurred;
}
Esempio n. 2
0
bool stk_classic::rebalance::rebalance(mesh::BulkData   & bulk_data  ,
                               const mesh::Selector  & selector ,
                               const VectorField     * rebal_coord_ref ,
                               const ScalarField     * rebal_elem_weight_ref ,
                               Partition & partition,
                               const stk_classic::mesh::EntityRank rank)
{
  stk_classic::mesh::fem::FEMMetaData &fem_meta = stk_classic::mesh::fem::FEMMetaData::get(bulk_data);
  const stk_classic::mesh::EntityRank element_rank = (rank != stk_classic::mesh::InvalidEntityRank) ? rank :
                                             fem_meta.element_rank();

  mesh::EntityVector rebal_elem_ptrs;
  mesh::EntityVector entities;

  mesh::get_selected_entities(selector,
                              bulk_data.buckets(element_rank),
                              entities);

  for (mesh::EntityVector::iterator iA = entities.begin() ; iA != entities.end() ; ++iA ) {
    if(rebal_elem_weight_ref)
    {
      double * const w = mesh::field_data( *rebal_elem_weight_ref, **iA );
      ThrowRequireMsg( NULL != w,
        "Rebalance weight field is not defined on entities but should be defined on all entities.");
      // Should this be a throw instead???
      if ( *w <= 0.0 ) {
        *w = 1.0 ;
      }
    }
    rebal_elem_ptrs.push_back( *iA );
  }

  (&partition)->set_mesh_info(
      rebal_elem_ptrs,
      rebal_coord_ref,
      rebal_elem_weight_ref);

  bool rebalancingHasOccurred = full_rebalance(bulk_data, &partition, rank);

  return rebalancingHasOccurred;
}