| 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 |
#include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc |
| 35 |
#include <stk_io/FillMesh.hpp> |
| 36 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 37 |
#include <fstream> |
| 38 |
#include "Assembly.hpp" |
| 39 |
|
| 40 |
namespace stk |
| 41 |
{ |
| 42 |
namespace io |
| 43 |
{ |
| 44 |
namespace unit_test |
| 45 |
{ |
| 46 |
|
| 47 |
TEST_F(Assembly, readWriteAssembly_simple_blocks) |
| 48 |
{ |
| 49 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 50 |
|
| 51 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 52 |
const std::string assemblyName("simpleAssembly"); |
| 53 |
const std::vector<std::string> partNames {"block_1", "block_2"}; |
| 54 |
|
| 55 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 56 |
stk::mesh::Part& block1Part = create_io_part(partNames[0]); |
| 57 |
stk::mesh::Part& block2Part = create_io_part(partNames[1]); |
| 58 |
declare_subsets(assemblyPart, {&block1Part, &block2Part}); |
| 59 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 60 |
move_element(1, block1Part, block2Part); |
| 61 |
|
| 62 |
test_write_then_read_block_assemblies(1); |
| 63 |
} |
| 64 |
|
| 65 |
TEST_F(Assembly, readWriteAssembly_simple_surfaces) |
| 66 |
{ |
| 67 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 68 |
return; |
| 69 |
} |
| 70 |
|
| 71 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 72 |
const std::string assemblyName("simpleAssembly"); |
| 73 |
const std::vector<std::string> partNames{"surface_1", "surface_2"}; |
| 74 |
|
| 75 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 76 |
stk::mesh::Part& surface1Part = create_io_part(partNames[0], 1, stk::topology::QUAD_4); |
| 77 |
stk::mesh::Part& surface2Part = create_io_part(partNames[1], 2, stk::topology::QUAD_4); |
| 78 |
declare_subsets(assemblyPart, {&surface1Part, &surface2Part}); |
| 79 |
stk::io::fill_mesh("generated:2x2x2|sideset:xX", get_bulk()); |
| 80 |
|
| 81 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface1Part, get_bulk().buckets(get_meta().side_rank()))); |
| 82 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface2Part, get_bulk().buckets(get_meta().side_rank()))); |
| 83 |
|
| 84 |
stk::mesh::PartVector inputSideBlocksToIgnore; |
| 85 |
inputSideBlocksToIgnore.push_back(get_meta().get_part("surface_1_quad4")); |
| 86 |
inputSideBlocksToIgnore.push_back(get_meta().get_part("surface_2_quad4")); |
| 87 |
test_for_null_parts(inputSideBlocksToIgnore); |
| 88 |
|
| 89 |
stk::mesh::PartVector outputPartsToIgnore; |
| 90 |
|
| 91 |
test_write_then_read_surface_assemblies(1, outputPartsToIgnore, inputSideBlocksToIgnore); |
| 92 |
} |
| 93 |
|
| 94 |
TEST_F(Assembly, readWriteAssembly_simple_nodesets) |
| 95 |
{ |
| 96 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 97 |
return; |
| 98 |
} |
| 99 |
|
| 100 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 101 |
const std::string assemblyName("simpleAssembly"); |
| 102 |
const std::vector<std::string> partNames{"nodelist_1", "nodelist_2"}; |
| 103 |
|
| 104 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 105 |
stk::mesh::Part& nodeset1Part = create_io_part(partNames[0], 1, stk::topology::NODE); |
| 106 |
stk::mesh::Part& nodeset2Part = create_io_part(partNames[1], 2, stk::topology::NODE); |
| 107 |
declare_subsets(assemblyPart, {&nodeset1Part, &nodeset2Part}); |
| 108 |
stk::io::fill_mesh("generated:2x2x2|nodeset:xX", get_bulk()); |
| 109 |
|
| 110 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset1Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 111 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset2Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 112 |
|
| 113 |
stk::mesh::PartVector inputPartsToIgnore; |
| 114 |
stk::mesh::PartVector outputPartsToIgnore; |
| 115 |
|
| 116 |
test_write_then_read_nodeset_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 117 |
} |
| 118 |
|
| 119 |
TEST_F(Assembly, readWriteAssembly_simple_emptyblock) |
| 120 |
{ |
| 121 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 122 |
|
| 123 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 124 |
const std::string assemblyName("simpleAssembly"); |
| 125 |
const std::vector<std::string> partNames {"block_1", "block_2"}; |
| 126 |
|
| 127 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 128 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1); |
| 129 |
stk::mesh::Part& block2Part = create_io_part(partNames[1], 2); |
| 130 |
declare_subsets(assemblyPart, {&block1Part, &block2Part}); |
| 131 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 132 |
|
| 133 |
test_write_then_read_block_assemblies(1, stk::mesh::PartVector{&block2Part}); |
| 134 |
} |
| 135 |
|
| 136 |
TEST_F(Assembly, readWriteAssembly_simple_emptysurface) |
| 137 |
{ |
| 138 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 139 |
return; |
| 140 |
} |
| 141 |
|
| 142 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 143 |
const std::string assemblyName("simpleAssembly"); |
| 144 |
const std::vector<std::string> partNames{"surface_1", "surface_2"}; |
| 145 |
|
| 146 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 147 |
stk::mesh::Part& surface1Part = create_io_part(partNames[0], 1, stk::topology::QUAD_4); |
| 148 |
stk::mesh::Part& surface2Part = create_io_part(partNames[1], 2, stk::topology::QUAD_4); |
| 149 |
declare_subsets(assemblyPart, {&surface1Part, &surface2Part}); |
| 150 |
stk::io::fill_mesh("generated:2x2x2|sideset:x", get_bulk()); |
| 151 |
|
| 152 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface1Part, get_bulk().buckets(get_meta().side_rank()))); |
| 153 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(surface2Part, get_bulk().buckets(get_meta().side_rank()))); |
| 154 |
|
| 155 |
stk::mesh::PartVector inputSideBlocksToIgnore; |
| 156 |
inputSideBlocksToIgnore.push_back(get_meta().get_part("surface_1_quad4")); |
| 157 |
test_for_null_parts(inputSideBlocksToIgnore); |
| 158 |
|
| 159 |
stk::mesh::PartVector outputPartsToIgnore; |
| 160 |
|
| 161 |
test_write_then_read_surface_assemblies(1, outputPartsToIgnore, inputSideBlocksToIgnore); |
| 162 |
} |
| 163 |
|
| 164 |
TEST_F(Assembly, readWriteAssembly_simple_emptynodeset) |
| 165 |
{ |
| 166 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 167 |
return; |
| 168 |
} |
| 169 |
|
| 170 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 171 |
const std::string assemblyName("simpleAssembly"); |
| 172 |
const std::vector<std::string> partNames{"nodelist_1", "nodelist_2"}; |
| 173 |
|
| 174 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 175 |
stk::mesh::Part& nodeset1Part = create_io_part(partNames[0], 1, stk::topology::NODE); |
| 176 |
stk::mesh::Part& nodeset2Part = create_io_part(partNames[1], 2, stk::topology::NODE); |
| 177 |
declare_subsets(assemblyPart, {&nodeset1Part, &nodeset2Part}); |
| 178 |
stk::io::fill_mesh("generated:2x2x2|nodeset:x", get_bulk()); |
| 179 |
|
| 180 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset1Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 181 |
EXPECT_EQ(0u, stk::mesh::count_selected_entities(nodeset2Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 182 |
|
| 183 |
stk::mesh::PartVector inputPartsToIgnore; |
| 184 |
stk::mesh::PartVector outputPartsToIgnore; |
| 185 |
|
| 186 |
test_write_then_read_nodeset_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 187 |
} |
| 188 |
|
| 189 |
TEST_F(Assembly, readWriteAssembly_simple_excludeBlock2) |
| 190 |
{ |
| 191 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 192 |
|
| 193 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 194 |
const std::string assemblyName("simpleAssembly"); |
| 195 |
const std::vector<std::string> partNames {"block_1", "block_2"}; |
| 196 |
|
| 197 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 198 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1); |
| 199 |
stk::mesh::Part& block2Part = create_io_part(partNames[1], 2); |
| 200 |
declare_subsets(assemblyPart, {&block1Part, &block2Part}); |
| 201 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 202 |
move_element(1, block1Part, block2Part); |
| 203 |
|
| 204 |
test_write_then_read_block_assemblies(1, {&block2Part}); |
| 205 |
} |
| 206 |
|
| 207 |
TEST_F(Assembly, readWriteAssembly_simple_excludeSurface2) |
| 208 |
{ |
| 209 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 210 |
return; |
| 211 |
} |
| 212 |
|
| 213 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 214 |
const std::string assemblyName("simpleAssembly"); |
| 215 |
const std::vector<std::string> partNames{"surface_1", "surface_2"}; |
| 216 |
|
| 217 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 218 |
stk::mesh::Part& surface1Part = create_io_part(partNames[0], 1, stk::topology::QUAD_4); |
| 219 |
stk::mesh::Part& surface2Part = create_io_part(partNames[1], 2, stk::topology::QUAD_4); |
| 220 |
declare_subsets(assemblyPart, {&surface1Part, &surface2Part}); |
| 221 |
stk::io::fill_mesh("generated:2x2x2|sideset:xX", get_bulk()); |
| 222 |
|
| 223 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface1Part, get_bulk().buckets(get_meta().side_rank()))); |
| 224 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface2Part, get_bulk().buckets(get_meta().side_rank()))); |
| 225 |
|
| 226 |
stk::mesh::PartVector outputPartsToIgnore; |
| 227 |
outputPartsToIgnore.push_back(get_meta().get_part("surface_2")); |
| 228 |
test_for_null_parts(outputPartsToIgnore); |
| 229 |
|
| 230 |
stk::mesh::PartVector inputPartsToIgnore; |
| 231 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_1_quad4")); |
| 232 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_2_quad4")); |
| 233 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_2")); |
| 234 |
test_for_null_parts(inputPartsToIgnore); |
| 235 |
|
| 236 |
test_write_then_read_surface_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 237 |
} |
| 238 |
|
| 239 |
TEST_F(Assembly, readWriteAssembly_simple_excludeNodeset2) |
| 240 |
{ |
| 241 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 242 |
return; |
| 243 |
} |
| 244 |
|
| 245 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 246 |
const std::string assemblyName("simpleAssembly"); |
| 247 |
const std::vector<std::string> partNames{"nodelist_1", "nodelist_2"}; |
| 248 |
|
| 249 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 250 |
stk::mesh::Part& nodeset1Part = create_io_part(partNames[0], 1, stk::topology::NODE); |
| 251 |
stk::mesh::Part& nodeset2Part = create_io_part(partNames[1], 2, stk::topology::NODE); |
| 252 |
declare_subsets(assemblyPart, {&nodeset1Part, &nodeset2Part}); |
| 253 |
stk::io::fill_mesh("generated:2x2x2|nodeset:xX", get_bulk()); |
| 254 |
|
| 255 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset1Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 256 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset2Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 257 |
|
| 258 |
stk::mesh::PartVector inputPartsToIgnore; |
| 259 |
inputPartsToIgnore.push_back(get_meta().get_part("nodelist_2")); |
| 260 |
test_for_null_parts(inputPartsToIgnore); |
| 261 |
|
| 262 |
stk::mesh::PartVector outputPartsToIgnore; |
| 263 |
outputPartsToIgnore.push_back(get_meta().get_part("nodelist_2")); |
| 264 |
test_for_null_parts(outputPartsToIgnore); |
| 265 |
|
| 266 |
test_write_then_read_nodeset_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 267 |
} |
| 268 |
|
| 269 |
TEST_F(Assembly, readWriteAssembly_simple_excludeBothAssemblyBlocks) |
| 270 |
{ |
| 271 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 272 |
|
| 273 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 274 |
const std::string assemblyName("simpleAssembly"); |
| 275 |
const std::vector<std::string> partNames {"block_1", "block_2", "block_3"}; |
| 276 |
|
| 277 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 278 |
stk::mesh::Part& block1Part = create_io_part(partNames[0], 1); |
| 279 |
stk::mesh::Part& block2Part = create_io_part(partNames[1], 2); |
| 280 |
stk::mesh::Part& block3Part = create_io_part(partNames[2], 3); |
| 281 |
declare_subsets(assemblyPart, {&block2Part, &block3Part}); |
| 282 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 283 |
move_element(1, block1Part, block2Part); |
| 284 |
move_element(2, block1Part, block3Part); |
| 285 |
|
| 286 |
test_write_then_read_block_assemblies(0, {&block2Part, &block3Part}); |
| 287 |
} |
| 288 |
|
| 289 |
TEST_F(Assembly, readWriteAssembly_simple_excludeBothAssemblySurfaces) |
| 290 |
{ |
| 291 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 292 |
return; |
| 293 |
} |
| 294 |
|
| 295 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 296 |
const std::string assemblyName("simpleAssembly"); |
| 297 |
const std::vector<std::string> partNames{"surface_1", "surface_2", "surface_3"}; |
| 298 |
|
| 299 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 300 |
stk::mesh::Part& surface1Part = create_io_part(partNames[0], 1, stk::topology::QUAD_4); |
| 301 |
stk::mesh::Part& surface2Part = create_io_part(partNames[1], 2, stk::topology::QUAD_4); |
| 302 |
stk::mesh::Part& surface3Part = create_io_part(partNames[2], 3, stk::topology::QUAD_4); |
| 303 |
declare_subsets(assemblyPart, {&surface2Part, &surface3Part}); |
| 304 |
stk::io::fill_mesh("generated:2x2x2|sideset:xyz", get_bulk()); |
| 305 |
|
| 306 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface1Part, get_bulk().buckets(get_meta().side_rank()))); |
| 307 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface2Part, get_bulk().buckets(get_meta().side_rank()))); |
| 308 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface3Part, get_bulk().buckets(get_meta().side_rank()))); |
| 309 |
|
| 310 |
stk::mesh::PartVector outputPartsToIgnore; |
| 311 |
outputPartsToIgnore.push_back(get_meta().get_part("surface_2")); |
| 312 |
outputPartsToIgnore.push_back(get_meta().get_part("surface_3")); |
| 313 |
test_for_null_parts(outputPartsToIgnore); |
| 314 |
|
| 315 |
stk::mesh::PartVector inputPartsToIgnore; |
| 316 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_1_quad4")); |
| 317 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_2_quad4")); |
| 318 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_3_quad4")); |
| 319 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_2")); |
| 320 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_3")); |
| 321 |
test_for_null_parts(inputPartsToIgnore); |
| 322 |
|
| 323 |
test_write_then_read_surface_assemblies(0, outputPartsToIgnore, inputPartsToIgnore); |
| 324 |
} |
| 325 |
|
| 326 |
TEST_F(Assembly, readWriteAssembly_simple_excludeBothAssemblyNodesets) |
| 327 |
{ |
| 328 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 329 |
return; |
| 330 |
} |
| 331 |
|
| 332 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 333 |
const std::string assemblyName("simpleAssembly"); |
| 334 |
const std::vector<std::string> partNames{"nodelist_1", "nodelist_2", "nodelist_3"}; |
| 335 |
|
| 336 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 337 |
stk::mesh::Part& nodeset1Part = create_io_part(partNames[0], 1, stk::topology::NODE); |
| 338 |
stk::mesh::Part& nodeset2Part = create_io_part(partNames[1], 2, stk::topology::NODE); |
| 339 |
stk::mesh::Part& nodeset3Part = create_io_part(partNames[2], 3, stk::topology::NODE); |
| 340 |
declare_subsets(assemblyPart, {&nodeset2Part, &nodeset3Part}); |
| 341 |
stk::io::fill_mesh("generated:2x2x2|nodeset:xyz", get_bulk()); |
| 342 |
|
| 343 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset1Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 344 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset2Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 345 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset3Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 346 |
|
| 347 |
stk::mesh::PartVector inputPartsToIgnore; |
| 348 |
inputPartsToIgnore.push_back(get_meta().get_part("nodelist_2")); |
| 349 |
inputPartsToIgnore.push_back(get_meta().get_part("nodelist_3")); |
| 350 |
test_for_null_parts(inputPartsToIgnore); |
| 351 |
|
| 352 |
stk::mesh::PartVector outputPartsToIgnore; |
| 353 |
outputPartsToIgnore.push_back(get_meta().get_part("nodelist_2")); |
| 354 |
outputPartsToIgnore.push_back(get_meta().get_part("nodelist_3")); |
| 355 |
test_for_null_parts(outputPartsToIgnore); |
| 356 |
|
| 357 |
test_write_then_read_nodeset_assemblies(0, outputPartsToIgnore, inputPartsToIgnore); |
| 358 |
} |
| 359 |
|
| 360 |
TEST_F(Assembly, readWriteAssembly_simple_includeBothAssemblySurfaces) |
| 361 |
{ |
| 362 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 363 |
return; |
| 364 |
} |
| 365 |
|
| 366 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 367 |
const std::string assemblyName("simpleAssembly"); |
| 368 |
const std::vector<std::string> partNames{"surface_1", "surface_2", "surface_3"}; |
| 369 |
|
| 370 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 371 |
stk::mesh::Part& surface1Part = create_io_part(partNames[0], 1, stk::topology::QUAD_4); |
| 372 |
stk::mesh::Part& surface2Part = create_io_part(partNames[1], 2, stk::topology::QUAD_4); |
| 373 |
stk::mesh::Part& surface3Part = create_io_part(partNames[2], 3, stk::topology::QUAD_4); |
| 374 |
declare_subsets(assemblyPart, {&surface2Part, &surface3Part}); |
| 375 |
stk::io::fill_mesh("generated:2x2x2|sideset:xyz", get_bulk()); |
| 376 |
|
| 377 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface1Part, get_bulk().buckets(get_meta().side_rank()))); |
| 378 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface2Part, get_bulk().buckets(get_meta().side_rank()))); |
| 379 |
EXPECT_EQ(4u, stk::mesh::count_selected_entities(surface3Part, get_bulk().buckets(get_meta().side_rank()))); |
| 380 |
|
| 381 |
stk::mesh::PartVector outputPartsToIgnore; |
| 382 |
stk::mesh::PartVector inputPartsToIgnore; |
| 383 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_2_quad4")); |
| 384 |
inputPartsToIgnore.push_back(get_meta().get_part("surface_3_quad4")); |
| 385 |
test_for_null_parts(inputPartsToIgnore); |
| 386 |
|
| 387 |
test_write_then_read_surface_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 388 |
} |
| 389 |
|
| 390 |
TEST_F(Assembly, readWriteAssembly_simple_includeBothAssemblyNodesets) |
| 391 |
{ |
| 392 |
if (stk::parallel_machine_size(get_comm()) != 1) { |
| 393 |
return; |
| 394 |
} |
| 395 |
|
| 396 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 397 |
const std::string assemblyName("simpleAssembly"); |
| 398 |
const std::vector<std::string> partNames{"nodelist_1", "nodelist_2", "nodelist_3"}; |
| 399 |
|
| 400 |
stk::mesh::Part& assemblyPart = create_assembly(assemblyName, 10); |
| 401 |
stk::mesh::Part& nodeset1Part = create_io_part(partNames[0], 1, stk::topology::NODE); |
| 402 |
stk::mesh::Part& nodeset2Part = create_io_part(partNames[1], 2, stk::topology::NODE); |
| 403 |
stk::mesh::Part& nodeset3Part = create_io_part(partNames[2], 3, stk::topology::NODE); |
| 404 |
declare_subsets(assemblyPart, {&nodeset2Part, &nodeset3Part}); |
| 405 |
stk::io::fill_mesh("generated:2x2x2|nodeset:xyz", get_bulk()); |
| 406 |
|
| 407 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset1Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 408 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset2Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 409 |
EXPECT_EQ(9u, stk::mesh::count_selected_entities(nodeset3Part, get_bulk().buckets(stk::topology::NODE_RANK))); |
| 410 |
|
| 411 |
stk::mesh::PartVector inputPartsToIgnore; |
| 412 |
stk::mesh::PartVector outputPartsToIgnore; |
| 413 |
|
| 414 |
test_write_then_read_nodeset_assemblies(1, outputPartsToIgnore, inputPartsToIgnore); |
| 415 |
} |
| 416 |
|
| 417 |
TEST_F(Assembly, readWriteAssembly_multiple) |
| 418 |
{ |
| 419 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 420 |
|
| 421 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 422 |
const std::string assembly1Name("assembly1"); |
| 423 |
const std::string assembly2Name("assembly2"); |
| 424 |
const std::vector<std::string> partNames {"block_1", "block_2"}; |
| 425 |
|
| 426 |
stk::mesh::Part& assembly1Part = create_assembly(assembly1Name, 100); |
| 427 |
stk::mesh::Part& assembly2Part = create_assembly(assembly2Name, 200); |
| 428 |
stk::mesh::Part& block1Part = create_io_part(partNames[0]); |
| 429 |
stk::mesh::Part& block2Part = create_io_part(partNames[1]); |
| 430 |
declare_subsets(assembly1Part, {&block1Part, &block2Part}); |
| 431 |
declare_subsets(assembly2Part, {&block1Part, &block2Part}); |
| 432 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 433 |
move_element(1, block1Part, block2Part); |
| 434 |
|
| 435 |
test_write_then_read_block_assemblies(2); |
| 436 |
} |
| 437 |
|
| 438 |
TEST_F(Assembly, readWriteAssembly_hierarchy) |
| 439 |
{ |
| 440 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 441 |
|
| 442 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 443 |
|
| 444 |
std::string parentAssemblyName("myParentAssembly"); |
| 445 |
std::string subAssembly1Name("mySubAssembly1"); |
| 446 |
std::string subAssembly2Name("mySubAssembly2"); |
| 447 |
std::vector<std::string> leafPartNames {"block_1", "block_2", "block_3"}; |
| 448 |
|
| 449 |
stk::mesh::Part* parentAssemblyPart; |
| 450 |
stk::mesh::PartVector subAssemblyParts; |
| 451 |
std::tie(parentAssemblyPart, subAssemblyParts) = create_assembly_hierarchy(parentAssemblyName, 1000, |
| 452 |
{subAssembly1Name, subAssembly2Name}, |
| 453 |
{2000, 2001}); |
| 454 |
stk::mesh::Part& block1Part = create_io_part(leafPartNames[0]); |
| 455 |
stk::mesh::Part& block2Part = create_io_part(leafPartNames[1]); |
| 456 |
stk::mesh::Part& block3Part = create_io_part(leafPartNames[2]); |
| 457 |
|
| 458 |
ASSERT_EQ(2u, subAssemblyParts.size()); |
| 459 |
declare_subsets(*subAssemblyParts[0], {&block1Part, &block2Part}); |
| 460 |
declare_subsets(*subAssemblyParts[1], {&block2Part, &block3Part}); |
| 461 |
|
| 462 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 463 |
|
| 464 |
move_element(1, block1Part, block2Part); |
| 465 |
move_element(2, block1Part, block3Part); |
| 466 |
|
| 467 |
test_write_then_read_block_assemblies(3); |
| 468 |
} |
| 469 |
|
| 470 |
TEST_F(Assembly, readWriteAssembly_deeperHierarchy) |
| 471 |
{ |
| 472 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 473 |
|
| 474 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 475 |
|
| 476 |
create_deep_assembly_hierarchy(); |
| 477 |
|
| 478 |
stk::io::fill_mesh("generated:2x2x2", get_bulk()); |
| 479 |
|
| 480 |
stk::mesh::Part& block1Part = *get_meta().get_part("block_1"); |
| 481 |
stk::mesh::Part& block2Part = *get_meta().get_part("block_2"); |
| 482 |
stk::mesh::Part& block3Part = *get_meta().get_part("block_3"); |
| 483 |
|
| 484 |
move_element(1, block1Part, block2Part); |
| 485 |
move_element(2, block1Part, block3Part); |
| 486 |
|
| 487 |
test_write_then_read_block_assemblies(6); |
| 488 |
} |
| 489 |
|
| 490 |
TEST_F(AssemblyFilter, omitLeafAssembly) |
| 491 |
{ |
| 492 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 493 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 494 |
|
| 495 |
const std::string fileName = "assembly.g"; |
| 496 |
unsigned nBlock = 5; |
| 497 |
create_multi_block_mesh_with_deep_assembly(nBlock, fileName); |
| 498 |
read_mesh_with_assembly_filter(fileName, {"assembly_9005"}, {}); |
| 499 |
|
| 500 |
test_omit_leaf_assembly(); |
| 501 |
} |
| 502 |
|
| 503 |
TEST_F(AssemblyFilter, omitBranchAssembly) |
| 504 |
{ |
| 505 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 506 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 507 |
|
| 508 |
const std::string fileName = "assembly.g"; |
| 509 |
unsigned nBlock = 5; |
| 510 |
create_multi_block_mesh_with_deep_assembly(nBlock, fileName); |
| 511 |
read_mesh_with_assembly_filter(fileName, {"assembly_9003"}, {}); |
| 512 |
|
| 513 |
test_omit_branch_assembly(); |
| 514 |
} |
| 515 |
|
| 516 |
TEST_F(AssemblyFilter, omitAndIncludeWillThrow) |
| 517 |
{ |
| 518 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 519 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 520 |
|
| 521 |
const std::string fileName = "assembly.g"; |
| 522 |
unsigned nBlock = 5; |
| 523 |
create_multi_block_mesh_with_deep_assembly(nBlock, fileName); |
| 524 |
|
| 525 |
EXPECT_THROW(read_mesh_with_assembly_filter(fileName, {"assembly_9001"}, {"assembly_9002"}), std::runtime_error); |
| 526 |
} |
| 527 |
|
| 528 |
TEST_F(AssemblyFilter, includeLeafAssembly) |
| 529 |
{ |
| 530 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 531 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 532 |
|
| 533 |
const std::string fileName = "assembly.g"; |
| 534 |
unsigned nBlock = 5; |
| 535 |
create_multi_block_mesh_with_deep_assembly(nBlock, fileName); |
| 536 |
read_mesh_with_assembly_filter(fileName, {}, {"assembly_9002"}); |
| 537 |
|
| 538 |
test_include_leaf_assembly(); |
| 539 |
} |
| 540 |
|
| 541 |
TEST_F(AssemblyFilter, includeBranchAssembly) |
| 542 |
{ |
| 543 |
if(stk::parallel_machine_size(get_comm()) != 1) { return; } |
| 544 |
setup_empty_mesh(stk::mesh::BulkData::AUTO_AURA); |
| 545 |
|
| 546 |
const std::string fileName = "assembly.g"; |
| 547 |
unsigned nBlock = 5; |
| 548 |
create_multi_block_mesh_with_deep_assembly(nBlock, fileName); |
| 549 |
read_mesh_with_assembly_filter(fileName, {}, {"assembly_9003"}); |
| 550 |
|
| 551 |
test_include_branch_assembly(); |
| 552 |
} |
| 553 |
|
| 554 |
} // namespace unit_test |
| 555 |
} // namespace io |
| 556 |
} // namespace stk |