| 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_ParameterList.hpp> |
| 13 |
#include <Teuchos_RCP.hpp> |
| 14 |
#include <Teuchos_TimeMonitor.hpp> |
| 15 |
#include <Teuchos_UnitTestHarness.hpp> |
| 16 |
|
| 17 |
#include "Panzer_STK_SquareTriMeshFactory.hpp" |
| 18 |
#include "Panzer_STK_SquareQuadMeshFactory.hpp" |
| 19 |
#include "Panzer_STK_CubeTetMeshFactory.hpp" |
| 20 |
#include "Panzer_STK_CubeHexMeshFactory.hpp" |
| 21 |
#include "Panzer_STKConnManager.hpp" |
| 22 |
|
| 23 |
#include "Panzer_FaceToElement.hpp" |
| 24 |
|
| 25 |
using Teuchos::rcp; |
| 26 |
using Teuchos::rcp_dynamic_cast; |
| 27 |
using Teuchos::RCP; |
| 28 |
using Teuchos::rcpFromRef; |
| 29 |
|
| 30 |
namespace panzer { |
| 31 |
namespace disc_fe { |
| 32 |
namespace core_tests { |
| 33 |
|
| 34 |
void setParamList(RCP<Teuchos::ParameterList> mesh_pl, int nx, int ny, int nz=0, int bx=1, int by=1, int bz=0) |
| 35 |
{ |
| 36 |
mesh_pl->set("X Blocks", bx); |
| 37 |
mesh_pl->set("Y Blocks", by); |
| 38 |
mesh_pl->set("X Elements", nx); |
| 39 |
mesh_pl->set("Y Elements", ny); |
| 40 |
|
| 41 |
mesh_pl->set("X0", 0.0); |
| 42 |
mesh_pl->set("Y0", 0.0); |
| 43 |
mesh_pl->set("Xf", 1.0); |
| 44 |
mesh_pl->set("Yf", 1.0); |
| 45 |
|
| 46 |
if ( nz > 0 ) { |
| 47 |
mesh_pl->set("Z Blocks", bz); |
| 48 |
mesh_pl->set("Z Elements", nz); |
| 49 |
mesh_pl->set("Z0", 0.0); |
| 50 |
mesh_pl->set("Zf", 1.0); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
#ifndef PANZER_HIDE_DEPRECATED_CODE |
| 55 |
TEUCHOS_UNIT_TEST(FaceToElement, test_default_communicator) |
| 56 |
{ |
| 57 |
Teuchos::RCP<const Teuchos::MpiComm<int>> comm_world(new Teuchos::MpiComm< int>(MPI_COMM_WORLD)); |
| 58 |
|
| 59 |
RCP<Teuchos::ParameterList> mesh_pl(new Teuchos::ParameterList("Mesh")); |
| 60 |
int nx=4, ny=8, nz=-1, bx=1, by=2, bz=-1; |
| 61 |
setParamList(mesh_pl, nx, ny, nz, bx, by, bz); |
| 62 |
|
| 63 |
RCP<panzer_stk::STK_MeshFactory> mesh_factory = rcp(new panzer_stk::SquareTriMeshFactory); |
| 64 |
mesh_factory->setParameterList(mesh_pl); |
| 65 |
|
| 66 |
RCP<panzer_stk::STK_Interface> mesh = mesh_factory->buildUncommitedMesh(*comm_world->getRawMpiComm()); |
| 67 |
mesh_factory->completeMeshConstruction(*mesh,*comm_world->getRawMpiComm()); |
| 68 |
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh)); |
| 69 |
|
| 70 |
auto faceToElement = Teuchos::rcp(new panzer::FaceToElement<panzer::LocalOrdinal,panzer::GlobalOrdinal>()); |
| 71 |
faceToElement->initialize(*conn_manager); |
| 72 |
|
| 73 |
MPI_Barrier(MPI_COMM_WORLD); |
| 74 |
} |
| 75 |
#endif |
| 76 |
|
| 77 |
TEUCHOS_UNIT_TEST(FaceToElement, test_comm_world) |
| 78 |
{ |
| 79 |
Teuchos::RCP<const Teuchos::MpiComm<int>> comm_world(new Teuchos::MpiComm< int>(MPI_COMM_WORLD)); |
| 80 |
|
| 81 |
RCP<Teuchos::ParameterList> mesh_pl(new Teuchos::ParameterList("Mesh")); |
| 82 |
int nx=4, ny=8, nz=-1, bx=1, by=2, bz=-1; |
| 83 |
setParamList(mesh_pl, nx, ny, nz, bx, by, bz); |
| 84 |
|
| 85 |
RCP<panzer_stk::STK_MeshFactory> mesh_factory = rcp(new panzer_stk::SquareTriMeshFactory); |
| 86 |
mesh_factory->setParameterList(mesh_pl); |
| 87 |
|
| 88 |
RCP<panzer_stk::STK_Interface> mesh = mesh_factory->buildUncommitedMesh(*comm_world->getRawMpiComm()); |
| 89 |
mesh_factory->completeMeshConstruction(*mesh,*comm_world->getRawMpiComm()); |
| 90 |
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh)); |
| 91 |
|
| 92 |
auto faceToElement = Teuchos::rcp(new panzer::FaceToElement<panzer::LocalOrdinal,panzer::GlobalOrdinal>()); |
| 93 |
faceToElement->initialize(*conn_manager, comm_world); |
| 94 |
|
| 95 |
MPI_Barrier(MPI_COMM_WORLD); |
| 96 |
} |
| 97 |
|
| 98 |
TEUCHOS_UNIT_TEST(FaceToElement, test_sub_communicator) |
| 99 |
{ |
| 100 |
std::vector<int> this_ranks = {0,1}; |
| 101 |
Teuchos::ArrayView<int> array_view(this_ranks); |
| 102 |
Teuchos::RCP<const Teuchos::MpiComm<int>> comm_world(new Teuchos::MpiComm< int>(MPI_COMM_WORLD)); |
| 103 |
auto sub_comm = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int>>(comm_world->createSubcommunicator(array_view),true); |
| 104 |
|
| 105 |
if (comm_world->getRank() < 2) { |
| 106 |
RCP<Teuchos::ParameterList> mesh_pl(new Teuchos::ParameterList("Mesh")); |
| 107 |
int nx=4, ny=8, nz=-1, bx=1, by=2, bz=-1; |
| 108 |
setParamList(mesh_pl, nx, ny, nz, bx, by, bz); |
| 109 |
|
| 110 |
RCP<panzer_stk::STK_MeshFactory> mesh_factory = rcp(new panzer_stk::SquareTriMeshFactory); |
| 111 |
mesh_factory->setParameterList(mesh_pl); |
| 112 |
|
| 113 |
RCP<panzer_stk::STK_Interface> mesh = mesh_factory->buildUncommitedMesh(*sub_comm->getRawMpiComm()); |
| 114 |
mesh_factory->completeMeshConstruction(*mesh,*sub_comm->getRawMpiComm()); |
| 115 |
const Teuchos::RCP<panzer::ConnManager> conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(mesh)); |
| 116 |
|
| 117 |
auto faceToElement = Teuchos::rcp(new panzer::FaceToElement<panzer::LocalOrdinal,panzer::GlobalOrdinal>()); |
| 118 |
faceToElement->initialize(*conn_manager, sub_comm); |
| 119 |
} |
| 120 |
|
| 121 |
MPI_Barrier(MPI_COMM_WORLD); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
} |