Sierra Toolkit  Version of the Day
PartImpl.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 
10 //----------------------------------------------------------------------
11 #include <stdexcept>
12 #include <iostream>
13 #include <sstream>
14 #include <algorithm>
15 
16 #include <stk_util/util/string_case_compare.hpp>
17 
18 #include <stk_mesh/base/PartRelation.hpp>
19 #include <stk_mesh/base/Part.hpp>
20 #include <stk_mesh/base/Trace.hpp>
21 
22 #include <stk_mesh/baseImpl/PartImpl.hpp>
23 #include <stk_util/environment/ReportHandler.hpp>
24 
25 //----------------------------------------------------------------------
26 
27 namespace stk_classic {
28 namespace mesh {
29 
30 namespace impl {
31 
32 void PartImpl::add_part_to_subset( Part & part)
33 {
34  TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_part_to_subset", LOG_PART, m_universe_ordinal);
35  DiagIfWatching(LOG_PART, m_universe_ordinal, "New subset is: " << part );
36 
37  insert( m_subsets, part );
38 }
39 
40 
41 void PartImpl::add_part_to_superset( Part & part )
42 {
43  TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_part_to_superset", LOG_PART, m_universe_ordinal);
44  DiagIfWatching(LOG_PART, m_universe_ordinal, "New superset is: " << part );
45 
46  insert( m_supersets, part );
47 }
48 
49 void PartImpl::add_relation( PartRelation relation )
50 {
51  TraceIfWatching("stk_classic::mesh::impl::PartImpl::add_relation", LOG_PART, m_universe_ordinal);
52  DiagIfWatching(LOG_PART, m_universe_ordinal, "New relation from: " << relation.m_root << ", to: " << relation.m_target );
53 
54  m_relations.push_back(relation);
55 }
56 
57 void PartImpl::set_intersection_of( const PartVector & pv )
58 {
59  TraceIfWatching("stk_classic::mesh::impl::PartImpl::set_intersection_of", LOG_PART, m_universe_ordinal);
60  DiagIfWatching(LOG_PART, m_universe_ordinal, "Intersection: " << pv );
61 
62  m_intersect = pv ;
63 }
64 
65 // Subset part constructor:
66 PartImpl::PartImpl( MetaData * arg_meta_data ,
67  const std::string & arg_name ,
68  EntityRank arg_rank ,
69  size_t arg_ordinal )
70  : m_name( arg_name ),
71  m_attribute(),
72  m_subsets() , m_supersets() , m_intersect() , m_relations() ,
73  m_mesh_meta_data( arg_meta_data ),
74  m_universe_ordinal( arg_ordinal ),
75  m_entity_rank( arg_rank )
76 {}
77 
78 void PartImpl::set_primary_entity_rank( EntityRank entity_rank )
79 {
80  TraceIfWatching("stk_classic::mesh::impl::PartImpl::set_primary_entity_rank", LOG_PART, m_universe_ordinal);
81  if ( entity_rank == m_entity_rank ) return;
82 
83  const bool rank_already_set = m_entity_rank != InvalidEntityRank && entity_rank != m_entity_rank;
84 
85 //const bool has_subsets = m_subsets.size() > 0;
86 //ThrowErrorMsgIf( has_subsets, " Error: Part '" << m_name << "' has subsets");
87 
88  if ( entity_rank == InvalidEntityRank ) return;
89  ThrowErrorMsgIf( rank_already_set, " Error: Different entity rank has already been set on Part");
90 
91  m_entity_rank = entity_rank;
92 }
93 
94 
95 //----------------------------------------------------------------------
96 
97 
98 
99 //----------------------------------------------------------------------
100 
101 } // namespace impl
102 
103 } // namespace mesh
104 } // namespace stk_classic
105 
106 
Sierra Toolkit.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
bool insert(PartVector &v, Part &part)
Insert a part into a properly ordered collection of parts. Returns true if this is a new insertion...
Definition: Part.cpp:85