| 1 |
// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering |
| 2 |
// Solutions of Sandia, LLC (NTESS). Under the terms of Contract |
| 3 |
// DE-NA0003525 with NTESS, the U.S. Government retains certain rights |
| 4 |
// in this software. |
| 5 |
// |
| 6 |
// Redistribution and use in source and binary forms, with or without |
| 7 |
// modification, are permitted provided that the following conditions are |
| 8 |
// met: |
| 9 |
// |
| 10 |
// * Redistributions of source code must retain the above copyright |
| 11 |
// notice, this list of conditions and the following disclaimer. |
| 12 |
// |
| 13 |
// * Redistributions in binary form must reproduce the above |
| 14 |
// copyright notice, this list of conditions and the following |
| 15 |
// disclaimer in the documentation and/or other materials provided |
| 16 |
// with the distribution. |
| 17 |
// |
| 18 |
// * Neither the name of NTESS nor the names of its contributors |
| 19 |
// may be used to endorse or promote products derived from this |
| 20 |
// software without specific prior written permission. |
| 21 |
// |
| 22 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
// |
| 34 |
|
| 35 |
#include <gtest/gtest.h> // for TEST |
| 36 |
#include <iostream> // for cout, endl |
| 37 |
#include <stk_mesh/base/BulkData.hpp> // for BulkData |
| 38 |
#include <stk_mesh/base/Entity.hpp> // for Entity |
| 39 |
#include <stk_mesh/base/MetaData.hpp> // for MetaData |
| 40 |
#include <stk_mesh/base/Types.hpp> // for EntityRank, PartVector, etc |
| 41 |
#include <stk_util/parallel/Parallel.hpp> // for parallel_machine_rank, etc |
| 42 |
#include <vector> // for vector |
| 43 |
#include "mpi.h" // for MPI_COMM_WORLD |
| 44 |
|
| 45 |
#include "stk_topology/topology.hpp" // for topology, etc |
| 46 |
#include "stk_unit_test_utils/stk_mesh_fixtures/GridFixture.hpp" // for GridFixture |
| 47 |
namespace stk { namespace mesh { class Part; } } |
| 48 |
namespace stk { namespace mesh { class Selector; } } |
| 49 |
|
| 50 |
using stk::mesh::MetaData; |
| 51 |
using stk::mesh::Part; |
| 52 |
using stk::mesh::PartVector; |
| 53 |
using stk::mesh::Entity; |
| 54 |
using stk::mesh::EntityVector; |
| 55 |
using stk::mesh::EntityRank; |
| 56 |
using stk::mesh::Selector; |
| 57 |
using stk::mesh::BulkData; |
| 58 |
using stk::ParallelMachine; |
| 59 |
using std::cout; |
| 60 |
using std::endl; |
| 61 |
|
| 62 |
TEST( UnitTestGridFixture, test_gridfixture ) |
| 63 |
{ |
| 64 |
//Coverage of GridFixture, Hexfixture, BoxFixture,QuadFixture |
| 65 |
//and RingFixture in fixture directory for more than one |
| 66 |
//processor. |
| 67 |
stk::mesh::fixtures::GridFixture grid_mesh(MPI_COMM_WORLD); |
| 68 |
|
| 69 |
stk::mesh::BulkData& bulk_data = grid_mesh.bulk_data(); |
| 70 |
stk::mesh::MetaData& fem_meta = grid_mesh.fem_meta(); |
| 71 |
|
| 72 |
int rank = stk::parallel_machine_rank( MPI_COMM_WORLD ); |
| 73 |
int size = stk::parallel_machine_size( MPI_COMM_WORLD ); |
| 74 |
|
| 75 |
// Create a part for the shells |
| 76 |
stk::mesh::Part & shell_part = fem_meta.declare_part_with_topology("shell_part", stk::topology::SHELL_LINE_2); |
| 77 |
|
| 78 |
fem_meta.commit(); |
| 79 |
|
| 80 |
// Generate the plain grid |
| 81 |
bulk_data.modification_begin(); |
| 82 |
grid_mesh.generate_grid(); |
| 83 |
bulk_data.modification_end(); |
| 84 |
|
| 85 |
// Add the shells |
| 86 |
bulk_data.modification_begin(); |
| 87 |
|
| 88 |
const unsigned num_shell_1_faces = 4*size + rank; |
| 89 |
const unsigned num_shell_2_faces = 2*size + rank; |
| 90 |
const unsigned num_shell_faces = num_shell_1_faces + num_shell_2_faces; |
| 91 |
|
| 92 |
stk::mesh::PartVector shell_parts; |
| 93 |
shell_parts.push_back(&shell_part); |
| 94 |
|
| 95 |
std::vector<stk::mesh::Entity> shell_faces; |
| 96 |
|
| 97 |
unsigned id_base = 0; |
| 98 |
unsigned id_offset = 500; // a safe offset to avoid id overlap |
| 99 |
//Start at 1 so as not to have same element on different processors |
| 100 |
for (id_base = 1; id_base <= num_shell_faces; ++id_base) { |
| 101 |
|
| 102 |
int new_id = rank * num_shell_faces + id_base; |
| 103 |
stk::mesh::Entity new_shell = bulk_data.declare_element(id_offset + new_id, shell_parts); |
| 104 |
for(unsigned node_ord = 0 ; node_ord < 2; ++node_ord) |
| 105 |
{ |
| 106 |
stk::mesh::Entity new_node = bulk_data.declare_node((node_ord+10)*(id_offset + new_id)); |
| 107 |
bulk_data.declare_relation( new_shell , new_node , node_ord); |
| 108 |
} |
| 109 |
shell_faces.push_back(new_shell); |
| 110 |
} |
| 111 |
|
| 112 |
bulk_data.modification_end(); |
| 113 |
} |
| 114 |
|
| 115 |
|