Debian Codegraph @

packages/panzer/adapters-stk/test/panzer_workset_builder/workset_container.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
16 using Teuchos::RCP;
17 using Teuchos::rcp;
18
19 #include "Teuchos_DefaultComm.hpp"
20 #include "Teuchos_GlobalMPISession.hpp"
21
22 #include "Panzer_STK_Version.hpp"
23 #include "PanzerAdaptersSTK_config.hpp"
24
25 #include "Panzer_WorksetContainer.hpp"
26 #include "Panzer_IntrepidBasisFactory.hpp"
27 #include "Panzer_DOFManager.hpp"
28
29 #include "Panzer_STK_Interface.hpp"
30 #include "Panzer_STK_CubeHexMeshFactory.hpp"
31 #include "Panzer_STKConnManager.hpp"
32 #include "Panzer_STK_WorksetFactory.hpp"
33
34 namespace panzer {
35
36 TEUCHOS_UNIT_TEST(workset_container, identifiers)
37 {
38 using Teuchos::RCP;
39 using Teuchos::rcp;
40
41 typedef Intrepid2::Basis<PHX::Device::execution_space,double,double> IntrepidBasis;
42
43 std::string element_block = "eblock-0_0_0";
44 std::string sideset = "left";
45 int workset_size = 10;
46
47 RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList);
48 pl->set("X Elements",8);
49 pl->set("Y Elements",8);
50 pl->set("Z Elements",8);
51
52 panzer_stk::CubeHexMeshFactory factory;
53 factory.setParameterList(pl);
54 RCP<panzer_stk::STK_Interface> mesh = factory.buildMesh(MPI_COMM_WORLD);
55 RCP<const Teuchos::MpiComm<int> > tComm = Teuchos::rcp(new Teuchos::MpiComm<int>(MPI_COMM_WORLD));
56
57 // build DOF Manager (with a single HDiv basis)
58 /////////////////////////////////////////////////////////////
59
60 // build the connection manager
61 const RCP<panzer::ConnManager>
62 conn_manager = rcp(new panzer_stk::STKConnManager(mesh));
63
64 RCP<panzer::DOFManager> dof_manager
65 = rcp(new panzer::DOFManager(conn_manager,MPI_COMM_WORLD));
66
67 // build an intrepid basis and a related field pattern for seeding the DOFManager
68 {
69 RCP<IntrepidBasis> intrepid_basis
70 = panzer::createIntrepid2Basis<PHX::Device::execution_space,double,double>("HGrad",1,
71 *mesh->getCellTopology(element_block));
72 RCP<panzer::Intrepid2FieldPattern> field_pattern = rcp(new panzer::Intrepid2FieldPattern(intrepid_basis));
73
74 dof_manager->addField(element_block, "T", field_pattern);
75 }
76 dof_manager->buildGlobalUnknowns();
77
78 // build WorksetContainer
79 //////////////////////////////////////////////////////////////
80
81 RCP<panzer_stk::WorksetFactory> wkstFactory
82 = rcp(new panzer_stk::WorksetFactory(mesh)); // build STK workset factory
83 RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
84 = rcp(new panzer::WorksetContainer);
85
86 // I'm surprised the needs are required
87 {
88 BasisDescriptor basis_desc(1,"HGrad");
89 WorksetNeeds needs;
90 needs.cellData = CellData(workset_size,mesh->getCellTopology(element_block));
91 needs.addBasis(basis_desc);
92 wkstContainer->setNeeds(element_block,needs);
93 }
94
95 wkstContainer->setFactory(wkstFactory);
96 wkstContainer->setGlobalIndexer(dof_manager);
97 wkstContainer->setWorksetSize(workset_size);
98
99 // check volume worksets, both for deviation from 0 (required) and number
100 // of unique identifiers
101 {
102 std::vector<Workset> & worksets = *wkstContainer->getWorksets(blockDescriptor(element_block));
103
104 std::set<std::size_t> identifiers;
105 for(auto wkst : worksets) {
106 // check a unique identifier
107 TEST_ASSERT(wkst.getIdentifier()!=0u);
108
109 identifiers.insert(wkst.getIdentifier());
110 }
111
112 // check uniqueness of identifiers
113 TEST_EQUALITY(worksets.size(),identifiers.size());
114 }
115
116 // check side set worksets, both for deviation from 0 (required) and number
117 // of unique identifiers
118 {
119
120 Teuchos::RCP<std::map<unsigned,Workset> > rcp_worksets = wkstContainer->getSideWorksets(sidesetDescriptor(element_block,sideset));
121
122 // because this is a boundary workset, sometimes these things are not relevant
123 if(rcp_worksets!=Teuchos::null) {
124 std::map<unsigned,Workset> & worksets = *rcp_worksets;
125
126 TEST_ASSERT(worksets.size()>0);
127
128 std::set<std::size_t> identifiers;
129 for(auto wkst : worksets) {
130 out << "IS THIS ZERO ???? " << wkst.second.getIdentifier() << " " << wkst.first << std::endl;
131
132 // check a unique identifier
133 TEST_ASSERT(wkst.second.getIdentifier()!=0u);
134
135 identifiers.insert(wkst.second.getIdentifier());
136 }
137
138 // check uniqueness of identifiers
139 TEST_EQUALITY(worksets.size(),identifiers.size());
140 }
141 }
142
143 // check side set worksets, both for deviation from 0 (required) and number
144 // of unique identifiers
145 {
146 Teuchos::RCP<std::map<unsigned,Workset> > rcp_worksets = wkstContainer->getSideWorksets(sidesetVolumeDescriptor(element_block,sideset));
147
148
149 if(rcp_worksets!=Teuchos::null) {
150 std::map<unsigned,Workset> & worksets = *rcp_worksets;
151
152 TEST_ASSERT(worksets.size()>0);
153
154 std::set<std::size_t> identifiers;
155 for(auto wkst : worksets) {
156 // check a unique identifier
157 TEST_ASSERT(wkst.second.getIdentifier()!=0u);
158
159 identifiers.insert(wkst.second.getIdentifier());
160 }
161
162 // check uniqueness of identifiers
163 TEST_EQUALITY(worksets.size(),identifiers.size());
164 }
165 }
166 }
167 }