17 #include <stk_mesh/base/Bucket.hpp> 18 #include <stk_mesh/base/Entity.hpp> 19 #include <stk_mesh/base/BulkData.hpp> 20 #include <stk_mesh/base/MetaData.hpp> 21 #include <stk_mesh/base/FieldData.hpp> 28 bool bucket_part_equal(
const unsigned * lhs ,
const unsigned * rhs )
32 const unsigned *
const end_lhs = lhs + *lhs ;
33 while ( result && end_lhs != lhs ) {
34 result = *lhs == *rhs ;
42 bool bucket_key_less(
const unsigned * lhs ,
const unsigned * rhs )
44 const unsigned *
const last_lhs = lhs + ( *lhs < *rhs ? *lhs : *rhs );
45 while ( last_lhs != lhs && *lhs == *rhs ) { ++lhs ; ++rhs ; }
50 bool BucketLess::operator()(
const Bucket * lhs_bucket ,
51 const unsigned * rhs )
const 52 {
return bucket_key_less( lhs_bucket->key() , rhs ); }
54 bool BucketLess::operator()(
const unsigned * lhs ,
55 const Bucket * rhs_bucket )
const 56 {
return bucket_key_less( lhs , rhs_bucket->key() ); }
62 const unsigned *
const i_beg = key() + 1 ;
63 const unsigned *
const i_end = key() + key()[0] ;
66 const unsigned *
const i = std::lower_bound( i_beg , i_end , ord );
68 return i_end != i && ord == *i ;
73 const unsigned *
const i_beg = key() + 1 ;
74 const unsigned *
const i_end = key() + key()[0] ;
76 const PartVector::const_iterator ip_end = parts.end();
77 PartVector::const_iterator ip = parts.begin() ;
79 bool result_all = true ;
81 for ( ; result_all && ip_end != ip ; ++ip ) {
82 const unsigned ord = (*ip)->mesh_meta_data_ordinal();
83 const unsigned *
const i = std::lower_bound( i_beg , i_end , ord );
84 result_all = i_end != i && ord == *i ;
91 const unsigned *
const i_beg = key() + 1 ;
92 const unsigned *
const i_end = key() + key()[0] ;
94 const PartVector::const_iterator ip_end = parts.end();
95 PartVector::const_iterator ip = parts.begin() ;
97 bool result_none = true ;
99 for ( ; result_none && ip_end != ip ; ++ip ) {
100 const unsigned ord = (*ip)->mesh_meta_data_ordinal();
101 const unsigned *
const i = std::lower_bound( i_beg , i_end , ord );
102 result_none = i_end == i || ord != *i ;
104 return ! result_none ;
109 const unsigned *
const i_beg = key() + 1 ;
110 const unsigned *
const i_end = key() + key()[0] ;
112 const OrdinalVector::const_iterator ip_end = parts.end();
113 OrdinalVector::const_iterator ip = parts.begin() ;
115 bool result_none = true ;
117 for ( ; result_none && ip_end != ip ; ++ip ) {
118 const unsigned ord = *ip;
119 const unsigned *
const i = std::lower_bound( i_beg , i_end , ord );
120 result_none = i_end == i || ord != *i ;
122 return ! result_none ;
129 std::pair<const unsigned *, const unsigned *>
133 std::lower_bound( part_ord.first , part_ord.second , ordinal );
135 return part_ord.first < part_ord.second && ordinal == *part_ord.first ;
146 const std::pair<const unsigned *, const unsigned *>
149 bool result = ! ps.empty();
151 for ( PartVector::const_iterator
152 i = ps.begin() ; result && i != ps.end() ; ++i ) {
154 const unsigned ordinal = (*i)->mesh_meta_data_ordinal();
156 const unsigned * iter =
157 std::lower_bound( part_ord.first , part_ord.second , ordinal );
159 result = iter < part_ord.second && ordinal == *iter ;
166 const MetaData & mesh_meta_data = MetaData::get( *
this );
168 std::pair<const unsigned *, const unsigned *>
171 ps.resize( part_ord.second - part_ord.first );
173 for (
unsigned i = 0 ;
174 part_ord.first < part_ord.second ; ++(part_ord.first) , ++i ) {
175 ps[i] = & mesh_meta_data.
get_part( * part_ord.first );
181 std::pair<const unsigned *, const unsigned *>
184 ps.resize( part_ord.second - part_ord.first );
186 for (
unsigned i = 0 ;
187 part_ord.first < part_ord.second ; ++(part_ord.first) , ++i ) {
188 ps[i] = *part_ord.first;
197 const char * required_by )
199 const MetaData *
const k_mesh_meta_data = & MetaData::get(k);
200 const MetaData *
const f_mesh_meta_data = & MetaData::get(f);
201 const bool ok_mesh_meta_data = k_mesh_meta_data == f_mesh_meta_data ;
202 const bool ok_ord = ord < k.
size() ;
203 const bool exists = ok_mesh_meta_data && ok_ord &&
206 if ( required_by && ! exists ) {
207 std::ostringstream msg_begin ;
208 msg_begin <<
"For args: " ;
209 msg_begin << f <<
" , " ;
210 msg_begin << k <<
" , " ;
211 msg_begin << ord <<
" , " ;
212 msg_begin << required_by ;
213 msg_begin <<
"; operation FAILED with " ;
214 ThrowErrorMsgIf( ! ok_mesh_meta_data,
215 msg_begin.str() <<
" different MetaData");
216 ThrowErrorMsgIf( ! ok_ord, msg_begin.str() <<
217 " Ordinal " << ord <<
" >= " <<
" size " << k.size());
218 ThrowErrorMsg( msg_begin.str() <<
" no data");
227 const Bucket* bucket =
this;
228 const Bucket * first = m_bucketImpl.first_bucket_in_family();
239 std::ostream & operator << ( std::ostream & s ,
const Bucket & k )
241 const MetaData & mesh_meta_data = MetaData::get(k);
242 const std::string & entity_rank_name =
244 mesh_meta_data.entity_rank_names()[ k.
entity_rank() ];
248 s <<
"Bucket( " << entity_rank_name <<
" : " ;
249 for ( PartVector::iterator i = parts.begin() ; i != parts.end() ; ++i ) {
250 s << (*i)->name() <<
" " ;
259 print( std::ostream & os ,
const std::string & indent ,
const Bucket & bucket )
261 const MetaData & mesh_meta_data = MetaData::get(bucket);
262 const std::string & entity_rank_name =
263 bucket.
entity_rank() == InvalidEntityRank ?
"Nil" :
264 mesh_meta_data.entity_rank_names()[ bucket.
entity_rank() ];
266 const std::pair<const unsigned *, const unsigned *>
269 os <<
"Bucket(" << std::endl << indent <<
"Part intersection {" ;
271 for (
const unsigned * i = part_ids.first ; i < part_ids.second ; ++i ) {
273 os <<
" " << part.
name();
276 os <<
" }" << std::endl << indent << entity_rank_name <<
" members {" ;
278 for (
unsigned j = 0 ; j < bucket.
size() ; ++j ) {
279 const EntityId
id = bucket[j].identifier();
282 os <<
" } )" << std::endl ;
std::ostream & print(std::ostream &os, const std::string &indent, const Bucket &bucket)
Print the parts and entities of this bucket.
Field base class with an anonymous data type and anonymous multi-dimension.
bool assert_correct() const
A method to assist in unit testing - accesses private data as necessary.
FieldTraits< field_type >::data_type * field_data(const field_type &f, const Bucket::iterator i)
Pointer to the field data array.
bool member_all(const PartVector &) const
Bucket is a subset of all of the given parts.
bool member_any(const PartVector &) const
Bucket is a subset of any of the given parts.
std::pair< const unsigned *, const unsigned * > superset_part_ordinals() const
An application-defined subset of a problem domain.
size_t size() const
Number of entities associated with this bucket.
const std::string & name() const
Application-defined text name of this part.
unsigned mesh_meta_data_ordinal() const
Internally generated ordinal of this part that is unique within the owning meta data manager...
iterator begin() const
Beginning of the bucket.
bool field_data_valid(const FieldBase &f, const Bucket &k, unsigned ord, const char *required_by)
Check for existence of field data.
void supersets(PartVector &) const
This bucket is a subset of these parts.
bool equivalent(const Bucket &b) const
Equivalent buckets have the same parts.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
A container for the field data of a homogeneous collection of entities.
bool member(const Part &) const
Bucket is a subset of the given part.
bool has_superset(const Bucket &bucket, const PartVector &ps)
Is this bucket a subset of all of the given parts.
unsigned entity_rank() const
Type of entities in this bucket.