10 #ifndef stk_mesh_Relation_hpp 11 #define stk_mesh_Relation_hpp 16 #include <stk_mesh/base/EntityKey.hpp> 18 #include <boost/static_assert.hpp> 20 #ifdef SIERRA_MIGRATION 60 typedef uint32_t raw_relation_id_type ;
61 typedef uint32_t attribute_type;
70 attribute_type attribute()
const {
return m_attribute; }
71 void set_attribute(attribute_type attr)
const { m_attribute = attr; }
74 static raw_relation_id_type
raw_relation_id(
unsigned rank ,
unsigned id );
93 {
return !(*
this == r); }
104 id_mask = ~(0u) >> rank_digits
105 #ifdef SIERRA_MIGRATION
107 fwmk_relation_type_digits = 8,
108 fmwk_orientation_digits = 24,
109 fmwk_orientation_mask = ~(0u) >> fwmk_relation_type_digits
113 BOOST_STATIC_ASSERT(( static_cast<unsigned>(EntityKey::rank_digits) == static_cast<unsigned>(rank_digits) ));
115 union RawRelationType {
117 raw_relation_id_type value ;
129 RawRelationType( raw_relation_id_type v ) : value(v) {}
130 RawRelationType() : value(0) {}
131 RawRelationType(
const RawRelationType & rhs ) : value( rhs.value ) {}
132 RawRelationType & operator = (
const RawRelationType & rhs )
133 { value = rhs.value ;
return *this ; }
136 RawRelationType m_raw_relation ;
137 mutable attribute_type m_attribute ;
138 Entity * m_target_entity ;
158 #ifdef SIERRA_MIGRATION 175 POLARITY_MASK = 0x80,
176 POLARITY_POSITIVE = 0x80,
177 POLARITY_NEGATIVE = 0x00,
178 POLARITY_IDENTITY = 0x80
181 static bool polarity(
unsigned orient) {
182 return (orient & POLARITY_MASK) == POLARITY_POSITIVE;
185 static unsigned permutation(
unsigned orient) {
186 return orient & ~POLARITY_MASK;
192 Relation(Entity *obj,
const unsigned relation_type,
const unsigned ordinal,
const unsigned orient = 0);
194 Entity *getMeshObj()
const {
198 void setMeshObj(Entity *
object);
200 RelationType getRelationType()
const {
201 return static_cast<RelationType
>(attribute() >> fmwk_orientation_digits);
204 void setRelationType(RelationType relation_type) {
205 set_attribute( (relation_type << fmwk_orientation_digits) | getOrientation() );
208 RelationIdentifier getOrdinal()
const {
212 void setOrdinal(RelationIdentifier ordinal) {
216 attribute_type getOrientation()
const {
217 return attribute() & fmwk_orientation_mask;
220 void setOrientation(attribute_type orientation) {
221 set_attribute( (getRelationType() << fmwk_orientation_digits) | orientation );
234 bool polarity()
const {
235 return (getOrientation() & POLARITY_MASK) == POLARITY_POSITIVE;
238 unsigned permutation()
const {
239 return getOrientation() & ~POLARITY_MASK;
243 bool has_fmwk_state()
const {
return getRelationType() != INVALID; }
244 #endif // SIERRA_MIGRATION 250 Relation::raw_relation_id_type
253 ThrowAssertMsg(
id <= id_mask,
254 "For args rank " << rank <<
", id " <<
id <<
": " <<
255 "id " <<
" > id_mask=" << id_mask );
257 return ( raw_relation_id_type(rank) << id_digits ) | id ;
262 {
return m_raw_relation.value >> id_digits; }
266 {
return unsigned( m_raw_relation.value & id_mask ); }
268 struct LessRelation {
270 {
return lhs < rhs ; }
272 bool operator() (
const Relation & lhs , Relation::raw_relation_id_type rhs )
const 281 const std::vector<Entity*> & entities ,
282 std::vector<Entity*> & entities_related );
289 const std::vector<Entity*> & entities ,
290 EntityRank entities_related_rank ,
291 std::vector<Entity*> & entities_related );
303 unsigned entity_rank_from ,
304 unsigned entity_rank_to ,
305 RelationIdentifier relation_identifier ,
306 OrdinalVector & induced_parts,
307 bool include_supersets=
true);
313 const OrdinalVector & omit ,
314 unsigned entity_rank_to ,
315 RelationIdentifier relation_identifier ,
316 OrdinalVector & induced_parts,
317 bool include_supersets=
true);
323 const OrdinalVector & omit ,
324 OrdinalVector & induced_parts,
325 bool include_supersets=
true);
333 print_relation( std::ostream & , Relation::raw__attr_type );
337 print_relation( std::ostream & ,
const MetaData & ,
338 Relation::raw__attr_type , EntityKey );
342 std::ostream & operator << ( std::ostream & ,
const Relation & );
350 m_target_entity(NULL)
352 #ifdef SIERRA_MIGRATION 353 setRelationType(INVALID);
360 return m_raw_relation.value == rhs.m_raw_relation.value && m_target_entity == rhs.m_target_entity
361 #ifdef SIERRA_MIGRATION 363 && m_attribute == rhs.m_attribute
371 #ifdef SIERRA_MIGRATION 373 lhs.getRelationType() == rhs.getRelationType() &&
374 lhs.getOrdinal() == rhs.getOrdinal();
Entity * entity() const
The referenced entity.
bool operator<(const Relation &r) const
Ordering operator.
bool membership_is_induced(const Part &part, unsigned entity_rank)
Query if a member entity of the given entity type has an induced membership.
void induced_part_membership(Part &part, unsigned entity_rank_from, unsigned entity_rank_to, RelationIdentifier relation_identifier, OrdinalVector &induced_parts, bool include_supersets)
Induce entities' part membership based upon relationships between entities. Insert the result into 'i...
bool operator!=(const Relation &r) const
Inequality operator.
raw_relation_id_type raw_relation_id() const
The encoded relation raw_relation_id.
RelationIdentifier identifier() const
The local relation identifier.
A relation between two mesh entities with a relation identifier and kind .
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
void get_entities_through_relations(const std::vector< Entity *> &entities, std::vector< Entity *> &entities_related)
Query which mesh entities have a relation to all of the input mesh entities.
unsigned entity_rank() const
The rank of the referenced entity.
static raw_relation_id_type raw_relation_id(unsigned rank, unsigned id)
The encoded relation raw_relation_id.
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
bool operator==(const Relation &r) const
Equality operator.