1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_IMPL_HPP
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 #include <Panzer_HierarchicParallelism.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
11 namespace BoundaryCondition
14 template<
class EvalType,
class Traits,
int NumSpaceDim>
15 IncompressibleCavityLid<EvalType, Traits, NumSpaceDim>::IncompressibleCavityLid(
16 const panzer::IntegrationRule& ir,
17 const Teuchos::ParameterList& fluid_params,
18 const Teuchos::ParameterList& bc_params,
20 : _boundary_lagrange_pressure(
"BOUNDARY_lagrange_pressure", ir.dl_scalar)
21 , _boundary_grad_lagrange_pressure(
"BOUNDARY_GRAD_lagrange_pressure",
23 , _boundary_temperature(
"BOUNDARY_temperature", ir.dl_scalar)
24 , _boundary_grad_temperature(
"BOUNDARY_GRAD_temperature", ir.dl_vector)
25 , _ir_degree(ir.cubature_degree)
26 , _lagrange_pressure(
"lagrange_pressure", ir.dl_scalar)
27 , _grad_lagrange_pressure(
"GRAD_lagrange_pressure", ir.dl_vector)
28 , _grad_temperature(
"GRAD_temperature", ir.dl_vector)
29 , _solve_temp(fluid_params.get<bool>(
"Build Temperature Equation"))
31 , _wall_dir(bc_params.get<int>(
"Wall Normal Direction"))
32 , _vel_dir(bc_params.get<int>(
"Velocity Direction"))
33 , _h(bc_params.get<double>(
"Half Width"))
34 , _u_wall(bc_params.get<double>(
"Wall Velocity"))
35 , _T_bc(std::numeric_limits<double>::quiet_NaN())
38 if (_wall_dir >= num_space_dim)
41 =
"Wall normal direction greater than "
42 "number of solution dimensions in Cavity Lid boundary "
45 throw std::runtime_error(msg);
47 if (_vel_dir >= num_space_dim)
50 =
"Velocity direction greater than "
51 "number of solution dimensions in Cavity Lid boundary "
54 throw std::runtime_error(msg);
56 if (_wall_dir == _vel_dir)
59 =
"Velocity direction is same as wall normal in "
60 "Cavity Lid boundary condition.";
62 throw std::runtime_error(msg);
66 this->addEvaluatedField(_boundary_lagrange_pressure);
68 this->addEvaluatedField(_boundary_grad_lagrange_pressure);
71 _T_bc = bc_params.get<
double>(
"Temperature");
72 this->addEvaluatedField(_boundary_temperature);
73 this->addEvaluatedField(_boundary_grad_temperature);
75 Utils::addEvaluatedVectorField(
76 *
this, ir.dl_scalar, _boundary_velocity,
"BOUNDARY_velocity_");
78 Utils::addEvaluatedVectorField(*
this,
80 _boundary_grad_velocity,
81 "BOUNDARY_GRAD_velocity_");
84 this->addDependentField(_lagrange_pressure);
86 this->addDependentField(_grad_lagrange_pressure);
88 this->addDependentField(_grad_temperature);
89 Utils::addDependentVectorField(
90 *
this, ir.dl_vector, _grad_velocity,
"GRAD_velocity_");
92 this->setName(
"Boundary State Incompressible Cavity Lid "
93 + std::to_string(num_space_dim) +
"D");
97 template<
class EvalType,
class Traits,
int NumSpaceDim>
98 void IncompressibleCavityLid<EvalType, Traits, NumSpaceDim>::postRegistrationSetup(
99 typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
101 _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
105 template<
class EvalType,
class Traits,
int NumSpaceDim>
106 void IncompressibleCavityLid<EvalType, Traits, NumSpaceDim>::evaluateFields(
107 typename Traits::EvalData workset)
109 _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
110 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
112 Kokkos::parallel_for(this->getName(), policy, *
this);
116 template<
class EvalType,
class Traits,
int NumSpaceDim>
117 KOKKOS_INLINE_FUNCTION
void
118 IncompressibleCavityLid<EvalType, Traits, NumSpaceDim>::operator()(
119 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
121 const int cell = team.league_rank();
122 const int num_point = _lagrange_pressure.extent(1);
123 const int num_grad_dim = _boundary_grad_velocity[0].extent(2);
127 Kokkos::parallel_for(
128 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
130 _boundary_lagrange_pressure(cell, point)
131 = _lagrange_pressure(cell, point);
134 for (
int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
136 if (vel_dim == _vel_dir)
138 _boundary_velocity[vel_dim](cell, point) = _u_wall;
140 for (
int dim = 0; dim < num_space_dim; ++dim)
142 if (dim != _wall_dir)
144 _boundary_velocity[vel_dim](cell, point) *= pow(
146 - pow(_ip_coords(cell, point, dim) / _h,
154 _boundary_velocity[vel_dim](cell, point) = 0.0;
159 _boundary_temperature(cell, point) = _T_bc;
162 for (
int d = 0; d < num_grad_dim; ++d)
166 _boundary_grad_lagrange_pressure(cell, point, d)
167 = _grad_lagrange_pressure(cell, point, d);
170 for (
int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
172 _boundary_grad_velocity[vel_dim](cell, point, d)
173 = _grad_velocity[vel_dim](cell, point, d);
178 _boundary_grad_temperature(cell, point, d)
179 = _grad_temperature(cell, point, d);
190 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_IMPL_HPP