1 #ifndef VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP
2 #define VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP
4 #include <Panzer_ResponseEvaluatorFactory_Functional.hpp>
6 #include <Teuchos_DefaultMpiComm.hpp>
13 namespace ComputeVolume
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)
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)
38 , _bc_factory(bc_factory)
39 , _eq_set_factory(eq_set_factory)
42 std::vector<std::string> element_blocks;
43 mesh->getElementBlockNames(element_blocks);
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;
50 response_builder_vol.quadPointField =
"volume";
52 _response_library->addResponse(
53 "compute volume", element_blocks, response_builder_vol);
56 _response_library->buildResponseEvaluators(
57 _physics_blocks, _cm_factory, _closure_params, _user_params);
61 template<
class Scalar>
62 void Volume<Scalar>::ComputeVol()
65 panzer::AssemblyEngineInArgs in_args;
66 in_args.container_ = _lof->buildLinearObjContainer();
67 in_args.ghostedContainer_ = _lof->buildGhostedLinearObjContainer();
68 in_args.evaluate_transient_terms =
false;
70 _lof->initializeGhostedContainer(panzer::LinearObjContainer::X
71 | panzer::LinearObjContainer::F
72 | panzer::LinearObjContainer::Mat,
73 *(in_args.ghostedContainer_));
76 auto resp_vol = _response_library->getResponse<panzer::Traits::Residual>(
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);
83 _response_library->addResponsesToInArgs<panzer::Traits::Residual>(in_args);
84 _response_library->evaluate<panzer::Traits::Residual>(in_args);
86 _volume = resp_func_vol->value;
90 template<
class Scalar>
91 double Volume<Scalar>::volume()
const
100 #endif // end VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP