10 #include <stk_mesh/fixtures/BoxFixture.hpp> 12 #include <stk_util/environment/ReportHandler.hpp> 14 #include <stk_mesh/base/Types.hpp> 15 #include <stk_mesh/base/MetaData.hpp> 16 #include <stk_mesh/base/BulkData.hpp> 17 #include <stk_mesh/base/GetEntities.hpp> 18 #include <stk_mesh/base/Field.hpp> 19 #include <stk_mesh/base/FieldData.hpp> 20 #include <stk_mesh/base/Comm.hpp> 21 #include <stk_mesh/base/GetBuckets.hpp> 31 const std::vector<std::string>& entity_names )
32 : m_fem_meta ( spatial_dimension, entity_names ),
33 m_bulk_data ( fem::FEMMetaData::get_meta_data(m_fem_meta) , pm , block_size ),
36 m_previous_state (
stk_classic::mesh::BulkData::MODIFIABLE )
39 Entity& BoxFixture::get_new_entity ( EntityRank rank , EntityId parallel_dependent_id )
41 return m_bulk_data.declare_entity ( rank , parallel_dependent_id*m_comm_size + m_comm_rank + 1 , std::vector<Part *> () );
44 void BoxFixture::generate_boxes(
const BOX root_box,
47 const unsigned p_rank = m_bulk_data.parallel_rank();
48 const unsigned p_size = m_bulk_data.parallel_size();
49 const unsigned ngx = root_box[0][1] - root_box[0][0] ;
50 const unsigned ngy = root_box[1][1] - root_box[1][0] ;
52 BOX *
const p_box =
new BOX[ p_size ];
54 box_partition( 0 , p_size , 2 , root_box , & p_box[0] );
56 local_box[0][0] = p_box[ p_rank ][0][0] ;
57 local_box[0][1] = p_box[ p_rank ][0][1] ;
58 local_box[1][0] = p_box[ p_rank ][1][0] ;
59 local_box[1][1] = p_box[ p_rank ][1][1] ;
60 local_box[2][0] = p_box[ p_rank ][2][0] ;
61 local_box[2][1] = p_box[ p_rank ][2][1] ;
65 std::vector<unsigned> local_count ;
69 for (
int k = local_box[2][0] ; k < local_box[2][1] ; ++k ) {
70 for (
int j = local_box[1][0] ; j < local_box[1][1] ; ++j ) {
71 for (
int i = local_box[0][0] ; i < local_box[0][1] ; ++i ) {
72 const EntityId n0= 1 + (i+0) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
73 const EntityId n1= 1 + (i+1) + (j+0) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
74 const EntityId n2= 1 + (i+1) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
75 const EntityId n3= 1 + (i+0) + (j+1) * (ngx+1) + (k+0) * (ngx+1) * (ngy+1);
76 const EntityId n4= 1 + (i+0) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
77 const EntityId n5= 1 + (i+1) + (j+0) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
78 const EntityId n6= 1 + (i+1) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
79 const EntityId n7= 1 + (i+0) + (j+1) * (ngx+1) + (k+1) * (ngx+1) * (ngy+1);
81 const EntityId elem_id = 1 + i + j * ngx + k * ngx * ngy;
83 Entity & node0 = m_bulk_data.declare_entity( 0 , n0 , no_parts );
84 Entity & node1 = m_bulk_data.declare_entity( 0 , n1 , no_parts );
85 Entity & node2 = m_bulk_data.declare_entity( 0 , n2 , no_parts );
86 Entity & node3 = m_bulk_data.declare_entity( 0 , n3 , no_parts );
87 Entity & node4 = m_bulk_data.declare_entity( 0 , n4 , no_parts );
88 Entity & node5 = m_bulk_data.declare_entity( 0 , n5 , no_parts );
89 Entity & node6 = m_bulk_data.declare_entity( 0 , n6 , no_parts );
90 Entity & node7 = m_bulk_data.declare_entity( 0 , n7 , no_parts );
91 Entity & elem = m_bulk_data.declare_entity( 3 , elem_id , no_parts );
93 m_bulk_data.declare_relation( elem , node0 , 0 );
94 m_bulk_data.declare_relation( elem , node1 , 1 );
95 m_bulk_data.declare_relation( elem , node2 , 2 );
96 m_bulk_data.declare_relation( elem , node3 , 3 );
97 m_bulk_data.declare_relation( elem , node4 , 4 );
98 m_bulk_data.declare_relation( elem , node5 , 5 );
99 m_bulk_data.declare_relation( elem , node6 , 6 );
100 m_bulk_data.declare_relation( elem , node7 , 7 );
108 void BoxFixture::box_partition(
int ip ,
int up ,
int axis ,
112 const int np = up - ip ;
114 p_box[ip][0][0] = box[0][0] ; p_box[ip][0][1] = box[0][1] ;
115 p_box[ip][1][0] = box[1][0] ; p_box[ip][1][1] = box[1][1] ;
116 p_box[ip][2][0] = box[2][0] ; p_box[ip][2][1] = box[2][1] ;
119 const int n = box[ axis ][1] - box[ axis ][0] ;
120 const int np_low = np / 2 ;
121 const int np_upp = np - np_low ;
123 const int n_upp = (int) (((
double) n) * ( ((double)np_upp) / ((double)np)));
124 const int n_low = n - n_upp ;
125 const int next_axis = ( axis + 2 ) % 3 ;
129 dbox[0][0] = box[0][0] ; dbox[0][1] = box[0][1] ;
130 dbox[1][0] = box[1][0] ; dbox[1][1] = box[1][1] ;
131 dbox[2][0] = box[2][0] ; dbox[2][1] = box[2][1] ;
133 dbox[ axis ][1] = dbox[ axis ][0] + n_low ;
135 box_partition( ip, ip + np_low, next_axis,
136 (
const int (*)[2]) dbox, p_box );
141 dbox[0][0] = box[0][0] ; dbox[0][1] = box[0][1] ;
142 dbox[1][0] = box[1][0] ; dbox[1][1] = box[1][1] ;
143 dbox[2][0] = box[2][0] ; dbox[2][1] = box[2][1] ;
146 dbox[ axis ][0] += n_low ;
147 dbox[ axis ][1] = dbox[ axis ][0] + n_upp ;
149 box_partition( ip, ip + np_upp, next_axis,
150 (
const int (*)[2]) dbox, p_box );
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.