1 #ifndef VERTEXCFD_CLOSURE_MHDVORTEXPROBLEMEXACT_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_MHDVORTEXPROBLEMEXACT_IMPL_HPP
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 #include <Panzer_GlobalIndexer.hpp>
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_PureBasis.hpp>
9 #include <Panzer_Workset_Utilities.hpp>
15 namespace ClosureModel
18 template<
class EvalType,
class Traits,
int NumSpaceDim>
19 MHDVortexProblemExact<EvalType, Traits, NumSpaceDim>::MHDVortexProblemExact(
20 const panzer::IntegrationRule& ir,
21 const Teuchos::ParameterList& vortex_params)
22 : _ir_degree(ir.cubature_degree)
23 , _lagrange_pressure(
"Exact_lagrange_pressure", ir.dl_scalar)
25 const auto vel_0 = vortex_params.get<Teuchos::Array<double>>(
"velocity_0");
26 const auto xy_0 = vortex_params.get<Teuchos::Array<double>>(
"center_0");
27 for (
int dim = 0; dim < 2; ++dim)
29 _vel_0[dim] = vel_0[dim];
30 _xy_0[dim] = xy_0[dim];
34 this->addEvaluatedField(_lagrange_pressure);
35 Utils::addEvaluatedVectorField(
36 *
this, ir.dl_scalar, _velocity,
"Exact_velocity_");
37 Utils::addEvaluatedVectorField(*
this,
39 _induced_magnetic_field,
40 "Exact_induced_magnetic_field_");
43 this->setName(
"MHD Vortex Problem Exact Solution "
44 + std::to_string(num_space_dim) +
"D.");
48 template<
class EvalType,
class Traits,
int NumSpaceDim>
49 void MHDVortexProblemExact<EvalType, Traits, NumSpaceDim>::postRegistrationSetup(
50 typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
52 _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
56 template<
class EvalType,
class Traits,
int NumSpaceDim>
57 void MHDVortexProblemExact<EvalType, Traits, NumSpaceDim>::evaluateFields(
58 typename Traits::EvalData workset)
61 _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
62 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
64 Kokkos::parallel_for(this->getName(), policy, *
this);
68 template<
class EvalType,
class Traits,
int NumSpaceDim>
69 KOKKOS_INLINE_FUNCTION
void
70 MHDVortexProblemExact<EvalType, Traits, NumSpaceDim>::operator()(
71 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
73 const int cell = team.league_rank();
74 const int num_point = _lagrange_pressure.extent(1);
76 const double exp_one = exp(1.0);
79 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
81 const double x = _ip_coords(cell, point, 0);
82 const double y = _ip_coords(cell, point, 1);
83 const double r2 = (x - _time * _vel_0[0] - _xy_0[0])
84 * (x - _time * _vel_0[0] - _xy_0[0])
85 + (y - _time * _vel_0[0] - _xy_0[1])
86 * (y - _time * _vel_0[0] - _xy_0[1]);
89 _lagrange_pressure(cell, point)
90 = 1.0 + 0.5 * exp_one * (1.0 - r2 * exp(-r2));
92 _induced_magnetic_field[0](cell, point) = exp(0.5 * (1.0 - r2))
94 _induced_magnetic_field[1](cell, point) = exp(0.5 * (1.0 - r2))
97 _velocity[0](cell, point) = _induced_magnetic_field[0](cell, point)
99 _velocity[1](cell, point) = _induced_magnetic_field[1](cell, point);
101 if (num_space_dim == 3)
103 _induced_magnetic_field[2](cell, point) = 0.0;
104 _velocity[2](cell, point) = 0.0;