| 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 |
#include <Teuchos_ParameterList.hpp> |
| 16 |
#include <Teuchos_Assert.hpp> |
| 17 |
|
| 18 |
#include "Panzer_Traits.hpp" |
| 19 |
#include "Panzer_BC.hpp" |
| 20 |
#include "Panzer_BCStrategy.hpp" |
| 21 |
#include <iostream> |
| 22 |
|
| 23 |
#include "PanzerAdaptersSTK_config.hpp" |
| 24 |
#include "Panzer_STK_Interface.hpp" |
| 25 |
#include "Panzer_STK_SquareQuadMeshFactory.hpp" |
| 26 |
#include "Panzer_STK_SetupUtilities.hpp" |
| 27 |
#include "Panzer_STK_WorksetFactory.hpp" |
| 28 |
#include "Panzer_Workset_Builder.hpp" |
| 29 |
#include "Panzer_WorksetContainer.hpp" |
| 30 |
#include "Panzer_FieldManagerBuilder.hpp" |
| 31 |
#include "Panzer_AssemblyEngine.hpp" |
| 32 |
#include "Panzer_AssemblyEngine_InArgs.hpp" |
| 33 |
#include "Panzer_AssemblyEngine_TemplateManager.hpp" |
| 34 |
#include "Panzer_AssemblyEngine_TemplateBuilder.hpp" |
| 35 |
#include "Panzer_DOFManagerFactory.hpp" |
| 36 |
#include "Panzer_GlobalData.hpp" |
| 37 |
|
| 38 |
#include "user_app_BCStrategy_Factory_Physics1.hpp" |
| 39 |
#include "user_app_BCStrategy_Factory_Physics2.hpp" |
| 40 |
|
| 41 |
#include "Panzer_BCStrategy_Factory_Composite.hpp" |
| 42 |
|
| 43 |
#include "user_app_EquationSetFactory.hpp" |
| 44 |
#include "user_app_ClosureModel_Factory_TemplateBuilder.hpp" |
| 45 |
|
| 46 |
#include "Epetra_MpiComm.h" |
| 47 |
|
| 48 |
namespace panzer { |
| 49 |
|
| 50 |
TEUCHOS_UNIT_TEST(bcstrategy, basic_construction) |
| 51 |
{ |
| 52 |
|
| 53 |
std::size_t bc_id = 0; |
| 54 |
panzer::BCType neumann = BCT_Dirichlet; |
| 55 |
std::string sideset_id = "4"; |
| 56 |
std::string element_block_id = "fluid"; |
| 57 |
std::string dof_name = "UX"; |
| 58 |
std::string strategy = "Constant"; |
| 59 |
double value = 5.0; |
| 60 |
Teuchos::ParameterList p; |
| 61 |
p.set("Value",value); |
| 62 |
panzer::BC bc(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 63 |
strategy, p); |
| 64 |
|
| 65 |
panzer::BC bc1(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 66 |
"Constant 1", p); |
| 67 |
|
| 68 |
panzer::BC bc2(bc_id, neumann, sideset_id, element_block_id, dof_name, |
| 69 |
"Constant 2", p); |
| 70 |
|
| 71 |
|
| 72 |
Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData(); |
| 73 |
|
| 74 |
// Build factory 1 and test that it builds bc 1 and throws on |
| 75 |
// failure to build bc 2 |
| 76 |
{ |
| 77 |
Teuchos::RCP<panzer::BCStrategy_TemplateManager<panzer::Traits> > bcs; |
| 78 |
user_app::BCFactoryPhysics1 my_factory1(true); |
| 79 |
TEST_NOTHROW(bcs = my_factory1.buildBCStrategy(bc1,gd)); |
| 80 |
TEST_ASSERT(nonnull(bcs)); |
| 81 |
TEST_THROW(bcs = my_factory1.buildBCStrategy(bc2,gd),std::logic_error); |
| 82 |
} |
| 83 |
|
| 84 |
// Build factory 2 and test that it builds bc 2 and throws on |
| 85 |
// failure to build bc 1 |
| 86 |
{ |
| 87 |
Teuchos::RCP<panzer::BCStrategy_TemplateManager<panzer::Traits> > bcs; |
| 88 |
user_app::BCFactoryPhysics2 my_factory2(true); |
| 89 |
TEST_NOTHROW(bcs = my_factory2.buildBCStrategy(bc2,gd)); |
| 90 |
TEST_ASSERT(nonnull(bcs)); |
| 91 |
TEST_THROW(bcs = my_factory2.buildBCStrategy(bc1,gd),std::logic_error); |
| 92 |
} |
| 93 |
|
| 94 |
// Build composite and test that it can build both bc 1 and bc 2 |
| 95 |
{ |
| 96 |
std::vector<Teuchos::RCP<panzer::BCStrategyFactory> > factories; |
| 97 |
Teuchos::RCP<user_app::BCFactoryPhysics1> factory1 = Teuchos::rcp(new user_app::BCFactoryPhysics1(false)); |
| 98 |
Teuchos::RCP<user_app::BCFactoryPhysics2> factory2 = Teuchos::rcp(new user_app::BCFactoryPhysics2(false)); |
| 99 |
factories.push_back(factory1); |
| 100 |
factories.push_back(factory2); |
| 101 |
panzer::BCFactoryComposite composite(factories); |
| 102 |
|
| 103 |
Teuchos::RCP<panzer::BCStrategy_TemplateManager<panzer::Traits> > bcs; |
| 104 |
TEST_NOTHROW(bcs = composite.buildBCStrategy(bc1,gd)); |
| 105 |
TEST_ASSERT(nonnull(bcs)); |
| 106 |
bcs = Teuchos::null; |
| 107 |
TEST_NOTHROW(bcs = composite.buildBCStrategy(bc2,gd)); |
| 108 |
TEST_ASSERT(nonnull(bcs)); |
| 109 |
} |
| 110 |
|
| 111 |
} |
| 112 |
|
| 113 |
} |