| 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 |
#ifndef EVALUATOR_TEST_TOOLS |
| 12 |
#define EVALUATOR_TEST_TOOLS |
| 13 |
|
| 14 |
#include "Panzer_STK_CubeHexMeshFactory.hpp" |
| 15 |
#include "Panzer_STK_CubeTetMeshFactory.hpp" |
| 16 |
#include "Panzer_STK_SquareQuadMeshFactory.hpp" |
| 17 |
#include "Panzer_STK_SquareTriMeshFactory.hpp" |
| 18 |
#include "Panzer_DOFManager.hpp" |
| 19 |
#include "Panzer_WorksetContainer.hpp" |
| 20 |
#include "Panzer_STKConnManager.hpp" |
| 21 |
#include "Panzer_STK_WorksetFactory.hpp" |
| 22 |
|
| 23 |
#include "Panzer_OrientationsInterface.hpp" |
| 24 |
|
| 25 |
namespace EvaluatorTestTools { |
| 26 |
|
| 27 |
struct WorksetsAndOrts { |
| 28 |
|
| 29 |
Teuchos::RCP<std::vector<panzer::Workset> > worksets; |
| 30 |
Teuchos::RCP<const std::vector<Intrepid2::Orientation> > orientations; |
| 31 |
|
| 32 |
}; |
| 33 |
|
| 34 |
/* @brief Create worksets and orientations for purposes of evaluator testing. |
| 35 |
* |
| 36 |
* @param[in] mesh STK Mesh |
| 37 |
* @param[in] fmap Map of field names to basis descriptors |
| 38 |
* @param[in] workset_size Maximal workset size. Use \c -1 to use one workset (all elements). |
| 39 |
* |
| 40 |
* @warning Will likely need to be modified for future evaluator tests. |
| 41 |
*/ |
| 42 |
|
| 43 |
WorksetsAndOrts getWorksetsAndOrtsForFields( |
| 44 |
Teuchos::RCP<panzer_stk::STK_Interface> mesh, |
| 45 |
std::map<std::string,panzer::BasisDescriptor> fmap, |
| 46 |
const int workset_size) |
| 47 |
{ |
| 48 |
|
| 49 |
WorksetsAndOrts wksOrts; |
| 50 |
|
| 51 |
// Dof manager is, at least, a global indexer |
| 52 |
// and is passed in/out, if needed |
| 53 |
|
| 54 |
// And a needs map (block to needs) |
| 55 |
std::map<std::string, panzer::WorksetNeeds> needs_map; |
| 56 |
|
| 57 |
// Assuming one element block for now... |
| 58 |
std::vector<std::string> eblocks; |
| 59 |
mesh->getElementBlockNames(eblocks); |
| 60 |
|
| 61 |
Teuchos::RCP<panzer::DOFManager> dof_manager; |
| 62 |
{ |
| 63 |
|
| 64 |
// Build a connectivity manager for the given mesh |
| 65 |
const auto conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh)); |
| 66 |
|
| 67 |
// Initialize the dof manager with the conn manager |
| 68 |
dof_manager = Teuchos::rcp(new panzer::DOFManager(conn_manager,MPI_COMM_WORLD)); |
| 69 |
|
| 70 |
// Build basis and fields |
| 71 |
const auto & cell_topology = mesh->getCellTopology(eblocks[0]); |
| 72 |
// Set cell data |
| 73 |
// numCells will get overwritten with our particular path thru getWorksets below |
| 74 |
needs_map[eblocks[0]].cellData = panzer::CellData(1,cell_topology); |
| 75 |
|
| 76 |
for (auto & map : fmap) |
| 77 |
{ |
| 78 |
auto name = map.first; |
| 79 |
auto bd = map.second; |
| 80 |
|
| 81 |
auto intrepid_basis = panzer::createIntrepid2Basis<PHX::Device::execution_space,double,double>(bd.getType(),bd.getOrder(),cell_topology); |
| 82 |
auto field_pattern = Teuchos::rcp(new panzer::Intrepid2FieldPattern(intrepid_basis)); |
| 83 |
|
| 84 |
// Add field to dof manager to lock in the field pattern |
| 85 |
dof_manager->addField(eblocks[0], name, field_pattern); |
| 86 |
|
| 87 |
needs_map[eblocks[0]].addBasis(bd); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
// Finalize the dof manager |
| 92 |
dof_manager->buildGlobalUnknowns(); |
| 93 |
|
| 94 |
// Build workset factory |
| 95 |
auto factory = Teuchos::rcp(new panzer_stk::WorksetFactory(mesh)); |
| 96 |
|
| 97 |
auto workset_container = Teuchos::rcp(new panzer::WorksetContainer(factory, needs_map)); |
| 98 |
workset_container->setGlobalIndexer(dof_manager); |
| 99 |
wksOrts.worksets = workset_container->getWorksets(panzer::WorksetDescriptor(eblocks[0], |
| 100 |
workset_size, false, true)); |
| 101 |
|
| 102 |
wksOrts.orientations = workset_container->getOrientations(); |
| 103 |
|
| 104 |
return wksOrts; |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
/* @brief Create a basic inline mesh for testing purposes |
| 109 |
* |
| 110 |
* @param[in] pl Mesh parameter list |
| 111 |
* |
| 112 |
* @note Limited to Square, Cube geometry and Quad, Tri, Tet, Hex |
| 113 |
*/ |
| 114 |
|
| 115 |
Teuchos::RCP<panzer_stk::STK_Interface> createInlineMesh(Teuchos::RCP<Teuchos::ParameterList> pl) |
| 116 |
{ |
| 117 |
|
| 118 |
auto dim = pl->get<int>("Mesh Dimension"); |
| 119 |
auto type = pl->get<std::string>("Type"); |
| 120 |
|
| 121 |
Teuchos::RCP<panzer_stk::STK_MeshFactory> mesh_factory; |
| 122 |
|
| 123 |
if (type == "Quad" && dim == 2) { |
| 124 |
mesh_factory = Teuchos::rcp(new panzer_stk::SquareQuadMeshFactory); |
| 125 |
} else if (type == "Tri" && dim == 2) { |
| 126 |
mesh_factory = Teuchos::rcp(new panzer_stk::SquareTriMeshFactory); |
| 127 |
} else if (type == "Tet" && dim == 3) { |
| 128 |
mesh_factory = Teuchos::rcp(new panzer_stk::CubeTetMeshFactory); |
| 129 |
} else if (type == "Hex" && dim == 3) { |
| 130 |
mesh_factory = Teuchos::rcp(new panzer_stk::CubeHexMeshFactory); |
| 131 |
} else { |
| 132 |
// Throw an error |
| 133 |
TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error, |
| 134 |
"ERROR: Type and/or dimension of inline mesh not valid!"); |
| 135 |
} |
| 136 |
|
| 137 |
mesh_factory->setParameterList(Teuchos::rcp(new Teuchos::ParameterList(pl->sublist("Mesh Factory Parameter List")))); |
| 138 |
auto mesh = mesh_factory->buildMesh(MPI_COMM_WORLD); |
| 139 |
|
| 140 |
return mesh; |
| 141 |
} |
| 142 |
|
| 143 |
} |
| 144 |
|
| 145 |
#endif |