1 #ifndef VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_IMPL_HPP
4 #include "utils/VertexCFD_Utils_Constants.hpp"
5 #include <utils/VertexCFD_Utils_VectorField.hpp>
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_Workset_Utilities.hpp>
12 namespace BoundaryCondition
15 template<
class EvalType,
class Traits,
int NumSpaceDim>
16 MethodManufacturedSolution<EvalType, Traits, NumSpaceDim>::MethodManufacturedSolution(
17 const panzer::IntegrationRule& ir)
18 : _boundary_lagrange_pressure(
"BOUNDARY_lagrange_pressure", ir.dl_scalar)
19 , _boundary_temperature(
"BOUNDARY_temperature", ir.dl_scalar)
20 , _boundary_grad_lagrange_pressure(
"BOUNDARY_GRAD_lagrange_pressure",
22 , _boundary_grad_temperature(
"BOUNDARY_GRAD_temperature", ir.dl_vector)
23 , _ir_degree(ir.cubature_degree)
26 this->addEvaluatedField(_boundary_lagrange_pressure);
27 Utils::addEvaluatedVectorField(
28 *
this, ir.dl_scalar, _boundary_velocity,
"BOUNDARY_velocity_");
29 this->addEvaluatedField(_boundary_temperature);
31 this->addEvaluatedField(_boundary_grad_lagrange_pressure);
32 Utils::addEvaluatedVectorField(*
this,
34 _boundary_grad_velocity,
35 "BOUNDARY_GRAD_velocity_");
36 this->addEvaluatedField(_boundary_grad_temperature);
38 this->setName(
"Boundary State Method Manufactured Solution "
39 + std::to_string(num_space_dim) +
"D");
42 _phi_coeff[0] = 0.0125;
46 _phi_coeff[4] = 0.125;
49 _vel_coeff[0][0] = 0.0125;
50 _vel_coeff[0][1] = 0.08;
51 _vel_coeff[0][2] = 0.125;
52 _vel_coeff[0][3] = 0.0;
53 _vel_coeff[0][4] = 0.125;
54 _vel_coeff[0][5] = 0.25;
56 _vel_coeff[1][0] = 0.0375;
57 _vel_coeff[1][1] = 1.125;
58 _vel_coeff[1][2] = 0.25;
59 _vel_coeff[1][3] = 0.0;
60 _vel_coeff[1][4] = 0.375;
61 _vel_coeff[1][5] = 0.5;
70 if (num_space_dim == 3)
72 _phi_coeff[6] = 0.375;
75 _vel_coeff[0][6] = 0.25;
76 _vel_coeff[0][7] = 0.0;
78 _vel_coeff[1][6] = 0.25;
79 _vel_coeff[1][7] = 0.5;
81 _vel_coeff[2][0] = 0.025;
82 _vel_coeff[2][1] = 0.0;
83 _vel_coeff[2][2] = 0.125;
84 _vel_coeff[2][3] = 1.0;
85 _vel_coeff[2][4] = 0.25;
86 _vel_coeff[2][5] = 0.25;
87 _vel_coeff[2][6] = 0.25;
88 _vel_coeff[2][7] = 0.25;
96 template<
class EvalType,
class Traits,
int NumSpaceDim>
97 void MethodManufacturedSolution<EvalType, Traits, NumSpaceDim>::postRegistrationSetup(
98 typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
100 _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
104 template<
class EvalType,
class Traits,
int NumSpaceDim>
105 void MethodManufacturedSolution<EvalType, Traits, NumSpaceDim>::evaluateFields(
106 typename Traits::EvalData workset)
108 _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
109 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
111 Kokkos::parallel_for(this->getName(), policy, *
this);
115 template<
class EvalType,
class Traits,
int NumSpaceDim>
116 KOKKOS_INLINE_FUNCTION
void
117 MethodManufacturedSolution<EvalType, Traits, NumSpaceDim>::operator()(
118 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
120 const int cell = team.league_rank();
121 const int num_point = _boundary_lagrange_pressure.extent(1);
126 Kokkos::parallel_for(
127 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
133 = [=](
const Kokkos::Array<double, num_coeff> coeff,
134 const Kokkos::Array<double, num_space_dim> coords) {
135 double return_val = coeff[0];
136 for (
int i = 0; i < num_space_dim; ++i)
138 *= sin(2.0 * pi * coeff[2 * (i + 1)]
139 * (coords[i] - coeff[2 * (i + 1) + 1]));
140 return_val += coeff[1];
147 auto set_gradX_function =
148 [=](
const Kokkos::Array<double, num_coeff> coeff,
149 const Kokkos::Array<double, num_space_dim> coords) {
151 = coeff[0] * 2.0 * pi * coeff[2]
152 * cos(2.0 * pi * coeff[2] * (coords[0] - coeff[3]))
153 * sin(2.0 * pi * coeff[4] * (coords[1] - coeff[5]));
154 if (num_space_dim == 3)
155 return_val *= sin(2.0 * pi * coeff[6]
156 * (coords[2] - coeff[7]));
163 auto set_gradY_function =
164 [=](
const Kokkos::Array<double, num_coeff> coeff,
165 const Kokkos::Array<double, num_space_dim> coords) {
167 = coeff[0] * 2.0 * pi * coeff[4]
168 * sin(2.0 * pi * coeff[2] * (coords[0] - coeff[3]))
169 * cos(2.0 * pi * coeff[4] * (coords[1] - coeff[5]));
170 if (num_space_dim == 3)
171 return_val *= sin(2.0 * pi * coeff[6]
172 * (coords[2] - coeff[7]));
178 auto set_gradZ_function =
179 [=](
const Kokkos::Array<double, num_coeff> coeff,
180 const Kokkos::Array<double, num_space_dim> coords) {
181 return coeff[0] * 2.0 * pi * coeff[6]
182 * sin(2.0 * pi * coeff[2] * (coords[0] - coeff[3]))
183 * sin(2.0 * pi * coeff[4] * (coords[1] - coeff[5]))
184 * cos(2.0 * pi * coeff[6] * (coords[2] - coeff[7]));
187 Kokkos::Array<double, num_space_dim> x;
188 for (
int dim = 0; dim < num_space_dim; ++dim)
189 x[dim] = _ip_coords(cell, point, dim);
191 const double phi = set_function(_phi_coeff, x);
192 const double T = set_function(_T_coeff, x);
194 _boundary_lagrange_pressure(cell, point) = phi;
195 Kokkos::Array<scalar_type, num_space_dim> vel;
196 for (
int i = 0; i < num_space_dim; ++i)
198 _boundary_velocity[i](cell, point)
199 = set_function(_vel_coeff[i], x);
200 vel[i] = _boundary_velocity[i](cell, point);
202 _boundary_temperature(cell, point) = T;
204 _boundary_grad_lagrange_pressure(cell, point, 0)
205 = set_gradX_function(_phi_coeff, x);
206 _boundary_grad_lagrange_pressure(cell, point, 1)
207 = set_gradY_function(_phi_coeff, x);
209 _boundary_grad_velocity[0](cell, point, 0)
210 = set_gradX_function(_vel_coeff[0], x);
211 _boundary_grad_velocity[0](cell, point, 1)
212 = set_gradY_function(_vel_coeff[0], x);
213 _boundary_grad_velocity[1](cell, point, 0)
214 = set_gradX_function(_vel_coeff[1], x);
215 _boundary_grad_velocity[1](cell, point, 1)
216 = set_gradY_function(_vel_coeff[1], x);
218 _boundary_grad_temperature(cell, point, 0)
219 = set_gradX_function(_T_coeff, x);
220 _boundary_grad_temperature(cell, point, 1)
221 = set_gradY_function(_T_coeff, x);
223 if (num_space_dim == 3)
225 _boundary_grad_lagrange_pressure(cell, point, 2)
226 = set_gradZ_function(_phi_coeff, x);
228 _boundary_grad_velocity[0](cell, point, 2)
229 = set_gradZ_function(_vel_coeff[0], x);
230 _boundary_grad_velocity[1](cell, point, 2)
231 = set_gradZ_function(_vel_coeff[1], x);
232 _boundary_grad_velocity[2](cell, point, 0)
233 = set_gradX_function(_vel_coeff[2], x);
234 _boundary_grad_velocity[2](cell, point, 1)
235 = set_gradY_function(_vel_coeff[2], x);
236 _boundary_grad_velocity[2](cell, point, 2)
237 = set_gradZ_function(_vel_coeff[2], x);
239 _boundary_grad_temperature(cell, point, 2)
240 = set_gradZ_function(_T_coeff, x);
250 #endif // VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_IMPL_HPP