Sierra Toolkit Version of the Day
UnitTestFEMMetaData.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2011 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 #include <stdexcept>
00010 #include <algorithm>
00011 
00012 #include <stk_mesh/fem/FEMMetaData.hpp>
00013 #include <stk_util/unit_test_support/stk_utest_macros.hpp>
00014 
00015 using stk::mesh::fem::FEMMetaData;
00016 
00017 namespace {
00018 
00019 static const stk::mesh::EntityRank NODE_RANK =   FEMMetaData::NODE_RANK;
00020 static const stk::mesh::EntityRank EDGE_RANK =   FEMMetaData::EDGE_RANK;
00021 static const stk::mesh::EntityRank FACE_RANK =   FEMMetaData::FACE_RANK;
00022 static const stk::mesh::EntityRank VOLUME_RANK =   FEMMetaData::VOLUME_RANK;
00023 static const stk::mesh::EntityRank INVALID_RANK =   FEMMetaData::INVALID_RANK;
00024 
00025 }
00026 
00027 //----------------------------------------------------------------------------
00028 
00029 STKUNIT_UNIT_TEST ( UnitTestFEMMetaData, create )
00030 {
00031   stk::mesh::fem::FEMMetaData fem_meta;
00032   STKUNIT_EXPECT_TRUE ( true );
00033   STKUNIT_EXPECT_FALSE( fem_meta.is_FEM_initialized() );
00034   STKUNIT_EXPECT_EQUAL( fem_meta.spatial_dimension(), 0u );
00035   STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK );
00036   STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK );
00037   STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK );
00038   STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), INVALID_RANK );
00039   STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), INVALID_RANK );
00040 
00041   // Verify throws/etc for FEM calls prior to initialization:
00042   stk::mesh::fem::CellTopology invalid_cell_topology( NULL );
00043   stk::mesh::Part & universal_part = fem_meta.universal_part();
00044   STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( invalid_cell_topology, INVALID_RANK ), std::logic_error );
00045   STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part( invalid_cell_topology), std::logic_error );
00046   STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology( universal_part), std::logic_error );
00047   STKUNIT_ASSERT_THROW( stk::mesh::fem::set_cell_topology( universal_part, invalid_cell_topology), std::logic_error );
00048   STKUNIT_EXPECT_EQUAL( fem_meta.get_entity_rank( invalid_cell_topology), INVALID_RANK );
00049 
00050 }
00051 
00052 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, initialize )
00053 {
00054   stk::mesh::fem::FEMMetaData fem_meta;
00055   const size_t spatial_dimension = 3;
00056   fem_meta.FEM_initialize(spatial_dimension);
00057   STKUNIT_EXPECT_TRUE( fem_meta.is_FEM_initialized() );
00058   STKUNIT_EXPECT_EQUAL( fem_meta.spatial_dimension(), spatial_dimension );
00059 }
00060 
00061 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, invalid_initialize )
00062 {
00063   stk::mesh::fem::FEMMetaData fem_meta;
00064   const size_t spatial_dimension = 0;
00065   STKUNIT_ASSERT_THROW( fem_meta.FEM_initialize(spatial_dimension), std::logic_error );
00066 }
00067 
00068 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, initialize_only_once )
00069 {
00070   stk::mesh::fem::FEMMetaData fem_meta;
00071   const size_t spatial_dimension = 3;
00072   fem_meta.FEM_initialize(spatial_dimension);
00073   STKUNIT_ASSERT_THROW( fem_meta.FEM_initialize(2), std::logic_error );
00074 }
00075 
00076 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_1 )
00077 {
00078   stk::mesh::fem::FEMMetaData fem_meta;
00079   const size_t spatial_dimension = 1;
00080   fem_meta.FEM_initialize(spatial_dimension);
00081   STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK );
00082   STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK );
00083   STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK );
00084   STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), NODE_RANK );
00085   STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), EDGE_RANK );
00086 
00087 }
00088 
00089 
00090 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_2 )
00091 {
00092   stk::mesh::fem::FEMMetaData fem_meta;
00093   const size_t spatial_dimension = 2;
00094   fem_meta.FEM_initialize(spatial_dimension);
00095   STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK );
00096   STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK );
00097   STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK );
00098   STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), EDGE_RANK );
00099   STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), FACE_RANK );
00100 
00101 }
00102 
00103 
00104 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_3 )
00105 {
00106   stk::mesh::fem::FEMMetaData fem_meta;
00107   const size_t spatial_dimension = 3;
00108   fem_meta.FEM_initialize(spatial_dimension);
00109   STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK );
00110   STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK );
00111   STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK );
00112   STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), FACE_RANK );
00113   STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), VOLUME_RANK );
00114 }
00115 
00116 
00117 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, entity_ranks_4 )
00118 {
00119   stk::mesh::fem::FEMMetaData fem_meta;
00120   const size_t spatial_dimension = 4;
00121   std::vector<std::string> entity_rank_names(spatial_dimension+1);
00122   // When using spatial_dimension > 3, you must pass in names.
00123   entity_rank_names[0] = "node";
00124   entity_rank_names[1] = "super node";
00125   entity_rank_names[2] = "super duper node";
00126   entity_rank_names[3] = "particle";
00127   entity_rank_names[4] = "thing";
00128 
00129   fem_meta.FEM_initialize(spatial_dimension,entity_rank_names);
00130   STKUNIT_EXPECT_EQUAL( fem_meta.node_rank(), NODE_RANK );
00131   STKUNIT_EXPECT_EQUAL( fem_meta.edge_rank(), EDGE_RANK );
00132   STKUNIT_EXPECT_EQUAL( fem_meta.face_rank(), FACE_RANK );
00133   STKUNIT_EXPECT_EQUAL( fem_meta.side_rank(), VOLUME_RANK );
00134   STKUNIT_EXPECT_EQUAL( fem_meta.element_rank(), 4u );
00135 }
00136 
00137 
00138 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_trivial )
00139 {
00140   stk::mesh::fem::FEMMetaData fem_meta;
00141   const size_t spatial_dimension = 3;
00142   fem_meta.FEM_initialize(spatial_dimension);
00143   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00144   stk::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top);
00145 
00146   STKUNIT_EXPECT_TRUE( stk::mesh::is_auto_declared_part(hex_part) );
00147   STKUNIT_EXPECT_EQUAL( hex_part.primary_entity_rank(), spatial_dimension );
00148   stk::mesh::fem::CellTopology topology = fem_meta.get_cell_topology(hex_part);
00149   STKUNIT_EXPECT_EQUAL( (topology == hex_top), true );
00150 }
00151 
00152 
00153 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_simple )
00154 {
00155   stk::mesh::fem::FEMMetaData fem_meta;
00156   const size_t spatial_dimension = 3;
00157   fem_meta.FEM_initialize(spatial_dimension);
00158   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00159   stk::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top);
00160   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00161   STKUNIT_EXPECT_TRUE( stk::mesh::is_auto_declared_part(hex_part) );
00162   STKUNIT_EXPECT_TRUE( !stk::mesh::is_auto_declared_part(A) );
00163   fem_meta.declare_part_subset( hex_part, A );
00164   stk::mesh::fem::CellTopology topology = fem_meta.get_cell_topology(A);
00165   STKUNIT_ASSERT_EQUAL( (topology == hex_top), true );
00166 }
00167 
00168 
00169 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, get_cell_topology_invalid )
00170 {
00171   stk::mesh::fem::FEMMetaData fem_meta;
00172   const size_t spatial_dimension = 2;
00173   fem_meta.FEM_initialize(spatial_dimension);
00174   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00175   STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part(hex_top), std::runtime_error );
00176 }
00177 
00178 
00179 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_subsetting )
00180 {
00181   stk::mesh::fem::FEMMetaData fem_meta;
00182   const size_t spatial_dimension = 3;
00183   const stk::mesh::EntityRank element_rank = spatial_dimension;
00184   fem_meta.FEM_initialize(spatial_dimension);
00185   stk::mesh::Part & element_part = fem_meta.declare_part("element part", element_rank );
00186   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00187   stk::mesh::fem::set_cell_topology( element_part, hex_top );
00188 
00189   stk::mesh::Part & hex_part = fem_meta.get_cell_topology_root_part(hex_top);
00190 
00191   const stk::mesh::PartVector & element_part_supersets = element_part.supersets();
00192   STKUNIT_EXPECT_EQUAL(
00193       std::count(element_part_supersets.begin(),element_part_supersets.end(),&hex_part), 1
00194       );
00195 }
00196 
00197 // 02/16/11:  Cell Topology Induced Membership
00198 //
00199 // Invariants:
00200 // 1.  Root cell topology parts cannot be subsets of parts with cell topologies
00201 // 2.  Incompatible cell topologies are prohibited.  I.e. parts with
00202 //     different cell topologies of the same rank (as the part) cannot be subsets
00203 //     of each other.
00204 //
00205 // Decision tree for declare_part_subset(superset,subset):
00206 // Q:  Does the superset part have a topology?
00207 // A:  No
00208 //     [ Okay, go forward ] (Test 1)
00209 // A:  Yes
00210 //     Q:  Is the subset part a root cell topology part or are any of the subset's parts subsets a root cell topology part?
00211 //     A:  Yes
00212 //         [ Throw ] (Test 2 a,b)
00213 //     A:  No
00214 //         Q:  How many cell topologies of the same rank as the superset are defined for the subset part and the subset's subsets parts?
00215 //         A:  0
00216 //             [ Okay, go forward ] (Test 3 a,b,c)
00217 //         A:  1+
00218 //             Q:  Are all the cell topologies the same?
00219 //             A:  Yes
00220 //                 [ Okay, go forward ] (Test 4 a,b)
00221 //             A:  No
00222 //                 [ Throw ] (Test 5 a,b,c)
00223 //
00224 // Tests:
00225 // The following parts are necessary for the tests [spatial_dimension = 3]:
00226 // Part A, rank 3, no topology
00227 // Part B, rank 3, no topology
00228 // Part C, rank 2, no topology
00229 // Part D, rank 2, no topolooy
00230 // Part E, rank 3, no topology
00231 // Part F, rank 3, no topolooy
00232 // Part H, rank 3, Hex<8> topology, HR > H (HR = Hex<8> root cell topology part)
00233 // Part Q, rank 2, Quad<4> topology, QR > Q (QR = Quad<4> root cell topology part)
00234 // Part W, rank 3, Wedge<6> topology, WR > W (WR = Wedge<6> root cell topology part)
00235 // 1:   Part A > HR -> Okay
00236 // 2a:  HR > QR -> Throw
00237 // 2b:  HR > A, B > QR, A > B -> Throw
00238 // 3a:  Subset has no cell topology and subset's subsets have no cell topology
00239 //      HR > A -> Okay
00240 // 3b:  Different rank cell topology on subset
00241 //      QR > D, HR > A, A > D -> Okay
00242 // 3c:  Different rank cell topology on subset's subset
00243 //      QR > C, B > C, HR > A, A > B -> Okay
00244 // 4a:  Subset has same cell topology
00245 //      HR > A, HR > B, A > B -> Okay
00246 // 4b:  Subset's subsets have same cell topology
00247 //      HR > C, B > C, HR > A, A > B -> Okay
00248 // 5a:  Subset has different cell topology
00249 //      WR > A, HR > B, A > B -> Throw
00250 // 5b:  Subset's subsets have different cell topology
00251 //      WR > E, B > E, HR > A, A > B -> Throw
00252 // 5c:  Multiple different cell topologies in subset's subsets
00253 //      HR > F, WR > E, B > F, B > E, HR > A, A > B -> Throw
00254 
00255 // 1:   Part A > HR -> Okay
00256 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_1 )
00257 {
00258   stk::mesh::fem::FEMMetaData fem_meta;
00259   const size_t spatial_dimension = 3;
00260   fem_meta.FEM_initialize(spatial_dimension);
00261   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00262   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00263 
00264   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00265 
00266   fem_meta.declare_part_subset(A, HR);
00267   const stk::mesh::PartVector & HR_supersets = HR.supersets();
00268   STKUNIT_EXPECT_EQUAL(
00269       std::count(HR_supersets.begin(),HR_supersets.end(),&A), 1
00270       );
00271 }
00272 
00273 
00274 // 2a:  HR > QR -> Throw
00275 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_2a )
00276 {
00277   stk::mesh::fem::FEMMetaData fem_meta;
00278   const size_t spatial_dimension = 3;
00279   fem_meta.FEM_initialize(spatial_dimension);
00280   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00281   stk::mesh::fem::CellTopology QR_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
00282 
00283   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00284   stk::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top);
00285 
00286   STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(HR, QR), std::runtime_error );
00287 }
00288 
00289 
00290 // 2b:  HR > A, B > QR, A > B -> Throw
00291 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_2b )
00292 {
00293   stk::mesh::fem::FEMMetaData fem_meta;
00294   const size_t spatial_dimension = 3;
00295   fem_meta.FEM_initialize(spatial_dimension);
00296 
00297   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00298   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00299 
00300   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00301   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00302 
00303   stk::mesh::fem::CellTopology QR_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
00304   stk::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top);
00305 
00306   fem_meta.declare_part_subset( HR, A );
00307   fem_meta.declare_part_subset( B, QR );
00308   STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error );
00309 }
00310 
00311 
00312 // 3a:  Subset has no cell topology and subset's subsets have no cell topology
00313 //      HR > A -> Okay
00314 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3a )
00315 {
00316   stk::mesh::fem::FEMMetaData fem_meta;
00317   const size_t spatial_dimension = 3;
00318   fem_meta.FEM_initialize(spatial_dimension);
00319 
00320   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00321 
00322   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00323   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00324 
00325   fem_meta.declare_part_subset( HR, A );
00326 
00327   const stk::mesh::PartVector & A_supersets = A.supersets();
00328   STKUNIT_EXPECT_EQUAL(
00329       std::count(A_supersets.begin(),A_supersets.end(),&HR), 1
00330       );
00331 }
00332 
00333 
00334 // 3b:  Different rank cell topology on subset
00335 //      QR > D, HR > A, A > D -> Okay
00336 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3b )
00337 {
00338   stk::mesh::fem::FEMMetaData fem_meta;
00339   const size_t spatial_dimension = 3;
00340   fem_meta.FEM_initialize(spatial_dimension);
00341 
00342   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00343   stk::mesh::Part & D = fem_meta.declare_part("Part D", fem_meta.side_rank() );
00344 
00345   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00346   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00347 
00348   stk::mesh::fem::CellTopology QR_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
00349   stk::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top);
00350 
00351   fem_meta.declare_part_subset( QR, D );
00352   fem_meta.declare_part_subset( HR, A );
00353   fem_meta.declare_part_subset( A, D );
00354 
00355   const stk::mesh::PartVector & D_supersets = D.supersets();
00356   STKUNIT_EXPECT_EQUAL(
00357       std::count(D_supersets.begin(),D_supersets.end(),&A), 1
00358       );
00359 }
00360 
00361 
00362 // 3c:  Different rank cell topology on subset's subset
00363 //      QR > C, B > C, HR > A, A > B -> Okay
00364 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_3c )
00365 {
00366   stk::mesh::fem::FEMMetaData fem_meta;
00367   const size_t spatial_dimension = 3;
00368   fem_meta.FEM_initialize(spatial_dimension);
00369 
00370   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00371   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00372   stk::mesh::Part & C = fem_meta.declare_part("Part C", fem_meta.side_rank() );
00373 
00374   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00375   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00376 
00377   stk::mesh::fem::CellTopology QR_top(shards::getCellTopologyData<shards::Quadrilateral<4> >());
00378   stk::mesh::Part & QR = fem_meta.get_cell_topology_root_part(QR_top);
00379 
00380   fem_meta.declare_part_subset( QR, C );
00381   fem_meta.declare_part_subset( B, C );
00382   fem_meta.declare_part_subset( HR, A );
00383   fem_meta.declare_part_subset( A, B );
00384 
00385   const stk::mesh::PartVector & B_supersets = B.supersets();
00386   STKUNIT_EXPECT_EQUAL(
00387       std::count(B_supersets.begin(),B_supersets.end(),&A), 1
00388       );
00389 }
00390 
00391 
00392 // 4a:  Subset has same cell topology
00393 //      HR > A, HR > B, A > B -> Okay
00394 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_4a )
00395 {
00396   stk::mesh::fem::FEMMetaData fem_meta;
00397   const size_t spatial_dimension = 3;
00398   fem_meta.FEM_initialize(spatial_dimension);
00399 
00400   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00401   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00402 
00403   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00404   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00405 
00406   fem_meta.declare_part_subset( HR, A );
00407   fem_meta.declare_part_subset( HR, B );
00408   fem_meta.declare_part_subset( A, B );
00409 
00410   const stk::mesh::PartVector & B_supersets = B.supersets();
00411   STKUNIT_EXPECT_EQUAL(
00412       std::count(B_supersets.begin(),B_supersets.end(),&A), 1
00413       );
00414 }
00415 
00416 
00417 // 4b:  Subset's subsets have same cell topology
00418 //      HR > C, B > C, HR > A, A > B -> Okay
00419 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_4b )
00420 {
00421   stk::mesh::fem::FEMMetaData fem_meta;
00422   const size_t spatial_dimension = 3;
00423   fem_meta.FEM_initialize(spatial_dimension);
00424 
00425   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00426   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00427   stk::mesh::Part & C = fem_meta.declare_part("Part C", fem_meta.side_rank() );
00428 
00429   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00430   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00431 
00432   fem_meta.declare_part_subset( HR, C );
00433   fem_meta.declare_part_subset( B, C );
00434   fem_meta.declare_part_subset( HR, A );
00435   fem_meta.declare_part_subset( A, B );
00436 
00437   const stk::mesh::PartVector & B_supersets = B.supersets();
00438   STKUNIT_EXPECT_EQUAL(
00439       std::count(B_supersets.begin(),B_supersets.end(),&A), 1
00440       );
00441 }
00442 
00443 
00444 // 5a:  Subset has different cell topology
00445 //      WR > A, HR > B, A > B -> Throw
00446 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5a )
00447 {
00448   stk::mesh::fem::FEMMetaData fem_meta;
00449   const size_t spatial_dimension = 3;
00450   fem_meta.FEM_initialize(spatial_dimension);
00451 
00452   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00453   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00454 
00455   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00456   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00457 
00458   stk::mesh::fem::CellTopology WR_top(shards::getCellTopologyData<shards::Wedge<6> >());
00459   stk::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top);
00460 
00461   fem_meta.declare_part_subset( WR, A );
00462   fem_meta.declare_part_subset( HR, B );
00463   STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error );
00464 }
00465 
00466 
00467 // 5b:  Subset's subsets have different cell topology
00468 //      WR > E, B > E, HR > A, A > B -> Throw
00469 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5b )
00470 {
00471   stk::mesh::fem::FEMMetaData fem_meta;
00472   const size_t spatial_dimension = 3;
00473   fem_meta.FEM_initialize(spatial_dimension);
00474 
00475   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00476   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00477   stk::mesh::Part & E = fem_meta.declare_part("Part E", fem_meta.element_rank() );
00478 
00479   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00480   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00481 
00482   stk::mesh::fem::CellTopology WR_top(shards::getCellTopologyData<shards::Wedge<6> >());
00483   stk::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top);
00484 
00485   fem_meta.declare_part_subset( WR, E );
00486   stk::mesh::fem::CellTopology top = fem_meta.get_cell_topology(E);
00487   STKUNIT_ASSERT_TRUE( top.isValid() );
00488   fem_meta.declare_part_subset( B, E );
00489   fem_meta.declare_part_subset( HR, A );
00490   STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error );
00491 }
00492 
00493 
00494 // 5c:  Multiple different cell topologies in subset's subsets
00495 //      HR > F, WR > E, B > F, B > E, HR > A, A > B -> Throw
00496 STKUNIT_UNIT_TEST( UnitTestFEMMetaData, cell_topology_test_5c )
00497 {
00498   stk::mesh::fem::FEMMetaData fem_meta;
00499   const size_t spatial_dimension = 3;
00500   fem_meta.FEM_initialize(spatial_dimension);
00501 
00502   stk::mesh::Part & A = fem_meta.declare_part("Part A", fem_meta.element_rank() );
00503   stk::mesh::Part & B = fem_meta.declare_part("Part B", fem_meta.element_rank() );
00504   stk::mesh::Part & F = fem_meta.declare_part("Part F", fem_meta.element_rank() );
00505   stk::mesh::Part & E = fem_meta.declare_part("Part E", fem_meta.element_rank() );
00506 
00507   stk::mesh::fem::CellTopology HR_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00508   stk::mesh::Part & HR = fem_meta.get_cell_topology_root_part(HR_top);
00509 
00510   stk::mesh::fem::CellTopology WR_top(shards::getCellTopologyData<shards::Wedge<6> >());
00511   stk::mesh::Part & WR = fem_meta.get_cell_topology_root_part(WR_top);
00512 
00513   fem_meta.declare_part_subset( HR, F );
00514   fem_meta.declare_part_subset( WR, E );
00515   fem_meta.declare_part_subset( B, F );
00516   fem_meta.declare_part_subset( B, E );
00517   fem_meta.declare_part_subset( HR, A );
00518   STKUNIT_ASSERT_THROW( fem_meta.declare_part_subset(A, B), std::runtime_error );
00519 }
00520 
00521 
00522 
00523 
00524 
00525 STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate )
00526 {
00527   stk::mesh::fem::FEMMetaData fem_meta;
00528   const size_t spatial_dimension = 2;
00529   fem_meta.FEM_initialize(spatial_dimension);
00530   const stk::mesh::EntityRank hex_rank = 2;
00531 
00532   fem_meta.register_cell_topology( shards::getCellTopologyData<shards::Hexahedron<8> >(), hex_rank );
00533   STKUNIT_ASSERT_NO_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData<shards::Hexahedron<8> >(), hex_rank ) );
00534 }
00535 
00536 
00537 STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate_with_different_ranks )
00538 {
00539   stk::mesh::fem::FEMMetaData fem_meta;
00540   const size_t spatial_dimension = 2;
00541   fem_meta.FEM_initialize(spatial_dimension);
00542   const stk::mesh::EntityRank hex_rank = 2;
00543   const stk::mesh::EntityRank bad_rank = 1;
00544 
00545   fem_meta.register_cell_topology( shards::getCellTopologyData<shards::Hexahedron<8> >(), hex_rank );
00546   STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData<shards::Hexahedron<8> >(), bad_rank ), std::runtime_error );
00547 }
00548 
00549 
00550 STKUNIT_UNIT_TEST( FEMMetaData, register_cell_topology_duplicate_with_invalid_rank )
00551 {
00552   stk::mesh::fem::FEMMetaData fem_meta;
00553   const size_t spatial_dimension = 2;
00554   fem_meta.FEM_initialize(spatial_dimension);
00555   const stk::mesh::EntityRank invalid_rank = 3;
00556 
00557   STKUNIT_ASSERT_THROW( fem_meta.register_cell_topology( shards::getCellTopologyData<shards::Hexahedron<8> >(), invalid_rank ), std::logic_error );
00558 }
00559 
00560 
00561 STKUNIT_UNIT_TEST( FEMMetaData, get_cell_topology_root_part_invalid )
00562 {
00563   stk::mesh::fem::FEMMetaData fem_meta;
00564   const size_t spatial_dimension = 2;
00565   fem_meta.FEM_initialize(spatial_dimension);
00566 
00567   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00568 
00569   STKUNIT_ASSERT_THROW( fem_meta.get_cell_topology_root_part( hex_top ), std::runtime_error );
00570 }
00571 
00572 
00573 STKUNIT_UNIT_TEST( FEMMetaData, get_entity_rank_invalid )
00574 {
00575   stk::mesh::fem::FEMMetaData fem_meta;
00576   const size_t spatial_dimension = 2;
00577   fem_meta.FEM_initialize(spatial_dimension);
00578 
00579   stk::mesh::fem::CellTopology hex_top(shards::getCellTopologyData<shards::Hexahedron<8> >());
00580   stk::mesh::EntityRank rank = fem_meta.get_entity_rank(hex_top);
00581 
00582   const stk::mesh::EntityRank invalid_rank = INVALID_RANK;
00583   STKUNIT_ASSERT_EQUAL( rank, invalid_rank );
00584 }
00585 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines