|
Sierra Toolkit
Version of the Day
|
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 #include <sstream> 00011 #include <stk_mesh/fixtures/SelectorFixture.hpp> 00012 00013 namespace stk_classic { 00014 namespace mesh { 00015 namespace fixtures { 00016 00017 SelectorFixture::~SelectorFixture() {} 00018 00019 SelectorFixture::SelectorFixture() 00020 : m_meta_data( std::vector<std::string>(1, std::string("MyEntityRank")) ) 00021 , m_bulk_data( m_meta_data , MPI_COMM_WORLD ) 00022 , m_partA( m_meta_data.declare_part( "PartA" , 0 ) ) 00023 , m_partB( m_meta_data.declare_part( "PartB" , 0 ) ) 00024 , m_partC( m_meta_data.declare_part( "PartC" , 0 ) ) 00025 , m_partD( m_meta_data.declare_part( "PartD" , 0 ) ) 00026 , m_entity1( NULL ) 00027 , m_entity2( NULL ) 00028 , m_entity3( NULL ) 00029 , m_entity4( NULL ) 00030 , m_entity5( NULL ) 00031 , m_fieldA(m_meta_data.declare_field<stk_classic::mesh::Field<double> >("FieldA")) 00032 , m_fieldABC(m_meta_data.declare_field<stk_classic::mesh::Field<double> >("FieldABC")) 00033 { 00034 stk_classic::mesh::EntityRank ent_rank = 0; 00035 00036 stk_classic::mesh::put_field(m_fieldA, ent_rank, m_partA); 00037 00038 stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partA); 00039 stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partB); 00040 stk_classic::mesh::put_field(m_fieldABC, ent_rank, m_partC); 00041 } 00042 00043 void SelectorFixture::generate_mesh() 00044 { 00045 const unsigned entity_count = 5 ; 00046 00047 stk_classic::mesh::EntityRank ent_type = 0; // rank 00048 00049 // Create Entities and assign to parts: 00050 stk_classic::mesh::EntityId ent_id = 00051 1 + entity_count * m_bulk_data.parallel_rank(); // Unique ID 00052 00053 std::vector<stk_classic::mesh::Part*> partMembership; 00054 00055 // Entity1 is contained in PartA 00056 partMembership.clear(); 00057 partMembership.push_back( & m_partA ); 00058 m_entity1 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); 00059 ++ent_id; 00060 00061 // Entity2 is contained in PartA and PartB 00062 partMembership.clear(); 00063 partMembership.push_back( & m_partA ); 00064 partMembership.push_back( & m_partB ); 00065 m_entity2 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); 00066 ++ent_id; 00067 00068 // Entity3 is contained in PartB and PartC 00069 partMembership.clear(); 00070 partMembership.push_back( & m_partB ); 00071 partMembership.push_back( & m_partC ); 00072 m_entity3 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); 00073 ++ent_id; 00074 00075 // Entity4 is contained in PartC 00076 partMembership.clear(); 00077 partMembership.push_back( & m_partC ); 00078 m_entity4 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); 00079 ++ent_id; 00080 00081 // Entity5 is not contained in any Part 00082 partMembership.clear(); 00083 m_entity5 = & m_bulk_data.declare_entity(ent_type, ent_id, partMembership); 00084 } 00085 00086 //-------------------------------------------------------------------------- 00087 00088 VariableSelectorFixture::~VariableSelectorFixture() {} 00089 00090 VariableSelectorFixture::VariableSelectorFixture(int NumParts) 00091 : m_MetaData( std::vector<std::string>(1, std::string("MyEntityRank")) ) 00092 , m_BulkData( m_MetaData , MPI_COMM_WORLD ) 00093 , m_declared_part_vector() 00094 { 00095 // Create Parts and commit: 00096 std::string myPartName; 00097 stk_classic::mesh::EntityRank myRank = 0; 00098 00099 std::string partName = "Part_"; 00100 for (int part_i=0 ; part_i<NumParts; ++part_i) { 00101 std::ostringstream localPartName(partName); 00102 localPartName << part_i; 00103 stk_classic::mesh::Part * part = 00104 & m_MetaData.declare_part(localPartName.str(),myRank); 00105 m_declared_part_vector.push_back( part ); 00106 } 00107 00108 m_MetaData.commit(); 00109 00110 // Create Entities and assign to parts: 00111 00112 m_BulkData.modification_begin(); 00113 00114 stk_classic::mesh::EntityRank ent_type = 0; // rank 00115 stk_classic::mesh::EntityId ent_id = 00116 1 + NumParts * m_BulkData.parallel_rank(); // Unique ID 00117 00118 for (int part_i = 0 ; part_i < NumParts ; ++part_i) { 00119 std::vector<stk_classic::mesh::Part*> partMembership; 00120 partMembership.push_back(m_declared_part_vector[part_i]); 00121 stk_classic::mesh::Entity * e = 00122 & m_BulkData.declare_entity(ent_type, ent_id, partMembership); 00123 m_entities.push_back( e ); 00124 ++ent_id; 00125 } 00126 00127 m_BulkData.modification_end(); 00128 } 00129 00130 } // fixtures 00131 } // mesh 00132 } // stk