1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_IMPL_HPP
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 #include <Panzer_HierarchicParallelism.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
8 #include <Teuchos_StandardParameterEntryValidators.hpp>
12 namespace BoundaryCondition
15 template<
class EvalType,
class Traits,
int NumSpaceDim>
16 IncompressibleNoSlip<EvalType, Traits, NumSpaceDim>::IncompressibleNoSlip(
17 const panzer::IntegrationRule& ir,
18 const Teuchos::ParameterList& fluid_params,
19 const Teuchos::ParameterList& bc_params,
21 : _boundary_lagrange_pressure(
"BOUNDARY_lagrange_pressure", ir.dl_scalar)
22 , _boundary_grad_lagrange_pressure(
"BOUNDARY_GRAD_lagrange_pressure",
24 , _boundary_temperature(
"BOUNDARY_temperature", ir.dl_scalar)
25 , _boundary_grad_temperature(
"BOUNDARY_GRAD_temperature", ir.dl_vector)
26 , _lagrange_pressure(
"lagrange_pressure", ir.dl_scalar)
27 , _temperature(
"temperature", ir.dl_scalar)
28 , _grad_lagrange_pressure(
"GRAD_lagrange_pressure", ir.dl_vector)
29 , _grad_temperature(
"GRAD_temperature", ir.dl_vector)
30 , _normals(
"Side Normal", ir.dl_vector)
31 , _kappa(
"thermal_conductivity", ir.dl_scalar)
32 , _solve_temp(fluid_params.get<bool>(
"Build Temperature Equation"))
33 , _set_lagrange_pressure(bc_params.isType<double>(
"Lagrange Pressure"))
34 , _lp_wall(std::numeric_limits<double>::quiet_NaN())
36 , _T_wall(std::numeric_limits<double>::quiet_NaN())
37 , _wall_flux(std::numeric_limits<double>::quiet_NaN())
38 , _temperature_profile(TempProfile::isothermal)
41 if (bc_params.isType<std::string>(
"Temperature Profile"))
43 const auto type_validator = Teuchos::rcp(
44 new Teuchos::StringToIntegralParameterEntryValidator<TempProfile>(
45 Teuchos::tuple<std::string>(
"Isothermal",
"Adiabatic",
"Flux"),
47 _temperature_profile = type_validator->getIntegralValue(
48 bc_params.get<std::string>(
"Temperature Profile"));
51 if (_set_lagrange_pressure)
52 _lp_wall = bc_params.get<
double>(
"Lagrange Pressure");
55 this->addEvaluatedField(_boundary_lagrange_pressure);
57 this->addEvaluatedField(_boundary_grad_lagrange_pressure);
59 Utils::addEvaluatedVectorField(
60 *
this, ir.dl_scalar, _boundary_velocity,
"BOUNDARY_velocity_");
61 Utils::addEvaluatedVectorField(*
this,
63 _boundary_grad_velocity,
64 "BOUNDARY_GRAD_velocity_");
67 this->addEvaluatedField(_boundary_temperature);
68 this->addEvaluatedField(_boundary_grad_temperature);
72 this->addDependentField(_lagrange_pressure);
75 this->addDependentField(_grad_lagrange_pressure);
76 this->addDependentField(_normals);
79 Utils::addDependentVectorField(
80 *
this, ir.dl_vector, _grad_velocity,
"GRAD_velocity_");
84 this->addDependentField(_grad_temperature);
85 if (_temperature_profile == TempProfile::isothermal)
87 _T_wall = bc_params.get<
double>(
"Wall Temperature");
89 else if (_temperature_profile == TempProfile::adiabatic)
91 this->addDependentField(_temperature);
93 this->addDependentField(_normals);
95 else if (_temperature_profile == TempProfile::flux)
97 this->addDependentField(_temperature);
98 this->addDependentField(_kappa);
100 this->addDependentField(_normals);
101 _wall_flux = bc_params.get<
double>(
"Wall Flux");
105 this->setName(
"Boundary State Incompressible No-Slip");
109 template<
class EvalType,
class Traits,
int NumSpaceDim>
110 void IncompressibleNoSlip<EvalType, Traits, NumSpaceDim>::evaluateFields(
111 typename Traits::EvalData workset)
113 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
115 Kokkos::parallel_for(this->getName(), policy, *
this);
119 template<
class EvalType,
class Traits,
int NumSpaceDim>
120 KOKKOS_INLINE_FUNCTION
void
121 IncompressibleNoSlip<EvalType, Traits, NumSpaceDim>::operator()(
122 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
124 const int cell = team.league_rank();
125 const int num_point = _boundary_lagrange_pressure.extent(1);
126 const int num_grad_dim = _boundary_grad_velocity[0].extent(2);
128 Kokkos::parallel_for(
129 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
131 if (_set_lagrange_pressure)
133 _boundary_lagrange_pressure(cell, point) = _lp_wall;
137 _boundary_lagrange_pressure(cell, point)
138 = _lagrange_pressure(cell, point);
142 for (
int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
143 _boundary_velocity[vel_dim](cell, point) = 0.0;
147 if (_temperature_profile == TempProfile::isothermal)
149 _boundary_temperature(cell, point) = _T_wall;
153 _boundary_temperature(cell, point)
154 = _temperature(cell, point);
159 for (
int d = 0; d < num_grad_dim; ++d)
164 _boundary_grad_lagrange_pressure(cell, point, d)
165 = _grad_lagrange_pressure(cell, point, d);
167 for (
int grad_dim = 0; grad_dim < num_space_dim; ++grad_dim)
169 _boundary_grad_lagrange_pressure(cell, point, d)
170 -= (_grad_lagrange_pressure(cell, point, grad_dim)
171 * _normals(cell, point, grad_dim))
172 * _normals(cell, point, d);
176 for (
int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
178 _boundary_grad_velocity[vel_dim](cell, point, d)
179 = _grad_velocity[vel_dim](cell, point, d);
184 _boundary_grad_temperature(cell, point, d)
185 = _grad_temperature(cell, point, d);
187 if (_temperature_profile != TempProfile::isothermal)
189 for (
int grad_dim = 0; grad_dim < num_space_dim;
192 _boundary_grad_temperature(cell, point, d)
193 -= (_grad_temperature(cell, point, grad_dim)
194 * _normals(cell, point, grad_dim))
195 * _normals(cell, point, d);
197 if (_temperature_profile == TempProfile::flux)
199 _boundary_grad_temperature(cell, point, d)
200 += (_wall_flux / _kappa(cell, point))
201 * _normals(cell, point, d);
214 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_IMPL_HPP