Debian Codegraph @

packages/panzer/adapters-stk/test/bcstrategy/user_app_BCStrategy_Dirichlet_Constant_impl.hpp

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_ParameterList.hpp"
12 #include "Teuchos_RCP.hpp"
13 #include "Teuchos_Assert.hpp"
14 #include "Phalanx_DataLayout_MDALayout.hpp"
15 #include "Phalanx_FieldManager.hpp"
16 #include "Panzer_PhysicsBlock.hpp"
17
18 #include "Panzer_BasisIRLayout.hpp"
19
20 // Evaluators
21 #include "Panzer_Constant.hpp"
22
23 #include "Phalanx_MDField.hpp"
24 #include "Phalanx_DataLayout.hpp"
25 #include "Phalanx_DataLayout_MDALayout.hpp"
26
27 // ***********************************************************************
28 template <typename EvalT>
29 user_app::BCStrategy_Dirichlet_Constant<EvalT>::
30 BCStrategy_Dirichlet_Constant(const panzer::BC& bc, const Teuchos::RCP<panzer::GlobalData>& global_data) :
31 panzer::BCStrategy_Dirichlet_DefaultImpl<EvalT>(bc,global_data)
32 {
33 TEUCHOS_ASSERT( (this->m_bc.strategy() == "Constant") ||
34 (this->m_bc.strategy() == "Constant 1") ||
35 (this->m_bc.strategy() == "Constant 2") );
36 }
37
38 // ***********************************************************************
39 template <typename EvalT>
40 void user_app::BCStrategy_Dirichlet_Constant<EvalT>::
41 setup(const panzer::PhysicsBlock& side_pb,
42 const Teuchos::ParameterList& /* user_data */)
43 {
44 using Teuchos::RCP;
45 using std::vector;
46 using std::string;
47 using std::pair;
48
49 /*
50 // need the dof value to form the residual
51 this->required_dof_names.push_back(this->m_bc.equationSetName());
52
53 // unique residual name
54 this->residual_name = "Residual_" + this->m_bc.identifier();
55
56 // map residual to dof
57 this->residual_to_dof_names_map[residual_name] = this->m_bc.equationSetName();
58
59 // map residual to target field
60 this->residual_to_target_field_map[residual_name] = "Constant_" + this->m_bc.equationSetName();
61 */
62
63 // add in gather DOF
64 this->addDOF(this->m_bc.equationSetName()); // DOF Name
65
66 // add in the target
67 this->addTarget("Constant_"+this->m_bc.equationSetName(), // Target Name
68 this->m_bc.equationSetName(), // DOF Name
69 "Residual_"+this->m_bc.identifier()); // Residual Name
70
71 // find the basis for this dof
72 const vector<pair<string,RCP<panzer::PureBasis> > >& dofs = side_pb.getProvidedDOFs();
73
74 for (vector<pair<string,RCP<panzer::PureBasis> > >::const_iterator dof_it =
75 dofs.begin(); dof_it != dofs.end(); ++dof_it) {
76 if (dof_it->first == this->m_bc.equationSetName())
77 this->basis = dof_it->second;
78 }
79
80 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(this->basis), std::runtime_error,
81 "Error the name \"" << this->m_bc.equationSetName()
82 << "\" is not a valid DOF for the boundary condition:\n"
83 << this->m_bc << "\n");
84
85 }
86
87 // ***********************************************************************
88 template <typename EvalT>
89 void user_app::BCStrategy_Dirichlet_Constant<EvalT>::
90 buildAndRegisterEvaluators(PHX::FieldManager<panzer::Traits>& fm,
91 const panzer::PhysicsBlock& /* pb */,
92 const panzer::ClosureModelFactory_TemplateManager<panzer::Traits>& /* factory */,
93 const Teuchos::ParameterList& /* models */,
94 const Teuchos::ParameterList& /* user_data */) const
95 {
96 using Teuchos::ParameterList;
97 using Teuchos::RCP;
98 using Teuchos::rcp;
99
100 // provide a constant target value to map into residual
101 {
102 ParameterList p("BC Constant Dirichlet");
103 p.set("Name", "Constant_" + this->m_bc.equationSetName());
104 p.set("Data Layout", basis->functional);
105 p.set("Value", this->m_bc.params()->template get<double>("Value"));
106
107 RCP< PHX::Evaluator<panzer::Traits> > op =
108 rcp(new panzer::Constant<EvalT,panzer::Traits>(p));
109
110 this->template registerEvaluator<EvalT>(fm, op);
111 }
112
113 }