| 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 |
using Teuchos::RCP; |
| 17 |
using Teuchos::rcp; |
| 18 |
|
| 19 |
#include "Teuchos_DefaultComm.hpp" |
| 20 |
#include "Teuchos_GlobalMPISession.hpp" |
| 21 |
#include "Panzer_STK_Version.hpp" |
| 22 |
#include "PanzerAdaptersSTK_config.hpp" |
| 23 |
#include "Panzer_STK_Interface.hpp" |
| 24 |
#include "Panzer_STK_SquareQuadMeshFactory.hpp" |
| 25 |
#include "Panzer_Workset_Builder.hpp" |
| 26 |
#include "Panzer_STK_SetupUtilities.hpp" |
| 27 |
#include "Panzer_PhysicsBlock.hpp" |
| 28 |
#include "Panzer_GlobalData.hpp" |
| 29 |
#include "Panzer_BC.hpp" |
| 30 |
|
| 31 |
#include "user_app_EquationSetFactory.hpp" |
| 32 |
|
| 33 |
namespace panzer { |
| 34 |
|
| 35 |
void testInitialzation(const Teuchos::RCP<Teuchos::ParameterList>& ipb, |
| 36 |
std::vector<panzer::BC>& bcs); |
| 37 |
|
| 38 |
TEUCHOS_UNIT_TEST(cascade, side_element_cascade) |
| 39 |
{ |
| 40 |
using Teuchos::RCP; |
| 41 |
|
| 42 |
#ifdef HAVE_MPI |
| 43 |
Teuchos::RCP<Teuchos::Comm<int> > tcomm = Teuchos::rcp(new Teuchos::MpiComm<int>(Teuchos::opaqueWrapper(MPI_COMM_WORLD))); |
| 44 |
#else |
| 45 |
Teuchos::RCP<Teuchos::Comm<int> > tcomm = Teuchos::rcp(new Teuchos::SerialComm<int>); |
| 46 |
#endif |
| 47 |
|
| 48 |
// excercise subcell entities capability |
| 49 |
{ |
| 50 |
RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList); |
| 51 |
pl->set("X Elements",4); |
| 52 |
pl->set("Y Elements",4); |
| 53 |
pl->set("X Procs",1); |
| 54 |
pl->set("Y Procs",2); |
| 55 |
|
| 56 |
panzer_stk::SquareQuadMeshFactory factory; |
| 57 |
factory.setParameterList(pl); |
| 58 |
RCP<panzer_stk::STK_Interface> mesh = factory.buildMesh(MPI_COMM_WORLD); |
| 59 |
|
| 60 |
std::vector<stk::mesh::Entity> sideEntities; |
| 61 |
mesh->getMySides("left","eblock-0_0",sideEntities); |
| 62 |
|
| 63 |
std::vector<std::vector<stk::mesh::Entity> > subcells; |
| 64 |
panzer_stk::workset_utils::getSubcellEntities(*mesh,sideEntities,subcells); |
| 65 |
|
| 66 |
if(tcomm->getRank()==0) { |
| 67 |
TEST_EQUALITY(subcells.size(),1); |
| 68 |
TEST_EQUALITY(subcells[0].size(),3); |
| 69 |
} |
| 70 |
else { |
| 71 |
TEST_EQUALITY(subcells.size(),1); |
| 72 |
TEST_EQUALITY(subcells[0].size(),3); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
{ |
| 77 |
RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList); |
| 78 |
pl->set("X Elements",4); |
| 79 |
pl->set("Y Elements",4); |
| 80 |
pl->set("X Procs",1); |
| 81 |
pl->set("Y Procs",2); |
| 82 |
|
| 83 |
panzer_stk::SquareQuadMeshFactory factory; |
| 84 |
factory.setParameterList(pl); |
| 85 |
RCP<panzer_stk::STK_Interface> mesh = factory.buildMesh(MPI_COMM_WORLD); |
| 86 |
|
| 87 |
std::vector<stk::mesh::Entity> sideEntities; |
| 88 |
mesh->getMySides("left","eblock-0_0",sideEntities); |
| 89 |
TEST_ASSERT(sideEntities.size()==2); |
| 90 |
|
| 91 |
std::vector<std::size_t> localSubcellDim,localSubcellIds; |
| 92 |
std::vector<stk::mesh::Entity> elements; |
| 93 |
|
| 94 |
panzer_stk::workset_utils::getSideElementCascade(*mesh,"eblock-0_0",sideEntities, |
| 95 |
localSubcellDim,localSubcellIds,elements); |
| 96 |
|
| 97 |
TEST_EQUALITY(localSubcellDim.size(),6); |
| 98 |
TEST_ASSERT(localSubcellDim.size()==localSubcellIds.size()); |
| 99 |
TEST_ASSERT(localSubcellDim.size()==elements.size()); |
| 100 |
|
| 101 |
int node_cnt = 0; |
| 102 |
int edge_cnt = 0; |
| 103 |
for(std::size_t i=0;i<localSubcellDim.size();i++) { |
| 104 |
node_cnt += (localSubcellDim[i]==0) ? 1 : 0; |
| 105 |
edge_cnt += (localSubcellDim[i]==1) ? 1 : 0; |
| 106 |
} |
| 107 |
|
| 108 |
TEST_EQUALITY(node_cnt,4); |
| 109 |
TEST_EQUALITY(edge_cnt,2); |
| 110 |
|
| 111 |
for(std::size_t i=0;i<localSubcellDim.size();i++) |
| 112 |
out << elements[i] << " " << localSubcellDim[i] << " " << localSubcellIds[i] << std::endl; |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
void testInitialzation(const Teuchos::RCP<Teuchos::ParameterList>& ipb, |
| 117 |
std::vector<panzer::BC>& bcs) |
| 118 |
{ |
| 119 |
// Physics block |
| 120 |
Teuchos::ParameterList& physics_block = ipb->sublist("test physics"); |
| 121 |
{ |
| 122 |
Teuchos::ParameterList& p = physics_block.sublist("a"); |
| 123 |
p.set("Type","Energy"); |
| 124 |
p.set("Prefix",""); |
| 125 |
p.set("Model ID","solid"); |
| 126 |
p.set("Basis Type","HGrad"); |
| 127 |
p.set("Basis Order",2); |
| 128 |
p.set("Integration Order",1); |
| 129 |
} |
| 130 |
{ |
| 131 |
Teuchos::ParameterList& p = physics_block.sublist("b"); |
| 132 |
p.set("Type","Energy"); |
| 133 |
p.set("Prefix","ION_"); |
| 134 |
p.set("Model ID","ion solid"); |
| 135 |
p.set("Basis Type","HGrad"); |
| 136 |
p.set("Basis Order",1); |
| 137 |
p.set("Integration Order",1); |
| 138 |
} |
| 139 |
|
| 140 |
{ |
| 141 |
std::size_t bc_id = 0; |
| 142 |
panzer::BCType neumann = BCT_Dirichlet; |
| 143 |
std::string sideset_id = "left"; |
| 144 |
std::string element_block_id = "eblock-0_0"; |
| 145 |
std::string dof_name = "UX"; |
| 146 |
std::string strategy = "Constant"; |
| 147 |
double value = 5.0; |
| 148 |
Teuchos::ParameterList p; |
| 149 |
p.set("Value",value); |
| 150 |
panzer::BC bc(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 151 |
strategy, p); |
| 152 |
bcs.push_back(bc); |
| 153 |
} |
| 154 |
{ |
| 155 |
std::size_t bc_id = 0; |
| 156 |
panzer::BCType neumann = BCT_Dirichlet; |
| 157 |
std::string sideset_id = "right"; |
| 158 |
std::string element_block_id = "eblock-1_0"; |
| 159 |
std::string dof_name = "UX"; |
| 160 |
std::string strategy = "Constant"; |
| 161 |
double value = 5.0; |
| 162 |
Teuchos::ParameterList p; |
| 163 |
p.set("Value",value); |
| 164 |
panzer::BC bc(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 165 |
strategy, p); |
| 166 |
bcs.push_back(bc); |
| 167 |
} |
| 168 |
{ |
| 169 |
std::size_t bc_id = 0; |
| 170 |
panzer::BCType neumann = BCT_Dirichlet; |
| 171 |
std::string sideset_id = "top"; |
| 172 |
std::string element_block_id = "eblock-1_0"; |
| 173 |
std::string dof_name = "UX"; |
| 174 |
std::string strategy = "Constant"; |
| 175 |
double value = 5.0; |
| 176 |
Teuchos::ParameterList p; |
| 177 |
p.set("Value",value); |
| 178 |
panzer::BC bc(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 179 |
strategy, p); |
| 180 |
bcs.push_back(bc); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
} |