VertexCFD  0.0-dev
VertexCFD_Compute_Volume_impl.hpp
1 #ifndef VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP
2 #define VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP
3 
4 #include <Panzer_ResponseEvaluatorFactory_Functional.hpp>
5 
6 #include <Teuchos_DefaultMpiComm.hpp>
7 
8 #include <string>
9 #include <vector>
10 
11 namespace VertexCFD
12 {
13 namespace ComputeVolume
14 {
15 //---------------------------------------------------------------------------//
16 template<class Scalar>
17 Volume<Scalar>::Volume(
18  const Teuchos::RCP<panzer_stk::STK_Interface>& mesh,
19  const Teuchos::RCP<const panzer::LinearObjFactory<panzer::Traits>>& lof,
20  const Teuchos::RCP<panzer::ResponseLibrary<panzer::Traits>>& response_library,
21  const std::vector<Teuchos::RCP<panzer::PhysicsBlock>>& physics_blocks,
22  const panzer::ClosureModelFactory_TemplateManager<panzer::Traits>& cm_factory,
23  const Teuchos::ParameterList& closure_params,
24  const Teuchos::ParameterList& user_params,
25  const Teuchos::RCP<panzer::WorksetContainer>& workset_container,
26  const std::vector<panzer::BC>& bcs,
27  const Teuchos::RCP<panzer::BCStrategyFactory>& bc_factory,
28  const Teuchos::RCP<panzer::EquationSetFactory>& eq_set_factory,
29  const int integration_order)
30  : _lof(lof)
31  , _response_library(response_library)
32  , _physics_blocks(physics_blocks)
33  , _cm_factory(cm_factory)
34  , _closure_params(closure_params)
35  , _user_params(user_params)
36  , _workset_container(workset_container)
37  , _bcs(bcs)
38  , _bc_factory(bc_factory)
39  , _eq_set_factory(eq_set_factory)
40 {
41  // Add response library
42  std::vector<std::string> element_blocks;
43  mesh->getElementBlockNames(element_blocks);
44 
45  panzer::FunctionalResponse_Builder<int, int> response_builder_vol;
46  response_builder_vol.comm = Teuchos::getRawMpiComm(*(mesh->getComm()));
47  response_builder_vol.cubatureDegree = integration_order;
48  response_builder_vol.requiresCellIntegral = true;
49 
50  response_builder_vol.quadPointField = "volume";
51 
52  _response_library->addResponse(
53  "compute volume", element_blocks, response_builder_vol);
54 
55  // Finalize construction of response library
56  _response_library->buildResponseEvaluators(
57  _physics_blocks, _cm_factory, _closure_params, _user_params);
58 }
59 
60 //---------------------------------------------------------------------------//
61 template<class Scalar>
62 void Volume<Scalar>::ComputeVol()
63 {
64  // Assemble linear system
65  panzer::AssemblyEngineInArgs in_args;
66  in_args.container_ = _lof->buildLinearObjContainer();
67  in_args.ghostedContainer_ = _lof->buildGhostedLinearObjContainer();
68  in_args.evaluate_transient_terms = false;
69 
70  _lof->initializeGhostedContainer(panzer::LinearObjContainer::X
71  | panzer::LinearObjContainer::F
72  | panzer::LinearObjContainer::Mat,
73  *(in_args.ghostedContainer_));
74 
75  // Set up resp, resp_func, resp_vec for volume
76  auto resp_vol = _response_library->getResponse<panzer::Traits::Residual>(
77  "compute volume");
78  auto resp_func_vol = Teuchos::rcp_dynamic_cast<
79  panzer::Response_Functional<panzer::Traits::Residual>>(resp_vol);
80  auto resp_vec_vol = Thyra::createMember(resp_func_vol->getVectorSpace());
81  resp_func_vol->setVector(resp_vec_vol);
82 
83  _response_library->addResponsesToInArgs<panzer::Traits::Residual>(in_args);
84  _response_library->evaluate<panzer::Traits::Residual>(in_args);
85 
86  _volume = resp_func_vol->value;
87 }
88 
89 //---------------------------------------------------------------------------//
90 template<class Scalar>
91 double Volume<Scalar>::volume() const
92 {
93  return _volume;
94 }
95 //---------------------------------------------------------------------------//
96 
97 } // end namespace ComputeVolume
98 } // end namespace VertexCFD
99 
100 #endif // end VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23