1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_IMPL_HPP
4 #include <utils/VertexCFD_Utils_VectorField.hpp>
6 #include "Panzer_GlobalIndexer.hpp"
7 #include "Panzer_PureBasis.hpp"
8 #include "Panzer_Workset_Utilities.hpp"
9 #include <Panzer_HierarchicParallelism.hpp>
11 #include <Teuchos_Array.hpp>
18 namespace ClosureModel
21 template<
class EvalType,
class Traits,
int NumSpaceDim>
22 IncompressibleErrorNorms<EvalType, Traits, NumSpaceDim>::IncompressibleErrorNorms(
23 const panzer::IntegrationRule& ir,
24 const Teuchos::ParameterList& fluid_params)
25 : _L1_error_continuity(
"L1_Error_continuity", ir.dl_scalar)
26 , _L1_error_energy(
"L1_Error_energy", ir.dl_scalar)
27 , _L2_error_continuity(
"L2_Error_continuity", ir.dl_scalar)
28 , _L2_error_energy(
"L2_Error_energy", ir.dl_scalar)
29 , _volume(
"volume", ir.dl_scalar)
30 , _exact_lagrange_pressure(
"Exact_lagrange_pressure", ir.dl_scalar)
31 , _exact_temperature(
"Exact_temperature", ir.dl_scalar)
32 , _lagrange_pressure(
"lagrange_pressure", ir.dl_scalar)
33 , _temperature(
"temperature", ir.dl_scalar)
36 _use_temp = fluid_params.isType<
bool>(
"Build Temperature Equation")
37 ? fluid_params.get<
bool>(
"Build Temperature Equation")
41 this->addDependentField(_exact_lagrange_pressure);
42 Utils::addDependentVectorField(
43 *
this, ir.dl_scalar, _exact_velocity,
"Exact_velocity_");
45 this->addDependentField(_exact_temperature);
48 this->addDependentField(_lagrange_pressure);
49 Utils::addDependentVectorField(*
this, ir.dl_scalar, _velocity,
"velocity_");
51 this->addDependentField(_temperature);
54 this->addEvaluatedField(_L1_error_continuity);
55 Utils::addEvaluatedVectorField(
56 *
this, ir.dl_scalar, _L1_error_momentum,
"L1_Error_momentum_");
57 this->addEvaluatedField(_L2_error_continuity);
58 Utils::addEvaluatedVectorField(
59 *
this, ir.dl_scalar, _L2_error_momentum,
"L2_Error_momentum_");
63 this->addEvaluatedField(_L1_error_energy);
64 this->addEvaluatedField(_L2_error_energy);
66 this->addEvaluatedField(_volume);
68 this->setName(
"Incompressible Error Norms " + std::to_string(num_space_dim)
73 template<
class EvalType,
class Traits,
int NumSpaceDim>
74 void IncompressibleErrorNorms<EvalType, Traits, NumSpaceDim>::evaluateFields(
75 typename Traits::EvalData workset)
77 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
79 Kokkos::parallel_for(this->getName(), policy, *
this);
83 template<
class EvalType,
class Traits,
int NumSpaceDim>
84 KOKKOS_INLINE_FUNCTION
void
85 IncompressibleErrorNorms<EvalType, Traits, NumSpaceDim>::operator()(
86 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
88 const int cell = team.league_rank();
89 const int num_point = _lagrange_pressure.extent(1);
92 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
97 _L1_error_continuity(cell, point)
98 = abs(_lagrange_pressure(cell, point)
99 - _exact_lagrange_pressure(cell, point));
103 _L1_error_energy(cell, point)
104 = abs(_temperature(cell, point)
105 - _exact_temperature(cell, point));
108 _L2_error_continuity(cell, point)
109 = pow(_lagrange_pressure(cell, point)
110 - _exact_lagrange_pressure(cell, point),
115 _L2_error_energy(cell, point) = pow(
116 _temperature(cell, point) - _exact_temperature(cell, point),
120 for (
int i = 0; i < num_space_dim; ++i)
122 _L1_error_momentum[i](cell, point)
123 = abs(_velocity[i](cell, point)
124 - _exact_velocity[i](cell, point));
125 _L2_error_momentum[i](cell, point) = pow(
126 _velocity[i](cell, point) - _exact_velocity[i](cell, point),
130 _volume(cell, point) = 1.0;
139 #endif // VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_IMPL_HPP