9 #include <use_cases/UseCase_Rebal_3.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> 16 #include <stk_mesh/base/MetaData.hpp> 17 #include <stk_mesh/base/BulkData.hpp> 19 #include <stk_mesh/fem/FEMMetaData.hpp> 20 #include <stk_mesh/fem/FEMHelpers.hpp> 21 #include <stk_mesh/fem/CoordinateSystems.hpp> 22 #include <stk_mesh/fem/CreateAdjacentEntities.hpp> 24 #include <stk_mesh/fixtures/HexFixture.hpp> 30 #include <stk_rebalance_utils/RebalanceUtils.hpp> 42 class Test_Case_3_Partition :
public stk_classic::rebalance::Zoltan {
46 Teuchos::ParameterList & rebal_region_parameters,
47 std::string parameters_name=default_parameters_name());
48 virtual ~Test_Case_3_Partition();
49 virtual bool partition_dependents_needed()
const;
54 Teuchos::ParameterList & rebal_region_parameters,
55 std::string parameters_name) :
57 Test_Case_3_Partition::~Test_Case_3_Partition() {}
58 bool Test_Case_3_Partition::partition_dependents_needed()
const 61 enum { nx = 4, ny = 4 };
65 unsigned spatial_dimension = 2;
66 std::vector<std::string> rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension);
67 const stk_classic::mesh::EntityRank constraint_rank = rank_names.size();
68 rank_names.push_back(
"Constraint");
75 const stk_classic::mesh::EntityRank element_rank = fem_meta.
element_rank();
76 const stk_classic::mesh::EntityRank side_rank = fem_meta.
side_rank();
77 const stk_classic::mesh::EntityRank node_rank = fem_meta.
node_rank();
79 stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
81 stk_classic::mesh::fem::CellTopology side_top(shards::getCellTopologyData<shards::Line<2> >());
92 const unsigned p_rank = bulk_data.parallel_rank();
94 bulk_data.modification_begin();
98 std::vector<stk_classic::mesh::EntityVector> quads(nx);
99 for (
unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny);
101 const unsigned nnx = nx + 1 ;
102 const unsigned nny = ny + 1 ;
103 unsigned face_id = 1;
104 for (
unsigned iy = 0 ; iy < ny ; ++iy ) {
105 for (
unsigned ix = 0 ; ix < nx ; ++ix ) {
106 stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ;
107 stk_classic::mesh::EntityId nodes[4] ;
108 nodes[0] = 1 + ix + iy * nnx ;
109 nodes[1] = 2 + ix + iy * nnx ;
110 nodes[2] = 2 + ix + ( iy + 1 ) * nnx ;
111 nodes[3] = 1 + ix + ( iy + 1 ) * nnx ;
122 for (
unsigned iy = 0 ; iy < ny ; ++iy ) {
123 for (
unsigned ix = 0 ; ix < nx ; ++ix ) {
124 stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ;
130 for (
unsigned iy = 0 ; iy <= ny ; ++iy ) {
131 for (
unsigned ix = 0 ; ix <= nx ; ++ix ) {
132 stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ;
143 const unsigned iy_bottom = 0;
144 const unsigned iy_top = ny;
146 for (
unsigned ix = 0 ; ix <= nx ; ++ix ) {
147 stk_classic::mesh::EntityId nid_bottom = 1 + ix + iy_bottom * nnx ;
148 stk_classic::mesh::EntityId nid_top = 1 + ix + iy_top * nnx ;
151 const stk_classic::mesh::EntityId constraint_entity_id = 1 + ix + nny * nnx;
153 bulk_data.declare_relation( c , *n_bottom , 0 );
154 bulk_data.declare_relation( c , *n_top , 1 );
160 bulk_data.modification_end();
167 Teuchos::ParameterList emptyList;
168 stk_classic::rebalance::use_cases::Test_Case_3_Partition zoltan_partition(comm, spatial_dimension, emptyList);
171 const double imbalance_threshold = 1.5;
172 const bool do_rebal = imbalance_threshold < stk_classic::rebalance::check_balance(bulk_data, NULL, side_rank, &selector);
175 std::cerr << std::endl
176 <<
"imbalance_threshold after rebalance = " << imbalance_threshold <<
", "<<do_rebal << std::endl;
179 bool result = !do_rebal ;
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.
FieldTraits< field_type >::data_type * field_data(const field_type &f, const Bucket::iterator i)
Pointer to the field data array.
Entity & declare_element(BulkData &mesh, Part &part, const EntityId elem_id, const EntityId node_id[])
Declare an element member of a Part with a CellTopology and nodes conformal to that topology...
This is a class for selecting buckets based on a set of meshparts and set logic.
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.
An application-defined subset of a problem domain.
Manager for an integrated collection of entities, entity relations, and buckets of field data...
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
For partitioning of mesh entities over a processing grid.
Static functions for dynamic load balancing.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Class for implementing Zoltan based rebalancing.
Entity & declare_element_side(Entity &elem, Entity &side, const unsigned local_side_id, Part *part)
Create (or find) an element side.