9 #include <stk_util/parallel/Parallel.hpp>
10 #include <stk_util/parallel/ParallelReduce.hpp>
11 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
13 #include <stk_mesh/base/Types.hpp>
14 #include <stk_mesh/base/MetaData.hpp>
15 #include <stk_mesh/base/BulkData.hpp>
16 #include <stk_mesh/base/FieldData.hpp>
17 #include <stk_mesh/base/GetEntities.hpp>
19 #include <stk_mesh/fem/CreateAdjacentEntities.hpp>
20 #include <stk_mesh/fem/TopologyDimensions.hpp>
21 #include <stk_mesh/fem/FEMMetaData.hpp>
22 #include <stk_mesh/fem/FEMHelpers.hpp>
28 #include <stk_rebalance_utils/RebalanceUtils.hpp>
30 static const size_t NODE_RANK = stk_classic::mesh::fem::FEMMetaData::NODE_RANK;
35 enum { nx = 2, ny = 2 };
38 void disabled_unit_test()
46 unsigned spatial_dimension = 2;
47 std::vector<std::string> rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension);
48 const stk_classic::mesh::EntityRank constraint_rank = rank_names.size();
49 rank_names.push_back(
"Constraint");
55 const stk_classic::mesh::EntityRank element_rank = fem_meta.
element_rank();
57 stk_classic::mesh::fem::CellTopology quad_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
65 const unsigned p_size = bulk_data.parallel_size();
66 const unsigned p_rank = bulk_data.parallel_rank();
68 bulk_data.modification_begin();
72 std::vector<std::vector<stk_classic::mesh::Entity*> > quads(nx);
73 for (
unsigned ix = 0 ; ix < nx ; ++ix ) quads[ix].resize(ny);
75 const unsigned nnx = nx + 1 ;
76 const unsigned nny = ny + 1 ;
77 for (
unsigned iy = 0 ; iy < ny ; ++iy ) {
78 for (
unsigned ix = 0 ; ix < nx ; ++ix ) {
79 stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ;
80 stk_classic::mesh::EntityId nodes[4] ;
81 nodes[0] = 1 + ix + iy * nnx ;
82 nodes[1] = 2 + ix + iy * nnx ;
83 nodes[2] = 2 + ix + ( iy + 1 ) * nnx ;
84 nodes[3] = 1 + ix + ( iy + 1 ) * nnx ;
91 for (
unsigned iy = 0 ; iy <= ny ; ++iy ) {
92 for (
unsigned ix = 0 ; ix <= nx ; ++ix ) {
93 stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ;
103 const unsigned iy_left = 0;
104 const unsigned iy_right = ny;
106 for (
unsigned ix = 0 ; ix <= nx ; ++ix ) {
107 stk_classic::mesh::EntityId nid_left = 1 + ix + iy_left * nnx ;
108 stk_classic::mesh::EntityId nid_right = 1 + ix + iy_right * nnx ;
111 const stk_classic::mesh::EntityId constraint_entity_id = 1 + ix + nny * nnx;
113 bulk_data.declare_relation( c , *n_left , 0 );
114 bulk_data.declare_relation( c , *n_right , 1 );
122 STKUNIT_ASSERT( ! bulk_data.buckets( NODE_RANK ).empty() );
123 STKUNIT_ASSERT( ! bulk_data.buckets( element_rank ).empty() );
126 STKUNIT_ASSERT( bulk_data.buckets( NODE_RANK ).empty() );
127 STKUNIT_ASSERT( bulk_data.buckets( element_rank ).empty() );
131 bulk_data.modification_end();
135 stk_classic::mesh::create_adjacent_entities(bulk_data, add_parts);
140 Teuchos::ParameterList graph;
141 Teuchos::ParameterList lb_method;
142 lb_method.set(
"LOAD BALANCING METHOD" ,
"4");
143 graph.sublist(stk_classic::rebalance::Zoltan::default_parameters_name())=lb_method;
144 stk_classic::rebalance::Zoltan zoltan_partition(comm, spatial_dimension, graph);
151 const double imbalance_threshold = stk_classic::rebalance::check_balance(bulk_data, NULL, fem_meta.
node_rank(), &selector);
152 const bool do_rebal = 1.5 < imbalance_threshold;
155 STKUNIT_ASSERT( !do_rebal );
156 if( (2 == p_size) || (4 == p_size) )
158 STKUNIT_ASSERT_NEAR(imbalance_threshold, 1.0, .1);
162 STKUNIT_ASSERT_LE(imbalance_threshold, 1.5);
167 stk_classic::mesh::EntityVector entities;
171 bool result = stk_classic::rebalance::verify_dependent_ownership(NODE_RANK, entities);
172 STKUNIT_ASSERT( result );