| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Panzer: A partial differential equation assembly |
| 4 |
// engine for strongly coupled complex multiphysics systems |
| 5 |
// |
| 6 |
// Copyright 2011 NTESS and the Panzer contributors. |
| 7 |
// SPDX-License-Identifier: BSD-3-Clause |
| 8 |
// ***************************************************************************** |
| 9 |
// @HEADER |
| 10 |
|
| 11 |
#include <Teuchos_ConfigDefs.hpp> |
| 12 |
#include <Teuchos_UnitTestHarness.hpp> |
| 13 |
#include <Teuchos_RCP.hpp> |
| 14 |
#include <Teuchos_TimeMonitor.hpp> |
| 15 |
|
| 16 |
#include "PanzerCore_config.hpp" |
| 17 |
|
| 18 |
#include "Panzer_Workset.hpp" |
| 19 |
|
| 20 |
#include "Panzer_WorksetNeeds.hpp" |
| 21 |
#include "Panzer_WorksetDescriptor.hpp" |
| 22 |
#include "Panzer_BasisDescriptor.hpp" |
| 23 |
#include "Panzer_IntegrationDescriptor.hpp" |
| 24 |
|
| 25 |
#include "Panzer_LocalMeshInfo.hpp" |
| 26 |
#include "Panzer_SetupPartitionedWorksetUtilities.hpp" |
| 27 |
|
| 28 |
#include "Panzer_UnitTest_LocalMeshUtilities.hpp" |
| 29 |
|
| 30 |
#include <vector> |
| 31 |
#include <string> |
| 32 |
#include <iostream> |
| 33 |
|
| 34 |
namespace panzer { |
| 35 |
|
| 36 |
TEUCHOS_UNIT_TEST(setupPartitionedWorksetUtilities, basic) |
| 37 |
{ |
| 38 |
|
| 39 |
// Test empty mesh |
| 40 |
{ |
| 41 |
panzer::LocalMeshInfo empty_mesh; |
| 42 |
|
| 43 |
panzer::WorksetDescriptor description("block",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 44 |
|
| 45 |
// It shouldn't return any worksets |
| 46 |
auto worksets = buildPartitionedWorksets(empty_mesh, description); |
| 47 |
|
| 48 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 49 |
|
| 50 |
TEST_EQUALITY(worksets->size(),0); |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
// Generate a local mesh info object |
| 55 |
Teuchos::RCP<panzer::LocalMeshInfo> mesh_info = generateLocalMeshInfo(); |
| 56 |
|
| 57 |
// Test bad descriptors |
| 58 |
{ |
| 59 |
panzer::WorksetDescriptor description("block0",panzer::WorksetSizeType::CLASSIC_MODE,true); |
| 60 |
|
| 61 |
// Should throw an error |
| 62 |
TEST_THROW(buildPartitionedWorksets(*mesh_info, description),std::logic_error); |
| 63 |
|
| 64 |
} |
| 65 |
{ |
| 66 |
panzer::WorksetDescriptor description("block0",panzer::WorksetSizeType::NO_ELEMENTS,true); |
| 67 |
|
| 68 |
// It shouldn't return any worksets |
| 69 |
TEST_THROW(buildPartitionedWorksets(*mesh_info, description),std::logic_error); |
| 70 |
} |
| 71 |
{ |
| 72 |
panzer::WorksetDescriptor description("block0",panzer::WorksetSizeType::ALL_ELEMENTS,false); |
| 73 |
|
| 74 |
// This should trow an error since the description doesn't allow partitioning |
| 75 |
TEST_THROW(buildPartitionedWorksets(*mesh_info, description),std::logic_error); |
| 76 |
} |
| 77 |
|
| 78 |
// Test the worksets |
| 79 |
|
| 80 |
// Non-existant block |
| 81 |
{ |
| 82 |
panzer::WorksetDescriptor description("block32",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 83 |
|
| 84 |
// It shouldn't return any worksets |
| 85 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 86 |
|
| 87 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 88 |
|
| 89 |
// Nothing should have been found |
| 90 |
TEST_EQUALITY(worksets->size(), 0); |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
// Non-existant sideset |
| 95 |
{ |
| 96 |
panzer::WorksetDescriptor description("block32","sideset0",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 97 |
|
| 98 |
// It shouldn't return any worksets |
| 99 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 100 |
|
| 101 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 102 |
|
| 103 |
// Nothing should have been found |
| 104 |
TEST_EQUALITY(worksets->size(), 0); |
| 105 |
|
| 106 |
} |
| 107 |
{ |
| 108 |
panzer::WorksetDescriptor description("block0","sideset32",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 109 |
|
| 110 |
// It shouldn't return any worksets |
| 111 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 112 |
|
| 113 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 114 |
|
| 115 |
// Nothing should have been found |
| 116 |
TEST_EQUALITY(worksets->size(), 0); |
| 117 |
|
| 118 |
} |
| 119 |
{ |
| 120 |
panzer::WorksetDescriptor description("block0","sideset1",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 121 |
|
| 122 |
// It shouldn't return any worksets |
| 123 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 124 |
|
| 125 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 126 |
|
| 127 |
// Nothing should have been found |
| 128 |
TEST_EQUALITY(worksets->size(), 0); |
| 129 |
} |
| 130 |
|
| 131 |
// Existing block partition |
| 132 |
{ |
| 133 |
panzer::WorksetDescriptor description("block0",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 134 |
|
| 135 |
// It shouldn't return any worksets |
| 136 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 137 |
|
| 138 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 139 |
|
| 140 |
// Only one partition since we requested a full partition |
| 141 |
TEST_EQUALITY(worksets->size(), 1); |
| 142 |
|
| 143 |
const auto & workset = (*worksets)[0]; |
| 144 |
TEST_EQUALITY(workset.numOwnedCells(),2); |
| 145 |
TEST_EQUALITY(workset.numGhostCells(),1); |
| 146 |
TEST_EQUALITY(workset.numVirtualCells(),1); |
| 147 |
} |
| 148 |
|
| 149 |
// Existing sideset partition |
| 150 |
{ |
| 151 |
panzer::WorksetDescriptor description("block0","sideset0",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 152 |
|
| 153 |
// It shouldn't return any worksets |
| 154 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 155 |
|
| 156 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 157 |
|
| 158 |
// Only one partition since we requested a full partition |
| 159 |
TEST_EQUALITY(worksets->size(), 1); |
| 160 |
|
| 161 |
const auto & workset = (*worksets)[0]; |
| 162 |
TEST_EQUALITY(workset.numOwnedCells(),1); |
| 163 |
TEST_EQUALITY(workset.numGhostCells(),0); |
| 164 |
TEST_EQUALITY(workset.numVirtualCells(),1); |
| 165 |
} |
| 166 |
{ |
| 167 |
panzer::WorksetDescriptor description("block1","sideset2",panzer::WorksetSizeType::ALL_ELEMENTS,true); |
| 168 |
|
| 169 |
// It shouldn't return any worksets |
| 170 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 171 |
|
| 172 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 173 |
|
| 174 |
// Only one partition since we requested a full partition |
| 175 |
TEST_EQUALITY(worksets->size(), 1); |
| 176 |
|
| 177 |
const auto & workset = (*worksets)[0]; |
| 178 |
TEST_EQUALITY(workset.numOwnedCells(),1); |
| 179 |
TEST_EQUALITY(workset.numGhostCells(),1); |
| 180 |
TEST_EQUALITY(workset.numVirtualCells(),0); |
| 181 |
} |
| 182 |
|
| 183 |
// Existing block double partition |
| 184 |
{ |
| 185 |
// We want two partitions, each with a size of 1 cell |
| 186 |
panzer::WorksetDescriptor description("block1",1,true); |
| 187 |
|
| 188 |
// It shouldn't return any worksets |
| 189 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 190 |
|
| 191 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 192 |
|
| 193 |
// Two partitions |
| 194 |
TEST_EQUALITY(worksets->size(), 2); |
| 195 |
|
| 196 |
{ |
| 197 |
const auto & workset = (*worksets)[0]; |
| 198 |
TEST_EQUALITY(workset.numOwnedCells(),1); |
| 199 |
|
| 200 |
// Either both extra cells are ghosts, or one is virtual and one is ghost |
| 201 |
TEST_EQUALITY(workset.numGhostCells()+workset.numVirtualCells(),2); |
| 202 |
} |
| 203 |
|
| 204 |
{ |
| 205 |
const auto & workset = (*worksets)[1]; |
| 206 |
TEST_EQUALITY(workset.numOwnedCells(),1); |
| 207 |
|
| 208 |
// Either both extra cells are ghosts, or one is virtual and one is ghost |
| 209 |
TEST_EQUALITY(workset.numGhostCells()+workset.numVirtualCells(),2); |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
// Existing sideset double partition, but only one partition is available |
| 214 |
{ |
| 215 |
// We want two partitions, each with a size of 1 cell |
| 216 |
panzer::WorksetDescriptor description("block1","sideset1",1,true); |
| 217 |
|
| 218 |
// It shouldn't return any worksets |
| 219 |
auto worksets = buildPartitionedWorksets(*mesh_info, description); |
| 220 |
|
| 221 |
TEST_INEQUALITY(worksets,Teuchos::null); |
| 222 |
|
| 223 |
// Only one partition should have been built |
| 224 |
TEST_EQUALITY(worksets->size(), 1); |
| 225 |
|
| 226 |
{ |
| 227 |
const auto & workset = (*worksets)[0]; |
| 228 |
TEST_EQUALITY(workset.numOwnedCells(),1); |
| 229 |
TEST_EQUALITY(workset.numGhostCells(),0); |
| 230 |
TEST_EQUALITY(workset.numVirtualCells(),1); |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
} |
| 236 |
|
| 237 |
} // end namespace panzer |