| 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 "PanzerSTK_UnitTest_STKInterfaceGenerator.hpp" |
| 12 |
|
| 13 |
#include "Teuchos_Assert.hpp" |
| 14 |
|
| 15 |
#include "Teuchos_DefaultComm.hpp" |
| 16 |
#include "Teuchos_ParameterList.hpp" |
| 17 |
|
| 18 |
#include "Tpetra_Core.hpp" |
| 19 |
|
| 20 |
#include "Panzer_STK_Interface.hpp" |
| 21 |
|
| 22 |
#include "PanzerAdaptersSTK_config.hpp" |
| 23 |
#include "Panzer_STK_Version.hpp" |
| 24 |
#include "Panzer_STK_LineMeshFactory.hpp" |
| 25 |
#include "Panzer_STK_SquareTriMeshFactory.hpp" |
| 26 |
#include "Panzer_STK_SquareQuadMeshFactory.hpp" |
| 27 |
#include "Panzer_STK_CubeTetMeshFactory.hpp" |
| 28 |
#include "Panzer_STK_CubeHexMeshFactory.hpp" |
| 29 |
|
| 30 |
#include <string> |
| 31 |
|
| 32 |
namespace panzer_stk |
| 33 |
{ |
| 34 |
|
| 35 |
Teuchos::RCP<panzer_stk::STK_Interface> |
| 36 |
generateMesh(const Teuchos::ParameterList & parameter_list_in) |
| 37 |
{ |
| 38 |
|
| 39 |
Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm(); |
| 40 |
|
| 41 |
// Setup mesh |
| 42 |
Teuchos::RCP<panzer_stk::STK_Interface> mesh; |
| 43 |
Teuchos::RCP<Teuchos::ParameterList> mesh_params; |
| 44 |
Teuchos::ParameterList parameter_list(parameter_list_in); |
| 45 |
|
| 46 |
// In case we don't have a wrapper around the mesh |
| 47 |
if(parameter_list.isSublist("Mesh")){ |
| 48 |
mesh_params.reset(new Teuchos::ParameterList(parameter_list.sublist("Mesh"))); |
| 49 |
} else if(parameter_list.name() == "Mesh"){ |
| 50 |
// mesh_params does not pass ownership outside of this function so we can wrap parameter_list in an RCP |
| 51 |
mesh_params = Teuchos::rcpFromRef(parameter_list); |
| 52 |
} else { |
| 53 |
TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "generate_mesh : Could not find 'Mesh' parameter list in input parameter list"); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
const std::string mesh_type = mesh_params->get<std::string>("Mesh Type"); |
| 58 |
|
| 59 |
// Have to remove this before we send it along to the interpreter |
| 60 |
mesh_params->remove("Mesh Type"); |
| 61 |
|
| 62 |
Teuchos::RCP<const Teuchos::MpiComm<int> > mpi_comm = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm,true); |
| 63 |
|
| 64 |
MPI_Comm raw_comm = *(mpi_comm->getRawMpiComm()); |
| 65 |
|
| 66 |
if(mesh_type == "Hex"){ |
| 67 |
panzer_stk::CubeHexMeshFactory meshFactory; |
| 68 |
meshFactory.setParameterList(mesh_params); |
| 69 |
mesh = meshFactory.buildMesh(raw_comm); |
| 70 |
} else if(mesh_type == "Tet"){ |
| 71 |
panzer_stk::CubeTetMeshFactory meshFactory; |
| 72 |
meshFactory.setParameterList(mesh_params); |
| 73 |
mesh = meshFactory.buildMesh(raw_comm); |
| 74 |
} else if(mesh_type == "Quad"){ |
| 75 |
panzer_stk::SquareQuadMeshFactory meshFactory; |
| 76 |
meshFactory.setParameterList(mesh_params); |
| 77 |
mesh = meshFactory.buildMesh(raw_comm); |
| 78 |
} else if(mesh_type == "Tri"){ |
| 79 |
panzer_stk::SquareTriMeshFactory meshFactory; |
| 80 |
meshFactory.setParameterList(mesh_params); |
| 81 |
mesh = meshFactory.buildMesh(raw_comm); |
| 82 |
} else if(mesh_type == "Line"){ |
| 83 |
panzer_stk::LineMeshFactory meshFactory; |
| 84 |
meshFactory.setParameterList(mesh_params); |
| 85 |
mesh = meshFactory.buildMesh(raw_comm); |
| 86 |
} else { |
| 87 |
TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "generate_mesh : Mesh Type '"<<mesh_type<<"' not found. Options: Line, Tri, Quad, Tet, and Hex."); |
| 88 |
} |
| 89 |
|
| 90 |
return mesh; |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
} |