VertexCFD  0.0-dev
VertexCFD_Closure_ConductionExactSolution_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_CONDUCTIONEXACTSOLUTION_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_CONDUCTIONEXACTSOLUTION_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
5 
6 #include "Panzer_GlobalIndexer.hpp"
7 #include "Panzer_PureBasis.hpp"
8 #include "Panzer_Workset_Utilities.hpp"
9 #include <Panzer_HierarchicParallelism.hpp>
10 
11 #include <Teuchos_Array.hpp>
12 
13 #include <cmath>
14 #include <string>
15 
16 namespace VertexCFD
17 {
18 namespace ClosureModel
19 {
20 //---------------------------------------------------------------------------//
21 template<class EvalType, class Traits, int NumSpaceDim>
23  const panzer::IntegrationRule& ir,
24  const Teuchos::ParameterList& closure_params)
25  : _lagrange_pressure("Exact_lagrange_pressure", ir.dl_scalar)
26  , _temperature("Exact_temperature", ir.dl_scalar)
27  , _ir_degree(ir.cubature_degree)
28 {
29  // Add evaluated field
30  this->addEvaluatedField(_lagrange_pressure);
31  Utils::addEvaluatedVectorField(
32  *this, ir.dl_scalar, _velocity, "Exact_velocity_");
33  this->addEvaluatedField(_temperature);
34 
35  // Get heat source value and coefficient for exact solution
36  _q = closure_params.get<double>("Volumetric Heat Source Value");
37  _k = closure_params.get<double>("Thermal Conductivity Coefficient");
38  _T_right = closure_params.get<double>("Right Temperature Boundary Value");
39 
40  // Set name
41  this->setName("Conduction Exact Solution");
42 }
43 
44 //---------------------------------------------------------------------------//
45 template<class EvalType, class Traits, int NumSpaceDim>
47  typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
48 {
49  _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
50 }
51 
52 //---------------------------------------------------------------------------//
53 template<class EvalType, class Traits, int NumSpaceDim>
55  typename Traits::EvalData workset)
56 {
57  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
58  workset.num_cells);
59 
60  _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
61  Kokkos::parallel_for(this->getName(), policy, *this);
62 }
63 
64 //---------------------------------------------------------------------------//
65 template<class EvalType, class Traits, int NumSpaceDim>
66 KOKKOS_INLINE_FUNCTION void
68  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
69 {
70  const int cell = team.league_rank();
71  const int num_point = _temperature.extent(1);
72  using std::exp;
73 
74  Kokkos::parallel_for(
75  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
76  // NS variables are still defined on a solid region because they
77  // are expected by the Tempus observer that compute the error
78  // norms.
79  _lagrange_pressure(cell, point) = 0.0;
80  _velocity[0](cell, point) = 0.0;
81  _velocity[1](cell, point) = 0.0;
82  if (num_space_dim == 3)
83  _velocity[2](cell, point) = 0.0;
84 
85  // With temperature-dependent k and variable heat source
86  const double x = _ip_coords(cell, point, 0);
87  _temperature(cell, point)
88  = _T_right * exp(_q / (6.0 * _k) * (1.0 - x * x * x));
89  });
90 }
91 
92 //---------------------------------------------------------------------------//
93 
94 } // end namespace ClosureModel
95 } // end namespace VertexCFD
96 
97 #endif // VERTEXCFD_CLOSURE_CONDUCTIONEXACTSOLUTION_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::ClosureModel::ConductionExactSolution::_temperature
PHX::MDField< double, panzer::Cell, panzer::Point > _temperature
Exact temperature field.
Definition: VertexCFD_Closure_ConductionExactSolution.hpp:114
VertexCFD::ClosureModel::ConductionExactSolution::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData sd, PHX::FieldManager< Traits > &fm) override
Perform post‑registration setup.
Definition: VertexCFD_Closure_ConductionExactSolution_impl.hpp:46
VertexCFD::ClosureModel::ConductionExactSolution::scalar_type
typename EvalType::ScalarT scalar_type
Scalar type used by the evaluation type.
Definition: VertexCFD_Closure_ConductionExactSolution.hpp:43
VertexCFD::ClosureModel::ConductionExactSolution::_lagrange_pressure
PHX::MDField< double, panzer::Cell, panzer::Point > _lagrange_pressure
Exact Lagrange pressure field.
Definition: VertexCFD_Closure_ConductionExactSolution.hpp:100
VertexCFD::ClosureModel::ConductionExactSolution::_velocity
Kokkos::Array< PHX::MDField< double, panzer::Cell, panzer::Point >, num_space_dim > _velocity
Exact velocity vector field.
Definition: VertexCFD_Closure_ConductionExactSolution.hpp:108
VertexCFD::ClosureModel::ConductionExactSolution::ConductionExactSolution
ConductionExactSolution(const panzer::IntegrationRule &ir, const Teuchos::ParameterList &closure_params)
Constructor.
Definition: VertexCFD_Closure_ConductionExactSolution_impl.hpp:22
VertexCFD::ClosureModel::ConductionExactSolution::operator()
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
Kokkos functor for team‑level parallel evaluation.
Definition: VertexCFD_Closure_ConductionExactSolution_impl.hpp:67
VertexCFD::ClosureModel::ConductionExactSolution::evaluateFields
void evaluateFields(typename Traits::EvalData workset) override
Evaluate the exact solution fields on the workset.
Definition: VertexCFD_Closure_ConductionExactSolution_impl.hpp:54