Debian Codegraph @

packages/panzer/adapters-stk/test/local_mesh/local_mesh_utilities.cpp

raw
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 #include "Teuchos_ParameterList.hpp"
16
17 #include "Teuchos_DefaultComm.hpp"
18 #include "Teuchos_GlobalMPISession.hpp"
19
20 #include "Panzer_STK_Interface.hpp"
21 #include "Panzer_STK_LocalMeshUtilities.hpp"
22
23 #include "Panzer_LocalMeshInfo.hpp"
24 #include "PanzerSTK_UnitTest_BuildMesh.hpp"
25
26 #include <string>
27
28 namespace panzer_stk {
29
30 Teuchos::RCP<panzer::LocalMeshInfo>
31 buildLocalMeshInfo(const std::vector<int> & N, // Cells per dimension
32 const std::vector<int> & B, // Blocks per dimension
33 const std::vector<double> &L) // Domain length per block
34 {
35 Teuchos::RCP<panzer_stk::STK_Interface> mesh = buildMesh(N,B,L);
36 return generateLocalMeshInfo(*mesh);
37 }
38
39
40 TEUCHOS_UNIT_TEST(localMeshUtilities, basic)
41 {
42
43 // This is not an all encompassing test.
44 // It just makes sure that the local mesh infos are being generated and sized correctly.
45
46 // Make sure if fails when you pass in a null mesh
47 {
48 panzer_stk::STK_Interface mesh;
49 TEST_THROW((generateLocalMeshInfo(mesh)),std::logic_error);
50 }
51
52 // 1D Mesh test
53 {
54 auto mesh_info = buildLocalMeshInfo({3},{2},{2.});
55
56 // Make sure there are two blocks (eblock-0, and eblock-1)
57 TEST_EQUALITY(mesh_info->element_blocks.size(), 2);
58
59 // Make sure there are two sidesets (left and right)
60 TEST_EQUALITY(mesh_info->sidesets.size(), 2);
61
62 // Test block 0
63 {
64 const auto & block = mesh_info->element_blocks.at("eblock-0");
65
66 // Block should have some basic stuff working
67 TEST_EQUALITY(block.num_owned_cells, 3);
68 TEST_EQUALITY(block.num_ghstd_cells, 1);
69 TEST_EQUALITY(block.num_virtual_cells, 1);
70 }
71 }
72
73
74 // 2D Mesh test
75 {
76 auto mesh_info = buildLocalMeshInfo({3,5},{4,3},{2.,6.});
77
78 // Make sure there are blocks
79 TEST_EQUALITY(mesh_info->element_blocks.size(), 4*3);
80
81 // Make sure there are sidesets
82 TEST_EQUALITY(mesh_info->sidesets.size(), 4*3);
83 TEST_EQUALITY(mesh_info->sidesets["eblock-0_0"].size(), (4+1) + (3+1));
84
85 // Test block 0,0
86 {
87 const auto & block = mesh_info->element_blocks.at("eblock-0_0");
88
89 // Block should have some basic stuff working
90 TEST_EQUALITY(block.num_owned_cells, 3*5);
91 TEST_EQUALITY(block.num_ghstd_cells, 5+3);
92 TEST_EQUALITY(block.num_virtual_cells, 5+3);
93 }
94
95 // Test block 1,1
96 {
97 const auto & block = mesh_info->element_blocks.at("eblock-1_1");
98
99 // Block should have some basic stuff working
100 TEST_EQUALITY(block.num_owned_cells, 3*5);
101 TEST_EQUALITY(block.num_ghstd_cells, 2*5+2*3);
102 TEST_EQUALITY(block.num_virtual_cells, 0);
103 }
104 }
105
106 // 3D Mesh test
107 {
108 auto mesh_info = buildLocalMeshInfo({3,5,2},{4,3,5},{2.,6.,1.});
109
110 // Make sure there are blocks
111 TEST_EQUALITY(mesh_info->element_blocks.size(), 4*3*5);
112
113 // Make sure there are sidesets
114 TEST_EQUALITY(mesh_info->sidesets.size(), 4*3*5);
115
116 // Note the naming scheme for 3D is different from 2D - there are no internal sidesets
117 //TEST_EQUALITY(mesh_info->sidesets["eblock-0_0_0"].size(), (4+1) + (3+1) + (5+1));
118 TEST_EQUALITY(mesh_info->sidesets["eblock-0_0_0"].size(), 6);
119
120 // Test block 0,0,0
121 {
122 const auto & block = mesh_info->element_blocks.at("eblock-0_0_0");
123
124 // Block should have some basic stuff working
125 TEST_EQUALITY(block.num_owned_cells, 3*5*2);
126 TEST_EQUALITY(block.num_ghstd_cells, 3*5+2*3+2*5);
127 TEST_EQUALITY(block.num_virtual_cells, 3*5+2*3+2*5);
128 }
129
130 // Test block 1,1,1
131 {
132 const auto & block = mesh_info->element_blocks.at("eblock-1_1_1");
133
134 // Block should have some basic stuff working
135 TEST_EQUALITY(block.num_owned_cells, 3*5*2);
136 TEST_EQUALITY(block.num_ghstd_cells, 2*3*5+2*2*3+2*2*5);
137 TEST_EQUALITY(block.num_virtual_cells, 0);
138 }
139 }
140
141 }
142
143 }