Sierra Toolkit Version of the Day
PartImpl.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 
00010 //----------------------------------------------------------------------
00011 #include <stdexcept>
00012 #include <iostream>
00013 #include <sstream>
00014 #include <algorithm>
00015 
00016 #include <stk_util/util/string_case_compare.hpp>
00017 
00018 #include <stk_mesh/base/PartRelation.hpp>
00019 #include <stk_mesh/base/Part.hpp>
00020 #include <stk_mesh/base/Trace.hpp>
00021 
00022 #include <stk_mesh/baseImpl/PartImpl.hpp>
00023 #include <stk_util/environment/ReportHandler.hpp>
00024 
00025 //----------------------------------------------------------------------
00026 
00027 namespace stk {
00028 namespace mesh {
00029 
00030 namespace impl {
00031 
00032 void PartImpl::add_part_to_subset( Part & part)
00033 {
00034   TraceIfWatching("stk::mesh::impl::PartImpl::add_part_to_subset", LOG_PART, m_universe_ordinal);
00035   DiagIfWatching(LOG_PART, m_universe_ordinal, "New subset is: " << part );
00036 
00037   insert( m_subsets, part );
00038 }
00039 
00040 
00041 void PartImpl::add_part_to_superset( Part & part )
00042 {
00043   TraceIfWatching("stk::mesh::impl::PartImpl::add_part_to_superset", LOG_PART, m_universe_ordinal);
00044   DiagIfWatching(LOG_PART, m_universe_ordinal, "New superset is: " << part );
00045 
00046   insert( m_supersets, part );
00047 }
00048 
00049 void PartImpl::add_relation( PartRelation relation )
00050 {
00051   TraceIfWatching("stk::mesh::impl::PartImpl::add_relation", LOG_PART, m_universe_ordinal);
00052   DiagIfWatching(LOG_PART, m_universe_ordinal, "New relation from: " << relation.m_root << ", to: " << relation.m_target );
00053 
00054   m_relations.push_back(relation);
00055 }
00056 
00057 void PartImpl::set_intersection_of( const PartVector & pv )
00058 {
00059   TraceIfWatching("stk::mesh::impl::PartImpl::set_intersection_of", LOG_PART, m_universe_ordinal);
00060   DiagIfWatching(LOG_PART, m_universe_ordinal, "Intersection: " << pv );
00061 
00062   m_intersect = pv ;
00063 }
00064 
00065 
00066 PartImpl::~PartImpl()
00067 {
00068 }
00069 
00070 
00071 // Subset part constructor:
00072 PartImpl::PartImpl( MetaData          * arg_meta_data ,
00073             const std::string & arg_name ,
00074             EntityRank            arg_rank ,
00075             size_t              arg_ordinal )
00076   : m_name( arg_name ),
00077     m_attribute(),
00078     m_subsets() , m_supersets() , m_intersect() , m_relations() ,
00079     m_mesh_meta_data( arg_meta_data ),
00080     m_universe_ordinal( arg_ordinal ),
00081     m_entity_rank( arg_rank )
00082 {}
00083 
00084 void PartImpl::set_primary_entity_rank( EntityRank entity_rank )
00085 {
00086   TraceIfWatching("stk::mesh::impl::PartImpl::set_primary_entity_rank", LOG_PART, m_universe_ordinal);
00087   if ( entity_rank == m_entity_rank ) return;
00088 
00089   const bool rank_already_set = m_entity_rank != InvalidEntityRank && entity_rank != m_entity_rank;
00090   
00091 //const bool has_subsets = m_subsets.size() > 0;
00092 //ThrowErrorMsgIf( has_subsets, " Error: Part '" << m_name  << "' has subsets");
00093   
00094   if ( entity_rank == InvalidEntityRank ) return;
00095   ThrowErrorMsgIf( rank_already_set, " Error: Different entity rank has already been set on Part");
00096 
00097   m_entity_rank = entity_rank;
00098 }
00099 
00100 
00101 //----------------------------------------------------------------------
00102 
00103 
00104 
00105 //----------------------------------------------------------------------
00106 
00107 } // namespace impl
00108 
00109 } // namespace mesh
00110 } // namespace stk
00111 
00112 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends