| 1 |
#ifndef STK_SETUP_2BLOCK_2HEX_MESH_H |
| 2 |
#define STK_SETUP_2BLOCK_2HEX_MESH_H |
| 3 |
|
| 4 |
// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering |
| 5 |
// Solutions of Sandia, LLC (NTESS). Under the terms of Contract |
| 6 |
// DE-NA0003525 with NTESS, the U.S. Government retains certain rights |
| 7 |
// in this software. |
| 8 |
// |
| 9 |
// Redistribution and use in source and binary forms, with or without |
| 10 |
// modification, are permitted provided that the following conditions are |
| 11 |
// met: |
| 12 |
// |
| 13 |
// * Redistributions of source code must retain the above copyright |
| 14 |
// notice, this list of conditions and the following disclaimer. |
| 15 |
// |
| 16 |
// * Redistributions in binary form must reproduce the above |
| 17 |
// copyright notice, this list of conditions and the following |
| 18 |
// disclaimer in the documentation and/or other materials provided |
| 19 |
// with the distribution. |
| 20 |
// |
| 21 |
// * Neither the name of NTESS nor the names of its contributors |
| 22 |
// may be used to endorse or promote products derived from this |
| 23 |
// software without specific prior written permission. |
| 24 |
// |
| 25 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 26 |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 27 |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 28 |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 29 |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 30 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 31 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 32 |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 33 |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 35 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 |
// |
| 37 |
|
| 38 |
#include <stddef.h> // for size_t |
| 39 |
#include <stdlib.h> // for exit |
| 40 |
#include <exception> // for exception |
| 41 |
#include <iostream> // for ostringstream, etc |
| 42 |
#include <iterator> // for distance |
| 43 |
#include <map> // for _Rb_tree_const_iterator, etc |
| 44 |
#include <stdexcept> // for logic_error, runtime_error |
| 45 |
#include <stk_mesh/base/BulkData.hpp> // for BulkData, etc |
| 46 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 47 |
#include <stk_util/parallel/Parallel.hpp> // for ParallelMachine, etc |
| 48 |
#include <string> // for string, basic_string, etc |
| 49 |
#include <utility> // for pair |
| 50 |
#include <vector> // for vector, etc |
| 51 |
#include "stk_mesh/base/Bucket.hpp" // for Bucket, has_superset |
| 52 |
#include "stk_mesh/base/Entity.hpp" // for Entity |
| 53 |
#include "stk_mesh/base/EntityKey.hpp" // for EntityKey |
| 54 |
#include "stk_mesh/base/MetaData.hpp" // for MetaData, entity_rank_names, etc |
| 55 |
#include "stk_mesh/base/Part.hpp" // for Part |
| 56 |
#include "stk_mesh/base/Types.hpp" // for EntityProc, EntityVector, etc |
| 57 |
#include "stk_topology/topology.hpp" // for topology, etc |
| 58 |
|
| 59 |
inline |
| 60 |
void setup2Block2HexMesh(stk::mesh::BulkData& bulk) |
| 61 |
{ |
| 62 |
// |
| 63 |
// proc 0 proc 1 |
| 64 |
// | |
| 65 |
// block_1 | block_2 |
| 66 |
// | |
| 67 |
// 8----7 | 7----12 |
| 68 |
// / /| | / / | |
| 69 |
// 5----6 3 | 6----11 10 |
| 70 |
// | 1 |/ | | 2 | / |
| 71 |
// 1----2 | 2----9 |
| 72 |
// | |
| 73 |
// | |
| 74 |
// | |
| 75 |
// |
| 76 |
//shared nodes 2, 3, 6, 7 |
| 77 |
// |
| 78 |
|
| 79 |
if (bulk.parallel_size() > 2) { |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
stk::mesh::MetaData& meta = bulk.mesh_meta_data(); |
| 84 |
|
| 85 |
stk::topology hex = stk::topology::HEX_8; |
| 86 |
stk::mesh::Part& block_1 = meta.declare_part_with_topology("block_1", hex); |
| 87 |
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", hex); |
| 88 |
meta.commit(); |
| 89 |
|
| 90 |
bulk.modification_begin(); |
| 91 |
|
| 92 |
stk::mesh::EntityIdVector elem1_nodes {1, 2, 3, 4, 5, 6, 7, 8}; |
| 93 |
stk::mesh::EntityIdVector elem2_nodes {2, 9, 10, 3, 6, 11, 12, 7}; |
| 94 |
|
| 95 |
stk::mesh::EntityId elemId = 1; |
| 96 |
if (bulk.parallel_rank() == 0) { |
| 97 |
stk::mesh::declare_element(bulk, block_1, elemId, elem1_nodes); |
| 98 |
} |
| 99 |
if (bulk.parallel_rank() == 1 || bulk.parallel_size() == 1) { |
| 100 |
elemId = 2; |
| 101 |
stk::mesh::declare_element(bulk, block_2, elemId, elem2_nodes); |
| 102 |
} |
| 103 |
if(bulk.parallel_rank() == 0 && bulk.parallel_size() == 2) |
| 104 |
{ |
| 105 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 2), 1); |
| 106 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 3), 1); |
| 107 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 6), 1); |
| 108 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 7), 1); |
| 109 |
} |
| 110 |
if(bulk.parallel_rank() == 1 && bulk.parallel_size() == 2) |
| 111 |
{ |
| 112 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 2), 0); |
| 113 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 3), 0); |
| 114 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 6), 0); |
| 115 |
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 7), 0); |
| 116 |
} |
| 117 |
|
| 118 |
bulk.modification_end(); |
| 119 |
} |
| 120 |
|
| 121 |
#endif |