|
Sierra Toolkit
Version of the Day
|
9 #include <use_cases/UseCase_Rebal_1.hpp>
11 #include <stk_util/parallel/Parallel.hpp>
12 #include <stk_util/parallel/ParallelReduce.hpp>
14 #include <stk_mesh/base/FieldData.hpp>
15 #include <stk_mesh/base/GetEntities.hpp>
21 #include <stk_rebalance_utils/RebalanceUtils.hpp>
25 using namespace stk_classic::mesh::fixtures;
38 const unsigned ngx = p_size*(p_size+1)/2;
52 const stk_classic::mesh::EntityRank element_rank = fem_meta.
element_rank();
61 std::vector<stk_classic::mesh::EntityId> my_element_ids;
62 for (
unsigned i = 0 ; i < nx*ny*nz; ++i )
63 my_element_ids.push_back(i+1);
65 fixture.generate_mesh(my_element_ids);
71 for (
unsigned l = 1 ; l <= p_size ; ++l ) {
72 for (
unsigned k = 0 ; k < nz ; ++k ) {
73 for (
unsigned j = 0 ; j < ny ; ++j ) {
74 for (
unsigned i = 0 ; i < l ; ++i ) {
75 const stk_classic::mesh::EntityId elem_id = 1 + nslabs + i + j*ngx + k*ngx*ny;
78 *e_weight = double(ngx) / double(l);
90 Teuchos::ParameterList emptyList;
91 stk_classic::rebalance::Zoltan zoltan_partition(pm, fixture.m_spatial_dimension, emptyList);
97 const double imbalance_threshold = stk_classic::rebalance::check_balance(bulk, &weight_field, element_rank);
98 const bool do_rebal = 1.5 < imbalance_threshold;
101 std::cerr << std::endl
102 <<
"imbalance_threshold after rebalance = " << imbalance_threshold <<
", " << do_rebal << std::endl;
111 result = (fabs(imbalance_threshold - 1.0) < 1.e-8);
112 result = result & (num_local_elems == p_rank+1);
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
FieldTraits< field_type >::data_type * field_data(const field_type &f, const Bucket::iterator i)
Pointer to the field data array.
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
bool rebalance(mesh::BulkData &bulk_data, const mesh::Selector &selector, const VectorField *coord_ref, const ScalarField *elem_weight_ref, Partition &partition, const stk_classic::mesh::EntityRank rank=stk_classic::mesh::InvalidEntityRank)
Rebalance with a Partition object.
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state.
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent....
This is a class for selecting buckets based on a set of meshparts and set logic.
Static functions for dynamic load balancing.
For partitioning of mesh entities over a processing grid.
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
unsigned count_selected_entities(const Selector &selector, const std::vector< Bucket * > &input_buckets)
Count entities in selected buckets (selected by the given selector instance), and sorted by ID.
A fundamental unit within the discretization of a problem domain, including but not limited to nodes,...
Manager for an integrated collection of entities, entity relations, and buckets of field data.
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.