// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering // Solutions of Sandia, LLC (NTESS). Under the terms of Contract // DE-NA0003525 with NTESS, the U.S. Government retains certain rights // in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // * Neither the name of NTESS nor the names of its contributors // may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // #include "SetupKeyholeMesh.hpp" #include "mpi.h" // for MPI_COMM_WORLD, etc #include "stk_mesh/base/Bucket.hpp" // for Bucket #include "stk_mesh/base/CreateEdges.hpp" // for create_edges #include "stk_mesh/base/Entity.hpp" // for Entity #include "stk_mesh/base/MetaData.hpp" // for MetaData #include "stk_mesh/base/Types.hpp" // for PartVector, BucketVector, etc #include "stk_topology/topology.hpp" // for topology, etc #include // for AssertHelper, EXPECT_TRUE, etc #include // for operator<<, basic_ostream, etc #include // for size_t #include // for BulkData #include // for parallel_machine_size, etc #include #include // for operator<<, char_traits namespace stk { namespace mesh { class Part; } } using stk::unit_test_util::build_mesh; TEST(UnitTestKeyhole, NodeParts_case1) { stk::ParallelMachine communicator = MPI_COMM_WORLD; int numProcs = stk::parallel_machine_size(communicator); if (numProcs != 2) { return; } const unsigned spatialDim = 2; std::shared_ptr bulkPtr = build_mesh(spatialDim, communicator); stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); stk::mesh::BulkData& bulk = *bulkPtr; stk::mesh::unit_test::setupKeyholeMesh2D_case1(bulk); stk::mesh::Part& shared = meta.globally_shared_part(); const stk::mesh::BucketVector& shared_node_buckets = bulk.get_buckets(stk::topology::NODE_RANK, shared); stk::mesh::PartVector blocksA(2); blocksA[0] = meta.get_part("block_1"); blocksA[1] = meta.get_part("block_2"); unsigned num_shared_nodes = 0; for(size_t i=0; isize(); const stk::mesh::Bucket& bucket = *shared_node_buckets[i]; std::ostringstream oss; oss<<"proc "< bulkPtr = build_mesh(spatialDim, communicator); stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); stk::mesh::BulkData& bulk = *bulkPtr; stk::mesh::unit_test::setupKeyholeMesh2D_case2(bulk); if (bulk.parallel_rank() == 0) { stk::mesh::Part& aura = meta.aura_part(); const stk::mesh::BucketVector& aura_node_buckets = bulk.get_buckets(stk::topology::NODE_RANK, aura); stk::mesh::PartVector blocks(2); blocks[0] = meta.get_part("block_2"); blocks[1] = meta.get_part("block_3"); unsigned num_aura_nodes = 0; for(size_t i=0; isize(); const stk::mesh::Bucket& bucket = *aura_node_buckets[i]; std::cerr<<"proc 0, aura node ids: "; for(size_t j=0; j bulkPtr = build_mesh(spatialDim, communicator); stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); stk::mesh::BulkData& bulk = *bulkPtr; stk::mesh::unit_test::setupKeyholeMesh2D_case1(bulk); stk::mesh::create_edges(bulk); //find the edge between nodes 2 and 3. stk::mesh::Entity edge = stk::mesh::Entity(); stk::mesh::EntityId nodeId2 = 2; stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, nodeId2); unsigned num_edges = bulk.num_edges(node2); const stk::mesh::Entity* edges = bulk.begin_edges(node2); for(unsigned i=0; i bulkPtr = build_mesh(spatialDim, communicator); stk::mesh::MetaData& meta = bulkPtr->mesh_meta_data(); stk::mesh::BulkData& bulk = *bulkPtr; bulk.initialize_face_adjacent_element_graph(); stk::mesh::unit_test::setupKeyholeMesh2D_case2(bulk); stk::mesh::create_edges(bulk); //find the edge between nodes 5 and 6. stk::mesh::Entity edge = stk::mesh::Entity(); stk::mesh::EntityId nodeId5 = 5; stk::mesh::Entity node5 = bulk.get_entity(stk::topology::NODE_RANK, nodeId5); unsigned num_edges = bulk.num_edges(node5); const stk::mesh::Entity* edges = bulk.begin_edges(node5); for(unsigned i=0; i