| 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 AssertHelper, EXPECT_EQ, etc |
| 36 |
#include <stk_mesh/base/MetaData.hpp> // for MetaData |
| 37 |
#include <stk_mesh/base/BulkData.hpp> |
| 38 |
#include <stk_mesh/base/SkinBoundary.hpp> |
| 39 |
#include <stk_mesh/base/GetEntities.hpp> |
| 40 |
#include "stk_mesh/baseImpl/elementGraph/ElemElemGraph.hpp" |
| 41 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 42 |
#include <stk_io/StkMeshIoBroker.hpp> |
| 43 |
#include <stk_io/FillMesh.hpp> |
| 44 |
#include <stk_io/WriteMesh.hpp> |
| 45 |
#include <stk_tools/mesh_tools/DisconnectBlocks.hpp> |
| 46 |
#include <stk_tools/mesh_tools/DisconnectBlocksImpl.hpp> |
| 47 |
#include <stk_tools/mesh_tools/DetectHingesImpl.hpp> |
| 48 |
#include <stk_unit_test_utils/TextMesh.hpp> |
| 49 |
#include <stk_unit_test_utils/BuildMesh.hpp> |
| 50 |
#include <stk_util/environment/WallTime.hpp> |
| 51 |
#include "DisconnectBlocksMeshConstruction.hpp" |
| 52 |
#include "stk_unit_test_utils/getOption.h" |
| 53 |
#include "stk_util/parallel/ParallelReduce.hpp" |
| 54 |
#include "stk_util/util/SortAndUnique.hpp" |
| 55 |
#include <stk_util/util/string_utils.hpp> |
| 56 |
#include "stk_util/util/GraphCycleDetector.hpp" |
| 57 |
#include "stk_mesh/base/Types.hpp" |
| 58 |
#include "stk_mesh/base/FEMHelpers.hpp" |
| 59 |
#include "stk_mesh/base/EntityLess.hpp" |
| 60 |
#include "stk_mesh/base/Comm.hpp" |
| 61 |
|
| 62 |
#include <string> |
| 63 |
#include <algorithm> |
| 64 |
|
| 65 |
using stk::unit_test_util::build_mesh; |
| 66 |
|
| 67 |
TEST(DetectHinge2D, EmptyMesh) |
| 68 |
{ |
| 69 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(3,MPI_COMM_WORLD); |
| 70 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 71 |
EXPECT_EQ(0u, hingeCount.first); |
| 72 |
EXPECT_EQ(0u, hingeCount.second); |
| 73 |
} |
| 74 |
|
| 75 |
TEST(DetectHinge2D, SingleBlockNoHinge) |
| 76 |
{ |
| 77 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) |
| 78 |
return; |
| 79 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 80 |
setup_mesh_1block_1quad(*bulk); |
| 81 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 82 |
EXPECT_EQ(0u, hingeCount.first); |
| 83 |
EXPECT_EQ(0u, hingeCount.second); |
| 84 |
output_mesh(*bulk); |
| 85 |
} |
| 86 |
|
| 87 |
TEST(DetectHinge2D, SingleBlockTwoElementsNoHinge) |
| 88 |
{ |
| 89 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 90 |
return; |
| 91 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 92 |
setup_mesh_1block_2quad(*bulk); |
| 93 |
two_elements_decomposition(*bulk); |
| 94 |
|
| 95 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 96 |
EXPECT_EQ(0u, hingeCount.first); |
| 97 |
EXPECT_EQ(0u, hingeCount.second); |
| 98 |
output_mesh(*bulk); |
| 99 |
} |
| 100 |
|
| 101 |
TEST(DetectHinge2D, SingleBlockTwoElementsOneNodeHinge) |
| 102 |
{ |
| 103 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 104 |
return; |
| 105 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 106 |
setup_mesh_1block_2quad_1node_hinge(*bulk); |
| 107 |
two_elements_decomposition(*bulk); |
| 108 |
|
| 109 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 110 |
EXPECT_EQ(1u, hingeCount.first); |
| 111 |
EXPECT_EQ(0u, hingeCount.second); |
| 112 |
output_mesh(*bulk); |
| 113 |
} |
| 114 |
|
| 115 |
TEST(DetectHinge2D, SingleBlockTwoElementsTwoNodeHinges) |
| 116 |
{ |
| 117 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 118 |
return; |
| 119 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 120 |
setup_mesh_1block_2quad_2hinge(*bulk); |
| 121 |
two_elements_decomposition(*bulk); |
| 122 |
|
| 123 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 124 |
EXPECT_EQ(2u, hingeCount.first); |
| 125 |
EXPECT_EQ(0u, hingeCount.second); |
| 126 |
output_mesh(*bulk); |
| 127 |
} |
| 128 |
|
| 129 |
TEST(DetectHinge2D, AreNodesPartOfASide) |
| 130 |
{ |
| 131 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_SELF); |
| 132 |
setup_mesh_1block_1quad(*bulk); |
| 133 |
stk::mesh::EntityVector elems = get_elements_from_id_range(*bulk, 1); |
| 134 |
stk::mesh::EntityVector nodes = get_nodes_from_id_range(*bulk, 4); |
| 135 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[1]})); |
| 136 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[3]})); |
| 137 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[3],nodes[2]})); |
| 138 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[2],nodes[0]})); |
| 139 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[3]})); |
| 140 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side(*bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[2]})); |
| 141 |
} |
| 142 |
|
| 143 |
TEST(DetectHinge2D, SingleBlockThreeElementsOneHinge_Decomp1) |
| 144 |
{ |
| 145 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 146 |
return; |
| 147 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 148 |
setup_mesh_1block_3quad_1hinge(*bulk); |
| 149 |
|
| 150 |
three_elements_decomposition(*bulk); |
| 151 |
|
| 152 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 153 |
EXPECT_EQ(1u, hingeCount.first); |
| 154 |
EXPECT_EQ(0u, hingeCount.second); |
| 155 |
output_mesh(*bulk); |
| 156 |
} |
| 157 |
|
| 158 |
TEST(DetectHinge2D, SingleBlockThreeElementsOneHinge_Decomp2) |
| 159 |
{ |
| 160 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 161 |
return; |
| 162 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 163 |
setup_mesh_1block_3quad_1hinge(*bulk); |
| 164 |
|
| 165 |
if(bulk->parallel_size() == 2) { |
| 166 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,1} }; |
| 167 |
distribute_mesh(*bulk, idProcVec); |
| 168 |
} |
| 169 |
else if(bulk->parallel_size() == 3) { |
| 170 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2} }; |
| 171 |
distribute_mesh(*bulk, idProcVec); |
| 172 |
} |
| 173 |
|
| 174 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 175 |
EXPECT_EQ(1u, hingeCount.first); |
| 176 |
EXPECT_EQ(0u, hingeCount.second); |
| 177 |
output_mesh(*bulk); |
| 178 |
} |
| 179 |
|
| 180 |
TEST(DetectHinge2D, SingleBlockThreeElementsOneHinge_LinearStack) |
| 181 |
{ |
| 182 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 183 |
return; |
| 184 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 185 |
setup_mesh_1block_3quad_1hinge_linear_stack(*bulk); |
| 186 |
|
| 187 |
three_elements_decomposition(*bulk); |
| 188 |
|
| 189 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 190 |
EXPECT_EQ(1u, hingeCount.first); |
| 191 |
EXPECT_EQ(0u, hingeCount.second); |
| 192 |
output_mesh(*bulk); |
| 193 |
} |
| 194 |
|
| 195 |
TEST(DetectHinge2D, SingleBlockFourElementsBowtie_Decomp1) |
| 196 |
{ |
| 197 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 198 |
return; |
| 199 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 200 |
setup_mesh_1block_4quad_bowtie_1hinge(*bulk); |
| 201 |
|
| 202 |
if(bulk->parallel_size() == 2) { |
| 203 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,1} }; |
| 204 |
distribute_mesh(*bulk, idProcVec); |
| 205 |
} |
| 206 |
else if(bulk->parallel_size() == 3) { |
| 207 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2} }; |
| 208 |
distribute_mesh(*bulk, idProcVec); |
| 209 |
} |
| 210 |
else if(bulk->parallel_size() == 4) { |
| 211 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2}, {4u,3} }; |
| 212 |
distribute_mesh(*bulk, idProcVec); |
| 213 |
} |
| 214 |
|
| 215 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 216 |
EXPECT_EQ(1u, hingeCount.first); |
| 217 |
EXPECT_EQ(0u, hingeCount.second); |
| 218 |
output_mesh(*bulk); |
| 219 |
} |
| 220 |
|
| 221 |
TEST(DetectHinge2D, SingleBlockFourElementsBowtie_Decomp2) |
| 222 |
{ |
| 223 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 224 |
return; |
| 225 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 226 |
setup_mesh_1block_4quad_bowtie_1hinge(*bulk); |
| 227 |
|
| 228 |
if(bulk->parallel_size() == 2) { |
| 229 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,1}, {4u,1} }; |
| 230 |
distribute_mesh(*bulk, idProcVec); |
| 231 |
} |
| 232 |
else if(bulk->parallel_size() == 3) { |
| 233 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,2} }; |
| 234 |
distribute_mesh(*bulk, idProcVec); |
| 235 |
} |
| 236 |
else if(bulk->parallel_size() == 4) { |
| 237 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2}, {4u,3} }; |
| 238 |
distribute_mesh(*bulk, idProcVec); |
| 239 |
} |
| 240 |
|
| 241 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 242 |
EXPECT_EQ(1u, hingeCount.first); |
| 243 |
EXPECT_EQ(0u, hingeCount.second); |
| 244 |
output_mesh(*bulk); |
| 245 |
} |
| 246 |
|
| 247 |
TEST(DetectHinge2D, SingleBlockFourElementsTwoHinge_Decomp1) |
| 248 |
{ |
| 249 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 250 |
return; |
| 251 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 252 |
setup_mesh_1block_4quad_2hinge(*bulk); |
| 253 |
|
| 254 |
if(bulk->parallel_size() == 2) { |
| 255 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,1}, {4u,1} }; |
| 256 |
distribute_mesh(*bulk, idProcVec); |
| 257 |
} |
| 258 |
else if(bulk->parallel_size() == 3) { |
| 259 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2} }; |
| 260 |
distribute_mesh(*bulk, idProcVec); |
| 261 |
} |
| 262 |
else if(bulk->parallel_size() == 4) { |
| 263 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2}, {4u,3} }; |
| 264 |
distribute_mesh(*bulk, idProcVec); |
| 265 |
} |
| 266 |
|
| 267 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 268 |
EXPECT_EQ(2u, hingeCount.first); |
| 269 |
EXPECT_EQ(0u, hingeCount.second); |
| 270 |
output_mesh(*bulk); |
| 271 |
} |
| 272 |
|
| 273 |
TEST(DetectHinge2D, SingleBlockFourElementsTwoHinge_Decomp2) |
| 274 |
{ |
| 275 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 276 |
return; |
| 277 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 278 |
setup_mesh_1block_4quad_2hinge(*bulk); |
| 279 |
|
| 280 |
four_elements_decomposition(*bulk); |
| 281 |
|
| 282 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 283 |
EXPECT_EQ(2u, hingeCount.first); |
| 284 |
EXPECT_EQ(0u, hingeCount.second); |
| 285 |
output_mesh(*bulk); |
| 286 |
} |
| 287 |
|
| 288 |
TEST(DetectHinge2D, SingleBlockFourElementsFourHinge_Decomp1) |
| 289 |
{ |
| 290 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 291 |
return; |
| 292 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 293 |
setup_mesh_1block_4quad_4hinge(*bulk); |
| 294 |
|
| 295 |
four_elements_decomposition(*bulk); |
| 296 |
|
| 297 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 298 |
EXPECT_EQ(4u, hingeCount.first); |
| 299 |
EXPECT_EQ(0u, hingeCount.second); |
| 300 |
output_mesh(*bulk); |
| 301 |
} |
| 302 |
|
| 303 |
TEST(DetectHinge2D, SingleBlockFourElementsFourHinge_Decomp2) |
| 304 |
{ |
| 305 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 306 |
return; |
| 307 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 308 |
setup_mesh_1block_4quad_4hinge(*bulk); |
| 309 |
|
| 310 |
if(bulk->parallel_size() == 2) { |
| 311 |
stk::mesh::EntityIdProcVec idProcVec{ {1u,1}, {3u,1} }; |
| 312 |
distribute_mesh(*bulk, idProcVec); |
| 313 |
} |
| 314 |
else if(bulk->parallel_size() == 3) { |
| 315 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,2} }; |
| 316 |
distribute_mesh(*bulk, idProcVec); |
| 317 |
} |
| 318 |
else if(bulk->parallel_size() == 4) { |
| 319 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2}, {4u,3} }; |
| 320 |
distribute_mesh(*bulk, idProcVec); |
| 321 |
} |
| 322 |
|
| 323 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 324 |
EXPECT_EQ(4u, hingeCount.first); |
| 325 |
EXPECT_EQ(0u, hingeCount.second); |
| 326 |
output_mesh(*bulk); |
| 327 |
} |
| 328 |
|
| 329 |
TEST(DetectHinge2D, SingleBlockFourElementsNoHingePacman) |
| 330 |
{ |
| 331 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 332 |
return; |
| 333 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 334 |
setup_mesh_1block_4quad_pacman(*bulk); |
| 335 |
|
| 336 |
four_elements_decomposition2(*bulk); |
| 337 |
|
| 338 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 339 |
EXPECT_EQ(0u, hingeCount.first); |
| 340 |
EXPECT_EQ(0u, hingeCount.second); |
| 341 |
output_mesh(*bulk); |
| 342 |
} |
| 343 |
|
| 344 |
TEST(DetectHinge2D, SingleBlockFourElementsOneHinge) |
| 345 |
{ |
| 346 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 347 |
return; |
| 348 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 349 |
setup_mesh_1block_4quad_1hinge(*bulk); |
| 350 |
|
| 351 |
four_elements_decomposition2(*bulk); |
| 352 |
|
| 353 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 354 |
EXPECT_EQ(1u, hingeCount.first); |
| 355 |
EXPECT_EQ(0u, hingeCount.second); |
| 356 |
output_mesh(*bulk); |
| 357 |
} |
| 358 |
|
| 359 |
TEST(DetectHinge2D, TwoBlockFiveElementsOneHinge) |
| 360 |
{ |
| 361 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(2,MPI_COMM_WORLD); |
| 362 |
setup_mesh_2block_3quad_2tri_1hinge(*bulk); |
| 363 |
five_elements_decomposition(*bulk); |
| 364 |
|
| 365 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 366 |
EXPECT_EQ(1u, hingeCount.first); |
| 367 |
EXPECT_EQ(0u, hingeCount.second); |
| 368 |
output_mesh(*bulk); |
| 369 |
} |
| 370 |
|
| 371 |
TEST(DetectHinge3D, SingleBlockNoHinge) |
| 372 |
{ |
| 373 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) |
| 374 |
return; |
| 375 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(3,MPI_COMM_WORLD); |
| 376 |
setup_mesh_1block_1hex(*bulk); |
| 377 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 378 |
EXPECT_EQ(0u, hingeCount.first); |
| 379 |
EXPECT_EQ(0u, hingeCount.second); |
| 380 |
output_mesh(*bulk); |
| 381 |
} |
| 382 |
|
| 383 |
TEST(DetectHinge3D, SingleBlockTwoElementsNoHinge) |
| 384 |
{ |
| 385 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 386 |
return; |
| 387 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 388 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 389 |
setup_mesh_1block_2hex(bulk); |
| 390 |
|
| 391 |
if(bulk.parallel_size() == 2) { |
| 392 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1} }; |
| 393 |
distribute_mesh(bulk, idProcVec); |
| 394 |
} |
| 395 |
|
| 396 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 397 |
EXPECT_EQ(0u, hingeCount.first); |
| 398 |
EXPECT_EQ(0u, hingeCount.second); |
| 399 |
output_mesh(bulk); |
| 400 |
} |
| 401 |
|
| 402 |
TEST(DetectHinge3D, SingleBlockTwoElementsNoHingeFaceTest) |
| 403 |
{ |
| 404 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) |
| 405 |
return; |
| 406 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 407 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 408 |
setup_mesh_1block_2hex_face_test(bulk); |
| 409 |
|
| 410 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 7u); |
| 411 |
stk::tools::impl::PairwiseSideInfoVector infoVec = stk::tools::impl::get_hinge_info_vec(bulk, node); |
| 412 |
|
| 413 |
EXPECT_EQ(1u, get_side_count(infoVec)); |
| 414 |
output_mesh(bulk); |
| 415 |
} |
| 416 |
|
| 417 |
TEST(DetectHinge3D, SingleBlockTwoElementsOneNodeHinge) |
| 418 |
{ |
| 419 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 420 |
return; |
| 421 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 422 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 423 |
setup_mesh_1block_2hex_1node_hinge(bulk); |
| 424 |
|
| 425 |
if(bulk.parallel_size() == 2) { |
| 426 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1} }; |
| 427 |
distribute_mesh(bulk, idProcVec); |
| 428 |
} |
| 429 |
|
| 430 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 431 |
EXPECT_EQ(1u, hingeCount.first); |
| 432 |
EXPECT_EQ(0u, hingeCount.second); |
| 433 |
output_mesh(bulk); |
| 434 |
} |
| 435 |
|
| 436 |
TEST(DetectHinge3D, SingleBlockTwoElementsTwoNodeHinge) |
| 437 |
{ |
| 438 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 439 |
return; |
| 440 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 441 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 442 |
setup_mesh_1block_2hex_2node_hinge(bulk); |
| 443 |
|
| 444 |
if(bulk.parallel_size() == 2) { |
| 445 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1} }; |
| 446 |
distribute_mesh(bulk, idProcVec); |
| 447 |
} |
| 448 |
|
| 449 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 450 |
EXPECT_EQ(2u, hingeCount.first); |
| 451 |
EXPECT_EQ(0u, hingeCount.second); |
| 452 |
output_mesh(bulk); |
| 453 |
} |
| 454 |
|
| 455 |
TEST(DetectHinge3D, SingleBlockThreeElementsOneNodeHinge) |
| 456 |
{ |
| 457 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 458 |
return; |
| 459 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(3,MPI_COMM_WORLD); |
| 460 |
setup_mesh_1block_3hex_1node_hinge(*bulk); |
| 461 |
|
| 462 |
three_elements_decomposition(*bulk); |
| 463 |
|
| 464 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 465 |
EXPECT_EQ(1u, hingeCount.first); |
| 466 |
EXPECT_EQ(0u, hingeCount.second); |
| 467 |
output_mesh(*bulk); |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
TEST(DetectHinge3D, SingleBlockEightElementsOneNodeHingeFlower) |
| 472 |
{ |
| 473 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 8) |
| 474 |
return; |
| 475 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 476 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 477 |
setup_mesh_1block_8hex_flower_1node_hinge(bulk); |
| 478 |
|
| 479 |
if(bulk.parallel_size() == 2) { |
| 480 |
stk::mesh::EntityIdProcVec idProcVec{ {5u,1}, {6u,1}, {7u,1}, {8u,1} }; |
| 481 |
distribute_mesh(bulk, idProcVec); |
| 482 |
} |
| 483 |
else if(bulk.parallel_size() == 3) { |
| 484 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,1}, {4u,1}, {5u,1}, {6u,2}, {7u,2}, {8u,2} }; |
| 485 |
distribute_mesh(bulk, idProcVec); |
| 486 |
} |
| 487 |
else if(bulk.parallel_size() == 4) { |
| 488 |
stk::mesh::EntityIdProcVec idProcVec{ {3u,1}, {4u,1}, {5u,2}, {6u,2}, {7u,3}, {8u,3} }; |
| 489 |
distribute_mesh(bulk, idProcVec); |
| 490 |
} |
| 491 |
|
| 492 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 493 |
EXPECT_EQ(1u, hingeCount.first); |
| 494 |
EXPECT_EQ(0u, hingeCount.second); |
| 495 |
output_mesh(bulk); |
| 496 |
} |
| 497 |
|
| 498 |
TEST(DetectHinge3D, SingleBlockTwoTetsOneNodeHinge) |
| 499 |
{ |
| 500 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 501 |
return; |
| 502 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 503 |
setup_mesh_1block_2tet_1node_hinge(*bulkPtr); |
| 504 |
|
| 505 |
two_elements_decomposition(*bulkPtr); |
| 506 |
|
| 507 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulkPtr); |
| 508 |
EXPECT_EQ(1u, hingeCount.first); |
| 509 |
EXPECT_EQ(0u, hingeCount.second); |
| 510 |
output_mesh(*bulkPtr); |
| 511 |
} |
| 512 |
|
| 513 |
TEST(DetectHinge3D, SingleBlockTwoHexOneEdgeHinge) |
| 514 |
{ |
| 515 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 516 |
return; |
| 517 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(3,MPI_COMM_WORLD); |
| 518 |
setup_mesh_1block_2hex_1edge_hinge(*bulk); |
| 519 |
|
| 520 |
two_elements_decomposition(*bulk); |
| 521 |
|
| 522 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 523 |
EXPECT_EQ(0u, hingeCount.first); |
| 524 |
EXPECT_EQ(1u, hingeCount.second); |
| 525 |
output_mesh(*bulk); |
| 526 |
} |
| 527 |
|
| 528 |
TEST(DetectHinge3D, SingleBlockThreeHexOneEdgeHinge) |
| 529 |
{ |
| 530 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 531 |
return; |
| 532 |
std::shared_ptr<stk::mesh::BulkData> bulk = build_mesh(3,MPI_COMM_WORLD); |
| 533 |
setup_mesh_1block_3hex_1edge_hinge(*bulk); |
| 534 |
|
| 535 |
three_elements_decomposition(*bulk); |
| 536 |
|
| 537 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(*bulk); |
| 538 |
EXPECT_EQ(0u, hingeCount.first); |
| 539 |
EXPECT_EQ(1u, hingeCount.second); |
| 540 |
output_mesh(*bulk); |
| 541 |
} |
| 542 |
|
| 543 |
TEST(DetectHinge3D, AreNodesPartOfASide) |
| 544 |
{ |
| 545 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_SELF); |
| 546 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 547 |
setup_mesh_1block_1hex(bulk); |
| 548 |
stk::mesh::EntityVector nodes = get_nodes_from_id_range(bulk, 8); |
| 549 |
stk::mesh::EntityVector elems = get_elements_from_id_range(bulk, 1); |
| 550 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[1],nodes[2],nodes[3]})); |
| 551 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[4],nodes[5],nodes[6],nodes[7]})); |
| 552 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[1],nodes[5],nodes[4]})); |
| 553 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[3],nodes[2],nodes[6],nodes[7]})); |
| 554 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[2],nodes[6],nodes[5]})); |
| 555 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[3],nodes[7],nodes[4]})); |
| 556 |
|
| 557 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[2],nodes[6],nodes[4]})); |
| 558 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[5],nodes[7],nodes[3]})); |
| 559 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[2],nodes[7],nodes[4]})); |
| 560 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[0],nodes[5],nodes[6],nodes[3]})); |
| 561 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[1],nodes[6],nodes[7],nodes[0]})); |
| 562 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_a_side (bulk, elems, stk::mesh::EntityVector{nodes[5],nodes[2],nodes[3],nodes[4]})); |
| 563 |
} |
| 564 |
|
| 565 |
TEST(DetectHinge3D, AreNodesPartOfAnEdge) |
| 566 |
{ |
| 567 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_SELF); |
| 568 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 569 |
setup_mesh_1block_1hex(bulk); |
| 570 |
|
| 571 |
stk::mesh::EntityVector nodes = get_nodes_from_id_range(bulk, 8); |
| 572 |
|
| 573 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[1])); |
| 574 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[2])); |
| 575 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[2], nodes[3])); |
| 576 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[3], nodes[0])); |
| 577 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[4], nodes[5])); |
| 578 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[5], nodes[6])); |
| 579 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[6], nodes[7])); |
| 580 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[7], nodes[3])); |
| 581 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[4])); |
| 582 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[5])); |
| 583 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[2], nodes[6])); |
| 584 |
EXPECT_TRUE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[3], nodes[7])); |
| 585 |
|
| 586 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[2])); |
| 587 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[3])); |
| 588 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[4], nodes[6])); |
| 589 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[5], nodes[7])); |
| 590 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[6])); |
| 591 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[2], nodes[5])); |
| 592 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[7])); |
| 593 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[3], nodes[4])); |
| 594 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[2], nodes[7])); |
| 595 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[3], nodes[6])); |
| 596 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[5])); |
| 597 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[4])); |
| 598 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[3], nodes[5])); |
| 599 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[0], nodes[6])); |
| 600 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[1], nodes[7])); |
| 601 |
EXPECT_FALSE(stk::tools::impl::common_nodes_are_part_of_an_edge(bulk, nodes[2], nodes[4])); |
| 602 |
} |
| 603 |
|
| 604 |
|
| 605 |
TEST(DetectHinge3D, SingleBlockThreeElementsOneNodeHingeOneEdgeHinge) |
| 606 |
{ |
| 607 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 608 |
return; |
| 609 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 610 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 611 |
setup_mesh_1block_3hex_1node_hinge_1edge_hinge(bulk); |
| 612 |
|
| 613 |
three_elements_decomposition(bulk); |
| 614 |
|
| 615 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 616 |
EXPECT_EQ(1u, hingeCount.first); |
| 617 |
EXPECT_EQ(1u, hingeCount.second); |
| 618 |
output_mesh(bulk); |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
TEST(DetectHinge3D, SingleBlockThreeElementsOneNodeHingeOneEdgeHinge2) |
| 623 |
{ |
| 624 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 625 |
return; |
| 626 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 627 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 628 |
setup_mesh_1block_3hex_1node_hinge_1edge_hinge2(bulk); |
| 629 |
|
| 630 |
three_elements_decomposition(bulk); |
| 631 |
|
| 632 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 633 |
EXPECT_EQ(1u, hingeCount.first); |
| 634 |
EXPECT_EQ(1u, hingeCount.second); |
| 635 |
output_mesh(bulk); |
| 636 |
} |
| 637 |
|
| 638 |
TEST(DetectHinge3D, SingleBlockThreeElementsOneNodeHingeOneEdgeHinge3) |
| 639 |
{ |
| 640 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 641 |
return; |
| 642 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 643 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 644 |
setup_mesh_1block_3hex_1node_hinge_1edge_hinge3(bulk); |
| 645 |
|
| 646 |
three_elements_decomposition(bulk); |
| 647 |
|
| 648 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 649 |
EXPECT_EQ(1u, hingeCount.first); |
| 650 |
EXPECT_EQ(1u, hingeCount.second); |
| 651 |
output_mesh(bulk); |
| 652 |
} |
| 653 |
|
| 654 |
|
| 655 |
TEST(DetectHinge3D, SingleBlockFourElementsBowtieOneEdgeHinge) |
| 656 |
{ |
| 657 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 658 |
return; |
| 659 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 660 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 661 |
setup_mesh_1block_4hex_bowtie_1edge_hinge(bulk); |
| 662 |
|
| 663 |
four_elements_decomposition(bulk); |
| 664 |
|
| 665 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 666 |
EXPECT_EQ(0u, hingeCount.first); |
| 667 |
EXPECT_EQ(1u, hingeCount.second); |
| 668 |
output_mesh(bulk); |
| 669 |
} |
| 670 |
|
| 671 |
|
| 672 |
TEST(DetectHinge3D, SingleBlockTwoByTwoHexTwoEdgeHinge_Decomp1) |
| 673 |
{ |
| 674 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 675 |
return; |
| 676 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 677 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 678 |
setup_mesh_1block_two_by_two_hex_2edge_hinge(bulk); |
| 679 |
|
| 680 |
four_elements_decomposition(bulk); |
| 681 |
|
| 682 |
stk::io::write_mesh("output_hinge", *bulkPtr); |
| 683 |
|
| 684 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 685 |
EXPECT_EQ(0u, hingeCount.first); |
| 686 |
|
| 687 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) == 4) { |
| 688 |
EXPECT_EQ(1u, hingeCount.second); |
| 689 |
} else { |
| 690 |
EXPECT_EQ(2u, hingeCount.second); |
| 691 |
} |
| 692 |
output_mesh(bulk); |
| 693 |
} |
| 694 |
|
| 695 |
TEST(DetectHinge3D, SingleBlockTwoByTwoHexTwoEdgeHinge_Decomp2) |
| 696 |
{ |
| 697 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 698 |
return; |
| 699 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 700 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 701 |
setup_mesh_1block_two_by_two_hex_2edge_hinge(bulk); |
| 702 |
|
| 703 |
four_elements_decomposition2(bulk); |
| 704 |
|
| 705 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 706 |
EXPECT_EQ(0u, hingeCount.first); |
| 707 |
|
| 708 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) == 4) { |
| 709 |
EXPECT_EQ(1u, hingeCount.second); |
| 710 |
} else { |
| 711 |
EXPECT_EQ(2u, hingeCount.second); |
| 712 |
} |
| 713 |
output_mesh(bulk); |
| 714 |
} |
| 715 |
|
| 716 |
TEST(DetectHinge3D, SingleBlockFourHexOneEdgeOneNodeHinge_Decomp1) |
| 717 |
{ |
| 718 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 719 |
return; |
| 720 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 721 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 722 |
setup_mesh_1block_four_hex_one_edge_one_node_hinge(bulk); |
| 723 |
|
| 724 |
four_elements_decomposition(bulk); |
| 725 |
|
| 726 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 727 |
EXPECT_EQ(1u, hingeCount.first); |
| 728 |
EXPECT_EQ(1u, hingeCount.second); |
| 729 |
output_mesh(bulk); |
| 730 |
} |
| 731 |
|
| 732 |
TEST(DetectHinge3D, SingleBlockFourHexOneEdgeOneNodeHinge_Decomp2) |
| 733 |
{ |
| 734 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 735 |
return; |
| 736 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 737 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 738 |
setup_mesh_1block_four_hex_one_edge_one_node_hinge(bulk); |
| 739 |
|
| 740 |
four_elements_decomposition2(bulk); |
| 741 |
|
| 742 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 743 |
EXPECT_EQ(1u, hingeCount.first); |
| 744 |
EXPECT_EQ(1u, hingeCount.second); |
| 745 |
output_mesh(bulk); |
| 746 |
} |
| 747 |
|
| 748 |
TEST(DetectHinge3D, SingleBlockFourHexTwoNodeHinges_Decomp1) |
| 749 |
{ |
| 750 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 751 |
return; |
| 752 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 753 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 754 |
setup_mesh_1block_four_hex_2node_hinge(bulk); |
| 755 |
|
| 756 |
four_elements_decomposition(bulk); |
| 757 |
|
| 758 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 759 |
EXPECT_EQ(2u, hingeCount.first); |
| 760 |
EXPECT_EQ(0u, hingeCount.second); |
| 761 |
output_mesh(bulk); |
| 762 |
} |
| 763 |
|
| 764 |
TEST(DetectHinge3D, SingleBlockFourHexTwoNodeHinges_Decomp2) |
| 765 |
{ |
| 766 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 767 |
return; |
| 768 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 769 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 770 |
setup_mesh_1block_four_hex_2node_hinge(bulk); |
| 771 |
|
| 772 |
four_elements_decomposition2(bulk); |
| 773 |
|
| 774 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 775 |
EXPECT_EQ(2u, hingeCount.first); |
| 776 |
EXPECT_EQ(0u, hingeCount.second); |
| 777 |
output_mesh(bulk); |
| 778 |
} |
| 779 |
|
| 780 |
TEST(DetectHinge3D, inputFile) |
| 781 |
{ |
| 782 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 783 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 784 |
std::string inputFileName = stk::unit_test_util::get_option("--inputFile", ""); |
| 785 |
bool nodesOnly = stk::unit_test_util::has_option("--nodesOnly"); |
| 786 |
|
| 787 |
if(!inputFileName.empty()) { |
| 788 |
double startTime = stk::wall_time(); |
| 789 |
stk::io::fill_mesh(inputFileName, bulk); |
| 790 |
double meshReadTime = stk::wall_time(); |
| 791 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 792 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 793 |
|
| 794 |
std::string blockList = ""; |
| 795 |
std::string inputBlockList = stk::unit_test_util::get_command_line_option("--blockList", blockList); |
| 796 |
|
| 797 |
std::vector<std::string> blocksToDetect = stk::split_csv_string(inputBlockList); |
| 798 |
for (std::string & blockToDetect : blocksToDetect) { |
| 799 |
blockToDetect = stk::trim_string(blockToDetect); |
| 800 |
} |
| 801 |
|
| 802 |
if(nodesOnly) { |
| 803 |
fill_mesh_hinges(bulk, blocksToDetect, hingeNodes); |
| 804 |
} else { |
| 805 |
fill_mesh_hinges(bulk, blocksToDetect, hingeNodes, hingeEdges); |
| 806 |
} |
| 807 |
double detectTime = stk::wall_time(); |
| 808 |
print_hinge_info(bulk, hingeNodes, hingeEdges); |
| 809 |
output_mesh(bulk); |
| 810 |
double meshWriteTime = stk::wall_time(); |
| 811 |
|
| 812 |
if (bulk.parallel_rank() == 0) { |
| 813 |
std::cout << " Mesh read time = " << (meshReadTime - startTime) << " s" << std::endl; |
| 814 |
std::cout << "Disconnect time = " << (detectTime - meshReadTime) << " s" << std::endl; |
| 815 |
std::cout << "Mesh write time = " << (meshWriteTime - detectTime) << " s" << std::endl; |
| 816 |
} |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
TEST(DetectHinge3D, GeneratedMesh) |
| 821 |
{ |
| 822 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 823 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 824 |
std::ostringstream os; |
| 825 |
unsigned nproc = stk::parallel_machine_size(MPI_COMM_WORLD); |
| 826 |
os << "generated:" << nproc << "x" << nproc << "x" << nproc; |
| 827 |
stk::io::fill_mesh(os.str(), bulk); |
| 828 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 829 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 830 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 831 |
print_hinge_info(bulk, hingeNodes, hingeEdges); |
| 832 |
|
| 833 |
EXPECT_EQ(0u, hingeNodes.size()); |
| 834 |
EXPECT_EQ(0u, hingeEdges.size()); |
| 835 |
output_mesh(bulk); |
| 836 |
} |
| 837 |
|
| 838 |
TEST(DetectHinge3D, SingleBlockFourHexTwoNodeHingeOneEdgeHinge) |
| 839 |
{ |
| 840 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 3) |
| 841 |
return; |
| 842 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 843 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 844 |
setup_mesh_1block_four_hex_2node_one_edge_hinge(bulk); |
| 845 |
|
| 846 |
stk::mesh::EntityIdProcVec idProcVec{ {1u,2}, {2u,2}, {4u,1} }; |
| 847 |
distribute_mesh(bulk, idProcVec); |
| 848 |
|
| 849 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 850 |
EXPECT_EQ(2u, hingeCount.first); |
| 851 |
EXPECT_EQ(1u, hingeCount.second); |
| 852 |
output_mesh(bulk); |
| 853 |
} |
| 854 |
|
| 855 |
TEST(DetectHinge3D, SingleBlockFourHexTwoNodeHingeOneEdgeHinge_Manual) |
| 856 |
{ |
| 857 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 3) |
| 858 |
return; |
| 859 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 860 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 861 |
setup_mesh_1block_four_hex_2node_one_edge_hinge_manual(bulk); |
| 862 |
|
| 863 |
std::pair<unsigned, unsigned> hingeCount = stk::tools::impl::get_hinge_count(bulk); |
| 864 |
|
| 865 |
EXPECT_EQ(2u, hingeCount.first); |
| 866 |
EXPECT_EQ(0u, hingeCount.second); |
| 867 |
output_mesh(bulk); |
| 868 |
} |
| 869 |
|
| 870 |
TEST(DetectHinge3D, DetectHingeRing) |
| 871 |
{ |
| 872 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 873 |
|
| 874 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 875 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 876 |
setup_mesh_with_hinge_ring(bulk); |
| 877 |
|
| 878 |
stk::tools::impl::HingeNodeVector hingeNodes = stk::tools::impl::get_hinge_nodes(bulk); |
| 879 |
stk::tools::impl::HingeEdgeVector hingeEdges = stk::tools::impl::get_hinge_edges(bulk, hingeNodes); |
| 880 |
stk::tools::impl::HingeNodeVector hingeCyclicNodes = stk::tools::impl::get_cyclic_hinge_nodes(bulk, hingeNodes); |
| 881 |
|
| 882 |
EXPECT_EQ(4u, hingeNodes.size()); |
| 883 |
EXPECT_EQ(4u, hingeEdges.size()); |
| 884 |
EXPECT_EQ(4u, hingeCyclicNodes.size()); |
| 885 |
} |
| 886 |
|
| 887 |
TEST(GraphTester, NoCycle) |
| 888 |
{ |
| 889 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 890 |
|
| 891 |
stk::tools::impl::GraphCycleDetector graph(0); |
| 892 |
|
| 893 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 894 |
EXPECT_EQ(0u, cyclesInGraph.size()); |
| 895 |
} |
| 896 |
|
| 897 |
TEST(GraphTester, OneNodeNoCycle) |
| 898 |
{ |
| 899 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 900 |
|
| 901 |
stk::tools::impl::GraphCycleDetector graph(1); |
| 902 |
|
| 903 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 904 |
EXPECT_EQ(0u, cyclesInGraph.size()); |
| 905 |
} |
| 906 |
|
| 907 |
TEST(GraphTester, InvalidNodeId) |
| 908 |
{ |
| 909 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 910 |
|
| 911 |
stk::tools::impl::GraphCycleDetector graph(2); |
| 912 |
EXPECT_THROW(graph.add_edge(0,2), std::logic_error); |
| 913 |
} |
| 914 |
|
| 915 |
TEST(GraphTester, TwoNodeNoCycle) |
| 916 |
{ |
| 917 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 918 |
|
| 919 |
stk::tools::impl::GraphCycleDetector graph(2); |
| 920 |
graph.add_edge(0,1); |
| 921 |
|
| 922 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 923 |
EXPECT_EQ(0u, cyclesInGraph.size()); |
| 924 |
} |
| 925 |
|
| 926 |
TEST(GraphTester, ThreeNodeOneCycle) |
| 927 |
{ |
| 928 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 929 |
|
| 930 |
stk::tools::impl::GraphCycleDetector graph(3); |
| 931 |
graph.add_edge(0,1); |
| 932 |
graph.add_edge(1,2); |
| 933 |
graph.add_edge(0,2); |
| 934 |
|
| 935 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 936 |
EXPECT_EQ(3u, cyclesInGraph.size()); |
| 937 |
} |
| 938 |
|
| 939 |
TEST(GraphTester, FourNodeOneCycle) |
| 940 |
{ |
| 941 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 942 |
|
| 943 |
stk::tools::impl::GraphCycleDetector graph(4); |
| 944 |
graph.add_edge(0,1); |
| 945 |
graph.add_edge(1,2); |
| 946 |
graph.add_edge(0,2); |
| 947 |
graph.add_edge(2,3); |
| 948 |
|
| 949 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 950 |
EXPECT_EQ(3u, cyclesInGraph.size()); |
| 951 |
} |
| 952 |
|
| 953 |
TEST(GraphTester, SixNodeOneCycle) |
| 954 |
{ |
| 955 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 956 |
|
| 957 |
stk::tools::impl::GraphCycleDetector graph(6); |
| 958 |
graph.add_edge(0,1); |
| 959 |
graph.add_edge(1,2); |
| 960 |
graph.add_edge(0,2); |
| 961 |
graph.add_edge(2,3); |
| 962 |
graph.add_edge(1,4); |
| 963 |
graph.add_edge(0,5); |
| 964 |
|
| 965 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 966 |
EXPECT_EQ(3u, cyclesInGraph.size()); |
| 967 |
} |
| 968 |
|
| 969 |
TEST(GraphTester, FiveNodeTwoCycle) |
| 970 |
{ |
| 971 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 972 |
|
| 973 |
stk::tools::impl::GraphCycleDetector graph(5); |
| 974 |
graph.add_edge(0,1); |
| 975 |
graph.add_edge(1,2); |
| 976 |
graph.add_edge(0,2); |
| 977 |
graph.add_edge(2,3); |
| 978 |
graph.add_edge(3,4); |
| 979 |
graph.add_edge(4,2); |
| 980 |
|
| 981 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 982 |
EXPECT_EQ(5u, cyclesInGraph.size()); |
| 983 |
} |
| 984 |
|
| 985 |
TEST(GraphTester, SixNodeTwoCycle) |
| 986 |
{ |
| 987 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) != 1) { return; } |
| 988 |
|
| 989 |
stk::tools::impl::GraphCycleDetector graph(6); |
| 990 |
graph.add_edge(0,1); |
| 991 |
graph.add_edge(1,2); |
| 992 |
graph.add_edge(0,2); |
| 993 |
graph.add_edge(3,4); |
| 994 |
graph.add_edge(4,5); |
| 995 |
graph.add_edge(5,3); |
| 996 |
|
| 997 |
const std::vector<unsigned>& cyclesInGraph = graph.get_nodes_in_cycles(); |
| 998 |
EXPECT_EQ(6u, cyclesInGraph.size()); |
| 999 |
} |
| 1000 |
|
| 1001 |
TEST(ElementGroups2D, SingleBlockFourQuadOneNodeHinge) |
| 1002 |
{ |
| 1003 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1004 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1005 |
setup_mesh_1block_4quad_bowtie_1hinge(bulk); |
| 1006 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 4u); |
| 1007 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node); |
| 1008 |
if(!groupings.empty()) { |
| 1009 |
EXPECT_EQ(groupings.size(), 4u); |
| 1010 |
EXPECT_EQ(groupings[0].size(), 1u); |
| 1011 |
} |
| 1012 |
output_mesh(bulk); |
| 1013 |
} |
| 1014 |
|
| 1015 |
TEST(ElementGroups2D, SingleBlockThreeQuadOneNodeHinge) |
| 1016 |
{ |
| 1017 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1018 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1019 |
setup_mesh_1block_3quad_1hinge(bulk); |
| 1020 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 4u); |
| 1021 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node); |
| 1022 |
if(!groupings.empty()) { |
| 1023 |
EXPECT_EQ(groupings.size(), 2u); |
| 1024 |
EXPECT_EQ(groupings[0].size(), 2u); |
| 1025 |
EXPECT_EQ(groupings[1].size(), 1u); |
| 1026 |
} |
| 1027 |
output_mesh(bulk); |
| 1028 |
} |
| 1029 |
|
| 1030 |
TEST(ElementGroups3D, EmptyMesh) |
| 1031 |
{ |
| 1032 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1033 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1034 |
stk::mesh::Entity entity; |
| 1035 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, entity); |
| 1036 |
if(!groupings.empty()) { |
| 1037 |
EXPECT_EQ(groupings.size(), 0u); |
| 1038 |
} |
| 1039 |
} |
| 1040 |
|
| 1041 |
TEST(ElementGroups3D, SingleBlockOneHex) |
| 1042 |
{ |
| 1043 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1044 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1045 |
setup_mesh_1block_1hex(bulk); |
| 1046 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 1u); |
| 1047 |
stk::mesh::Entity elem = bulk.get_entity(stk::topology::ELEMENT_RANK, 1u); |
| 1048 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node); |
| 1049 |
if(!groupings.empty()) { |
| 1050 |
EXPECT_EQ(groupings.size(), 1u); |
| 1051 |
EXPECT_EQ(groupings[0].size(), 1u); |
| 1052 |
EXPECT_EQ(groupings[0][0], elem); |
| 1053 |
} |
| 1054 |
} |
| 1055 |
|
| 1056 |
TEST(ElementGroups3D, SingleBlockTwoHex) |
| 1057 |
{ |
| 1058 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) { |
| 1059 |
return; |
| 1060 |
} |
| 1061 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1062 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1063 |
setup_mesh_1block_2hex(bulk); |
| 1064 |
two_elements_decomposition(bulk); |
| 1065 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 1u); |
| 1066 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node); |
| 1067 |
if(!groupings.empty()) { |
| 1068 |
EXPECT_EQ(groupings.size(), 1u); |
| 1069 |
EXPECT_EQ(groupings[0].size(), 1u); |
| 1070 |
} |
| 1071 |
} |
| 1072 |
|
| 1073 |
TEST(ElementGroups3D, SingleBlockTwoHexOneNodeHinge) |
| 1074 |
{ |
| 1075 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) { |
| 1076 |
return; |
| 1077 |
} |
| 1078 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1079 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1080 |
setup_mesh_1block_2hex_1node_hinge(bulk); |
| 1081 |
two_elements_decomposition(bulk); |
| 1082 |
stk::mesh::Entity node = bulk.get_entity(stk::topology::NODE_RANK, 5u); |
| 1083 |
|
| 1084 |
test_two_element_one_hinge_grouping(bulk, stk::tools::impl::convert_to_hinge_node(bulk, node)); |
| 1085 |
output_mesh(bulk); |
| 1086 |
} |
| 1087 |
|
| 1088 |
TEST(ElementGroups3D, InsertGroupTest) |
| 1089 |
{ |
| 1090 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) { |
| 1091 |
return; |
| 1092 |
} |
| 1093 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1094 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1095 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 1096 |
|
| 1097 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEMENT_RANK, 1u); |
| 1098 |
stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEMENT_RANK, 2u); |
| 1099 |
stk::mesh::Entity elem3 = bulk.get_entity(stk::topology::ELEMENT_RANK, 3u); |
| 1100 |
stk::mesh::Entity elem4 = bulk.get_entity(stk::topology::ELEMENT_RANK, 4u); |
| 1101 |
stk::tools::impl::PairwiseSideInfoVector infoVec; |
| 1102 |
infoVec.push_back(stk::tools::impl::PairwiseSideInfo(bulk, elem1, elem2)); |
| 1103 |
infoVec.push_back(stk::tools::impl::PairwiseSideInfo(bulk, elem3, elem4)); |
| 1104 |
infoVec.push_back(stk::tools::impl::PairwiseSideInfo(bulk, elem1, elem3)); |
| 1105 |
|
| 1106 |
stk::tools::impl::HingeGroupVector groupings; |
| 1107 |
insert_into_group(infoVec, groupings); |
| 1108 |
|
| 1109 |
if(!groupings.empty()) { |
| 1110 |
EXPECT_EQ(groupings.size(), 1u); |
| 1111 |
EXPECT_EQ(groupings[0].size(), 4u); |
| 1112 |
EXPECT_EQ(groupings[0][0], elem1); |
| 1113 |
EXPECT_EQ(groupings[0][1], elem2); |
| 1114 |
EXPECT_EQ(groupings[0][2], elem3); |
| 1115 |
EXPECT_EQ(groupings[0][3], elem4); |
| 1116 |
} |
| 1117 |
output_mesh(bulk); |
| 1118 |
} |
| 1119 |
|
| 1120 |
TEST(ElementGroups3D, MergeTest) |
| 1121 |
{ |
| 1122 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) { |
| 1123 |
return; |
| 1124 |
} |
| 1125 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1126 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1127 |
stk::io::fill_mesh("generated:2x2x2", bulk); |
| 1128 |
|
| 1129 |
stk::tools::impl::HingeGroupVector groupings; |
| 1130 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEMENT_RANK, 1u); |
| 1131 |
stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEMENT_RANK, 2u); |
| 1132 |
stk::mesh::Entity elem3 = bulk.get_entity(stk::topology::ELEMENT_RANK, 3u); |
| 1133 |
stk::mesh::Entity elem4 = bulk.get_entity(stk::topology::ELEMENT_RANK, 4u); |
| 1134 |
groupings.push_back( {elem1,elem2} ); |
| 1135 |
groupings.push_back( {elem2,elem3} ); |
| 1136 |
stk::mesh::EntityLess compare(bulk); |
| 1137 |
stk::tools::impl::merge_groups(groupings, 5, 6, compare); |
| 1138 |
if(!groupings.empty()) { |
| 1139 |
EXPECT_EQ(groupings.size(), 2u); |
| 1140 |
} |
| 1141 |
|
| 1142 |
stk::tools::impl::merge_groups(groupings, 0, 1, compare); |
| 1143 |
if(!groupings.empty()) { |
| 1144 |
EXPECT_EQ(groupings.size(), 1u); |
| 1145 |
EXPECT_EQ(groupings[0].size(), 3u); |
| 1146 |
EXPECT_EQ(groupings[0][0], elem1); |
| 1147 |
EXPECT_EQ(groupings[0][1], elem2); |
| 1148 |
EXPECT_EQ(groupings[0][2], elem3); |
| 1149 |
} |
| 1150 |
|
| 1151 |
groupings.clear(); |
| 1152 |
groupings.push_back( {elem1,elem2} ); |
| 1153 |
groupings.push_back( {elem3,elem4} ); |
| 1154 |
|
| 1155 |
stk::tools::impl::merge_groups(groupings, 0, 1, compare); |
| 1156 |
if(!groupings.empty()) { |
| 1157 |
EXPECT_EQ(groupings.size(), 1u); |
| 1158 |
EXPECT_EQ(groupings[0].size(), 4u); |
| 1159 |
EXPECT_EQ(groupings[0][0], elem1); |
| 1160 |
EXPECT_EQ(groupings[0][1], elem2); |
| 1161 |
EXPECT_EQ(groupings[0][2], elem3); |
| 1162 |
EXPECT_EQ(groupings[0][3], elem4); |
| 1163 |
} |
| 1164 |
} |
| 1165 |
|
| 1166 |
TEST(ElementGroups2D, TwoBlockFiveElementsOneHinge) |
| 1167 |
{ |
| 1168 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1169 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1170 |
setup_mesh_2block_3quad_2tri_1hinge(bulk); |
| 1171 |
five_elements_decomposition(bulk); |
| 1172 |
|
| 1173 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1174 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1175 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1176 |
|
| 1177 |
int ranTest = 0; |
| 1178 |
|
| 1179 |
if(hingeNodes.size() == 1) { |
| 1180 |
ranTest = 1; |
| 1181 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, hingeNodes[0].get_node()); |
| 1182 |
EXPECT_EQ(2u, groupings.size()); |
| 1183 |
EXPECT_EQ(5u, groupings[0].size() + groupings[1].size() ); |
| 1184 |
if(groupings[0].size() == 2) { |
| 1185 |
EXPECT_EQ(3u, groupings[1].size()); |
| 1186 |
} else { |
| 1187 |
EXPECT_EQ(2u, groupings[1].size()); |
| 1188 |
} |
| 1189 |
} |
| 1190 |
verify_test_run(bulk.parallel(), ranTest); |
| 1191 |
} |
| 1192 |
|
| 1193 |
TEST(ElementGroups3D, OneBlockFourElementsTwoNodeHinge) |
| 1194 |
{ |
| 1195 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) { |
| 1196 |
return; |
| 1197 |
} |
| 1198 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1199 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1200 |
setup_mesh_1block_four_hex_2node_hinge(bulk); |
| 1201 |
four_elements_decomposition2(bulk); |
| 1202 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1203 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1204 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1205 |
|
| 1206 |
stk::mesh::Entity elem1 = bulk.get_entity(stk::topology::ELEM_RANK, 1u); |
| 1207 |
stk::mesh::Entity elem2 = bulk.get_entity(stk::topology::ELEM_RANK, 2u); |
| 1208 |
|
| 1209 |
for(const stk::tools::impl::HingeNode& node : hingeNodes) { |
| 1210 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node.get_node()); |
| 1211 |
if(!groupings.empty()) { |
| 1212 |
EXPECT_EQ(2u, groupings.size()); |
| 1213 |
EXPECT_EQ(3u, groupings[0].size() + groupings[1].size()); |
| 1214 |
if(groupings[0].size() == 1u) { |
| 1215 |
stk::mesh::EntityId id = bulk.identifier(groupings[0][0]); |
| 1216 |
EXPECT_TRUE( (id == 3u) || (id == 4u) ); |
| 1217 |
EXPECT_EQ(2u, groupings[1].size()); |
| 1218 |
bool foundElem1 = std::find(groupings[1].begin(), groupings[1].end(), elem1) != groupings[1].end(); |
| 1219 |
bool foundElem2 = std::find(groupings[1].begin(), groupings[1].end(), elem2) != groupings[1].end(); |
| 1220 |
|
| 1221 |
EXPECT_TRUE( (foundElem1 && foundElem2) ); |
| 1222 |
} |
| 1223 |
if(groupings[1].size() == 1u) { |
| 1224 |
stk::mesh::EntityId id = bulk.identifier(groupings[1][0]); |
| 1225 |
EXPECT_TRUE( (id == 3u) || (id == 4u) ); |
| 1226 |
EXPECT_EQ(2u, groupings[0].size()); |
| 1227 |
bool foundElem1 = std::find(groupings[0].begin(), groupings[0].end(), elem1) != groupings[0].end(); |
| 1228 |
bool foundElem2 = std::find(groupings[0].begin(), groupings[0].end(), elem2) != groupings[0].end(); |
| 1229 |
|
| 1230 |
EXPECT_TRUE( (foundElem1 && foundElem2) ); |
| 1231 |
} |
| 1232 |
} |
| 1233 |
} |
| 1234 |
} |
| 1235 |
|
| 1236 |
TEST(ElementGroups3D, OneBlockEightElementsOneNodeHinge) |
| 1237 |
{ |
| 1238 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) { |
| 1239 |
return; |
| 1240 |
} |
| 1241 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1242 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1243 |
setup_mesh_1block_eight_tri_1node_hinge(bulk); |
| 1244 |
|
| 1245 |
if(bulk.parallel_size() == 2) { |
| 1246 |
stk::mesh::EntityIdProcVec idProcVec{ {1u,1}, {3u,1} }; |
| 1247 |
distribute_mesh(bulk, idProcVec); |
| 1248 |
} |
| 1249 |
else if(bulk.parallel_size() == 3) { |
| 1250 |
stk::mesh::EntityIdProcVec idProcVec{ {5u,1}, {7u,2} }; |
| 1251 |
distribute_mesh(bulk, idProcVec); |
| 1252 |
} |
| 1253 |
else if(bulk.parallel_size() == 4) { |
| 1254 |
stk::mesh::EntityIdProcVec idProcVec{ {2u,1}, {3u,2}, {4u,3}, {5u,3} }; |
| 1255 |
distribute_mesh(bulk, idProcVec); |
| 1256 |
} |
| 1257 |
|
| 1258 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1259 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1260 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1261 |
|
| 1262 |
int ranTest = 0; |
| 1263 |
|
| 1264 |
if(hingeNodes.size() > 0) { |
| 1265 |
ranTest = 1; |
| 1266 |
for(const stk::tools::impl::HingeNode& node : hingeNodes) { |
| 1267 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, node); |
| 1268 |
if(!groupings.empty()) { |
| 1269 |
EXPECT_EQ(4u, groupings.size()); |
| 1270 |
EXPECT_EQ(8u, groupings[0].size() + groupings[1].size() + groupings[2].size() + groupings[3].size()); |
| 1271 |
EXPECT_EQ(2u, groupings[1].size()); |
| 1272 |
EXPECT_EQ(2u, groupings[2].size()); |
| 1273 |
EXPECT_EQ(2u, groupings[3].size()); |
| 1274 |
} |
| 1275 |
} |
| 1276 |
} |
| 1277 |
|
| 1278 |
verify_test_run(bulk.parallel(), ranTest); |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
TEST(ElementGroups3D, SingleBlockTwoHexOneEdgeHinge) |
| 1283 |
{ |
| 1284 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 1285 |
return; |
| 1286 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1287 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1288 |
setup_mesh_1block_2hex_1edge_hinge(bulk); |
| 1289 |
|
| 1290 |
two_elements_decomposition(bulk); |
| 1291 |
|
| 1292 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1293 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1294 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1295 |
|
| 1296 |
EXPECT_EQ(0u, hingeNodes.size()); |
| 1297 |
EXPECT_EQ(1u, hingeEdges.size()); |
| 1298 |
|
| 1299 |
test_two_element_one_hinge_grouping(bulk, hingeEdges[0]); |
| 1300 |
output_mesh(bulk); |
| 1301 |
} |
| 1302 |
|
| 1303 |
TEST(ElementGroups3D, SingleBlockFourElementsBowtieOneEdgeHinge) |
| 1304 |
{ |
| 1305 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1306 |
return; |
| 1307 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1308 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1309 |
setup_mesh_1block_4hex_bowtie_1edge_hinge(bulk); |
| 1310 |
|
| 1311 |
four_elements_decomposition2(bulk); |
| 1312 |
|
| 1313 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1314 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1315 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1316 |
int ranTest = 0; |
| 1317 |
|
| 1318 |
if(hingeEdges.size() > 0) { |
| 1319 |
ranTest = 1; |
| 1320 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, hingeEdges[0]); |
| 1321 |
if(!groupings.empty()) { |
| 1322 |
EXPECT_EQ(4u, groupings.size()); |
| 1323 |
EXPECT_EQ(4u, groupings[0].size() + groupings[1].size() + groupings[2].size() + groupings[3].size()); |
| 1324 |
EXPECT_EQ(1u, groupings[0].size()); |
| 1325 |
EXPECT_EQ(1u, groupings[1].size()); |
| 1326 |
EXPECT_EQ(1u, groupings[2].size()); |
| 1327 |
EXPECT_EQ(1u, groupings[3].size()); |
| 1328 |
EXPECT_TRUE(groupings[0][0] != groupings[1][0]); |
| 1329 |
EXPECT_TRUE(groupings[1][0] != groupings[2][0]); |
| 1330 |
EXPECT_TRUE(groupings[2][0] != groupings[3][0]); |
| 1331 |
EXPECT_TRUE(groupings[3][0] != groupings[0][0]); |
| 1332 |
} |
| 1333 |
} |
| 1334 |
|
| 1335 |
verify_test_run(bulk.parallel(), ranTest); |
| 1336 |
} |
| 1337 |
|
| 1338 |
TEST(ElementGroups3D, SingleBlockTwoByTwoHexTwoEdgeHinge_Decomp2) |
| 1339 |
{ |
| 1340 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1341 |
return; |
| 1342 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1343 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1344 |
setup_mesh_1block_two_by_two_hex_2edge_hinge(bulk); |
| 1345 |
|
| 1346 |
four_elements_decomposition2(bulk); |
| 1347 |
|
| 1348 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1349 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1350 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1351 |
int ranTest = 0; |
| 1352 |
|
| 1353 |
if(hingeEdges.size() > 0) { |
| 1354 |
ranTest = 1; |
| 1355 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, hingeEdges[0]); |
| 1356 |
if(!groupings.empty()) { |
| 1357 |
EXPECT_EQ(2u, groupings.size()); |
| 1358 |
EXPECT_EQ(2u, groupings[0].size() + groupings[1].size()); |
| 1359 |
EXPECT_EQ(1u, groupings[0].size()); |
| 1360 |
EXPECT_EQ(1u, groupings[1].size()); |
| 1361 |
EXPECT_TRUE(groupings[0] != groupings[1]); |
| 1362 |
} |
| 1363 |
|
| 1364 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) == 1) { |
| 1365 |
groupings = stk::tools::impl::get_convex_groupings(bulk, hingeEdges[1]); |
| 1366 |
if(!groupings.empty()) { |
| 1367 |
EXPECT_EQ(2u, groupings.size()); |
| 1368 |
EXPECT_EQ(2u, groupings[0].size() + groupings[1].size()); |
| 1369 |
EXPECT_EQ(1u, groupings[0].size()); |
| 1370 |
EXPECT_EQ(1u, groupings[1].size()); |
| 1371 |
EXPECT_TRUE(groupings[0] != groupings[1]); |
| 1372 |
} |
| 1373 |
} |
| 1374 |
} |
| 1375 |
|
| 1376 |
verify_test_run(bulk.parallel(), ranTest); |
| 1377 |
output_mesh(bulk); |
| 1378 |
} |
| 1379 |
|
| 1380 |
TEST(ElementGroups3D, SingleBlockThreeElementsOneNodeHingeOneEdgeHinge) |
| 1381 |
{ |
| 1382 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1383 |
return; |
| 1384 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1385 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1386 |
setup_mesh_1block_3hex_1node_hinge_1edge_hinge(bulk); |
| 1387 |
|
| 1388 |
three_elements_decomposition(bulk); |
| 1389 |
|
| 1390 |
stk::tools::impl::HingeNodeVector hingeNodes; |
| 1391 |
stk::tools::impl::HingeEdgeVector hingeEdges; |
| 1392 |
fill_mesh_hinges(bulk, hingeNodes, hingeEdges); |
| 1393 |
|
| 1394 |
|
| 1395 |
int ranTest = 0; |
| 1396 |
|
| 1397 |
if(hingeNodes.size() > 0) { |
| 1398 |
ranTest = 1; |
| 1399 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, hingeNodes[0]); |
| 1400 |
if(!groupings.empty()) { |
| 1401 |
EXPECT_EQ(3u, groupings.size()); |
| 1402 |
EXPECT_EQ(3u, groupings[0].size() + groupings[1].size() + groupings[2].size()); |
| 1403 |
EXPECT_EQ(1u, groupings[0].size()); |
| 1404 |
EXPECT_EQ(1u, groupings[1].size()); |
| 1405 |
EXPECT_EQ(1u, groupings[2].size()); |
| 1406 |
EXPECT_TRUE(groupings[0] != groupings[1]); |
| 1407 |
EXPECT_TRUE(groupings[1] != groupings[2]); |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
verify_test_run(bulk.parallel(), ranTest); |
| 1412 |
|
| 1413 |
ranTest = 0; |
| 1414 |
if(hingeEdges.size() > 0) { |
| 1415 |
ranTest = 1; |
| 1416 |
stk::tools::impl::HingeGroupVector groupings = stk::tools::impl::get_convex_groupings(bulk, hingeEdges[0]); |
| 1417 |
if(!groupings.empty()) { |
| 1418 |
EXPECT_EQ(2u, groupings.size()); |
| 1419 |
EXPECT_EQ(2u, groupings[0].size() + groupings[1].size()); |
| 1420 |
EXPECT_EQ(1u, groupings[0].size()); |
| 1421 |
EXPECT_EQ(1u, groupings[1].size()); |
| 1422 |
EXPECT_TRUE(groupings[0] != groupings[1]); |
| 1423 |
} |
| 1424 |
} |
| 1425 |
|
| 1426 |
verify_test_run(bulk.parallel(), ranTest); |
| 1427 |
} |
| 1428 |
|
| 1429 |
void test_snipping_result(const stk::mesh::BulkData& bulk, |
| 1430 |
unsigned expectedNumElems, unsigned expectedNumNodes, |
| 1431 |
unsigned expectedHingeNodeCount, unsigned expectedHingeEdgeCount) |
| 1432 |
{ |
| 1433 |
std::pair<unsigned,unsigned> hingeCounts; |
| 1434 |
std::pair<unsigned,unsigned> entityCounts; |
| 1435 |
|
| 1436 |
hingeCounts = stk::tools::impl::get_hinge_count(bulk); |
| 1437 |
|
| 1438 |
EXPECT_EQ(expectedHingeNodeCount, hingeCounts.first); |
| 1439 |
EXPECT_EQ(expectedHingeEdgeCount, hingeCounts.second); |
| 1440 |
|
| 1441 |
entityCounts = get_reduced_entity_counts(bulk); |
| 1442 |
|
| 1443 |
EXPECT_EQ(expectedNumElems, entityCounts.first); |
| 1444 |
EXPECT_EQ(expectedNumNodes, entityCounts.second); |
| 1445 |
} |
| 1446 |
|
| 1447 |
void snip_hinges(stk::mesh::BulkData& bulk) |
| 1448 |
{ |
| 1449 |
stk::tools::impl::snip_all_hinges_between_blocks(bulk); |
| 1450 |
} |
| 1451 |
|
| 1452 |
// Hinge snipping tests |
| 1453 |
TEST(SnipHinge2D, TwoBlockTwoElementsNoHinge) |
| 1454 |
{ |
| 1455 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 1456 |
return; |
| 1457 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1458 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1459 |
setup_mesh_2block_2quad_only_on_proc_0(bulk); |
| 1460 |
two_elements_decomposition(bulk); |
| 1461 |
|
| 1462 |
snip_hinges(bulk); |
| 1463 |
test_snipping_result(bulk, 2u, 6u, 0u, 0u); |
| 1464 |
output_mesh(bulk); |
| 1465 |
} |
| 1466 |
|
| 1467 |
TEST(SnipHinge2D, TwoBlockTwoElementsOneNodeHinge) |
| 1468 |
{ |
| 1469 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 1470 |
return; |
| 1471 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1472 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1473 |
setup_mesh_2block_2quad_1node_hinge(bulk); |
| 1474 |
two_elements_decomposition(bulk); |
| 1475 |
|
| 1476 |
snip_hinges(bulk); |
| 1477 |
test_snipping_result(bulk, 2u, 8u, 0u, 0u); |
| 1478 |
output_mesh(bulk); |
| 1479 |
} |
| 1480 |
|
| 1481 |
TEST(SnipHinge2D, TwoBlockTwoElementsTwoNodeHinges) |
| 1482 |
{ |
| 1483 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 1484 |
return; |
| 1485 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1486 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1487 |
setup_mesh_2block_2quad_2hinge(bulk); |
| 1488 |
two_elements_decomposition(bulk); |
| 1489 |
|
| 1490 |
snip_hinges(bulk); |
| 1491 |
test_snipping_result(bulk, 2u, 8u, 0u, 0u); |
| 1492 |
output_mesh(bulk); |
| 1493 |
} |
| 1494 |
|
| 1495 |
TEST(SnipHinge2D, ThreeBlockThreeElementsOneHinge_LinearStack) |
| 1496 |
{ |
| 1497 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1498 |
return; |
| 1499 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1500 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1501 |
setup_mesh_3block_3quad_1hinge_linear_stack(bulk); |
| 1502 |
three_elements_decomposition(bulk); |
| 1503 |
|
| 1504 |
snip_hinges(bulk); |
| 1505 |
test_snipping_result(bulk, 3u, 10u, 0u, 0u); |
| 1506 |
output_mesh(bulk); |
| 1507 |
} |
| 1508 |
|
| 1509 |
TEST(SnipHinge2D, FourBlockFourElementsBowtie_Decomp2) |
| 1510 |
{ |
| 1511 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1512 |
return; |
| 1513 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1514 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1515 |
setup_mesh_4block_4quad_bowtie_1hinge(bulk); |
| 1516 |
four_elements_decomposition(bulk); |
| 1517 |
|
| 1518 |
snip_hinges(bulk); |
| 1519 |
test_snipping_result(bulk, 4u, 16u, 0u, 0u); |
| 1520 |
output_mesh(bulk); |
| 1521 |
} |
| 1522 |
|
| 1523 |
TEST(SnipHinge2D, ThreeBlockThreeElementsOneHinge_HorizontalCut) |
| 1524 |
{ |
| 1525 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1526 |
return; |
| 1527 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1528 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1529 |
setup_mesh_3block_3quad_1hinge(bulk); |
| 1530 |
three_elements_decomposition(bulk); |
| 1531 |
|
| 1532 |
snip_hinges(bulk); |
| 1533 |
test_snipping_result(bulk, 3u, 10u, 0u, 0u); |
| 1534 |
output_mesh(bulk); |
| 1535 |
} |
| 1536 |
|
| 1537 |
TEST(SnipHinge2D, FourBlockFourElementsTwoHinge_Decomp2) |
| 1538 |
{ |
| 1539 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1540 |
return; |
| 1541 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1542 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1543 |
setup_mesh_4block_4quad_2hinge(bulk); |
| 1544 |
four_elements_decomposition(bulk); |
| 1545 |
|
| 1546 |
snip_hinges(bulk); |
| 1547 |
test_snipping_result(bulk, 4u, 12u, 0u, 0u); |
| 1548 |
output_mesh(bulk); |
| 1549 |
} |
| 1550 |
|
| 1551 |
TEST(SnipHinge2D, FourBlockFourElementsFourHinge_Decomp2) |
| 1552 |
{ |
| 1553 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1554 |
return; |
| 1555 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1556 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1557 |
setup_mesh_4block_4quad_4hinge(bulk); |
| 1558 |
four_elements_decomposition2(bulk); |
| 1559 |
|
| 1560 |
snip_hinges(bulk); |
| 1561 |
test_snipping_result(bulk, 4u, 16u, 0u, 0u); |
| 1562 |
output_mesh(bulk); |
| 1563 |
} |
| 1564 |
|
| 1565 |
TEST(SnipHinge2D, FourBlockFourElementsNoHingePacman) |
| 1566 |
{ |
| 1567 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1568 |
return; |
| 1569 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1570 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1571 |
setup_mesh_4block_4quad_pacman(bulk); |
| 1572 |
four_elements_decomposition2(bulk); |
| 1573 |
|
| 1574 |
snip_hinges(bulk); |
| 1575 |
test_snipping_result(bulk, 4u, 10u, 0u, 0u); |
| 1576 |
output_mesh(bulk); |
| 1577 |
} |
| 1578 |
|
| 1579 |
TEST(SnipHinge2D, FourBlockFourElementsOneHinge) |
| 1580 |
{ |
| 1581 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1582 |
return; |
| 1583 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1584 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1585 |
setup_mesh_4block_4quad_1hinge(bulk); |
| 1586 |
four_elements_decomposition2(bulk); |
| 1587 |
|
| 1588 |
snip_hinges(bulk); |
| 1589 |
test_snipping_result(bulk, 4u, 12u, 0u, 0u); |
| 1590 |
output_mesh(bulk); |
| 1591 |
} |
| 1592 |
|
| 1593 |
TEST(SnipHinge2D, FiveBlockFiveElementsOneHinge) |
| 1594 |
{ |
| 1595 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(2,MPI_COMM_WORLD); |
| 1596 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1597 |
setup_mesh_5block_3quad_2tri_1hinge(bulk); |
| 1598 |
five_elements_decomposition(bulk); |
| 1599 |
|
| 1600 |
snip_hinges(bulk); |
| 1601 |
test_snipping_result(bulk, 5u, 12u, 0u, 0u); |
| 1602 |
output_mesh(bulk); |
| 1603 |
} |
| 1604 |
|
| 1605 |
TEST(SnipHinge3D, TwoBlockTwoHexOneEdgeHinge) |
| 1606 |
{ |
| 1607 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 2) |
| 1608 |
return; |
| 1609 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1610 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1611 |
setup_mesh_2block_2hex_1edge_hinge(bulk); |
| 1612 |
two_elements_decomposition(bulk); |
| 1613 |
|
| 1614 |
snip_hinges(bulk); |
| 1615 |
test_snipping_result(bulk, 2u, 16u, 0u, 0u); |
| 1616 |
output_mesh(bulk); |
| 1617 |
} |
| 1618 |
|
| 1619 |
TEST(SnipHinge3D, ThreeBlockThreeHexOneEdgeHinge) |
| 1620 |
{ |
| 1621 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1622 |
return; |
| 1623 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1624 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1625 |
setup_mesh_3block_3hex_1edge_hinge(bulk); |
| 1626 |
three_elements_decomposition(bulk); |
| 1627 |
|
| 1628 |
snip_hinges(bulk); |
| 1629 |
test_snipping_result(bulk, 3u, 20u, 0u, 0u); |
| 1630 |
output_mesh(bulk); |
| 1631 |
} |
| 1632 |
|
| 1633 |
TEST(SnipHinge3D, ThreeBlockThreeElementsOneNodeHingeOneEdgeHinge) |
| 1634 |
{ |
| 1635 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1636 |
return; |
| 1637 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1638 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1639 |
setup_mesh_3block_3hex_1node_hinge_1edge_hinge(bulk); |
| 1640 |
three_elements_decomposition(bulk); |
| 1641 |
|
| 1642 |
snip_hinges(bulk); |
| 1643 |
test_snipping_result(bulk, 3u, 24u, 0u, 0u); |
| 1644 |
output_mesh(bulk); |
| 1645 |
} |
| 1646 |
|
| 1647 |
TEST(SnipHinge3D, ThreeBlockThreeElementsOneNodeHingeOneEdgeHinge2) |
| 1648 |
{ |
| 1649 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1650 |
return; |
| 1651 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1652 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1653 |
setup_mesh_3block_3hex_1node_hinge_1edge_hinge2(bulk); |
| 1654 |
three_elements_decomposition(bulk); |
| 1655 |
|
| 1656 |
snip_hinges(bulk); |
| 1657 |
test_snipping_result(bulk, 3u, 24u, 0u, 0u); |
| 1658 |
output_mesh(bulk); |
| 1659 |
} |
| 1660 |
|
| 1661 |
TEST(SnipHinge3D, ThreeBlockThreeElementsOneNodeHingeOneEdgeHinge3) |
| 1662 |
{ |
| 1663 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 3) |
| 1664 |
return; |
| 1665 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1666 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1667 |
setup_mesh_3block_3hex_1node_hinge_1edge_hinge3(bulk); |
| 1668 |
three_elements_decomposition(bulk); |
| 1669 |
|
| 1670 |
snip_hinges(bulk); |
| 1671 |
test_snipping_result(bulk, 3u, 24u, 0u, 0u); |
| 1672 |
output_mesh(bulk); |
| 1673 |
} |
| 1674 |
|
| 1675 |
TEST(SnipHinge3D, FourBlockFourElementsBowtieOneEdgeHinge) |
| 1676 |
{ |
| 1677 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1678 |
return; |
| 1679 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1680 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1681 |
setup_mesh_4block_4hex_bowtie_1edge_hinge(bulk); |
| 1682 |
four_elements_decomposition(bulk); |
| 1683 |
|
| 1684 |
snip_hinges(bulk); |
| 1685 |
test_snipping_result(bulk, 4u, 32u, 0u, 0u); |
| 1686 |
output_mesh(bulk); |
| 1687 |
} |
| 1688 |
|
| 1689 |
TEST(SnipHinge3D, FourBlockTwoByTwoHexTwoEdgeHinge_Decomp2) |
| 1690 |
{ |
| 1691 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1692 |
return; |
| 1693 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1694 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1695 |
setup_mesh_4block_two_by_two_hex_2edge_hinge(bulk); |
| 1696 |
four_elements_decomposition2(bulk); |
| 1697 |
|
| 1698 |
snip_hinges(bulk); |
| 1699 |
test_snipping_result(bulk, 4u, 24u, 0u, 0u); |
| 1700 |
output_mesh(bulk); |
| 1701 |
} |
| 1702 |
|
| 1703 |
TEST(SnipHinge3D, FourBlockFourHexOneEdgeOneNodeHinge_Decomp2) |
| 1704 |
{ |
| 1705 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1706 |
return; |
| 1707 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1708 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1709 |
setup_mesh_4block_four_hex_one_edge_one_node_hinge(bulk); |
| 1710 |
four_elements_decomposition2(bulk); |
| 1711 |
|
| 1712 |
snip_hinges(bulk); |
| 1713 |
test_snipping_result(bulk, 4u, 28u, 0u, 0u); |
| 1714 |
output_mesh(bulk); |
| 1715 |
} |
| 1716 |
|
| 1717 |
TEST(SnipHinge3D, FourBlockFourHexTwoNodeHinges_Decomp2) |
| 1718 |
{ |
| 1719 |
if(stk::parallel_machine_size(MPI_COMM_WORLD) > 4) |
| 1720 |
return; |
| 1721 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1722 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1723 |
setup_mesh_4block_four_hex_2node_hinge(bulk); |
| 1724 |
four_elements_decomposition2(bulk); |
| 1725 |
|
| 1726 |
snip_hinges(bulk); |
| 1727 |
test_snipping_result(bulk, 4u, 28u, 0u, 0u); |
| 1728 |
output_mesh(bulk); |
| 1729 |
} |
| 1730 |
|
| 1731 |
TEST(SnipHinge, inputFile) |
| 1732 |
{ |
| 1733 |
std::shared_ptr<stk::mesh::BulkData> bulkPtr = build_mesh(3,MPI_COMM_WORLD); |
| 1734 |
stk::mesh::BulkData& bulk = *bulkPtr; |
| 1735 |
std::string inputFileName = stk::unit_test_util::get_option("--inputFile", ""); |
| 1736 |
if(!inputFileName.empty()) { |
| 1737 |
double startTime = stk::wall_time(); |
| 1738 |
stk::io::fill_mesh(inputFileName, bulk); |
| 1739 |
double meshReadTime = stk::wall_time(); |
| 1740 |
snip_hinges(bulk); |
| 1741 |
double snipTime = stk::wall_time(); |
| 1742 |
output_mesh(bulk); |
| 1743 |
double meshWriteTime = stk::wall_time(); |
| 1744 |
|
| 1745 |
if (bulk.parallel_rank() == 0) { |
| 1746 |
std::cout << " Mesh read time = " << (meshReadTime - startTime) << " s" << std::endl; |
| 1747 |
std::cout << " Mesh snip time = " << (snipTime - meshReadTime) << " s" << std::endl; |
| 1748 |
std::cout << "Mesh write time = " << (meshWriteTime - snipTime) << " s" << std::endl; |
| 1749 |
} |
| 1750 |
} |
| 1751 |
} |
| 1752 |
|
| 1753 |
|